| 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 DeclarativeUserScriptMaster; |
| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 void Terminate(); | 229 void Terminate(); |
| 229 | 230 |
| 230 // Clears data in the storage partition of this guest. | 231 // Clears data in the storage partition of this guest. |
| 231 // | 232 // |
| 232 // Partition data that are newer than |removal_since| will be removed. | 233 // Partition data that are newer than |removal_since| will be removed. |
| 233 // |removal_mask| corresponds to bitmask in StoragePartition::RemoveDataMask. | 234 // |removal_mask| corresponds to bitmask in StoragePartition::RemoveDataMask. |
| 234 bool ClearData(const base::Time remove_since, | 235 bool ClearData(const base::Time remove_since, |
| 235 uint32 removal_mask, | 236 uint32 removal_mask, |
| 236 const base::Closure& callback); | 237 const base::Closure& callback); |
| 237 | 238 |
| 239 // Adds content script to inject on the guest. |
| 240 void AddContentScripts(const std::string& script_name, |
| 241 const UserScript& script); |
| 242 |
| 243 // Removes content script by |script_name|. |
| 244 void RemoveContentScripts(const std::string& script_name); |
| 245 |
| 246 // Removes all content scripts added by the guest. |
| 247 void RemoveAllContentScripts(); |
| 248 |
| 238 ScriptExecutor* script_executor() { return script_executor_.get(); } | 249 ScriptExecutor* script_executor() { return script_executor_.get(); } |
| 250 const HostID* host_id() const { return host_id_.get(); } |
| 251 void set_host_id(scoped_ptr<const HostID> host_id) { |
| 252 host_id_ = host_id.Pass(); |
| 253 } |
| 239 | 254 |
| 240 private: | 255 private: |
| 241 friend class WebViewPermissionHelper; | 256 friend class WebViewPermissionHelper; |
| 242 | 257 |
| 258 using UserScriptMap = std::map<std::string, UserScript>; |
| 259 |
| 243 explicit WebViewGuest(content::WebContents* owner_web_contents); | 260 explicit WebViewGuest(content::WebContents* owner_web_contents); |
| 244 | 261 |
| 245 ~WebViewGuest() override; | 262 ~WebViewGuest() override; |
| 246 | 263 |
| 247 void AttachWebViewHelpers(content::WebContents* contents); | 264 void AttachWebViewHelpers(content::WebContents* contents); |
| 248 | 265 |
| 249 void OnWebViewNewWindowResponse(int new_window_instance_id, | 266 void OnWebViewNewWindowResponse(int new_window_instance_id, |
| 250 bool allow, | 267 bool allow, |
| 251 const std::string& user_input); | 268 const std::string& user_input); |
| 252 | 269 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 382 |
| 366 using PendingWindowMap = std::map<WebViewGuest*, NewWindowInfo>; | 383 using PendingWindowMap = std::map<WebViewGuest*, NewWindowInfo>; |
| 367 PendingWindowMap pending_new_windows_; | 384 PendingWindowMap pending_new_windows_; |
| 368 | 385 |
| 369 // Stores the current zoom factor. | 386 // Stores the current zoom factor. |
| 370 double current_zoom_factor_; | 387 double current_zoom_factor_; |
| 371 | 388 |
| 372 // Determines if this guest accepts pinch-zoom gestures. | 389 // Determines if this guest accepts pinch-zoom gestures. |
| 373 bool allow_scaling_; | 390 bool allow_scaling_; |
| 374 | 391 |
| 392 // The ID of the injection host of the guest. |
| 393 scoped_ptr<const HostID> host_id_; |
| 394 |
| 395 DeclarativeUserScriptMaster* master_; |
| 396 |
| 397 UserScriptMap user_script_map_; |
| 398 |
| 375 // This is used to ensure pending tasks will not fire after this object is | 399 // This is used to ensure pending tasks will not fire after this object is |
| 376 // destroyed. | 400 // destroyed. |
| 377 base::WeakPtrFactory<WebViewGuest> weak_ptr_factory_; | 401 base::WeakPtrFactory<WebViewGuest> weak_ptr_factory_; |
| 378 | 402 |
| 379 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); | 403 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); |
| 380 }; | 404 }; |
| 381 | 405 |
| 382 } // namespace extensions | 406 } // namespace extensions |
| 383 | 407 |
| 384 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ | 408 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ |
| OLD | NEW |