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

Side by Side Diff: extensions/browser/api/web_view/web_view_internal_api.h

Issue 541753004: Split web_view_internal_api and move part of it to extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing Created 6 years, 3 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
« no previous file with comments | « extensions/browser/DEPS ('k') | extensions/browser/api/web_view/web_view_internal_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 CHROME_BROWSER_EXTENSIONS_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ 5 #ifndef EXTENSIONS_BROWSER_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ 6 #define EXTENSIONS_BROWSER_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_
7 7
8 #include "extensions/browser/api/capture_web_contents_function.h" 8 #include "extensions/browser/api/capture_web_contents_function.h"
9 #include "extensions/browser/api/execute_code_function.h" 9 #include "extensions/browser/api/execute_code_function.h"
10 #include "extensions/browser/extension_function.h" 10 #include "extensions/browser/extension_function.h"
11 #include "extensions/browser/guest_view/web_view/web_view_guest.h" 11 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
12 12
13 // WARNING: WebViewInternal could be loaded in an unblessed context, thus any 13 // WARNING: WebViewInternal could be loaded in an unblessed context, thus any
14 // new APIs must extend WebViewInternalExtensionFunction or 14 // new APIs must extend WebViewInternalExtensionFunction or
15 // WebViewInternalExecuteCodeFunction which do a process ID check to prevent 15 // WebViewInternalExecuteCodeFunction which do a process ID check to prevent
16 // abuse by normal renderer processes. 16 // abuse by normal renderer processes.
17 // TODO(guohui): refactor WebViewInternalExecuteCodeFunction to also extend
18 // WebViewInternalExtensionFunction.
19 namespace extensions { 17 namespace extensions {
20 18
21 // An abstract base class for async webview APIs. It does a process ID check 19 // An abstract base class for async webview APIs. It does a process ID check
22 // in RunAsync, and then calls RunAsyncSafe which must be overriden by all 20 // in RunAsync, and then calls RunAsyncSafe which must be overriden by all
23 // subclasses. 21 // subclasses.
24 class WebViewInternalExtensionFunction : public AsyncExtensionFunction { 22 class WebViewInternalExtensionFunction : public AsyncExtensionFunction {
25 public: 23 public:
26 WebViewInternalExtensionFunction() {} 24 WebViewInternalExtensionFunction() {}
27 25
28 protected: 26 protected:
29 virtual ~WebViewInternalExtensionFunction() {} 27 virtual ~WebViewInternalExtensionFunction() {}
30 28
31 // ExtensionFunction implementation. 29 // ExtensionFunction implementation.
32 virtual bool RunAsync() OVERRIDE FINAL; 30 virtual bool RunAsync() OVERRIDE FINAL;
33 31
34 private: 32 private:
35 virtual bool RunAsyncSafe(WebViewGuest* guest) = 0; 33 virtual bool RunAsyncSafe(WebViewGuest* guest) = 0;
36 }; 34 };
37 35
38 class WebViewInternalContextMenusCreateFunction
39 : public AsyncExtensionFunction {
40 public:
41 DECLARE_EXTENSION_FUNCTION("webViewInternal.contextMenusCreate",
42 WEBVIEWINTERNAL_CONTEXTMENUSCREATE);
43 WebViewInternalContextMenusCreateFunction() {}
44
45 protected:
46 virtual ~WebViewInternalContextMenusCreateFunction() {}
47
48 // ExtensionFunction implementation.
49 virtual bool RunAsync() OVERRIDE;
50
51 private:
52 DISALLOW_COPY_AND_ASSIGN(WebViewInternalContextMenusCreateFunction);
53 };
54
55 class WebViewInternalContextMenusUpdateFunction
56 : public AsyncExtensionFunction {
57 public:
58 DECLARE_EXTENSION_FUNCTION("webViewInternal.contextMenusUpdate",
59 WEBVIEWINTERNAL_CONTEXTMENUSUPDATE);
60 WebViewInternalContextMenusUpdateFunction() {}
61
62 protected:
63 virtual ~WebViewInternalContextMenusUpdateFunction() {}
64
65 // ExtensionFunction implementation.
66 virtual bool RunAsync() OVERRIDE;
67
68 private:
69 DISALLOW_COPY_AND_ASSIGN(WebViewInternalContextMenusUpdateFunction);
70 };
71
72 class WebViewInternalContextMenusRemoveFunction
73 : public AsyncExtensionFunction {
74 public:
75 DECLARE_EXTENSION_FUNCTION("webViewInternal.contextMenusRemove",
76 WEBVIEWINTERNAL_CONTEXTMENUSREMOVE);
77 WebViewInternalContextMenusRemoveFunction() {}
78
79 protected:
80 virtual ~WebViewInternalContextMenusRemoveFunction() {}
81
82 // ExtensionFunction implementation.
83 virtual bool RunAsync() OVERRIDE;
84
85 private:
86 DISALLOW_COPY_AND_ASSIGN(WebViewInternalContextMenusRemoveFunction);
87 };
88
89 class WebViewInternalContextMenusRemoveAllFunction
90 : public AsyncExtensionFunction {
91 public:
92 DECLARE_EXTENSION_FUNCTION("webViewInternal.contextMenusRemoveAll",
93 WEBVIEWINTERNAL_CONTEXTMENUSREMOVEALL);
94 WebViewInternalContextMenusRemoveAllFunction() {}
95
96 protected:
97 virtual ~WebViewInternalContextMenusRemoveAllFunction() {}
98
99 // ExtensionFunction implementation.
100 virtual bool RunAsync() OVERRIDE;
101
102 private:
103 DISALLOW_COPY_AND_ASSIGN(WebViewInternalContextMenusRemoveAllFunction);
104 };
105
106 class WebViewInternalNavigateFunction 36 class WebViewInternalNavigateFunction
107 : public WebViewInternalExtensionFunction { 37 : public WebViewInternalExtensionFunction {
108 public: 38 public:
109 DECLARE_EXTENSION_FUNCTION("webViewInternal.navigate", 39 DECLARE_EXTENSION_FUNCTION("webViewInternal.navigate",
110 WEBVIEWINTERNAL_NAVIGATE); 40 WEBVIEWINTERNAL_NAVIGATE);
111 WebViewInternalNavigateFunction() {} 41 WebViewInternalNavigateFunction() {}
112 42
113 protected: 43 protected:
114 virtual ~WebViewInternalNavigateFunction() {} 44 virtual ~WebViewInternalNavigateFunction() {}
115 45
116 private: 46 private:
117 // WebViewInternalExtensionFunction implementation. 47 // WebViewInternalExtensionFunction implementation.
118 virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; 48 virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE;
119 49
120 DISALLOW_COPY_AND_ASSIGN(WebViewInternalNavigateFunction); 50 DISALLOW_COPY_AND_ASSIGN(WebViewInternalNavigateFunction);
121 }; 51 };
122 52
123 class WebViewInternalClearDataFunction
124 : public WebViewInternalExtensionFunction {
125 public:
126 DECLARE_EXTENSION_FUNCTION("webViewInternal.clearData",
127 WEBVIEWINTERNAL_CLEARDATA);
128
129 WebViewInternalClearDataFunction();
130
131 protected:
132 virtual ~WebViewInternalClearDataFunction();
133
134 private:
135 // WebViewInternalExtensionFunction implementation.
136 virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE;
137
138 uint32 GetRemovalMask();
139 void ClearDataDone();
140
141 // Removal start time.
142 base::Time remove_since_;
143 // Removal mask, corresponds to StoragePartition::RemoveDataMask enum.
144 uint32 remove_mask_;
145 // Tracks any data related or parse errors.
146 bool bad_message_;
147
148 DISALLOW_COPY_AND_ASSIGN(WebViewInternalClearDataFunction);
149 };
150
151 class WebViewInternalExecuteCodeFunction 53 class WebViewInternalExecuteCodeFunction
152 : public extensions::ExecuteCodeFunction { 54 : public extensions::ExecuteCodeFunction {
153 public: 55 public:
154 WebViewInternalExecuteCodeFunction(); 56 WebViewInternalExecuteCodeFunction();
155 57
156 protected: 58 protected:
157 virtual ~WebViewInternalExecuteCodeFunction(); 59 virtual ~WebViewInternalExecuteCodeFunction();
158 60
159 // Initialize |details_| if it hasn't already been. 61 // Initialize |details_| if it hasn't already been.
160 virtual bool Init() OVERRIDE; 62 virtual bool Init() OVERRIDE;
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 protected: 262 protected:
361 virtual ~WebViewInternalSetPermissionFunction(); 263 virtual ~WebViewInternalSetPermissionFunction();
362 264
363 private: 265 private:
364 // WebViewInternalExtensionFunction implementation. 266 // WebViewInternalExtensionFunction implementation.
365 virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; 267 virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE;
366 268
367 DISALLOW_COPY_AND_ASSIGN(WebViewInternalSetPermissionFunction); 269 DISALLOW_COPY_AND_ASSIGN(WebViewInternalSetPermissionFunction);
368 }; 270 };
369 271
370 class WebViewInternalShowContextMenuFunction
371 : public WebViewInternalExtensionFunction {
372 public:
373 DECLARE_EXTENSION_FUNCTION("webViewInternal.showContextMenu",
374 WEBVIEWINTERNAL_SHOWCONTEXTMENU);
375
376 WebViewInternalShowContextMenuFunction();
377
378 protected:
379 virtual ~WebViewInternalShowContextMenuFunction();
380
381 private:
382 // WebViewInternalExtensionFunction implementation.
383 virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE;
384
385 DISALLOW_COPY_AND_ASSIGN(WebViewInternalShowContextMenuFunction);
386 };
387
388 class WebViewInternalOverrideUserAgentFunction 272 class WebViewInternalOverrideUserAgentFunction
389 : public WebViewInternalExtensionFunction { 273 : public WebViewInternalExtensionFunction {
390 public: 274 public:
391 DECLARE_EXTENSION_FUNCTION("webViewInternal.overrideUserAgent", 275 DECLARE_EXTENSION_FUNCTION("webViewInternal.overrideUserAgent",
392 WEBVIEWINTERNAL_OVERRIDEUSERAGENT); 276 WEBVIEWINTERNAL_OVERRIDEUSERAGENT);
393 277
394 WebViewInternalOverrideUserAgentFunction(); 278 WebViewInternalOverrideUserAgentFunction();
395 279
396 protected: 280 protected:
397 virtual ~WebViewInternalOverrideUserAgentFunction(); 281 virtual ~WebViewInternalOverrideUserAgentFunction();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 private: 317 private:
434 // WebViewInternalExtensionFunction implementation. 318 // WebViewInternalExtensionFunction implementation.
435 virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; 319 virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE;
436 320
437 DISALLOW_COPY_AND_ASSIGN(WebViewInternalTerminateFunction); 321 DISALLOW_COPY_AND_ASSIGN(WebViewInternalTerminateFunction);
438 }; 322 };
439 323
440 } // namespace extensions 324 } // namespace extensions
441 325
442 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ 326 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_
OLDNEW
« no previous file with comments | « extensions/browser/DEPS ('k') | extensions/browser/api/web_view/web_view_internal_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698