Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Unified Diff: components/web_restrictions/content_resolver_web_restrictions_provider.h

Issue 1631603002: Web restrictions component only. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/web_restrictions/content_resolver_web_restrictions_provider.h
diff --git a/components/web_restrictions/content_resolver_web_restrictions_provider.h b/components/web_restrictions/content_resolver_web_restrictions_provider.h
new file mode 100644
index 0000000000000000000000000000000000000000..b64c2b0ab078112d230e1e516915f060e5a7935f
--- /dev/null
+++ b/components/web_restrictions/content_resolver_web_restrictions_provider.h
@@ -0,0 +1,65 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_WEB_RESTRICTION_CONTENT_RESOLVER_WEB_RESTRICTION_PROVIDER_H_
+#define COMPONENTS_WEB_RESTRICTION_CONTENT_RESOLVER_WEB_RESTRICTION_PROVIDER_H_
+
+#include <jni.h>
+#include <list>
+#include <map>
+
+#include "base/android/jni_android.h"
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/memory/ref_counted.h"
+#include "base/task_runner.h"
+#include "components/web_restrictions/web_restrictions_provider.h"
+
+namespace web_restrictions {
+
+class ContentResolverWebRestrictionsProvider : public WebRestrictionsProvider {
+ public:
+ ContentResolverWebRestrictionsProvider();
+ ~ContentResolverWebRestrictionsProvider() override;
+
+ // Register JNI methods.
+ static bool Register(JNIEnv* env);
+
+ // Verify the content provider and query it for basic information like does it
+ // support handling requests. This should be called everytime the provider
+ // changes.
+ void Initialize(const std::string& content_provider_authority);
+
+ // WebRestrictionsProvider:
+ UrlAccess ShouldProceed(bool is_main_frame,
+ const GURL& url,
+ const base::Callback<void(bool)>& callback) override;
+
+ bool SupportsRequest() const override;
+
+ bool GetErrorHtml(const GURL& url, std::string* error_html) const override;
+
+ void RequestPermission(const GURL& url,
+ const base::Callback<void(bool)>& callback) override;
+
+ void ClearCache();
+
+ private:
+ friend class SelfDeletingCallback; // For updating the cache.
+
+ bool initialized_;
+ // Set up during Initialize.
+ bool supports_request_;
+ base::android::ScopedJavaGlobalRef<jobject> java_provider_;
+
+ std::map<GURL, std::string> error_page_cache_;
+ std::map<GURL, bool> url_access_cache_;
+ std::list<GURL> recent_urls_;
+
+ DISALLOW_COPY_AND_ASSIGN(ContentResolverWebRestrictionsProvider);
+};
+
+} // namespace web_restrictions
+
+#endif // COMPONENTS_WEB_RESTRICTION_CONTENT_RESOLVER_WEB_RESTRICTION_PROVIDER_H_

Powered by Google App Engine
This is Rietveld 408576698