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