OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_WEB_CONTENTS_DELEGATE_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_DELEGATE_H_ |
6 #define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_DELEGATE_H_ | 6 #define CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_DELEGATE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // should be opened in a new tab or window. | 70 // should be opened in a new tab or window. |
71 // | 71 // |
72 // A NULL source indicates the current tab (callers should probably use | 72 // A NULL source indicates the current tab (callers should probably use |
73 // OpenURL() for these cases which does it for you). | 73 // OpenURL() for these cases which does it for you). |
74 | 74 |
75 // Returns the WebContents the URL is opened in, or NULL if the URL wasn't | 75 // Returns the WebContents the URL is opened in, or NULL if the URL wasn't |
76 // opened immediately. | 76 // opened immediately. |
77 virtual WebContents* OpenURLFromTab(WebContents* source, | 77 virtual WebContents* OpenURLFromTab(WebContents* source, |
78 const OpenURLParams& params); | 78 const OpenURLParams& params); |
79 | 79 |
80 // Called to inform the delegate that the tab content's navigation state | 80 // Called to inform the delegate that the WebContents's navigation state |
81 // changed. The |changed_flags| indicates the parts of the navigation state | 81 // changed. The |changed_flags| indicates the parts of the navigation state |
82 // that have been updated, and is any combination of the | 82 // that have been updated, and is any combination of the |
83 // |WebContents::InvalidateTypes| bits. | 83 // |WebContents::InvalidateTypes| bits. |
84 virtual void NavigationStateChanged(const WebContents* source, | 84 virtual void NavigationStateChanged(const WebContents* source, |
85 unsigned changed_flags) {} | 85 unsigned changed_flags) {} |
86 | 86 |
87 // Adds the navigation request headers to |headers|. Use | 87 // Adds the navigation request headers to |headers|. Use |
88 // net::HttpUtil::AppendHeaderIfMissing to build the set of headers. | 88 // net::HttpUtil::AppendHeaderIfMissing to build the set of headers. |
89 virtual void AddNavigationHeaders(const GURL& url, std::string* headers) {} | 89 virtual void AddNavigationHeaders(const GURL& url, std::string* headers) {} |
90 | 90 |
(...skipping 27 matching lines...) Expand all Loading... |
118 virtual void LoadProgressChanged(double progress) {} | 118 virtual void LoadProgressChanged(double progress) {} |
119 | 119 |
120 // Request the delegate to close this web contents, and do whatever cleanup | 120 // Request the delegate to close this web contents, and do whatever cleanup |
121 // it needs to do. | 121 // it needs to do. |
122 virtual void CloseContents(WebContents* source) {} | 122 virtual void CloseContents(WebContents* source) {} |
123 | 123 |
124 // Informs the delegate that the underlying RenderViewHost has been swapped | 124 // Informs the delegate that the underlying RenderViewHost has been swapped |
125 // out so it can perform any cleanup necessary. | 125 // out so it can perform any cleanup necessary. |
126 virtual void SwappedOut(WebContents* source) {} | 126 virtual void SwappedOut(WebContents* source) {} |
127 | 127 |
128 // Request the delegate to move this tab contents to the specified position | 128 // Request the delegate to move this WebContents to the specified position |
129 // in screen coordinates. | 129 // in screen coordinates. |
130 virtual void MoveContents(WebContents* source, const gfx::Rect& pos) {} | 130 virtual void MoveContents(WebContents* source, const gfx::Rect& pos) {} |
131 | 131 |
132 // Causes the delegate to detach |source| and clean up any internal data | 132 // Causes the delegate to detach |source| and clean up any internal data |
133 // pointing to it. After this call ownership of |source| passes to the | 133 // pointing to it. After this call ownership of |source| passes to the |
134 // caller, and it is safe to call "source->set_delegate(someone_else);". | 134 // caller, and it is safe to call "source->set_delegate(someone_else);". |
135 virtual void DetachContents(WebContents* source) {} | 135 virtual void DetachContents(WebContents* source) {} |
136 | 136 |
137 // Called to determine if the WebContents is contained in a popup window | 137 // Called to determine if the WebContents is contained in a popup window |
138 // or a panel window. | 138 // or a panel window. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 // render view widget during various animations (e.g. infobar closing). | 226 // render view widget during various animations (e.g. infobar closing). |
227 // This is used to make painting look smoother. | 227 // This is used to make painting look smoother. |
228 virtual int GetExtraRenderViewHeight() const; | 228 virtual int GetExtraRenderViewHeight() const; |
229 | 229 |
230 // Returns true if the context menu operation was handled by the delegate. | 230 // Returns true if the context menu operation was handled by the delegate. |
231 virtual bool HandleContextMenu(const content::ContextMenuParams& params); | 231 virtual bool HandleContextMenu(const content::ContextMenuParams& params); |
232 | 232 |
233 // Returns true if the context menu command was handled | 233 // Returns true if the context menu command was handled |
234 virtual bool ExecuteContextMenuCommand(int command); | 234 virtual bool ExecuteContextMenuCommand(int command); |
235 | 235 |
236 // Opens source view for given tab contents that is navigated to the given | 236 // Opens source view for given WebContents that is navigated to the given |
237 // page url. | 237 // page url. |
238 virtual void ViewSourceForTab(WebContents* source, const GURL& page_url); | 238 virtual void ViewSourceForTab(WebContents* source, const GURL& page_url); |
239 | 239 |
240 // Opens source view for the given subframe. | 240 // Opens source view for the given subframe. |
241 virtual void ViewSourceForFrame(WebContents* source, | 241 virtual void ViewSourceForFrame(WebContents* source, |
242 const GURL& url, | 242 const GURL& url, |
243 const std::string& content_state); | 243 const std::string& content_state); |
244 | 244 |
245 // Allows delegates to handle keyboard events before sending to the renderer. | 245 // Allows delegates to handle keyboard events before sending to the renderer. |
246 // Returns true if the |event| was handled. Otherwise, if the |event| would be | 246 // Returns true if the |event| was handled. Otherwise, if the |event| would be |
(...skipping 13 matching lines...) Expand all Loading... |
260 // Render view drag n drop ended. | 260 // Render view drag n drop ended. |
261 virtual void DragEnded() {} | 261 virtual void DragEnded() {} |
262 | 262 |
263 // Shows the repost form confirmation dialog box. | 263 // Shows the repost form confirmation dialog box. |
264 virtual void ShowRepostFormWarningDialog(WebContents* source) {} | 264 virtual void ShowRepostFormWarningDialog(WebContents* source) {} |
265 | 265 |
266 // Allows delegate to override navigation to the history entries. | 266 // Allows delegate to override navigation to the history entries. |
267 // Returns true to allow WebContents to continue with the default processing. | 267 // Returns true to allow WebContents to continue with the default processing. |
268 virtual bool OnGoToEntryOffset(int offset); | 268 virtual bool OnGoToEntryOffset(int offset); |
269 | 269 |
270 // Returns whether this tab contents should add the specified navigation to | 270 // Returns whether this WebContents should add the specified navigation to |
271 // history. | 271 // history. |
272 virtual bool ShouldAddNavigationToHistory( | 272 virtual bool ShouldAddNavigationToHistory( |
273 const history::HistoryAddPageArgs& add_page_args, | 273 const history::HistoryAddPageArgs& add_page_args, |
274 NavigationType navigation_type); | 274 NavigationType navigation_type); |
275 | 275 |
276 // Returns the native window framing the view containing the tab contents. | 276 // Returns the native window framing the view containing the WebContents. |
277 virtual gfx::NativeWindow GetFrameNativeWindow(); | 277 virtual gfx::NativeWindow GetFrameNativeWindow(); |
278 | 278 |
279 // Allows delegate to control whether a WebContents will be created. Returns | 279 // Allows delegate to control whether a WebContents will be created. Returns |
280 // true to allow the creation. Default is to allow it. In cases where the | 280 // true to allow the creation. Default is to allow it. In cases where the |
281 // delegate handles the creation/navigation itself, it will use |target_url|. | 281 // delegate handles the creation/navigation itself, it will use |target_url|. |
282 virtual bool ShouldCreateWebContents( | 282 virtual bool ShouldCreateWebContents( |
283 WebContents* web_contents, | 283 WebContents* web_contents, |
284 int route_id, | 284 int route_id, |
285 WindowContainerType window_container_type, | 285 WindowContainerType window_container_type, |
286 const string16& frame_name, | 286 const string16& frame_name, |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 // Called when |this| is no longer the WebContentsDelegate for |source|. | 421 // Called when |this| is no longer the WebContentsDelegate for |source|. |
422 void Detach(WebContents* source); | 422 void Detach(WebContents* source); |
423 | 423 |
424 // The WebContents that this is currently a delegate for. | 424 // The WebContents that this is currently a delegate for. |
425 std::set<WebContents*> attached_contents_; | 425 std::set<WebContents*> attached_contents_; |
426 }; | 426 }; |
427 | 427 |
428 } // namespace content | 428 } // namespace content |
429 | 429 |
430 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_DELEGATE_H_ | 430 #endif // CONTENT_PUBLIC_BROWSER_WEB_CONTENTS_DELEGATE_H_ |
OLD | NEW |