Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 5a5326fb authored by Carmelo Messina's avatar Carmelo Messina
Browse files

Miscellaneous: change absl::optional to std::optional

parent 71aab81c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -977,7 +977,7 @@ new file mode 100644
+  }
+
+  if (const std::string* pacURL = config.FindString("pac_url")) {
+    absl::optional<bool> pacMandatory = config.FindBool("pac_mandatory");
+    std::optional<bool> pacMandatory = config.FindBool("pac_mandatory");
+    auto proxyConfig = net::ProxyConfig::CreateFromCustomPacURL(
+                                GURL(*pacURL));
+    proxyConfig.set_pac_mandatory(pacMandatory.value_or(false));
@@ -1037,7 +1037,7 @@ new file mode 100644
+    if (bypass_rules == nullptr)
+      return;
+
+    absl::optional<bool> reverse_bypass = rules->FindBool("reverse_bypass");
+    std::optional<bool> reverse_bypass = rules->FindBool("reverse_bypass");
+
+    proxyConfig.proxy_rules().bypass_rules.ParseFromString(*bypass_rules);
+    proxyConfig.proxy_rules().reverse_bypass = reverse_bypass.value_or(false);
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ diff --git a/content/browser/network/cross_origin_embedder_policy_reporter.cc b/
         kType, context_url_, blink::mojom::ReportBody::New(std::move(list))));
   }
