| 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 EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ | 5 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ |
| 6 #define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ | 6 #define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
| 11 #include "content/public/browser/javascript_dialog_manager.h" | 11 #include "content/public/browser/javascript_dialog_manager.h" |
| 12 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
| 13 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
| 14 #include "extensions/browser/guest_view/guest_view.h" | 14 #include "extensions/browser/guest_view/guest_view.h" |
| 15 #include "extensions/browser/guest_view/web_view/javascript_dialog_helper.h" | 15 #include "extensions/browser/guest_view/web_view/javascript_dialog_helper.h" |
| 16 #include "extensions/browser/guest_view/web_view/web_view_find_helper.h" | 16 #include "extensions/browser/guest_view/web_view/web_view_find_helper.h" |
| 17 #include "extensions/browser/guest_view/web_view/web_view_guest_delegate.h" | 17 #include "extensions/browser/guest_view/web_view/web_view_guest_delegate.h" |
| 18 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h" | 18 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h" |
| 19 #include "extensions/browser/guest_view/web_view/web_view_permission_types.h" | 19 #include "extensions/browser/guest_view/web_view/web_view_permission_types.h" |
| 20 #include "extensions/browser/script_executor.h" | 20 #include "extensions/browser/script_executor.h" |
| 21 | 21 |
| 22 namespace blink { | 22 namespace blink { |
| 23 struct WebFindOptions; | 23 struct WebFindOptions; |
| 24 } // nanespace blink | 24 } // nanespace blink |
| 25 | 25 |
| 26 namespace extensions { | 26 namespace extensions { |
| 27 | 27 |
| 28 class RulesRegistryService; |
| 28 class WebViewInternalFindFunction; | 29 class WebViewInternalFindFunction; |
| 29 | 30 |
| 30 // A WebViewGuest provides the browser-side implementation of the <webview> API | 31 // A WebViewGuest provides the browser-side implementation of the <webview> API |
| 31 // and manages the dispatch of <webview> extension events. WebViewGuest is | 32 // and manages the dispatch of <webview> extension events. WebViewGuest is |
| 32 // created on attachment. That is, when a guest WebContents is associated with | 33 // created on attachment. That is, when a guest WebContents is associated with |
| 33 // a particular embedder WebContents. This happens on either initial navigation | 34 // a particular embedder WebContents. This happens on either initial navigation |
| 34 // or through the use of the New Window API, when a new window is attached to | 35 // or through the use of the New Window API, when a new window is attached to |
| 35 // a particular <webview>. | 36 // a particular <webview>. |
| 36 class WebViewGuest : public GuestView<WebViewGuest>, | 37 class WebViewGuest : public GuestView<WebViewGuest>, |
| 37 public content::NotificationObserver { | 38 public content::NotificationObserver { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 50 std::string* partition_domain, | 51 std::string* partition_domain, |
| 51 std::string* partition_name, | 52 std::string* partition_name, |
| 52 bool* in_memory); | 53 bool* in_memory); |
| 53 | 54 |
| 54 // Returns guestview::kInstanceIDNone if |contents| does not correspond to a | 55 // Returns guestview::kInstanceIDNone if |contents| does not correspond to a |
| 55 // WebViewGuest. | 56 // WebViewGuest. |
| 56 static int GetViewInstanceId(content::WebContents* contents); | 57 static int GetViewInstanceId(content::WebContents* contents); |
| 57 | 58 |
| 58 static const char Type[]; | 59 static const char Type[]; |
| 59 | 60 |
| 61 static void GenerateRulesRegistryID( |
| 62 int embedder_process_id, |
| 63 int webview_instance_id, |
| 64 RulesRegistryService* rules_registry_service, |
| 65 int* rules_registry_id); |
| 66 |
| 67 static int GetEmbedderProcessID(int process_id); |
| 68 |
| 69 static void RemoveRulesRegistryID(int rules_registry_id); |
| 70 |
| 60 // Request navigating the guest to the provided |src| URL. | 71 // Request navigating the guest to the provided |src| URL. |
| 61 void NavigateGuest(const std::string& src, bool force_navigation); | 72 void NavigateGuest(const std::string& src, bool force_navigation); |
| 62 | 73 |
| 63 // Shows the context menu for the guest. | 74 // Shows the context menu for the guest. |
| 64 // |items| acts as a filter. This restricts the current context's default | 75 // |items| acts as a filter. This restricts the current context's default |
| 65 // menu items to contain only the items from |items|. | 76 // menu items to contain only the items from |items|. |
| 66 // |items| == NULL means no filtering will be applied. | 77 // |items| == NULL means no filtering will be applied. |
| 67 void ShowContextMenu( | 78 void ShowContextMenu( |
| 68 int request_id, | 79 int request_id, |
| 69 const WebViewGuestDelegate::MenuItemVector* items); | 80 const WebViewGuestDelegate::MenuItemVector* items); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 // Partition data that are newer than |removal_since| will be removed. | 240 // Partition data that are newer than |removal_since| will be removed. |
| 230 // |removal_mask| corresponds to bitmask in StoragePartition::RemoveDataMask. | 241 // |removal_mask| corresponds to bitmask in StoragePartition::RemoveDataMask. |
| 231 bool ClearData(const base::Time remove_since, | 242 bool ClearData(const base::Time remove_since, |
| 232 uint32 removal_mask, | 243 uint32 removal_mask, |
| 233 const base::Closure& callback); | 244 const base::Closure& callback); |
| 234 | 245 |
| 235 ScriptExecutor* script_executor() { return script_executor_.get(); } | 246 ScriptExecutor* script_executor() { return script_executor_.get(); } |
| 236 | 247 |
| 237 private: | 248 private: |
| 238 friend class WebViewPermissionHelper; | 249 friend class WebViewPermissionHelper; |
| 250 |
| 239 WebViewGuest(content::BrowserContext* browser_context, | 251 WebViewGuest(content::BrowserContext* browser_context, |
| 240 int guest_instance_id); | 252 int guest_instance_id); |
| 241 | 253 |
| 242 ~WebViewGuest() override; | 254 ~WebViewGuest() override; |
| 243 | 255 |
| 244 void AttachWebViewHelpers(content::WebContents* contents); | 256 void AttachWebViewHelpers(content::WebContents* contents); |
| 245 | 257 |
| 246 void OnWebViewNewWindowResponse(int new_window_instance_id, | 258 void OnWebViewNewWindowResponse(int new_window_instance_id, |
| 247 bool allow, | 259 bool allow, |
| 248 const std::string& user_input); | 260 const std::string& user_input); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 // This is used to ensure pending tasks will not fire after this object is | 373 // This is used to ensure pending tasks will not fire after this object is |
| 362 // destroyed. | 374 // destroyed. |
| 363 base::WeakPtrFactory<WebViewGuest> weak_ptr_factory_; | 375 base::WeakPtrFactory<WebViewGuest> weak_ptr_factory_; |
| 364 | 376 |
| 365 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); | 377 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); |
| 366 }; | 378 }; |
| 367 | 379 |
| 368 } // namespace extensions | 380 } // namespace extensions |
| 369 | 381 |
| 370 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ | 382 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ |
| OLD | NEW |