| 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 base::DictionaryValue& args) OVERRIDE; | 37 const base::DictionaryValue& args) OVERRIDE; |
| 38 virtual GuestView::Type GetViewType() const OVERRIDE; | 38 virtual GuestView::Type GetViewType() const OVERRIDE; |
| 39 virtual WebViewGuest* AsWebView() OVERRIDE; | 39 virtual WebViewGuest* AsWebView() OVERRIDE; |
| 40 virtual AdViewGuest* AsAdView() OVERRIDE; | 40 virtual AdViewGuest* AsAdView() OVERRIDE; |
| 41 | 41 |
| 42 // GuestDelegate implementation. | 42 // GuestDelegate implementation. |
| 43 virtual void AddMessageToConsole(int32 level, | 43 virtual void AddMessageToConsole(int32 level, |
| 44 const string16& message, | 44 const string16& message, |
| 45 int32 line_no, | 45 int32 line_no, |
| 46 const string16& source_id) OVERRIDE; | 46 const string16& source_id) OVERRIDE; |
| 47 virtual void LoadProgressed(double progress) OVERRIDE; | 47 virtual void LoadProgressed(double progress) OVERRIDE; |
| 48 virtual void Close() OVERRIDE; | 48 virtual void Close() OVERRIDE; |
| 49 virtual void EmbedderDestroyed() OVERRIDE; | 49 virtual void EmbedderDestroyed() OVERRIDE; |
| 50 virtual void GuestProcessGone(base::TerminationStatus status) OVERRIDE; | 50 virtual void GuestProcessGone(base::TerminationStatus status) OVERRIDE; |
| 51 virtual bool HandleKeyboardEvent( | 51 virtual bool HandleKeyboardEvent( |
| 52 const content::NativeWebKeyboardEvent& event) OVERRIDE; | 52 const content::NativeWebKeyboardEvent& event) OVERRIDE; |
| 53 virtual bool IsDragAndDropEnabled() OVERRIDE; | 53 virtual bool IsDragAndDropEnabled() OVERRIDE; |
| 54 virtual bool IsOverridingUserAgent() const OVERRIDE; | 54 virtual bool IsOverridingUserAgent() const OVERRIDE; |
| 55 virtual void LoadAbort(bool is_top_level, | 55 virtual void LoadAbort(bool is_top_level, |
| 56 const GURL& url, | 56 const GURL& url, |
| 57 const std::string& error_type) OVERRIDE; | 57 const std::string& error_type) OVERRIDE; |
| 58 virtual void RendererResponsive() OVERRIDE; | 58 virtual void RendererResponsive() OVERRIDE; |
| 59 virtual void RendererUnresponsive() OVERRIDE; | 59 virtual void RendererUnresponsive() OVERRIDE; |
| 60 virtual bool RequestPermission( | 60 virtual bool RequestPermission( |
| 61 BrowserPluginPermissionType permission_type, | 61 BrowserPluginPermissionType permission_type, |
| 62 const base::DictionaryValue& request_info, | 62 const base::DictionaryValue& request_info, |
| 63 const PermissionResponseCallback& callback, | 63 const PermissionResponseCallback& callback, |
| 64 bool allowed_by_default) OVERRIDE; | 64 bool allowed_by_default) OVERRIDE; |
| 65 virtual GURL ResolveURL(const std::string& src) OVERRIDE; |
| 65 virtual void SizeChanged(const gfx::Size& old_size, const gfx::Size& new_size) | 66 virtual void SizeChanged(const gfx::Size& old_size, const gfx::Size& new_size) |
| 66 OVERRIDE; | 67 OVERRIDE; |
| 67 | 68 |
| 68 // NotificationObserver implementation. | 69 // NotificationObserver implementation. |
| 69 virtual void Observe(int type, | 70 virtual void Observe(int type, |
| 70 const content::NotificationSource& source, | 71 const content::NotificationSource& source, |
| 71 const content::NotificationDetails& details) OVERRIDE; | 72 const content::NotificationDetails& details) OVERRIDE; |
| 72 | 73 |
| 73 // If possible, navigate the guest to |relative_index| entries away from the | 74 // If possible, navigate the guest to |relative_index| entries away from the |
| 74 // current navigation entry. | 75 // current navigation entry. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 typedef std::map<int, PermissionResponseInfo> RequestMap; | 185 typedef std::map<int, PermissionResponseInfo> RequestMap; |
| 185 RequestMap pending_permission_requests_; | 186 RequestMap pending_permission_requests_; |
| 186 | 187 |
| 187 // True if the user agent is overridden. | 188 // True if the user agent is overridden. |
| 188 bool is_overriding_user_agent_; | 189 bool is_overriding_user_agent_; |
| 189 | 190 |
| 190 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); | 191 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); |
| 191 }; | 192 }; |
| 192 | 193 |
| 193 #endif // CHROME_BROWSER_GUESTVIEW_WEBVIEW_WEBVIEW_GUEST_H_ | 194 #endif // CHROME_BROWSER_GUESTVIEW_WEBVIEW_WEBVIEW_GUEST_H_ |
| OLD | NEW |