+#if BUILDFLAG(ENABLE_REPORTING)
+  const absl::optional<std::string>& endpoint =
+  const std::optional<std::string>& endpoint =
+      report_only ? report_only_endpoint_ : endpoint_;
   if (endpoint) {
     base::Value::Dict body_to_pass;
+17 −17
Original line number Diff line number Diff line
@@ -5414,7 +5414,7 @@ new file mode 100755
+         MatchesPath(StripTrailingWildcard(other.path()));
+}
+
+absl::optional<URLPattern> URLPattern::CreateIntersection(
+std::optional<URLPattern> URLPattern::CreateIntersection(
+    const URLPattern& other) const {
+  // Easy case: Schemes don't overlap. Return nullopt.
+  int intersection_schemes = URLPattern::SCHEME_NONE;
@@ -5816,7 +5816,7 @@ new file mode 100755
+  //   contains another, it will be handled correctly, but this method does not
+  //   deal with cases like /*a* and /*b* (where technically the intersection
+  //   is /*a*b*|/*b*a*); the intersection returned for that case will be empty.
+  absl::optional<URLPattern> CreateIntersection(const URLPattern& other) const;
+  std::optional<URLPattern> CreateIntersection(const URLPattern& other) const;
+
+  // Converts this URLPattern into an equivalent set of URLPatterns that don't
+  // use a wildcard in the scheme component. If this URLPattern doesn't use a
@@ -5984,7 +5984,7 @@ new file mode 100755
+  // they have with the other patterns.
+  for (const auto* pattern : unique_set1) {
+    for (const auto* pattern2 : unique_set2) {
+      absl::optional<URLPattern> intersection =
+      std::optional<URLPattern> intersection =
+          pattern->CreateIntersection(*pattern2);
+      if (intersection)
+        result.patterns_.insert(std::move(*intersection));
@@ -8280,7 +8280,7 @@ new file mode 100755
+  }
+
+void ScriptInjection::OnJsInjectionCompleted(
+    absl::optional<base::Value> results,
+    std::optional<base::Value> results,
+    base::TimeTicks start_time) {
+  DCHECK(!did_inject_js_);
+
@@ -8304,13 +8304,13 @@ new file mode 100755
+      run_location_, injected_stylesheets, num_injected_stylesheets);
+  blink::WebLocalFrame* web_frame = render_frame_->GetWebFrame();
+  // Default CSS origin is "author", but can be overridden to "user" by scripts.
+  absl::optional<CSSOrigin> css_origin = injector_->GetCssOrigin();
+  std::optional<CSSOrigin> css_origin = injector_->GetCssOrigin();
+  blink::WebCssOrigin blink_css_origin =
+      css_origin && *css_origin == CSS_ORIGIN_USER
+          ? blink::WebCssOrigin::kUser
+          : blink::WebCssOrigin::kAuthor;
+  blink::WebStyleSheetKey style_sheet_key;
+  if (const absl::optional<std::string>& injection_key =
+  if (const std::optional<std::string>& injection_key =
+          injector_->GetInjectionKey())
+    style_sheet_key = blink::WebString::FromASCII(*injection_key);
+  for (const blink::WebString& css : css_sources)
@@ -8414,7 +8414,7 @@ new file mode 100755
+
+  // Called when JS injection for the given frame has been completed or
+  // cancelled.
+  void OnJsInjectionCompleted(absl::optional<base::Value> results,
+  void OnJsInjectionCompleted(std::optional<base::Value> results,
+                              base::TimeTicks start_time);
+
+ private:
@@ -8465,7 +8465,7 @@ new file mode 100755
+  bool log_activity_;
+
+  // Results storage.
+  absl::optional<base::Value> execution_result_;
+  std::optional<base::Value> execution_result_;
+
+  // The callback to run upon completing asynchronously.
+  CompletionCallback async_completion_callback_;
@@ -9052,10 +9052,10 @@ new file mode 100755
+  virtual bool IsUserGesture() const = 0;
+
+  // Returns the CSS origin of this injection.
+  virtual absl::optional<CSSOrigin> GetCssOrigin() const = 0;
+  virtual std::optional<CSSOrigin> GetCssOrigin() const = 0;
+
+  // Returns the key for this injection, if it's a CSS injection.
+  virtual const absl::optional<std::string> GetInjectionKey() const = 0;
+  virtual const std::optional<std::string> GetInjectionKey() const = 0;
+
+  // Returns true if the script expects results.
+  virtual bool ExpectsResults() const = 0;
@@ -9090,7 +9090,7 @@ new file mode 100755
+  // |render_frame| contains the render frame, or null if the frame was
+  // invalidated.
+  virtual void OnInjectionComplete(
+      absl::optional<base::Value> execution_result,
+      std::optional<base::Value> execution_result,
+      UserScript::RunLocation run_location,
+      content::RenderFrame* render_frame) = 0;
+
@@ -9355,11 +9355,11 @@ new file mode 100755
+  return false;
+}
+
+absl::optional<CSSOrigin> UserScriptInjector::GetCssOrigin() const {
+std::optional<CSSOrigin> UserScriptInjector::GetCssOrigin() const {
+  return absl::nullopt;
+}
+
+const absl::optional<std::string> UserScriptInjector::GetInjectionKey() const {
+const std::optional<std::string> UserScriptInjector::GetInjectionKey() const {
+  return absl::nullopt;
+}
+
@@ -9437,7 +9437,7 @@ new file mode 100755
+}
+
+void UserScriptInjector::OnInjectionComplete(
+    absl::optional<base::Value> execution_result,
+    std::optional<base::Value> execution_result,
+    UserScript::RunLocation run_location,
+    content::RenderFrame* render_frame) {}
+
@@ -9493,8 +9493,8 @@ new file mode 100755
+  // ScriptInjector implementation.
+  UserScript::InjectionType script_type() const override;
+  bool IsUserGesture() const override;
+  absl::optional<CSSOrigin> GetCssOrigin() const override;
+  const absl::optional<std::string> GetInjectionKey() const override;
+  std::optional<CSSOrigin> GetCssOrigin() const override;
+  const std::optional<std::string> GetInjectionKey() const override;
+  bool ExpectsResults() const override;
+  bool ShouldInjectJs(
+      UserScript::RunLocation run_location,
@@ -9510,7 +9510,7 @@ new file mode 100755
+      UserScript::RunLocation run_location,
+      std::set<std::string>* injected_stylesheets,
+      size_t* num_injected_stylesheets) const override;
+  void OnInjectionComplete(absl::optional<base::Value> execution_result,
+  void OnInjectionComplete(std::optional<base::Value> execution_result,
+                           UserScript::RunLocation run_location,
+                           content::RenderFrame* render_frame) override;
+  void OnWillNotInject(InjectFailureReason reason,
+14 −14
Original line number Diff line number Diff line
@@ -350,7 +350,7 @@ diff --git a/chrome/browser/adblock/adblock_content_browser_client.cc b/chrome/b
     const GURL& url,
+    const url::Origin& initiator_origin,
     const net::SiteForCookies& site_for_cookies,
-    const absl::optional<std::string>& user_agent,
-    const std::optional<std::string>& user_agent,
+    const std::optional<std::string>& user_agent,
     mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
         handshake_client) {
@@ -378,7 +378,7 @@ diff --git a/chrome/browser/adblock/adblock_content_browser_client.cc b/chrome/b
     const GURL& url,
+    const url::Origin& initiator_origin,
     const net::SiteForCookies& site_for_cookies,
-    const absl::optional<std::string>& user_agent,
-    const std::optional<std::string>& user_agent,
+    const std::optional<std::string>& user_agent,
     mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
         handshake_client) {
@@ -413,7 +413,7 @@ diff --git a/chrome/browser/adblock/adblock_content_browser_client.cc b/chrome/b
     const GURL& url,
+    const url::Origin& initiator_origin,
     const net::SiteForCookies& site_for_cookies,
-    const absl::optional<std::string>& user_agent,
-    const std::optional<std::string>& user_agent,
+    const std::optional<std::string>& user_agent,
     mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
         handshake_client,
@@ -563,7 +563,7 @@ diff --git a/chrome/browser/adblock/adblock_content_browser_client.cc b/chrome/b
     int render_process_id,
     URLLoaderFactoryType type,
     const url::Origin& request_initiator,
-    absl::optional<int64_t> navigation_id,
-    std::optional<int64_t> navigation_id,
+    const net::IsolationInfo& isolation_info,
+    std::optional<int64_t> navigation_id,
     ukm::SourceIdObj ukm_source_id,
@@ -643,7 +643,7 @@ diff --git a/chrome/browser/adblock/adblock_content_browser_client.h b/chrome/br
       const GURL& url,
+      const url::Origin& initiator_origin,
       const net::SiteForCookies& site_for_cookies,
-      const absl::optional<std::string>& user_agent,
-      const std::optional<std::string>& user_agent,
+      const std::optional<std::string>& user_agent,
       mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
           handshake_client) override;
@@ -664,7 +664,7 @@ diff --git a/chrome/browser/adblock/adblock_content_browser_client.h b/chrome/br
       int render_process_id,
       URLLoaderFactoryType type,
       const url::Origin& request_initiator,
-      absl::optional<int64_t> navigation_id,
-      std::optional<int64_t> navigation_id,
+      const net::IsolationInfo& isolation_info,
+      std::optional<int64_t> navigation_id,
       ukm::SourceIdObj ukm_source_id,
@@ -699,7 +699,7 @@ diff --git a/chrome/browser/adblock/adblock_content_browser_client.h b/chrome/br
       const GURL& url,
+      const url::Origin& initiator_origin,
       const net::SiteForCookies& site_for_cookies,
-      const absl::optional<std::string>& user_agent,
-      const std::optional<std::string>& user_agent,
+      const std::optional<std::string>& user_agent,
       mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
           handshake_client);
@@ -710,7 +710,7 @@ diff --git a/chrome/browser/adblock/adblock_content_browser_client.h b/chrome/br
       const GURL& url,
+      const url::Origin& initiator_origin,
       const net::SiteForCookies& site_for_cookies,
-      const absl::optional<std::string>& user_agent,
-      const std::optional<std::string>& user_agent,
+      const std::optional<std::string>& user_agent,
       mojo::PendingRemote<network::mojom::WebSocketHandshakeClient>
           handshake_client,
@@ -854,7 +854,7 @@ diff --git a/chrome/browser/extensions/api/adblock_private/adblock_private_api.c
+AdblockPrivateSetPrivilegedFiltersEnabledFunction::~AdblockPrivateSetPrivilegedFiltersEnabledFunction() {}
+
+ExtensionFunction::ResponseAction AdblockPrivateSetPrivilegedFiltersEnabledFunction::Run() {
+  absl::optional<api::adblock_private::SetEnabled::Params> params =
+  std::optional<api::adblock_private::SetEnabled::Params> params =
+      api::adblock_private::SetEnabled::Params::Create(args());
+  EXTENSION_FUNCTION_VALIDATE(params);
+
@@ -4357,7 +4357,7 @@ diff --git a/components/adblock/core/converter/flatbuffer_converter.cc b/compone
diff --git a/components/adblock/core/converter/parser/metadata.cc b/components/adblock/core/converter/parser/metadata.cc
--- a/components/adblock/core/converter/parser/metadata.cc
+++ b/components/adblock/core/converter/parser/metadata.cc
@@ -58,13 +58,6 @@ absl::optional<Metadata> Metadata::FromStream(std::istream& filter_stream) {
@@ -58,13 +58,6 @@ std::optional<Metadata> Metadata::FromStream(std::istream& filter_stream) {
     if (key == "homepage") {
       homepage = value;
     } else if (key == "redirect") {
@@ -4428,7 +4428,7 @@ diff --git a/components/adblock/core/converter/parser/url_filter.cc b/components
     piece.remove_suffix(1);
   }
   if (piece.find('|') == base::StringPiece::npos) {
@@ -108,21 +112,21 @@ absl::optional<UrlFilter> UrlFilter::FromString(std::string filter_str) {
@@ -108,21 +112,21 @@ std::optional<UrlFilter> UrlFilter::FromString(std::string filter_str) {
 
     if (options->Csp().has_value() && options->Csp().value().empty() &&
         !is_allowing) {
@@ -4456,7 +4456,7 @@ diff --git a/components/adblock/core/converter/parser/url_filter.cc b/components
diff --git a/components/adblock/core/converter/parser/url_filter_options.cc b/components/adblock/core/converter/parser/url_filter_options.cc
--- a/components/adblock/core/converter/parser/url_filter_options.cc
+++ b/components/adblock/core/converter/parser/url_filter_options.cc
@@ -88,20 +88,14 @@ absl::optional<UrlFilterOptions> UrlFilterOptions::FromString(
@@ -88,20 +88,14 @@ std::optional<UrlFilterOptions> UrlFilterOptions::FromString(
       }
       domains = DomainOption::FromString(value, kDomainOrSitekeySeparator);
     } else if (key == "sitekey") {
@@ -4483,7 +4483,7 @@ diff --git a/components/adblock/core/converter/parser/url_filter_options.cc b/co
     } else {
       ContentType content_type = ContentTypeFromString(key);
       if (content_type != ContentType::Unknown) {
@@ -184,6 +178,7 @@ absl::optional<UrlFilterOptions::RewriteOption> UrlFilterOptions::ParseRewrite(
@@ -184,6 +178,7 @@ std::optional<UrlFilterOptions::RewriteOption> UrlFilterOptions::ParseRewrite(
 // static
 SiteKeys UrlFilterOptions::ParseSitekeys(const std::string& sitekey_value) {
   SiteKeys sitekeys;
@@ -4663,7 +4663,7 @@ diff --git a/components/adblock/core/sitekey_storage_impl.cc b/components/adbloc
     return;
@@ -53,6 +55,7 @@ void SitekeyStorageImpl::ProcessResponseHeaders(
 
 absl::optional<std::pair<GURL, SiteKey>>
 std::optional<std::pair<GURL, SiteKey>>
 SitekeyStorageImpl::FindSiteKeyForAnyUrl(const std::vector<GURL>& urls) const {
+  if ((true)) return {};
   DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+3 −3
Original line number Diff line number Diff line
@@ -548,13 +548,13 @@ new file mode 100644
+  return it->second.allowed;
+}
+
+absl::optional<builders::EntryDecoder> FirewallService::GetEntry(
+std::optional<builders::EntryDecoder> FirewallService::GetEntry(
+                                int32_t unique_id_hash_code) const {
+  const auto it = decode_map_.find(unique_id_hash_code);
+  if (it == decode_map_.end())
+    return absl::nullopt;
+
+  return absl::optional<builders::EntryDecoder>(it->second);
+  return std::optional<builders::EntryDecoder>(it->second);
+}
+
+}
@@ -608,7 +608,7 @@ new file mode 100644
+  ~FirewallService();
+
+  bool IsAllowed(int32_t unique_id_hash_code);
+  absl::optional<builders::EntryDecoder> GetEntry(int32_t unique_id_hash_code) const;
+  std::optional<builders::EntryDecoder> GetEntry(int32_t unique_id_hash_code) const;
+
+ private:
+  raw_ptr<PrefService> pref_service_;
Loading