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

Side by Side Diff: components/web_restriction/content_resolver_web_restriction_provider.h

Issue 1423713015: [WIP] WebRestrictions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 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
10 #include "base/android/jni_android.h"
11 #include "base/callback.h"
12 #include "base/macros.h"
13 #include "base/observer_list.h"
14 #include "components/web_restriction/web_restriction_provider.h"
15
16 namespace web_restriction {
17
18 namespace android {
Bernhard Bauer 2016/01/22 17:32:31 Empty line after this one? Also, add a comment fo
knn 2016/01/25 11:54:24 Done.
19 class SelfDeletingCallback {
20 public:
21 SelfDeletingCallback(const GURL& url,
22 const base::Callback<void(bool)>& callback);
23
24 void ShouldProceed(JNIEnv* env,
25 const base::android::JavaParamRef<jobject>& obj,
26 jboolean should_proceed);
27
28 private:
29 GURL url_;
30 base::Callback<void(bool)> callback_;
31
32 // Only the callback can delete itself. We must ensure it is indeed
33 // called back.
34 ~SelfDeletingCallback();
Bernhard Bauer 2016/01/22 17:32:31 Methods come before members in each section. Also
knn 2016/01/25 11:54:24 Done.
35 };
36
37 } // namespace android
38
39 class ContentResolverWebRestrictionProvider : public WebRestrictionProvider {
40 public:
41 ContentResolverWebRestrictionProvider();
42 ~ContentResolverWebRestrictionProvider() override;
43
44 // Register JNI methods.
45 static bool Register(JNIEnv* env);
46
47 // Verify the content provider and Setup.
48 void Initialize(const std::string& content_provider_authority);
49
50 // WebRestrictionProvider:
51 UrlAccess ShouldProceed(bool is_main_frame, const GURL& url) const override;
52
53 void ShouldProceed(bool is_main_frame,
54 const GURL& url,
55 const base::Callback<void(bool)>& callback) const override;
56
57 bool SupportsRequest() const override;
58
59 bool SupportsCustomErrorPage() const override;
60
61 std::string GetErrorHtml() const override;
62
63 void RequestPermission(const GURL& url) override;
64
65 void AddObserver(Observer* observer) override;
66
67 void RemoveObserver(Observer* observer) override;
68
69 private:
70 friend class SelfDeletingCallback; // For updating the cache.
71
72 base::ObserverList<Observer> observer_list_;
73 base::android::ScopedJavaGlobalRef<jobject> java_provider_;
74
75 // Setup during Initialize.
76 bool initialized_;
77 bool supports_request_;
78 std::string error_page_;
Bernhard Bauer 2016/01/22 17:32:31 |error_page_html_| maybe?
knn 2016/01/25 11:54:24 Removed this to support error page per url.
79
80 DISALLOW_COPY_AND_ASSIGN(ContentResolverWebRestrictionProvider);
81 };
82
83 } // namespace web_restriction
84
85 #endif // COMPONENTS_WEB_RESTRICTION_CONTENT_RESOLVER_WEB_RESTRICTION_PROVIDER_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698