| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_WEB_DIALOGS_WEB_DIALOG_DELEGATE_H_ |
| 6 #define UI_WEB_DIALOGS_WEB_DIALOG_DELEGATE_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/string16.h" |
| 13 #include "ui/base/ui_base_types.h" |
| 14 #include "ui/web_dialogs/web_dialogs_export.h" |
| 15 #include "webkit/glue/window_open_disposition.h" |
| 16 |
| 17 class GURL; |
| 18 |
| 19 namespace content { |
| 20 class WebUIMessageHandler; |
| 21 class WebContents; |
| 22 struct ContextMenuParams; |
| 23 struct OpenURLParams; |
| 24 } |
| 25 |
| 26 namespace gfx { |
| 27 class Rect; |
| 28 class Size; |
| 29 } |
| 30 |
| 31 namespace web_dialogs { |
| 32 // Implement this class to receive notifications. |
| 33 class WEB_DIALOGS_EXPORT WebDialogDelegate { |
| 34 public: |
| 35 // Returns true if the contents needs to be run in a modal dialog. |
| 36 virtual ui::ModalType GetDialogModalType() const = 0; |
| 37 |
| 38 // Returns the title of the dialog. |
| 39 virtual string16 GetDialogTitle() const = 0; |
| 40 |
| 41 // Returns the dialog's name identifier. Used to identify this dialog for |
| 42 // state restoration. |
| 43 virtual std::string GetDialogName() const; |
| 44 |
| 45 // Get the HTML file path for the content to load in the dialog. |
| 46 virtual GURL GetDialogContentURL() const = 0; |
| 47 |
| 48 // Get WebUIMessageHandler objects to handle messages from the HTML/JS page. |
| 49 // The handlers are used to send and receive messages from the page while it |
| 50 // is still open. Ownership of each handler is taken over by the WebUI |
| 51 // hosting the page. |
| 52 virtual void GetWebUIMessageHandlers( |
| 53 std::vector<content::WebUIMessageHandler*>* handlers) const = 0; |
| 54 |
| 55 // Get the size of the dialog. |
| 56 virtual void GetDialogSize(gfx::Size* size) const = 0; |
| 57 |
| 58 // Get the size of the dialog. |
| 59 virtual void GetMinimumDialogSize(gfx::Size* size) const; |
| 60 |
| 61 // Gets the JSON string input to use when showing the dialog. |
| 62 virtual std::string GetDialogArgs() const = 0; |
| 63 |
| 64 // A callback to notify the delegate that |source|'s loading state has |
| 65 // changed. |
| 66 virtual void OnLoadingStateChanged(content::WebContents* source) {} |
| 67 |
| 68 // A callback to notify the delegate that the dialog closed. |
| 69 // IMPORTANT: Implementations should delete |this| here (unless they've |
| 70 // arranged for the delegate to be deleted in some other way, e.g. by |
| 71 // registering it as a message handler in the WebUI object). |
| 72 virtual void OnDialogClosed(const std::string& json_retval) = 0; |
| 73 |
| 74 // A callback to notify the delegate that the contents have gone |
| 75 // away. Only relevant if your dialog hosts code that calls |
| 76 // windows.close() and you've allowed that. If the output parameter |
| 77 // is set to true, then the dialog is closed. The default is false. |
| 78 virtual void OnCloseContents(content::WebContents* source, |
| 79 bool* out_close_dialog) = 0; |
| 80 |
| 81 // A callback to allow the delegate to dictate that the window should not |
| 82 // have a title bar. This is useful when presenting branded interfaces. |
| 83 virtual bool ShouldShowDialogTitle() const = 0; |
| 84 |
| 85 // A callback to allow the delegate to inhibit context menu or show |
| 86 // customized menu. |
| 87 // Returns true iff you do NOT want the standard context menu to be |
| 88 // shown (because you want to handle it yourself). |
| 89 virtual bool HandleContextMenu(const content::ContextMenuParams& params); |
| 90 |
| 91 // A callback to allow the delegate to open a new URL inside |source|. |
| 92 // On return |out_new_contents| should contain the WebContents the URL |
| 93 // is opened in. Return false to use the default handler. |
| 94 virtual bool HandleOpenURLFromTab(content::WebContents* source, |
| 95 const content::OpenURLParams& params, |
| 96 content::WebContents** out_new_contents); |
| 97 |
| 98 // A callback to create a new tab with |new_contents|. |source| is the |
| 99 // WebContent where the operation originated. |disposition| controls how the |
| 100 // new tab should be opened. |initial_pos| is the position of the window if a |
| 101 // new window is created. |user_gesture| is true if the operation was started |
| 102 // by a user gesture. Return false to use the default handler. |
| 103 virtual bool HandleAddNewContents(content::WebContents* source, |
| 104 content::WebContents* new_contents, |
| 105 WindowOpenDisposition disposition, |
| 106 const gfx::Rect& initial_pos, |
| 107 bool user_gesture); |
| 108 |
| 109 // Stores the dialog bounds. |
| 110 virtual void StoreDialogSize(const gfx::Size& dialog_size) {} |
| 111 |
| 112 protected: |
| 113 virtual ~WebDialogDelegate() {} |
| 114 }; |
| 115 } // namespace web_dialogs |
| 116 |
| 117 #endif // UI_WEB_DIALOGS_WEB_DIALOG_DELEGATE_H_ |
| OLD | NEW |