Browse Source

LibWeb: Remove OOM handling from the AutoplayAllowlist

Timothy Flynn 6 days ago
parent
commit
6f1710121d

+ 5 - 7
Libraries/LibWeb/PermissionsPolicy/AutoplayAllowlist.cpp

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
+ * Copyright (c) 2023-2025, Tim Flynn <trflynn89@ladybird.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -66,27 +66,25 @@ void AutoplayAllowlist::enable_globally()
     m_allowlist = Global {};
 }
 
-ErrorOr<void> AutoplayAllowlist::enable_for_origins(ReadonlySpan<String> origins)
+void AutoplayAllowlist::enable_for_origins(ReadonlySpan<String> origins)
 {
     m_allowlist = Patterns {};
 
     auto& allowlist = m_allowlist->get<Patterns>();
-    TRY(allowlist.try_ensure_capacity(origins.size()));
+    allowlist.ensure_capacity(origins.size());
 
     for (auto const& origin : origins) {
         auto url = URL::Parser::basic_parse(origin);
 
         if (!url.has_value())
-            url = URL::Parser::basic_parse(TRY(String::formatted("https://{}", origin)));
+            url = URL::Parser::basic_parse(MUST(String::formatted("https://{}", origin)));
         if (!url.has_value()) {
             dbgln("Invalid origin for autoplay allowlist: {}", origin);
             continue;
         }
 
-        TRY(allowlist.try_append(url->origin()));
+        allowlist.append(url->origin());
     }
-
-    return {};
 }
 
 }

+ 1 - 1
Libraries/LibWeb/PermissionsPolicy/AutoplayAllowlist.h

@@ -22,7 +22,7 @@ public:
     Decision is_allowed_for_origin(DOM::Document const&, URL::Origin const&) const;
 
     void enable_globally();
-    ErrorOr<void> enable_for_origins(ReadonlySpan<String>);
+    void enable_for_origins(ReadonlySpan<String>);
 
 private:
     AutoplayAllowlist();

+ 1 - 1
Services/WebContent/ConnectionFromClient.cpp

@@ -1066,7 +1066,7 @@ void ConnectionFromClient::set_autoplay_allowed_on_all_websites(u64)
 void ConnectionFromClient::set_autoplay_allowlist(u64, Vector<String> allowlist)
 {
     auto& autoplay_allowlist = Web::PermissionsPolicy::AutoplayAllowlist::the();
-    autoplay_allowlist.enable_for_origins(allowlist).release_value_but_fixme_should_propagate_errors();
+    autoplay_allowlist.enable_for_origins(allowlist);
 }
 
 void ConnectionFromClient::set_proxy_mappings(u64, Vector<ByteString> proxies, HashMap<ByteString, size_t> mappings)