| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_GUESTVIEW_WEBVIEW_WEBVIEW_GUEST_H_ | 5 #ifndef CHROME_BROWSER_GUESTVIEW_WEBVIEW_WEBVIEW_GUEST_H_ |
| 6 #define CHROME_BROWSER_GUESTVIEW_WEBVIEW_WEBVIEW_GUEST_H_ | 6 #define CHROME_BROWSER_GUESTVIEW_WEBVIEW_WEBVIEW_GUEST_H_ |
| 7 | 7 |
| 8 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
| 9 #include "chrome/browser/extensions/tab_helper.h" | 9 #include "chrome/browser/extensions/tab_helper.h" |
| 10 #include "chrome/browser/guestview/guestview.h" | 10 #include "chrome/browser/guestview/guestview.h" |
| 11 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
| 12 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
| 13 | 13 |
| 14 namespace extensions { | 14 namespace extensions { |
| 15 class ScriptExecutor; | 15 class ScriptExecutor; |
| 16 } // namespace extensions | 16 } // namespace extensions |
| 17 | 17 |
| 18 // A WebViewGuest is a WebContentsObserver on the guest WebContents of a | 18 // A WebViewGuest is a WebContentsObserver on the guest WebContents of a |
| 19 // <webview> tag. It provides the browser-side implementation of the <webview> | 19 // <webview> tag. It provides the browser-side implementation of the <webview> |
| 20 // API and manages the lifetime of <webview> extension events. WebViewGuest is | 20 // API and manages the lifetime of <webview> extension events. WebViewGuest is |
| 21 // created on attachment. That is, when a guest WebContents is associated with | 21 // created on attachment. That is, when a guest WebContents is associated with |
| 22 // a particular embedder WebContents. This happens on either initial navigation | 22 // a particular embedder WebContents. This happens on either initial navigation |
| 23 // or through the use of the New Window API, when a new window is attached to | 23 // or through the use of the New Window API, when a new window is attached to |
| 24 // a particular <webview>. | 24 // a particular <webview>. |
| 25 class WebViewGuest : public GuestView, | 25 class WebViewGuest : public GuestView, |
| 26 public content::NotificationObserver, | 26 public content::NotificationObserver, |
| 27 public content::WebContentsObserver { | 27 public content::WebContentsObserver { |
| 28 public: | 28 public: |
| 29 explicit WebViewGuest(content::WebContents* guest_web_contents); | 29 WebViewGuest(content::WebContents* guest_web_contents, |
| 30 const std::string& extension_id); |
| 30 | 31 |
| 31 static WebViewGuest* From(int embedder_process_id, int instance_id); | 32 static WebViewGuest* From(int embedder_process_id, int instance_id); |
| 32 static WebViewGuest* FromWebContents(content::WebContents* contents); | 33 static WebViewGuest* FromWebContents(content::WebContents* contents); |
| 33 | 34 |
| 34 // GuestView implementation. | 35 // GuestView implementation. |
| 35 virtual void Attach(content::WebContents* embedder_web_contents, | 36 virtual void Attach(content::WebContents* embedder_web_contents, |
| 36 const std::string& extension_id, | 37 const std::string& extension_id, |
| 37 const base::DictionaryValue& args) OVERRIDE; | 38 const base::DictionaryValue& args) OVERRIDE; |
| 38 virtual GuestView::Type GetViewType() const OVERRIDE; | 39 virtual GuestView::Type GetViewType() const OVERRIDE; |
| 39 virtual WebViewGuest* AsWebView() OVERRIDE; | 40 virtual WebViewGuest* AsWebView() OVERRIDE; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 55 virtual void LoadAbort(bool is_top_level, | 56 virtual void LoadAbort(bool is_top_level, |
| 56 const GURL& url, | 57 const GURL& url, |
| 57 const std::string& error_type) OVERRIDE; | 58 const std::string& error_type) OVERRIDE; |
| 58 virtual void RendererResponsive() OVERRIDE; | 59 virtual void RendererResponsive() OVERRIDE; |
| 59 virtual void RendererUnresponsive() OVERRIDE; | 60 virtual void RendererUnresponsive() OVERRIDE; |
| 60 virtual bool RequestPermission( | 61 virtual bool RequestPermission( |
| 61 BrowserPluginPermissionType permission_type, | 62 BrowserPluginPermissionType permission_type, |
| 62 const base::DictionaryValue& request_info, | 63 const base::DictionaryValue& request_info, |
| 63 const PermissionResponseCallback& callback, | 64 const PermissionResponseCallback& callback, |
| 64 bool allowed_by_default) OVERRIDE; | 65 bool allowed_by_default) OVERRIDE; |
| 66 virtual GURL ResolveURL(const std::string& src) OVERRIDE; |
| 65 virtual void SizeChanged(const gfx::Size& old_size, const gfx::Size& new_size) | 67 virtual void SizeChanged(const gfx::Size& old_size, const gfx::Size& new_size) |
| 66 OVERRIDE; | 68 OVERRIDE; |
| 67 | 69 |
| 68 // NotificationObserver implementation. | 70 // NotificationObserver implementation. |
| 69 virtual void Observe(int type, | 71 virtual void Observe(int type, |
| 70 const content::NotificationSource& source, | 72 const content::NotificationSource& source, |
| 71 const content::NotificationDetails& details) OVERRIDE; | 73 const content::NotificationDetails& details) OVERRIDE; |
| 72 | 74 |
| 73 // If possible, navigate the guest to |relative_index| entries away from the | 75 // If possible, navigate the guest to |relative_index| entries away from the |
| 74 // current navigation entry. | 76 // current navigation entry. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 typedef std::map<int, PermissionResponseInfo> RequestMap; | 186 typedef std::map<int, PermissionResponseInfo> RequestMap; |
| 185 RequestMap pending_permission_requests_; | 187 RequestMap pending_permission_requests_; |
| 186 | 188 |
| 187 // True if the user agent is overridden. | 189 // True if the user agent is overridden. |
| 188 bool is_overriding_user_agent_; | 190 bool is_overriding_user_agent_; |
| 189 | 191 |
| 190 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); | 192 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); |
| 191 }; | 193 }; |
| 192 | 194 |
| 193 #endif // CHROME_BROWSER_GUESTVIEW_WEBVIEW_WEBVIEW_GUEST_H_ | 195 #endif // CHROME_BROWSER_GUESTVIEW_WEBVIEW_WEBVIEW_GUEST_H_ |
| OLD | NEW |