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

Side by Side Diff: content/public/browser/browser_plugin_guest_delegate.h

Issue 272573005: <webview>: Move NewWindow API to chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@guestview_manager_rename
Patch Set: Merge with ToT Created 6 years, 7 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
« no previous file with comments | « content/content_tests.gypi ('k') | content/public/browser/browser_plugin_guest_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_
6 #define CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_ 6 #define CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_
7 7
8 #include "base/callback_forward.h" 8 #include "base/callback_forward.h"
9 #include "base/process/kill.h" 9 #include "base/process/kill.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
13 #include "content/public/common/browser_plugin_permission_type.h"
14 #include "content/public/common/media_stream_request.h" 13 #include "content/public/common/media_stream_request.h"
15 #include "third_party/skia/include/core/SkColor.h" 14 #include "third_party/skia/include/core/SkColor.h"
15 #include "ui/base/window_open_disposition.h"
16 #include "ui/gfx/geometry/rect.h" 16 #include "ui/gfx/geometry/rect.h"
17 #include "ui/gfx/size.h" 17 #include "ui/gfx/size.h"
18 #include "url/gurl.h" 18 #include "url/gurl.h"
19 19
20 namespace content { 20 namespace content {
21 21
22 class ColorChooser; 22 class ColorChooser;
23 class JavaScriptDialogManager; 23 class JavaScriptDialogManager;
24 class WebContents; 24 class WebContents;
25 struct ColorSuggestion; 25 struct ColorSuggestion;
26 struct ContextMenuParams; 26 struct ContextMenuParams;
27 struct FileChooserParams; 27 struct FileChooserParams;
28 struct NativeWebKeyboardEvent; 28 struct NativeWebKeyboardEvent;
29 struct OpenURLParams;
29 30
30 // Objects implement this interface to get notified about changes in the guest 31 // Objects implement this interface to get notified about changes in the guest
31 // WebContents and to provide necessary functionality. 32 // WebContents and to provide necessary functionality.
32 class CONTENT_EXPORT BrowserPluginGuestDelegate { 33 class CONTENT_EXPORT BrowserPluginGuestDelegate {
33 public: 34 public:
34 virtual ~BrowserPluginGuestDelegate() {} 35 virtual ~BrowserPluginGuestDelegate() {}
35 36
36 // Add a message to the console. 37 // Add a message to the console.
38 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
39 // WebContentsDelegate.
37 virtual void AddMessageToConsole(int32 level, 40 virtual void AddMessageToConsole(int32 level,
38 const base::string16& message, 41 const base::string16& message,
39 int32 line_no, 42 int32 line_no,
40 const base::string16& source_id) {} 43 const base::string16& source_id) {}
41 44
42 // Request the delegate to close this guest, and do whatever cleanup it needs 45 // Request the delegate to close this guest, and do whatever cleanup it needs
43 // to do. 46 // to do.
47 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
48 // WebContentsDelegate.
44 virtual void Close() {} 49 virtual void Close() {}
45 50
46 // Notification that the embedder has completed attachment. 51 // Notification that the embedder has completed attachment.
47 virtual void DidAttach() {} 52 virtual void DidAttach() {}
48 53
49 // Returns the opener for this guest.
50 // TODO(fsamuel): Remove this once the New Window API is migrated outside of
51 // the content layer.
52 virtual WebContents* GetOpener() const;
53
54 // Informs the delegate that the guest render process is gone. |status| 54 // Informs the delegate that the guest render process is gone. |status|
55 // indicates whether the guest was killed, crashed, or was terminated 55 // indicates whether the guest was killed, crashed, or was terminated
56 // gracefully. 56 // gracefully.
57 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
58 // WebContentsDelegate.
57 virtual void GuestProcessGone(base::TerminationStatus status) {} 59 virtual void GuestProcessGone(base::TerminationStatus status) {}
58 60
59 // Informs the delegate that the embedder has been destroyed. 61 // Informs the delegate that the embedder has been destroyed.
60 virtual void EmbedderDestroyed() {} 62 virtual void EmbedderDestroyed() {}
61 63
62 // Informs the delegate of a reply to the find request specified by 64 // Informs the delegate of a reply to the find request specified by
63 // |request_id|. 65 // |request_id|.
66 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
67 // WebContentsDelegate.
64 virtual void FindReply(int request_id, 68 virtual void FindReply(int request_id,
65 int number_of_matches, 69 int number_of_matches,
66 const gfx::Rect& selection_rect, 70 const gfx::Rect& selection_rect,
67 int active_match_ordinal, 71 int active_match_ordinal,
68 bool final_update) {} 72 bool final_update) {}
69 73
74 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
75 // WebContentsDelegate.
70 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {} 76 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {}
71 77
72 // Requests setting the zoom level to the provided |zoom_level|. 78 // Requests setting the zoom level to the provided |zoom_level|.
73 virtual void SetZoom(double zoom_factor) {} 79 virtual void SetZoom(double zoom_factor) {}
74 80
75 virtual bool IsDragAndDropEnabled(); 81 virtual bool IsDragAndDropEnabled();
76 82
77 // Returns whether the user agent for the guest is being overridden.
78 virtual bool IsOverridingUserAgent() const;
79
80 // Notification that a load in the guest resulted in abort. Note that |url|
81 // may be invalid.
82 virtual void LoadAbort(bool is_top_level,
83 const GURL& url,
84 const std::string& error_type) {}
85
86 // Notification that the page has made some progress loading. |progress| is a 83 // Notification that the page has made some progress loading. |progress| is a
87 // value between 0.0 (nothing loaded) and 1.0 (page loaded completely). 84 // value between 0.0 (nothing loaded) and 1.0 (page loaded completely).
85 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
86 // WebContentsDelegate.
88 virtual void LoadProgressed(double progress) {} 87 virtual void LoadProgressed(double progress) {}
89 88
90 // Notification that the guest is no longer hung. 89 // Notification that the guest is no longer hung.
90 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
91 // WebContentsDelegate.
91 virtual void RendererResponsive() {} 92 virtual void RendererResponsive() {}
92 93
93 // Notification that the guest is hung. 94 // Notification that the guest is hung.
95 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
96 // WebContentsDelegate.
94 virtual void RendererUnresponsive() {} 97 virtual void RendererUnresponsive() {}
95 98
96 typedef base::Callback<void(bool /* allow */,
97 const std::string& /* user_input */)>
98 PermissionResponseCallback;
99
100 // Request permission from the delegate to perform an action of the provided
101 // |permission_type|. Details of the permission request are found in
102 // |request_info|. A |callback| is provided to make the decision.
103 virtual void RequestPermission(
104 BrowserPluginPermissionType permission_type,
105 const base::DictionaryValue& request_info,
106 const PermissionResponseCallback& callback,
107 bool allowed_by_default) {}
108
109 // Requests resolution of a potentially relative URL.
110 virtual GURL ResolveURL(const std::string& src);
111
112 // Informs the delegate of the WebContents that created delegate's associated
113 // WebContents.
114 // TODO(fsamuel): Remove this once the New Window API is migrated outside of
115 // the content layer.
116 virtual void SetOpener(WebContents* opener) {}
117
118 // Notifies that the content size of the guest has changed in autosize mode. 99 // Notifies that the content size of the guest has changed in autosize mode.
119 virtual void SizeChanged(const gfx::Size& old_size, 100 virtual void SizeChanged(const gfx::Size& old_size,
120 const gfx::Size& new_size) {} 101 const gfx::Size& new_size) {}
121 102
122 // Asks permission to use the camera and/or microphone. If permission is 103 // Asks permission to use the camera and/or microphone. If permission is
123 // granted, a call should be made to |callback| with the devices. If the 104 // granted, a call should be made to |callback| with the devices. If the
124 // request is denied, a call should be made to |callback| with an empty list 105 // request is denied, a call should be made to |callback| with an empty list
125 // of devices. |request| has the details of the request (e.g. which of audio 106 // of devices. |request| has the details of the request (e.g. which of audio
126 // and/or video devices are requested, and lists of available devices). 107 // and/or video devices are requested, and lists of available devices).
108 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
109 // WebContentsDelegate.
127 virtual void RequestMediaAccessPermission( 110 virtual void RequestMediaAccessPermission(
128 const MediaStreamRequest& request, 111 const MediaStreamRequest& request,
129 const MediaResponseCallback& callback); 112 const MediaResponseCallback& callback);
130 113
131 // Asks the delegate if the given guest can download. 114 // Asks the delegate if the given guest can download.
132 // Invoking the |callback| synchronously is OK. 115 // Invoking the |callback| synchronously is OK.
116 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
117 // WebContentsDelegate.
133 virtual void CanDownload(const std::string& request_method, 118 virtual void CanDownload(const std::string& request_method,
134 const GURL& url, 119 const GURL& url,
135 const base::Callback<void(bool)>& callback); 120 const base::Callback<void(bool)>& callback);
136 121
137 // Asks the delegate if the given guest can lock the pointer. 122 // Asks the delegate if the given guest can lock the pointer.
138 // Invoking the |callback| synchronously is OK. 123 // Invoking the |callback| synchronously is OK.
139 virtual void RequestPointerLockPermission( 124 virtual void RequestPointerLockPermission(
140 bool user_gesture, 125 bool user_gesture,
141 bool last_unlocked_by_target, 126 bool last_unlocked_by_target,
142 const base::Callback<void(bool)>& callback) {} 127 const base::Callback<void(bool)>& callback) {}
143 128
144 // Returns a pointer to a service to manage JavaScript dialogs. May return 129 // Returns a pointer to a service to manage JavaScript dialogs. May return
145 // NULL in which case dialogs aren't shown. 130 // NULL in which case dialogs aren't shown.
131 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
132 // WebContentsDelegate.
146 virtual JavaScriptDialogManager* GetJavaScriptDialogManager(); 133 virtual JavaScriptDialogManager* GetJavaScriptDialogManager();
147 134
148 // Called when color chooser should open. Returns the opened color chooser. 135 // Called when color chooser should open. Returns the opened color chooser.
149 // Returns NULL if we failed to open the color chooser (e.g. when there is a 136 // Returns NULL if we failed to open the color chooser (e.g. when there is a
150 // ColorChooserDialog already open on Windows). Ownership of the returned 137 // ColorChooserDialog already open on Windows). Ownership of the returned
151 // pointer is transferred to the caller. 138 // pointer is transferred to the caller.
139 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
140 // WebContentsDelegate.
152 virtual ColorChooser* OpenColorChooser( 141 virtual ColorChooser* OpenColorChooser(
153 WebContents* web_contents, 142 WebContents* web_contents,
154 SkColor color, 143 SkColor color,
155 const std::vector<ColorSuggestion>& suggestions); 144 const std::vector<ColorSuggestion>& suggestions);
156 145
157 // Called when a file selection is to be done. 146 // Called when a file selection is to be done.
147 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
148 // WebContentsDelegate.
158 virtual void RunFileChooser(WebContents* web_contents, 149 virtual void RunFileChooser(WebContents* web_contents,
159 const FileChooserParams& params) {} 150 const FileChooserParams& params) {}
160 151
161 // Returns true if the context menu operation was handled by the delegate. 152 // Returns true if the context menu operation was handled by the delegate.
153 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
154 // WebContentsDelegate.
162 virtual bool HandleContextMenu(const ContextMenuParams& params); 155 virtual bool HandleContextMenu(const ContextMenuParams& params);
156
157 // Request navigating the guest to the provided |src| URL.
158 virtual void NavigateGuest(const std::string& src) {}
159
160 // Requests that the delegate destroy itself along with its associated
161 // WebContents.
162 virtual void Destroy() {}
163
164 // Creates a new tab with the already-created WebContents |new_contents|.
165 // The window for the added contents should be reparented correctly when this
166 // method returns. If |disposition| is NEW_POPUP, |initial_pos| should hold
167 // the initial position. If |was_blocked| is non-NULL, then |*was_blocked|
168 // will be set to true if the popup gets blocked, and left unchanged
169 // otherwise.
170 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
171 // WebContentsDelegate.
172 virtual void AddNewContents(WebContents* source,
173 WebContents* new_contents,
174 WindowOpenDisposition disposition,
175 const gfx::Rect& initial_pos,
176 bool user_gesture,
177 bool* was_blocked) {}
178
179 // Opens a new URL inside the passed in WebContents (if source is 0 open
180 // in the current front-most tab), unless |disposition| indicates the url
181 // should be opened in a new tab or window.
182 //
183 // A NULL source indicates the current tab (callers should probably use
184 // OpenURL() for these cases which does it for you).
185 //
186 // Returns the WebContents the URL is opened in, or NULL if the URL wasn't
187 // opened immediately.
188 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
189 // WebContentsDelegate.
190 virtual WebContents* OpenURLFromTab(WebContents* source,
191 const OpenURLParams& params);
192
193 // Notifies the delegate about the creation of a new WebContents. This
194 // typically happens when popups are created.
195 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a
196 // WebContentsDelegate.
197 virtual void WebContentsCreated(WebContents* source_contents,
198 int opener_render_frame_id,
199 const base::string16& frame_name,
200 const GURL& target_url,
201 WebContents* new_contents) {}
202
203 // Registers a |callback| with the delegate that the delegate would call when
204 // it is about to be destroyed.
205 typedef base::Callback<void(WebContents*)> DestructionCallback;
206 virtual void RegisterDestructionCallback(
207 const DestructionCallback& callback) {}
163 }; 208 };
164 209
165 } // namespace content 210 } // namespace content
166 211
167 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_ 212 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_
OLDNEW
« no previous file with comments | « content/content_tests.gypi ('k') | content/public/browser/browser_plugin_guest_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698