OLD | NEW |
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 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 protected: | 290 protected: |
361 virtual ~WebViewInternalSetPermissionFunction(); | 291 virtual ~WebViewInternalSetPermissionFunction(); |
362 | 292 |
363 private: | 293 private: |
364 // WebViewInternalExtensionFunction implementation. | 294 // WebViewInternalExtensionFunction implementation. |
365 virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; | 295 virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; |
366 | 296 |
367 DISALLOW_COPY_AND_ASSIGN(WebViewInternalSetPermissionFunction); | 297 DISALLOW_COPY_AND_ASSIGN(WebViewInternalSetPermissionFunction); |
368 }; | 298 }; |
369 | 299 |
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 | 300 class WebViewInternalOverrideUserAgentFunction |
389 : public WebViewInternalExtensionFunction { | 301 : public WebViewInternalExtensionFunction { |
390 public: | 302 public: |
391 DECLARE_EXTENSION_FUNCTION("webViewInternal.overrideUserAgent", | 303 DECLARE_EXTENSION_FUNCTION("webViewInternal.overrideUserAgent", |
392 WEBVIEWINTERNAL_OVERRIDEUSERAGENT); | 304 WEBVIEWINTERNAL_OVERRIDEUSERAGENT); |
393 | 305 |
394 WebViewInternalOverrideUserAgentFunction(); | 306 WebViewInternalOverrideUserAgentFunction(); |
395 | 307 |
396 protected: | 308 protected: |
397 virtual ~WebViewInternalOverrideUserAgentFunction(); | 309 virtual ~WebViewInternalOverrideUserAgentFunction(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 private: | 345 private: |
434 // WebViewInternalExtensionFunction implementation. | 346 // WebViewInternalExtensionFunction implementation. |
435 virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; | 347 virtual bool RunAsyncSafe(WebViewGuest* guest) OVERRIDE; |
436 | 348 |
437 DISALLOW_COPY_AND_ASSIGN(WebViewInternalTerminateFunction); | 349 DISALLOW_COPY_AND_ASSIGN(WebViewInternalTerminateFunction); |
438 }; | 350 }; |
439 | 351 |
440 } // namespace extensions | 352 } // namespace extensions |
441 | 353 |
442 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ | 354 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ |
OLD | NEW |