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

Side by Side 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: moar comments Created 4 years, 10 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 unified diff | Download patch
OLDNEW
(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/sequenced_task_runner.h"
17 #include "base/task_runner.h"
18 #include "components/web_restrictions/web_restrictions_provider.h"
19
20 namespace web_restrictions {
21
22 class ContentResolverWebRestrictionsProvider : public WebRestrictionsProvider {
23 public:
24 ContentResolverWebRestrictionsProvider();
25 ~ContentResolverWebRestrictionsProvider() override;
26
27 // Register JNI methods.
28 static bool Register(JNIEnv* env);
29
30 // Verify the content provider and query it for basic information like does it
31 // support handling requests. This should be called everytime the provider
32 // changes.
33 void SetAuthority(const std::string& content_provider_authority);
34
35 // WebRestrictionsProvider:
36 UrlAccess ShouldProceed(bool is_main_frame,
37 const GURL& url,
38 const base::Callback<void(bool)>& callback) override;
39
40 bool SupportsRequest() const override;
41
42 bool GetErrorHtml(const GURL& url, std::string* error_html) const override;
43
44 void RequestPermission(const GURL& url,
45 const base::Callback<void(bool)>& callback) override;
46
47 void ClearCache();
48
49 private:
50 friend class SelfDeletingCallback; // For updating the cache.
51
52 void RecordURLAccess(const GURL& url);
53
54 void UpdateCache(const GURL& url,
55 bool should_proceed,
56 std::string* error_page);
57
58 void RequestSupportKnown(bool supports_request);
59
60 // Set up after SetAuthority().
61 bool initialized_;
62 bool supports_request_;
63 base::android::ScopedJavaGlobalRef<jobject> java_provider_;
64
65 scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
66
67 std::map<GURL, std::string> error_page_cache_;
68 std::map<GURL, bool> url_access_cache_;
69 std::list<GURL> recent_urls_;
70
71 DISALLOW_COPY_AND_ASSIGN(ContentResolverWebRestrictionsProvider);
72 };
73
74 } // namespace web_restrictions
75
76 #endif // COMPONENTS_WEB_RESTRICTION_CONTENT_RESOLVER_WEB_RESTRICTION_PROVIDER_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698