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" | 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" |
| 14 #include "ui/base/window_open_disposition.h" | |
| 15 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
| 16 #include "ui/gfx/size.h" | 16 #include "ui/gfx/size.h" |
| 17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 class JavaScriptDialogManager; | 21 class JavaScriptDialogManager; |
| 22 class WebContents; | |
| 22 struct ContextMenuParams; | 23 struct ContextMenuParams; |
| 23 struct NativeWebKeyboardEvent; | 24 struct NativeWebKeyboardEvent; |
| 24 class WebContents; | 25 struct OpenURLParams; |
| 25 | 26 |
| 26 // Objects implement this interface to get notified about changes in the guest | 27 // Objects implement this interface to get notified about changes in the guest |
| 27 // WebContents and to provide necessary functionality. | 28 // WebContents and to provide necessary functionality. |
| 28 class CONTENT_EXPORT BrowserPluginGuestDelegate { | 29 class CONTENT_EXPORT BrowserPluginGuestDelegate { |
| 29 public: | 30 public: |
| 30 virtual ~BrowserPluginGuestDelegate() {} | 31 virtual ~BrowserPluginGuestDelegate() {} |
| 31 | 32 |
| 32 // Add a message to the console. | 33 // Add a message to the console. |
| 33 virtual void AddMessageToConsole(int32 level, | 34 virtual void AddMessageToConsole(int32 level, |
| 34 const base::string16& message, | 35 const base::string16& message, |
| 35 int32 line_no, | 36 int32 line_no, |
| 36 const base::string16& source_id) {} | 37 const base::string16& source_id) {} |
| 37 | 38 |
| 38 // Request the delegate to close this guest, and do whatever cleanup it needs | 39 // Request the delegate to close this guest, and do whatever cleanup it needs |
| 39 // to do. | 40 // to do. |
| 40 virtual void Close() {} | 41 virtual void Close() {} |
| 41 | 42 |
| 42 // Notification that the embedder has completed attachment. | 43 // Notification that the embedder has completed attachment. |
| 43 virtual void DidAttach() {} | 44 virtual void DidAttach() {} |
| 44 | 45 |
| 45 // Returns the opener for this guest. | |
| 46 // TODO(fsamuel): Remove this once the New Window API is migrated outside of | |
| 47 // the content layer. | |
| 48 virtual WebContents* GetOpener() const; | |
| 49 | |
| 50 // Informs the delegate that the guest render process is gone. |status| | 46 // Informs the delegate that the guest render process is gone. |status| |
| 51 // indicates whether the guest was killed, crashed, or was terminated | 47 // indicates whether the guest was killed, crashed, or was terminated |
| 52 // gracefully. | 48 // gracefully. |
| 53 virtual void GuestProcessGone(base::TerminationStatus status) {} | 49 virtual void GuestProcessGone(base::TerminationStatus status) {} |
| 54 | 50 |
| 55 // Informs the delegate that the embedder has been destroyed. | 51 // Informs the delegate that the embedder has been destroyed. |
| 56 virtual void EmbedderDestroyed() {} | 52 virtual void EmbedderDestroyed() {} |
| 57 | 53 |
| 58 // Informs the delegate of a reply to the find request specified by | 54 // Informs the delegate of a reply to the find request specified by |
| 59 // |request_id|. | 55 // |request_id|. |
| 60 virtual void FindReply(int request_id, | 56 virtual void FindReply(int request_id, |
| 61 int number_of_matches, | 57 int number_of_matches, |
| 62 const gfx::Rect& selection_rect, | 58 const gfx::Rect& selection_rect, |
| 63 int active_match_ordinal, | 59 int active_match_ordinal, |
| 64 bool final_update) {} | 60 bool final_update) {} |
| 65 | 61 |
| 66 virtual bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event); | 62 virtual bool HandleKeyboardEvent(const NativeWebKeyboardEvent& event); |
| 67 | 63 |
| 68 // Requests setting the zoom level to the provided |zoom_level|. | 64 // Requests setting the zoom level to the provided |zoom_level|. |
| 69 virtual void SetZoom(double zoom_factor) {} | 65 virtual void SetZoom(double zoom_factor) {} |
| 70 | 66 |
| 71 virtual bool IsDragAndDropEnabled(); | 67 virtual bool IsDragAndDropEnabled(); |
| 72 | 68 |
| 73 // Returns whether the user agent for the guest is being overridden. | 69 // Returns whether the user agent for the guest is being overridden. |
| 74 virtual bool IsOverridingUserAgent() const; | 70 virtual bool IsOverridingUserAgent() const; |
| 75 | 71 |
| 76 // Notification that a load in the guest resulted in abort. Note that |url| | |
| 77 // may be invalid. | |
| 78 virtual void LoadAbort(bool is_top_level, | |
| 79 const GURL& url, | |
| 80 const std::string& error_type) {} | |
| 81 | |
| 82 // Notification that the page has made some progress loading. |progress| is a | 72 // Notification that the page has made some progress loading. |progress| is a |
| 83 // value between 0.0 (nothing loaded) and 1.0 (page loaded completely). | 73 // value between 0.0 (nothing loaded) and 1.0 (page loaded completely). |
| 84 virtual void LoadProgressed(double progress) {} | 74 virtual void LoadProgressed(double progress) {} |
| 85 | 75 |
| 86 // Notification that the guest is no longer hung. | 76 // Notification that the guest is no longer hung. |
| 87 virtual void RendererResponsive() {} | 77 virtual void RendererResponsive() {} |
| 88 | 78 |
| 89 // Notification that the guest is hung. | 79 // Notification that the guest is hung. |
| 90 virtual void RendererUnresponsive() {} | 80 virtual void RendererUnresponsive() {} |
| 91 | 81 |
| 92 typedef base::Callback<void(bool /* allow */, | |
| 93 const std::string& /* user_input */)> | |
| 94 PermissionResponseCallback; | |
| 95 | |
| 96 // Request permission from the delegate to perform an action of the provided | |
| 97 // |permission_type|. Details of the permission request are found in | |
| 98 // |request_info|. A |callback| is provided to make the decision. | |
| 99 virtual void RequestPermission( | |
| 100 BrowserPluginPermissionType permission_type, | |
| 101 const base::DictionaryValue& request_info, | |
| 102 const PermissionResponseCallback& callback, | |
| 103 bool allowed_by_default) {} | |
| 104 | |
| 105 // Requests resolution of a potentially relative URL. | |
| 106 virtual GURL ResolveURL(const std::string& src); | |
| 107 | |
| 108 // Informs the delegate of the WebContents that created delegate's associated | |
| 109 // WebContents. | |
| 110 // TODO(fsamuel): Remove this once the New Window API is migrated outside of | |
| 111 // the content layer. | |
| 112 virtual void SetOpener(WebContents* opener) {} | |
| 113 | |
| 114 // Notifies that the content size of the guest has changed in autosize mode. | 82 // Notifies that the content size of the guest has changed in autosize mode. |
| 115 virtual void SizeChanged(const gfx::Size& old_size, | 83 virtual void SizeChanged(const gfx::Size& old_size, |
| 116 const gfx::Size& new_size) {} | 84 const gfx::Size& new_size) {} |
| 117 | 85 |
| 118 // Asks permission to use the camera and/or microphone. If permission is | 86 // Asks permission to use the camera and/or microphone. If permission is |
| 119 // granted, a call should be made to |callback| with the devices. If the | 87 // granted, a call should be made to |callback| with the devices. If the |
| 120 // request is denied, a call should be made to |callback| with an empty list | 88 // request is denied, a call should be made to |callback| with an empty list |
| 121 // of devices. |request| has the details of the request (e.g. which of audio | 89 // of devices. |request| has the details of the request (e.g. which of audio |
| 122 // and/or video devices are requested, and lists of available devices). | 90 // and/or video devices are requested, and lists of available devices). |
| 123 virtual void RequestMediaAccessPermission( | 91 virtual void RequestMediaAccessPermission( |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 136 bool user_gesture, | 104 bool user_gesture, |
| 137 bool last_unlocked_by_target, | 105 bool last_unlocked_by_target, |
| 138 const base::Callback<void(bool)>& callback) {} | 106 const base::Callback<void(bool)>& callback) {} |
| 139 | 107 |
| 140 // Returns a pointer to a service to manage JavaScript dialogs. May return | 108 // Returns a pointer to a service to manage JavaScript dialogs. May return |
| 141 // NULL in which case dialogs aren't shown. | 109 // NULL in which case dialogs aren't shown. |
| 142 virtual JavaScriptDialogManager* GetJavaScriptDialogManager(); | 110 virtual JavaScriptDialogManager* GetJavaScriptDialogManager(); |
| 143 | 111 |
| 144 // Returns true if the context menu operation was handled by the delegate. | 112 // Returns true if the context menu operation was handled by the delegate. |
| 145 virtual bool HandleContextMenu(const ContextMenuParams& params); | 113 virtual bool HandleContextMenu(const ContextMenuParams& params); |
| 114 | |
| 115 // Request navigating the guest to the provided |src| URL. | |
| 116 virtual void NavigateGuest(const std::string& src) {} | |
| 117 | |
| 118 // Requests that the delegate destroy itself along with its associated | |
| 119 // WebContents. | |
| 120 virtual void Destroy() {} | |
| 121 | |
| 122 // Creates a new tab with the already-created WebContents 'new_contents'. | |
|
lazyboy
2014/05/12 23:00:20
s/'new_contents'/|new_contents|
Fady Samuel
2014/05/13 18:59:02
Done.
| |
| 123 // The window for the added contents should be reparented correctly when this | |
| 124 // method returns. If |disposition| is NEW_POPUP, |initial_pos| should hold | |
| 125 // the initial position. If |was_blocked| is non-NULL, then |*was_blocked| | |
| 126 // will be set to true if the popup gets blocked, and left unchanged | |
| 127 // otherwise. | |
| 128 virtual void AddNewContents(WebContents* source, | |
| 129 WebContents* new_contents, | |
| 130 WindowOpenDisposition disposition, | |
| 131 const gfx::Rect& initial_pos, | |
| 132 bool user_gesture, | |
| 133 bool* was_blocked) {} | |
| 134 | |
| 135 // Opens a new URL inside the passed in WebContents (if source is 0 open | |
| 136 // in the current front-most tab), unless |disposition| indicates the url | |
| 137 // should be opened in a new tab or window. | |
| 138 // | |
| 139 // A NULL source indicates the current tab (callers should probably use | |
| 140 // OpenURL() for these cases which does it for you). | |
| 141 | |
|
lazyboy
2014/05/12 23:00:20
Add continuing //
Fady Samuel
2014/05/13 18:59:02
Done.
| |
| 142 // Returns the WebContents the URL is opened in, or NULL if the URL wasn't | |
| 143 // opened immediately. | |
| 144 virtual WebContents* OpenURLFromTab(WebContents* source, | |
| 145 const OpenURLParams& params); | |
| 146 | |
| 147 // Notifies the delegate about the creation of a new WebContents. This | |
| 148 // typically happens when popups are created. | |
| 149 virtual void WebContentsCreated(WebContents* source_contents, | |
| 150 int opener_render_frame_id, | |
| 151 const base::string16& frame_name, | |
| 152 const GURL& target_url, | |
| 153 WebContents* new_contents) {} | |
| 154 | |
| 155 // Registers a |callback| with the delegate that the delegate would call when | |
| 156 // it is about to be destroyed. | |
| 157 typedef base::Callback<void(WebContents*)> DestructionCallback; | |
| 158 virtual void RegisterDestructionCallback( | |
| 159 const DestructionCallback& callback) {} | |
| 146 }; | 160 }; |
| 147 | 161 |
| 148 } // namespace content | 162 } // namespace content |
| 149 | 163 |
| 150 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_ | 164 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_PLUGIN_GUEST_DELEGATE_H_ |
| OLD | NEW |