Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: chrome/browser/guest_view/web_view/web_view_guest.h

Issue 306003002: Move guest lifetime management to chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed content_browsertests crash Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 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_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ 5 #ifndef CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_
6 #define CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ 6 #define CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/observer_list.h" 10 #include "base/observer_list.h"
11 #include "chrome/browser/extensions/tab_helper.h" 11 #include "chrome/browser/extensions/tab_helper.h"
12 #include "chrome/browser/guest_view/guest_view.h" 12 #include "chrome/browser/guest_view/guest_view.h"
13 #include "chrome/browser/guest_view/web_view/javascript_dialog_helper.h" 13 #include "chrome/browser/guest_view/web_view/javascript_dialog_helper.h"
14 #include "chrome/browser/guest_view/web_view/web_view_find_helper.h" 14 #include "chrome/browser/guest_view/web_view/web_view_find_helper.h"
15 #include "chrome/browser/guest_view/web_view/web_view_permission_types.h" 15 #include "chrome/browser/guest_view/web_view/web_view_permission_types.h"
16 #include "chrome/common/extensions/api/webview.h" 16 #include "chrome/common/extensions/api/webview.h"
17 #include "content/public/browser/javascript_dialog_manager.h" 17 #include "content/public/browser/javascript_dialog_manager.h"
18 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
19 #include "content/public/browser/web_contents_observer.h"
20 #include "third_party/WebKit/public/web/WebFindOptions.h" 19 #include "third_party/WebKit/public/web/WebFindOptions.h"
21 20
22 #if defined(OS_CHROMEOS) 21 #if defined(OS_CHROMEOS)
23 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" 22 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
24 #endif 23 #endif
25 24
26 namespace webview_api = extensions::api::webview; 25 namespace webview_api = extensions::api::webview;
27 26
28 class RenderViewContextMenu; 27 class RenderViewContextMenu;
29 28
30 namespace extensions { 29 namespace extensions {
31 class ScriptExecutor; 30 class ScriptExecutor;
32 class WebviewFindFunction; 31 class WebviewFindFunction;
33 } // namespace extensions 32 } // namespace extensions
34 33
35 namespace ui { 34 namespace ui {
36 class SimpleMenuModel; 35 class SimpleMenuModel;
37 } // namespace ui 36 } // namespace ui
38 37
39 // A WebViewGuest is a WebContentsObserver on the guest WebContents of a 38 // A WebViewGuest provides the browser-side implementation of the <webview> API
40 // <webview> tag. It provides the browser-side implementation of the <webview> 39 // and manages the dispatch of <webview> extension events. WebViewGuest is
41 // API and manages the lifetime of <webview> extension events. WebViewGuest is
42 // created on attachment. That is, when a guest WebContents is associated with 40 // created on attachment. That is, when a guest WebContents is associated with
43 // a particular embedder WebContents. This happens on either initial navigation 41 // a particular embedder WebContents. This happens on either initial navigation
44 // or through the use of the New Window API, when a new window is attached to 42 // or through the use of the New Window API, when a new window is attached to
45 // a particular <webview>. 43 // a particular <webview>.
46 class WebViewGuest : public GuestView<WebViewGuest>, 44 class WebViewGuest : public GuestView<WebViewGuest>,
47 public content::NotificationObserver, 45 public content::NotificationObserver {
48 public content::WebContentsObserver {
49 public: 46 public:
50 WebViewGuest(int guest_instance_id, 47 WebViewGuest(int guest_instance_id,
51 content::WebContents* guest_web_contents, 48 content::WebContents* guest_web_contents,
52 const std::string& embedder_extension_id); 49 const std::string& embedder_extension_id);
53 50
54 // Returns guestview::kInstanceIDNone if |contents| does not correspond to a 51 // Returns guestview::kInstanceIDNone if |contents| does not correspond to a
55 // WebViewGuest. 52 // WebViewGuest.
56 static int GetViewInstanceId(content::WebContents* contents); 53 static int GetViewInstanceId(content::WebContents* contents);
57 static const char Type[]; 54 static const char Type[];
58 55
59 typedef std::vector<linked_ptr<webview_api::ContextMenuItem> > MenuItemVector; 56 typedef std::vector<linked_ptr<webview_api::ContextMenuItem> > MenuItemVector;
60 // Shows the context menu for the guest. 57 // Shows the context menu for the guest.
61 // |items| acts as a filter. This restricts the current context's default 58 // |items| acts as a filter. This restricts the current context's default
62 // menu items to contain only the items from |items|. 59 // menu items to contain only the items from |items|.
63 // |items| == NULL means no filtering will be applied. 60 // |items| == NULL means no filtering will be applied.
64 void ShowContextMenu(int request_id, const MenuItemVector* items); 61 void ShowContextMenu(int request_id, const MenuItemVector* items);
65 62
66 // Sets the frame name of the guest. 63 // Sets the frame name of the guest.
67 void SetName(const std::string& name); 64 void SetName(const std::string& name);
68 65
69 // GuestViewBase implementation. 66 // GuestViewBase implementation.
70 virtual void Attach(content::WebContents* embedder_web_contents, 67 virtual void Attach(content::WebContents* embedder_web_contents,
71 const base::DictionaryValue& args) OVERRIDE; 68 const base::DictionaryValue& args) OVERRIDE;
72 69 virtual void EmbedderDestroyed() OVERRIDE;
73 // BrowserPluginGuestDelegate public implementation.
74 virtual bool HandleContextMenu(
75 const content::ContextMenuParams& params) OVERRIDE;
76 70
77 // WebContentsDelegate implementation. 71 // WebContentsDelegate implementation.
78 virtual bool AddMessageToConsole(content::WebContents* source, 72 virtual bool AddMessageToConsole(content::WebContents* source,
79 int32 level, 73 int32 level,
80 const base::string16& message, 74 const base::string16& message,
81 int32 line_no, 75 int32 line_no,
82 const base::string16& source_id) OVERRIDE; 76 const base::string16& source_id) OVERRIDE;
83 virtual void LoadProgressChanged(content::WebContents* source, 77 virtual void LoadProgressChanged(content::WebContents* source,
84 double progress) OVERRIDE; 78 double progress) OVERRIDE;
85 virtual void CloseContents(content::WebContents* source) OVERRIDE; 79 virtual void CloseContents(content::WebContents* source) OVERRIDE;
86 virtual void FindReply(content::WebContents* source, 80 virtual void FindReply(content::WebContents* source,
87 int request_id, 81 int request_id,
88 int number_of_matches, 82 int number_of_matches,
89 const gfx::Rect& selection_rect, 83 const gfx::Rect& selection_rect,
90 int active_match_ordinal, 84 int active_match_ordinal,
91 bool final_update) OVERRIDE; 85 bool final_update) OVERRIDE;
86 virtual bool HandleContextMenu(
87 const content::ContextMenuParams& params) OVERRIDE;
92 virtual void HandleKeyboardEvent( 88 virtual void HandleKeyboardEvent(
93 content::WebContents* source, 89 content::WebContents* source,
94 const content::NativeWebKeyboardEvent& event) OVERRIDE; 90 const content::NativeWebKeyboardEvent& event) OVERRIDE;
95 virtual void RendererResponsive(content::WebContents* source) OVERRIDE; 91 virtual void RendererResponsive(content::WebContents* source) OVERRIDE;
96 virtual void RendererUnresponsive(content::WebContents* source) OVERRIDE; 92 virtual void RendererUnresponsive(content::WebContents* source) OVERRIDE;
97 virtual void RequestMediaAccessPermission( 93 virtual void RequestMediaAccessPermission(
98 content::WebContents* source, 94 content::WebContents* source,
99 const content::MediaStreamRequest& request, 95 const content::MediaStreamRequest& request,
100 const content::MediaResponseCallback& callback) OVERRIDE; 96 const content::MediaResponseCallback& callback) OVERRIDE;
101 virtual void CanDownload(content::RenderViewHost* render_view_host, 97 virtual void CanDownload(content::RenderViewHost* render_view_host,
(...skipping 17 matching lines...) Expand all
119 bool* was_blocked) OVERRIDE; 115 bool* was_blocked) OVERRIDE;
120 virtual content::WebContents* OpenURLFromTab( 116 virtual content::WebContents* OpenURLFromTab(
121 content::WebContents* source, 117 content::WebContents* source,
122 const content::OpenURLParams& params) OVERRIDE; 118 const content::OpenURLParams& params) OVERRIDE;
123 virtual void WebContentsCreated(content::WebContents* source_contents, 119 virtual void WebContentsCreated(content::WebContents* source_contents,
124 int opener_render_frame_id, 120 int opener_render_frame_id,
125 const base::string16& frame_name, 121 const base::string16& frame_name,
126 const GURL& target_url, 122 const GURL& target_url,
127 content::WebContents* new_contents) OVERRIDE; 123 content::WebContents* new_contents) OVERRIDE;
128 124
129 // GuestDelegate implementation. 125 // BrowserPluginGuestDelegate implementation.
130 virtual void DidAttach() OVERRIDE; 126 virtual void DidAttach() OVERRIDE;
131 virtual void EmbedderDestroyed() OVERRIDE;
132 virtual bool IsDragAndDropEnabled() OVERRIDE; 127 virtual bool IsDragAndDropEnabled() OVERRIDE;
133 virtual void SizeChanged(const gfx::Size& old_size, const gfx::Size& new_size) 128 virtual void SizeChanged(const gfx::Size& old_size, const gfx::Size& new_size)
134 OVERRIDE; 129 OVERRIDE;
135 virtual void RequestPointerLockPermission( 130 virtual void RequestPointerLockPermission(
136 bool user_gesture, 131 bool user_gesture,
137 bool last_unlocked_by_target, 132 bool last_unlocked_by_target,
138 const base::Callback<void(bool)>& callback) OVERRIDE; 133 const base::Callback<void(bool)>& callback) OVERRIDE;
139 virtual void NavigateGuest(const std::string& src) OVERRIDE; 134 virtual void NavigateGuest(const std::string& src) OVERRIDE;
140 virtual void Destroy() OVERRIDE; 135 virtual void Destroy() OVERRIDE;
141 136
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 name(name) {} 430 name(name) {}
436 }; 431 };
437 432
438 typedef std::map<WebViewGuest*, NewWindowInfo> PendingWindowMap; 433 typedef std::map<WebViewGuest*, NewWindowInfo> PendingWindowMap;
439 PendingWindowMap pending_new_windows_; 434 PendingWindowMap pending_new_windows_;
440 435
441 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); 436 DISALLOW_COPY_AND_ASSIGN(WebViewGuest);
442 }; 437 };
443 438
444 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ 439 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_
OLDNEW
« no previous file with comments | « chrome/browser/guest_view/guest_view_base.cc ('k') | chrome/browser/guest_view/web_view/web_view_guest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698