Chromium Code Reviews| Index: chrome/browser/guest_view/web_view/web_view_guest.h |
| diff --git a/chrome/browser/guest_view/web_view/web_view_guest.h b/chrome/browser/guest_view/web_view/web_view_guest.h |
| index 37557bfd2ce7a75355cecd7fe2008c5b19fb6781..9811636df4191511d9acded13fd98ff54bbfca29 100644 |
| --- a/chrome/browser/guest_view/web_view/web_view_guest.h |
| +++ b/chrome/browser/guest_view/web_view/web_view_guest.h |
| @@ -12,6 +12,7 @@ |
| #include "chrome/browser/guest_view/guest_view.h" |
| #include "chrome/browser/guest_view/web_view/javascript_dialog_helper.h" |
| #include "chrome/browser/guest_view/web_view/web_view_find_helper.h" |
| +#include "chrome/browser/guest_view/web_view/web_view_permission_types.h" |
| #include "chrome/common/extensions/api/webview.h" |
| #include "content/public/browser/javascript_dialog_manager.h" |
| #include "content/public/browser/notification_registrar.h" |
| @@ -47,8 +48,7 @@ class WebViewGuest : public GuestView<WebViewGuest>, |
| public content::WebContentsObserver { |
| public: |
| WebViewGuest(content::WebContents* guest_web_contents, |
| - const std::string& embedder_extension_id, |
| - const base::WeakPtr<GuestViewBase>& opener); |
| + const std::string& embedder_extension_id); |
| // Returns guestview::kInstanceIDNone if |contents| does not correspond to a |
| // WebViewGuest. |
| @@ -89,17 +89,8 @@ class WebViewGuest : public GuestView<WebViewGuest>, |
| const content::NativeWebKeyboardEvent& event) OVERRIDE; |
| virtual bool IsDragAndDropEnabled() OVERRIDE; |
| virtual bool IsOverridingUserAgent() const OVERRIDE; |
| - virtual void LoadAbort(bool is_top_level, |
| - const GURL& url, |
| - const std::string& error_type) OVERRIDE; |
| virtual void RendererResponsive() OVERRIDE; |
| virtual void RendererUnresponsive() OVERRIDE; |
| - virtual void RequestPermission( |
| - BrowserPluginPermissionType permission_type, |
| - const base::DictionaryValue& request_info, |
| - const PermissionResponseCallback& callback, |
| - bool allowed_by_default) OVERRIDE; |
| - virtual GURL ResolveURL(const std::string& src) OVERRIDE; |
| virtual void SizeChanged(const gfx::Size& old_size, const gfx::Size& new_size) |
| OVERRIDE; |
| virtual void RequestMediaAccessPermission( |
| @@ -114,6 +105,22 @@ class WebViewGuest : public GuestView<WebViewGuest>, |
| const base::Callback<void(bool)>& callback) OVERRIDE; |
| virtual content::JavaScriptDialogManager* |
| GetJavaScriptDialogManager() OVERRIDE; |
| + virtual void NavigateGuest(const std::string& src) OVERRIDE; |
| + virtual void Destroy() OVERRIDE; |
| + virtual void AddNewContents(content::WebContents* source, |
| + content::WebContents* new_contents, |
| + WindowOpenDisposition disposition, |
| + const gfx::Rect& initial_pos, |
| + bool user_gesture, |
| + bool* was_blocked) OVERRIDE; |
| + virtual content::WebContents* OpenURLFromTab( |
| + content::WebContents* source, |
| + const content::OpenURLParams& params) OVERRIDE; |
| + virtual void WebContentsCreated(content::WebContents* source_contents, |
| + int opener_render_frame_id, |
| + const base::string16& frame_name, |
| + const GURL& target_url, |
| + content::WebContents* new_contents) OVERRIDE; |
| // NotificationObserver implementation. |
| virtual void Observe(int type, |
| @@ -141,6 +148,15 @@ class WebViewGuest : public GuestView<WebViewGuest>, |
| // Reload the guest. |
| void Reload(); |
| + typedef base::Callback<void(bool /* allow */, |
| + const std::string& /* user_input */)> |
| + PermissionResponseCallback; |
| + int RequestPermission( |
| + WebViewPermissionType permission_type, |
| + const base::DictionaryValue& request_info, |
| + const PermissionResponseCallback& callback, |
| + bool allowed_by_default); |
| + |
| // Requests Geolocation Permission from the embedder. |
| void RequestGeolocationPermission(int bridge_id, |
| const GURL& requesting_frame, |
| @@ -172,6 +188,11 @@ class WebViewGuest : public GuestView<WebViewGuest>, |
| bool allow, |
| const std::string& user_input); |
| + void OnWebViewNewWindowResponse( |
| + int new_window_instance_id, |
|
lazyboy
2014/05/12 23:00:20
Can fit in previous line, indentation is off.
Fady Samuel
2014/05/13 18:59:02
Done.
|
| + bool allow, |
| + const std::string& user_input); |
| + |
| enum PermissionResponseAction { |
| DENY, |
| ALLOW, |
| @@ -219,11 +240,11 @@ class WebViewGuest : public GuestView<WebViewGuest>, |
| // A map to store the callback for a request keyed by the request's id. |
| struct PermissionResponseInfo { |
| PermissionResponseCallback callback; |
| - BrowserPluginPermissionType permission_type; |
| + WebViewPermissionType permission_type; |
| bool allowed_by_default; |
| PermissionResponseInfo(); |
| PermissionResponseInfo(const PermissionResponseCallback& callback, |
| - BrowserPluginPermissionType permission_type, |
| + WebViewPermissionType permission_type, |
| bool allowed_by_default); |
| ~PermissionResponseInfo(); |
| }; |
| @@ -292,11 +313,34 @@ class WebViewGuest : public GuestView<WebViewGuest>, |
| // provided |bridge_id|. It returns the request ID of the geolocation request. |
| int RemoveBridgeID(int bridge_id); |
| - int RequestPermissionInternal( |
| - BrowserPluginPermissionType permission_type, |
| - const base::DictionaryValue& request_info, |
| - const PermissionResponseCallback& callback, |
| - bool allowed_by_default); |
| + void LoadURLWithParams(const GURL& url, |
| + const content::Referrer& referrer, |
| + content::PageTransition transition_type, |
| + content::WebContents* web_contents); |
| + |
| + void RequestNewWindowPermission( |
| + WindowOpenDisposition disposition, |
| + const gfx::Rect& initial_bounds, |
| + bool user_gesture, |
| + content::WebContents* new_contents); |
| + |
| + // Destroy unattached new windows that have been opened by this |
| + // WebViewGuest. |
| + void DestroyUnattachedWindows(); |
| + |
| + // Requests resolution of a potentially relative URL. |
| + GURL ResolveURL(const std::string& src); |
| + |
| + // Notification that a load in the guest resulted in abort. Note that |url| |
| + // may be invalid. |
| + void LoadAbort(bool is_top_level, |
| + const GURL& url, |
| + const std::string& error_type); |
| + |
| + |
| + // Creates a new guest window owned by this WebViewGuest |
| + // BrowserPluginGuest. |
| + WebViewGuest* CreateNewGuestWindow(const content::OpenURLParams& params); |
| ObserverList<extensions::TabHelper::ScriptExecutionObserver> |
| script_observers_; |
| @@ -352,6 +396,21 @@ class WebViewGuest : public GuestView<WebViewGuest>, |
| std::map<int, int> bridge_id_to_request_id_map_; |
| + // Tracks the name, and target URL of the new window and whether or not it has |
| + // changed since the WebContents has been created and before the new window |
| + // has been attached to a BrowserPlugin. Once the first navigation commits, we |
| + // no longer track this information. |
| + struct NewWindowInfo { |
| + GURL url; |
| + std::string name; |
| + NewWindowInfo(const GURL& url, const std::string& name) : |
| + url(url), |
| + name(name) {} |
| + }; |
| + |
| + typedef std::map<WebViewGuest*, NewWindowInfo> PendingWindowMap; |
| + PendingWindowMap pending_new_windows_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(WebViewGuest); |
| }; |