OLD | NEW |
1 // Copyright 2013 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 CHROME_BROWSER_GUESTVIEW_WEBVIEW_WEBVIEW_GUEST_H_ | 5 #ifndef CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ |
6 #define CHROME_BROWSER_GUESTVIEW_WEBVIEW_WEBVIEW_GUEST_H_ | 6 #define CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_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/guest_view/guest_view.h" |
11 #include "chrome/browser/guestview/webview/javascript_dialog_helper.h" | 11 #include "chrome/browser/guest_view/web_view/javascript_dialog_helper.h" |
12 #include "chrome/browser/guestview/webview/webview_find_helper.h" | 12 #include "chrome/browser/guest_view/web_view/web_view_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, | 34 class WebViewGuest : public GuestView<WebViewGuest>, |
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); | |
43 // Returns guestview::kInstanceIDNone if |contents| does not correspond to a | 41 // Returns guestview::kInstanceIDNone if |contents| does not correspond to a |
44 // WebViewGuest. | 42 // WebViewGuest. |
45 static int GetViewInstanceId(content::WebContents* contents); | 43 static int GetViewInstanceId(content::WebContents* contents); |
| 44 static const std::string& Type; |
46 | 45 |
47 // GuestView implementation. | 46 // GuestViewBase implementation. |
48 virtual void Attach(content::WebContents* embedder_web_contents, | 47 virtual void Attach(content::WebContents* embedder_web_contents, |
49 const base::DictionaryValue& args) OVERRIDE; | 48 const base::DictionaryValue& args) OVERRIDE; |
50 virtual GuestView::Type GetViewType() const OVERRIDE; | |
51 virtual WebViewGuest* AsWebView() OVERRIDE; | |
52 virtual AdViewGuest* AsAdView() OVERRIDE; | |
53 | 49 |
54 // GuestDelegate implementation. | 50 // GuestDelegate implementation. |
55 virtual void AddMessageToConsole(int32 level, | 51 virtual void AddMessageToConsole(int32 level, |
56 const base::string16& message, | 52 const base::string16& message, |
57 int32 line_no, | 53 int32 line_no, |
58 const base::string16& source_id) OVERRIDE; | 54 const base::string16& source_id) OVERRIDE; |
59 virtual void LoadProgressed(double progress) OVERRIDE; | 55 virtual void LoadProgressed(double progress) OVERRIDE; |
60 virtual void Close() OVERRIDE; | 56 virtual void Close() OVERRIDE; |
61 virtual void DidAttach() OVERRIDE; | 57 virtual void DidAttach() OVERRIDE; |
62 virtual void EmbedderDestroyed() OVERRIDE; | 58 virtual void EmbedderDestroyed() OVERRIDE; |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 // Subscription to receive notifications on changes to a11y settings. | 313 // Subscription to receive notifications on changes to a11y settings. |
318 scoped_ptr<chromeos::AccessibilityStatusSubscription> | 314 scoped_ptr<chromeos::AccessibilityStatusSubscription> |
319 accessibility_subscription_; | 315 accessibility_subscription_; |
320 #endif | 316 #endif |
321 | 317 |
322 std::map<int, int> bridge_id_to_request_id_map_; | 318 std::map<int, int> bridge_id_to_request_id_map_; |
323 | 319 |
324 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); | 320 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); |
325 }; | 321 }; |
326 | 322 |
327 #endif // CHROME_BROWSER_GUESTVIEW_WEBVIEW_WEBVIEW_GUEST_H_ | 323 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ |
OLD | NEW |