OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_WEB_RESTRICTION_CONTENT_RESOLVER_WEB_RESTRICTION_PROVIDER_H_ |
| 6 #define COMPONENTS_WEB_RESTRICTION_CONTENT_RESOLVER_WEB_RESTRICTION_PROVIDER_H_ |
| 7 |
| 8 #include <jni.h> |
| 9 #include <list> |
| 10 #include <map> |
| 11 |
| 12 #include "base/android/jni_android.h" |
| 13 #include "base/callback.h" |
| 14 #include "base/macros.h" |
| 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/task_runner.h" |
| 17 #include "components/web_restrictions/web_restrictions_provider.h" |
| 18 |
| 19 namespace web_restrictions { |
| 20 |
| 21 class ContentResolverWebRestrictionsProvider : public WebRestrictionsProvider { |
| 22 public: |
| 23 ContentResolverWebRestrictionsProvider(); |
| 24 ~ContentResolverWebRestrictionsProvider() override; |
| 25 |
| 26 // Register JNI methods. |
| 27 static bool Register(JNIEnv* env); |
| 28 |
| 29 // Verify the content provider and query it for basic information like does it |
| 30 // support handling requests. This should be called everytime the provider |
| 31 // changes. |
| 32 void Initialize(const std::string& content_provider_authority); |
| 33 |
| 34 // WebRestrictionsProvider: |
| 35 UrlAccess ShouldProceed(bool is_main_frame, |
| 36 const GURL& url, |
| 37 const base::Callback<void(bool)>& callback) override; |
| 38 |
| 39 bool SupportsRequest() const override; |
| 40 |
| 41 bool GetErrorHtml(const GURL& url, std::string* error_html) const override; |
| 42 |
| 43 void RequestPermission(const GURL& url, |
| 44 const base::Callback<void(bool)>& callback) override; |
| 45 |
| 46 void ClearCache(); |
| 47 |
| 48 private: |
| 49 friend class SelfDeletingCallback; // For updating the cache. |
| 50 |
| 51 bool initialized_; |
| 52 // Set up during Initialize. |
| 53 bool supports_request_; |
| 54 base::android::ScopedJavaGlobalRef<jobject> java_provider_; |
| 55 |
| 56 std::map<GURL, std::string> error_page_cache_; |
| 57 std::map<GURL, bool> url_access_cache_; |
| 58 std::list<GURL> recent_urls_; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(ContentResolverWebRestrictionsProvider); |
| 61 }; |
| 62 |
| 63 } // namespace web_restrictions |
| 64 |
| 65 #endif // COMPONENTS_WEB_RESTRICTION_CONTENT_RESOLVER_WEB_RESTRICTION_PROVIDER_
H_ |
OLD | NEW |