Chromium Code Reviews| 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 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" | |
| 11 #include "base/values.h" | |
| 12 #include "content/common/content_export.h" | 10 #include "content/common/content_export.h" |
| 13 #include "content/public/common/media_stream_request.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" | |
| 17 #include "ui/gfx/size.h" | |
| 18 #include "url/gurl.h" | |
| 19 | 11 |
| 20 namespace blink { | 12 namespace gfx { |
| 21 class WebGestureEvent; | 13 class Size; |
| 22 } // namespace blink | 14 } // namespace gfx |
| 23 | 15 |
| 24 namespace content { | 16 namespace content { |
| 25 | 17 |
| 26 class ColorChooser; | |
| 27 class JavaScriptDialogManager; | |
| 28 class WebContents; | 18 class WebContents; |
| 29 struct ColorSuggestion; | |
| 30 struct ContextMenuParams; | |
| 31 struct FileChooserParams; | |
| 32 struct NativeWebKeyboardEvent; | |
| 33 struct OpenURLParams; | |
| 34 | 19 |
| 35 // Objects implement this interface to get notified about changes in the guest | 20 // Objects implement this interface to get notified about changes in the guest |
| 36 // WebContents and to provide necessary functionality. | 21 // WebContents and to provide necessary functionality. |
| 37 class CONTENT_EXPORT BrowserPluginGuestDelegate { | 22 class CONTENT_EXPORT BrowserPluginGuestDelegate { |
| 38 public: | 23 public: |
| 39 virtual ~BrowserPluginGuestDelegate() {} | 24 virtual ~BrowserPluginGuestDelegate() {} |
| 40 | 25 |
| 41 // Add a message to the console. | |
| 42 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a | |
| 43 // WebContentsDelegate. | |
| 44 virtual void AddMessageToConsole(int32 level, | |
| 45 const base::string16& message, | |
| 46 int32 line_no, | |
| 47 const base::string16& source_id) {} | |
| 48 | |
| 49 // Request the delegate to close this guest, and do whatever cleanup it needs | |
| 50 // to do. | |
| 51 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a | |
| 52 // WebContentsDelegate. | |
| 53 virtual void Close() {} | |
| 54 | |
| 55 // Notification that the embedder has completed attachment. | 26 // Notification that the embedder has completed attachment. |
| 56 virtual void DidAttach() {} | 27 virtual void DidAttach() {} |
| 57 | 28 |
| 58 // Informs the delegate that the guest render process is gone. |status| | 29 // Informs the delegate that the guest render process is gone. |status| |
| 59 // indicates whether the guest was killed, crashed, or was terminated | 30 // indicates whether the guest was killed, crashed, or was terminated |
| 60 // gracefully. | 31 // gracefully. |
| 61 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a | 32 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a |
| 62 // WebContentsDelegate. | 33 // WebContentsDelegate. |
|
jam
2014/05/27 01:37:42
what about this one?
| |
| 63 virtual void GuestProcessGone(base::TerminationStatus status) {} | 34 virtual void GuestProcessGone(base::TerminationStatus status) {} |
| 64 | 35 |
| 65 // Informs the delegate that the embedder has been destroyed. | 36 // Informs the delegate that the embedder has been destroyed. |
| 66 virtual void EmbedderDestroyed() {} | 37 virtual void EmbedderDestroyed() {} |
| 67 | 38 |
| 68 // Informs the delegate of a reply to the find request specified by | |
| 69 // |request_id|. | |
| 70 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a | |
| 71 // WebContentsDelegate. | |
| 72 virtual void FindReply(int request_id, | |
| 73 int number_of_matches, | |
| 74 const gfx::Rect& selection_rect, | |
| 75 int active_match_ordinal, | |
| 76 bool final_update) {} | |
| 77 | |
| 78 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a | |
| 79 // WebContentsDelegate. | |
| 80 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {} | |
| 81 | |
| 82 // Requests setting the zoom level to the provided |zoom_level|. | 39 // Requests setting the zoom level to the provided |zoom_level|. |
| 83 virtual void SetZoom(double zoom_factor) {} | 40 virtual void SetZoom(double zoom_factor) {} |
| 84 | 41 |
| 85 virtual bool IsDragAndDropEnabled(); | 42 virtual bool IsDragAndDropEnabled(); |
| 86 | 43 |
| 87 // Notification that the page has made some progress loading. |progress| is a | |
| 88 // value between 0.0 (nothing loaded) and 1.0 (page loaded completely). | |
| 89 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a | |
| 90 // WebContentsDelegate. | |
| 91 virtual void LoadProgressed(double progress) {} | |
| 92 | |
| 93 // Notification that the guest is no longer hung. | |
| 94 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a | |
| 95 // WebContentsDelegate. | |
| 96 virtual void RendererResponsive() {} | |
| 97 | |
| 98 // Notification that the guest is hung. | |
| 99 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a | |
| 100 // WebContentsDelegate. | |
| 101 virtual void RendererUnresponsive() {} | |
| 102 | |
| 103 // Notifies that the content size of the guest has changed in autosize mode. | 44 // Notifies that the content size of the guest has changed in autosize mode. |
| 104 virtual void SizeChanged(const gfx::Size& old_size, | 45 virtual void SizeChanged(const gfx::Size& old_size, |
| 105 const gfx::Size& new_size) {} | 46 const gfx::Size& new_size) {} |
| 106 | 47 |
| 107 // Asks permission to use the camera and/or microphone. If permission is | |
| 108 // granted, a call should be made to |callback| with the devices. If the | |
| 109 // request is denied, a call should be made to |callback| with an empty list | |
| 110 // of devices. |request| has the details of the request (e.g. which of audio | |
| 111 // and/or video devices are requested, and lists of available devices). | |
| 112 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a | |
| 113 // WebContentsDelegate. | |
| 114 virtual void RequestMediaAccessPermission( | |
| 115 const MediaStreamRequest& request, | |
| 116 const MediaResponseCallback& callback); | |
| 117 | |
| 118 // Asks the delegate if the given guest can download. | |
| 119 // Invoking the |callback| synchronously is OK. | |
| 120 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a | |
| 121 // WebContentsDelegate. | |
| 122 virtual void CanDownload(const std::string& request_method, | |
| 123 const GURL& url, | |
| 124 const base::Callback<void(bool)>& callback); | |
| 125 | |
| 126 // Asks the delegate if the given guest can lock the pointer. | 48 // Asks the delegate if the given guest can lock the pointer. |
| 127 // Invoking the |callback| synchronously is OK. | 49 // Invoking the |callback| synchronously is OK. |
| 128 virtual void RequestPointerLockPermission( | 50 virtual void RequestPointerLockPermission( |
| 129 bool user_gesture, | 51 bool user_gesture, |
| 130 bool last_unlocked_by_target, | 52 bool last_unlocked_by_target, |
| 131 const base::Callback<void(bool)>& callback) {} | 53 const base::Callback<void(bool)>& callback) {} |
| 132 | 54 |
| 133 // Returns a pointer to a service to manage JavaScript dialogs. May return | |
| 134 // NULL in which case dialogs aren't shown. | |
| 135 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a | |
| 136 // WebContentsDelegate. | |
| 137 virtual JavaScriptDialogManager* GetJavaScriptDialogManager(); | |
| 138 | |
| 139 // Called when color chooser should open. Returns the opened color chooser. | |
| 140 // Returns NULL if we failed to open the color chooser (e.g. when there is a | |
| 141 // ColorChooserDialog already open on Windows). Ownership of the returned | |
| 142 // pointer is transferred to the caller. | |
| 143 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a | |
| 144 // WebContentsDelegate. | |
| 145 virtual ColorChooser* OpenColorChooser( | |
| 146 WebContents* web_contents, | |
| 147 SkColor color, | |
| 148 const std::vector<ColorSuggestion>& suggestions); | |
| 149 | |
| 150 // Called when a file selection is to be done. | |
| 151 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a | |
| 152 // WebContentsDelegate. | |
| 153 virtual void RunFileChooser(WebContents* web_contents, | |
| 154 const FileChooserParams& params) {} | |
| 155 | |
| 156 // Returns true if the context menu operation was handled by the delegate. | |
| 157 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a | |
| 158 // WebContentsDelegate. | |
| 159 virtual bool HandleContextMenu(const ContextMenuParams& params); | |
| 160 | |
| 161 // Request navigating the guest to the provided |src| URL. | 55 // Request navigating the guest to the provided |src| URL. |
| 162 virtual void NavigateGuest(const std::string& src) {} | 56 virtual void NavigateGuest(const std::string& src) {} |
| 163 | 57 |
| 164 // Requests that the delegate destroy itself along with its associated | 58 // Requests that the delegate destroy itself along with its associated |
| 165 // WebContents. | 59 // WebContents. |
| 166 virtual void Destroy() {} | 60 virtual void Destroy() {} |
| 167 | 61 |
| 168 // Creates a new tab with the already-created WebContents |new_contents|. | |
| 169 // The window for the added contents should be reparented correctly when this | |
| 170 // method returns. If |disposition| is NEW_POPUP, |initial_pos| should hold | |
| 171 // the initial position. If |was_blocked| is non-NULL, then |*was_blocked| | |
| 172 // will be set to true if the popup gets blocked, and left unchanged | |
| 173 // otherwise. | |
| 174 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a | |
| 175 // WebContentsDelegate. | |
| 176 virtual void AddNewContents(WebContents* source, | |
| 177 WebContents* new_contents, | |
| 178 WindowOpenDisposition disposition, | |
| 179 const gfx::Rect& initial_pos, | |
| 180 bool user_gesture, | |
| 181 bool* was_blocked) {} | |
| 182 | |
| 183 // Opens a new URL inside the passed in WebContents (if source is 0 open | |
| 184 // in the current front-most tab), unless |disposition| indicates the url | |
| 185 // should be opened in a new tab or window. | |
| 186 // | |
| 187 // A NULL source indicates the current tab (callers should probably use | |
| 188 // OpenURL() for these cases which does it for you). | |
| 189 // | |
| 190 // Returns the WebContents the URL is opened in, or NULL if the URL wasn't | |
| 191 // opened immediately. | |
| 192 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a | |
| 193 // WebContentsDelegate. | |
| 194 virtual WebContents* OpenURLFromTab(WebContents* source, | |
| 195 const OpenURLParams& params); | |
| 196 | |
| 197 // Notifies the delegate about the creation of a new WebContents. This | |
| 198 // typically happens when popups are created. | |
| 199 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a | |
| 200 // WebContentsDelegate. | |
| 201 virtual void WebContentsCreated(WebContents* source_contents, | |
| 202 int opener_render_frame_id, | |
| 203 const base::string16& frame_name, | |
| 204 const GURL& target_url, | |
| 205 WebContents* new_contents) {} | |
| 206 | |
| 207 // Registers a |callback| with the delegate that the delegate would call when | 62 // Registers a |callback| with the delegate that the delegate would call when |
| 208 // it is about to be destroyed. | 63 // it is about to be destroyed. |
| 209 typedef base::Callback<void(WebContents*)> DestructionCallback; | 64 typedef base::Callback<void(WebContents*)> DestructionCallback; |
| 210 virtual void RegisterDestructionCallback( | 65 virtual void RegisterDestructionCallback( |
| 211 const DestructionCallback& callback) {} | 66 const DestructionCallback& callback) {} |
| 212 | |
| 213 // Allows delegates to handle gesture events before sending to the renderer. | |
| 214 // Returns true if the |event| was handled and thus shouldn't be processed | |
| 215 // by the renderer's event handler. Note that the touch events that create | |
| 216 // the gesture are always passed to the renderer since the gesture is created | |
| 217 // and dispatched after the touches return without being "preventDefault()"ed. | |
| 218 // TODO(fsamuel): Delete this once BrowserPluginGuest is no longer a | |
| 219 // WebContentsDelegate. | |
| 220 virtual bool PreHandleGestureEvent(WebContents* source, | |
| 221 const blink::WebGestureEvent& event); | |
| 222 }; | 67 }; |
| 223 | 68 |
| 224 } // namespace content | 69 } // namespace content |
| 225 | 70 |
| 226 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_ | 71 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_ |
| OLD | NEW |