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

Side by Side Diff: components/web_restrictions/browser/web_restrictions_client.h

Issue 1847523002: Avoid HTML in WebRestrictionsContentProvider interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to one more comment Created 4 years, 8 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_WEB_RESTRICTION_WEB_RESTRICTIONS_CLIENT_H_ 5 #ifndef COMPONENTS_WEB_RESTRICTION_WEB_RESTRICTIONS_CLIENT_H_
6 #define COMPONENTS_WEB_RESTRICTION_WEB_RESTRICTIONS_CLIENT_H_ 6 #define COMPONENTS_WEB_RESTRICTION_WEB_RESTRICTIONS_CLIENT_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 12
13 #include "base/android/jni_android.h" 13 #include "base/android/jni_android.h"
14 #include "base/android/scoped_java_ref.h"
14 #include "base/callback.h" 15 #include "base/callback.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
17 #include "base/sequenced_task_runner.h" 18 #include "base/sequenced_task_runner.h"
18 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
19 #include "url/gurl.h" 20 #include "url/gurl.h"
20 21
21 namespace web_restrictions { 22 namespace web_restrictions {
22 23
23 enum UrlAccess { ALLOW, DISALLOW, PENDING }; 24 enum UrlAccess { ALLOW, DISALLOW, PENDING };
(...skipping 15 matching lines...) Expand all
39 // changes. An empty authority can be used to disable this class. 40 // changes. An empty authority can be used to disable this class.
40 void SetAuthority(const std::string& content_provider_authority); 41 void SetAuthority(const std::string& content_provider_authority);
41 42
42 // WebRestrictionsProvider: 43 // WebRestrictionsProvider:
43 UrlAccess ShouldProceed(bool is_main_frame, 44 UrlAccess ShouldProceed(bool is_main_frame,
44 const GURL& url, 45 const GURL& url,
45 const base::Callback<void(bool)>& callback); 46 const base::Callback<void(bool)>& callback);
46 47
47 bool SupportsRequest() const; 48 bool SupportsRequest() const;
48 49
49 bool GetErrorHtml(const GURL& url, std::string* error_html) const; 50 int GetResultColumnCount(const GURL& url) const;
51
52 std::string GetResultColumnName(const GURL& url, int column) const;
53
54 int GetResultIntValue(const GURL& url, int column) const;
55
56 std::string GetResultStringValue(const GURL& url, int column) const;
50 57
51 void RequestPermission(const GURL& url, 58 void RequestPermission(const GURL& url,
52 const base::Callback<void(bool)>& callback); 59 const base::Callback<void(bool)>& callback);
53 60
54 void OnWebRestrictionsChanged(); 61 void OnWebRestrictionsChanged();
55 62
56 private: 63 private:
57 struct ShouldProceedResult {
58 bool ok_to_proceed;
59 std::string error_page;
60 };
61 64
62 void RecordURLAccess(const GURL& url); 65 void RecordURLAccess(const GURL& url);
63 66
64 void UpdateCache(std::string provider_authority, 67 void UpdateCache(std::string provider_authority,
65 GURL url, 68 GURL url,
66 bool should_proceed, 69 base::android::ScopedJavaGlobalRef<jobject> result);
67 std::string error_page);
68 70
69 void RequestSupportKnown(std::string provider_authority, 71 void RequestSupportKnown(std::string provider_authority,
70 bool supports_request); 72 bool supports_request);
71 73
72 void ClearCache(); 74 void ClearCache();
73 75
74 static ShouldProceedResult ShouldProceedTask( 76 static base::android::ScopedJavaGlobalRef<jobject> ShouldProceedTask(
75 const GURL& url, 77 const GURL& url,
76 const base::android::JavaRef<jobject>& java_provider); 78 const base::android::JavaRef<jobject>& java_provider);
77 79
78 void OnShouldProceedComplete(std::string provider_authority, 80 void OnShouldProceedComplete(
79 const GURL& url, 81 std::string provider_authority,
80 const base::Callback<void(bool)>& callback, 82 const GURL& url,
81 const ShouldProceedResult& result); 83 const base::Callback<void(bool)>& callback,
84 const base::android::ScopedJavaGlobalRef<jobject>& result);
82 85
83 // Set up after SetAuthority(). 86 // Set up after SetAuthority().
84 bool initialized_; 87 bool initialized_;
85 bool supports_request_; 88 bool supports_request_;
86 base::android::ScopedJavaGlobalRef<jobject> java_provider_; 89 base::android::ScopedJavaGlobalRef<jobject> java_provider_;
87 std::string provider_authority_; 90 std::string provider_authority_;
88 91
89 scoped_refptr<base::SequencedTaskRunner> background_task_runner_; 92 scoped_refptr<base::SequencedTaskRunner> background_task_runner_;
90 scoped_refptr<base::SingleThreadTaskRunner> single_thread_task_runner_; 93 scoped_refptr<base::SingleThreadTaskRunner> single_thread_task_runner_;
91 94
92 std::map<GURL, std::string> error_page_cache_; 95 std::map<GURL, base::android::ScopedJavaGlobalRef<jobject>> cache_;
93 std::map<GURL, bool> url_access_cache_;
94 std::list<GURL> recent_urls_; 96 std::list<GURL> recent_urls_;
95 97
96 DISALLOW_COPY_AND_ASSIGN(WebRestrictionsClient); 98 DISALLOW_COPY_AND_ASSIGN(WebRestrictionsClient);
97 }; 99 };
98 100
99 } // namespace web_restrictions 101 } // namespace web_restrictions
100 102
101 #endif // COMPONENTS_WEB_RESTRICTION_WEB_RESTRICTIONS_CLIENT_H_ 103 #endif // COMPONENTS_WEB_RESTRICTION_WEB_RESTRICTIONS_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698