| 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 CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_DELEGATE_BASE_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_DELEGATE_BASE_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_DELEGATE_BASE_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_DELEGATE_BASE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" | 10 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" |
| 11 #include "ui/web_dialogs/web_dialog_ui.h" | 11 #include "ui/web_dialogs/web_dialog_ui.h" |
| 12 #include "ui/web_dialogs/web_dialog_web_contents_delegate.h" | 12 #include "ui/web_dialogs/web_dialog_web_contents_delegate.h" |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 class BrowserContext; | 15 class BrowserContext; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace ui { | 18 namespace ui { |
| 19 class WebDialogDelegate; | 19 class WebDialogDelegate; |
| 20 } | 20 } |
| 21 | 21 |
| 22 // Platform-agnostic base implementation of ConstrainedWebDialogDelegate. | 22 // Platform-agnostic base implementation of ConstrainedWebDialogDelegate. |
| 23 class ConstrainedWebDialogDelegateBase | 23 class ConstrainedWebDialogDelegateBase |
| 24 : public ConstrainedWebDialogDelegate, | 24 : public ConstrainedWebDialogDelegate, |
| 25 public ui::WebDialogWebContentsDelegate { | 25 public ui::WebDialogWebContentsDelegate { |
| 26 public: | 26 public: |
| 27 // |browser_context| and |delegate| must outlive |this| instance, whereas |
| 28 // |this| will take ownership of |tab_delegate|. |
| 27 ConstrainedWebDialogDelegateBase(content::BrowserContext* browser_context, | 29 ConstrainedWebDialogDelegateBase(content::BrowserContext* browser_context, |
| 28 ui::WebDialogDelegate* delegate, | 30 ui::WebDialogDelegate* delegate, |
| 29 WebDialogWebContentsDelegate* tab_delegate); | 31 WebDialogWebContentsDelegate* tab_delegate); |
| 30 ~ConstrainedWebDialogDelegateBase() override; | 32 ~ConstrainedWebDialogDelegateBase() override; |
| 31 | 33 |
| 32 bool closed_via_webui() const; | 34 bool closed_via_webui() const; |
| 33 | 35 |
| 34 // ConstrainedWebDialogDelegate interface. | 36 // ConstrainedWebDialogDelegate interface. |
| 35 const ui::WebDialogDelegate* GetWebDialogDelegate() const override; | 37 const ui::WebDialogDelegate* GetWebDialogDelegate() const override; |
| 36 ui::WebDialogDelegate* GetWebDialogDelegate() override; | 38 ui::WebDialogDelegate* GetWebDialogDelegate() override; |
| 37 void OnDialogCloseFromWebUI() override; | 39 void OnDialogCloseFromWebUI() override; |
| 38 void ReleaseWebContentsOnDialogClose() override; | 40 void ReleaseWebContentsOnDialogClose() override; |
| 39 content::WebContents* GetWebContents() override; | 41 content::WebContents* GetWebContents() override; |
| 40 gfx::NativeWindow GetNativeDialog() override; | 42 gfx::NativeWindow GetNativeDialog() override; |
| 41 gfx::Size GetMinimumSize() const override; | 43 gfx::Size GetMinimumSize() const override; |
| 42 gfx::Size GetMaximumSize() const override; | 44 gfx::Size GetMaximumSize() const override; |
| 43 gfx::Size GetPreferredSize() const override; | 45 gfx::Size GetPreferredSize() const override; |
| 44 | 46 |
| 45 // WebDialogWebContentsDelegate interface. | 47 // WebDialogWebContentsDelegate interface. |
| 46 void HandleKeyboardEvent( | 48 void HandleKeyboardEvent( |
| 47 content::WebContents* source, | 49 content::WebContents* source, |
| 48 const content::NativeWebKeyboardEvent& event) override; | 50 const content::NativeWebKeyboardEvent& event) override; |
| 49 | 51 |
| 52 // Resize the dialog to the given size. |
| 53 virtual void ResizeToGivenSize(const gfx::Size size); |
| 54 |
| 50 private: | 55 private: |
| 51 scoped_ptr<ui::WebDialogDelegate> web_dialog_delegate_; | 56 scoped_ptr<ui::WebDialogDelegate> web_dialog_delegate_; |
| 52 | 57 |
| 53 // Holds the HTML to display in the constrained dialog. | 58 // Holds the HTML to display in the constrained dialog. |
| 54 scoped_ptr<content::WebContents> web_contents_; | 59 scoped_ptr<content::WebContents> web_contents_; |
| 55 | 60 |
| 56 // Was the dialog closed from WebUI (in which case |web_dialog_delegate_|'s | 61 // Was the dialog closed from WebUI (in which case |web_dialog_delegate_|'s |
| 57 // OnDialogClosed() method has already been called)? | 62 // OnDialogClosed() method has already been called)? |
| 58 bool closed_via_webui_; | 63 bool closed_via_webui_; |
| 59 | 64 |
| 60 // If true, release |web_contents_| on close instead of destroying it. | 65 // If true, release |web_contents_| on close instead of destroying it. |
| 61 bool release_contents_on_close_; | 66 bool release_contents_on_close_; |
| 62 | 67 |
| 63 scoped_ptr<WebDialogWebContentsDelegate> override_tab_delegate_; | 68 scoped_ptr<WebDialogWebContentsDelegate> override_tab_delegate_; |
| 64 | 69 |
| 65 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateBase); | 70 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateBase); |
| 66 }; | 71 }; |
| 67 | 72 |
| 68 #endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_DELEGATE_BASE_H_ | 73 #endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_WEB_DIALOG_DELEGATE_BASE_H_ |
| OLD | NEW |