| OLD | NEW |
| 1 // Copyright 2014 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_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ | 5 #ifndef CHROME_BROWSER_GUESTVIEW_WEBVIEW_WEBVIEW_GUEST_H_ |
| 6 #define CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_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/guest_view/guest_view.h" | 10 #include "chrome/browser/guestview/guestview.h" |
| 11 #include "chrome/browser/guest_view/web_view/javascript_dialog_helper.h" | 11 #include "chrome/browser/guestview/webview/javascript_dialog_helper.h" |
| 12 #include "chrome/browser/guest_view/web_view/web_view_find_helper.h" | 12 #include "chrome/browser/guestview/webview/webview_find_helper.h" |
| 13 #include "content/public/browser/javascript_dialog_manager.h" | 13 #include "content/public/browser/javascript_dialog_manager.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 15 #include "content/public/browser/web_contents_observer.h" | 15 #include "content/public/browser/web_contents_observer.h" |
| 16 #include "third_party/WebKit/public/web/WebFindOptions.h" | 16 #include "third_party/WebKit/public/web/WebFindOptions.h" |
| 17 | 17 |
| 18 #if defined(OS_CHROMEOS) | 18 #if defined(OS_CHROMEOS) |
| 19 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 19 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 20 #endif | 20 #endif |
| 21 | 21 |
| 22 namespace extensions { | 22 namespace extensions { |
| 23 class ScriptExecutor; | 23 class ScriptExecutor; |
| 24 class WebviewFindFunction; | 24 class WebviewFindFunction; |
| 25 } // namespace extensions | 25 } // namespace extensions |
| 26 | 26 |
| 27 // A WebViewGuest is a WebContentsObserver on the guest WebContents of a | 27 // A WebViewGuest is a WebContentsObserver on the guest WebContents of a |
| 28 // <webview> tag. It provides the browser-side implementation of the <webview> | 28 // <webview> tag. It provides the browser-side implementation of the <webview> |
| 29 // API and manages the lifetime of <webview> extension events. WebViewGuest is | 29 // API and manages the lifetime of <webview> extension events. WebViewGuest is |
| 30 // created on attachment. That is, when a guest WebContents is associated with | 30 // created on attachment. That is, when a guest WebContents is associated with |
| 31 // a particular embedder WebContents. This happens on either initial navigation | 31 // a particular embedder WebContents. This happens on either initial navigation |
| 32 // or through the use of the New Window API, when a new window is attached to | 32 // or through the use of the New Window API, when a new window is attached to |
| 33 // a particular <webview>. | 33 // a particular <webview>. |
| 34 class WebViewGuest : public GuestView<WebViewGuest>, | 34 class WebViewGuest : public GuestView, |
| 35 public content::NotificationObserver, | 35 public content::NotificationObserver, |
| 36 public content::WebContentsObserver { | 36 public content::WebContentsObserver { |
| 37 public: | 37 public: |
| 38 WebViewGuest(content::WebContents* guest_web_contents, | 38 WebViewGuest(content::WebContents* guest_web_contents, |
| 39 const std::string& embedder_extension_id); | 39 const std::string& embedder_extension_id); |
| 40 | 40 |
| 41 static WebViewGuest* From(int embedder_process_id, int instance_id); |
| 42 static WebViewGuest* FromWebContents(content::WebContents* contents); |
| 41 // Returns guestview::kInstanceIDNone if |contents| does not correspond to a | 43 // Returns guestview::kInstanceIDNone if |contents| does not correspond to a |
| 42 // WebViewGuest. | 44 // WebViewGuest. |
| 43 static int GetViewInstanceId(content::WebContents* contents); | 45 static int GetViewInstanceId(content::WebContents* contents); |
| 44 static const std::string& Type; | |
| 45 | 46 |
| 46 // GuestViewBase implementation. | 47 // GuestView implementation. |
| 47 virtual void Attach(content::WebContents* embedder_web_contents, | 48 virtual void Attach(content::WebContents* embedder_web_contents, |
| 48 const base::DictionaryValue& args) OVERRIDE; | 49 const base::DictionaryValue& args) OVERRIDE; |
| 50 virtual GuestView::Type GetViewType() const OVERRIDE; |
| 51 virtual WebViewGuest* AsWebView() OVERRIDE; |
| 52 virtual AdViewGuest* AsAdView() OVERRIDE; |
| 49 | 53 |
| 50 // GuestDelegate implementation. | 54 // GuestDelegate implementation. |
| 51 virtual void AddMessageToConsole(int32 level, | 55 virtual void AddMessageToConsole(int32 level, |
| 52 const base::string16& message, | 56 const base::string16& message, |
| 53 int32 line_no, | 57 int32 line_no, |
| 54 const base::string16& source_id) OVERRIDE; | 58 const base::string16& source_id) OVERRIDE; |
| 55 virtual void LoadProgressed(double progress) OVERRIDE; | 59 virtual void LoadProgressed(double progress) OVERRIDE; |
| 56 virtual void Close() OVERRIDE; | 60 virtual void Close() OVERRIDE; |
| 57 virtual void DidAttach() OVERRIDE; | 61 virtual void DidAttach() OVERRIDE; |
| 58 virtual void EmbedderDestroyed() OVERRIDE; | 62 virtual void EmbedderDestroyed() OVERRIDE; |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 // Subscription to receive notifications on changes to a11y settings. | 317 // Subscription to receive notifications on changes to a11y settings. |
| 314 scoped_ptr<chromeos::AccessibilityStatusSubscription> | 318 scoped_ptr<chromeos::AccessibilityStatusSubscription> |
| 315 accessibility_subscription_; | 319 accessibility_subscription_; |
| 316 #endif | 320 #endif |
| 317 | 321 |
| 318 std::map<int, int> bridge_id_to_request_id_map_; | 322 std::map<int, int> bridge_id_to_request_id_map_; |
| 319 | 323 |
| 320 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); | 324 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); |
| 321 }; | 325 }; |
| 322 | 326 |
| 323 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ | 327 #endif // CHROME_BROWSER_GUESTVIEW_WEBVIEW_WEBVIEW_GUEST_H_ |
| OLD | NEW |