| 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_VIEWS_WEB_DIALOG_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_WEB_DIALOG_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_WEB_DIALOG_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_WEB_DIALOG_VIEW_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "chrome/browser/tab_render_watcher.h" | 14 #include "chrome/browser/tab_render_watcher.h" |
| 15 #include "chrome/browser/ui/webui/web_dialog_delegate.h" | |
| 16 #include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h" | 15 #include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h" |
| 17 #include "ui/gfx/size.h" | 16 #include "ui/gfx/size.h" |
| 18 #include "ui/views/widget/widget_delegate.h" | 17 #include "ui/views/widget/widget_delegate.h" |
| 19 #include "ui/views/window/client_view.h" | 18 #include "ui/views/window/client_view.h" |
| 19 #include "ui/web_dialogs/web_dialog_delegate.h" |
| 20 | 20 |
| 21 class Browser; | 21 class Browser; |
| 22 class WebDialogController; | 22 class WebDialogController; |
| 23 class Profile; | 23 class Profile; |
| 24 | 24 |
| 25 namespace views { | 25 namespace views { |
| 26 class WebView; | 26 class WebView; |
| 27 } | 27 } |
| 28 | 28 |
| 29 //////////////////////////////////////////////////////////////////////////////// | 29 //////////////////////////////////////////////////////////////////////////////// |
| 30 // | 30 // |
| 31 // WebDialogView is a view used to display an web dialog to the user. The | 31 // WebDialogView is a view used to display an web dialog to the user. The |
| 32 // content of the dialogs is determined by the delegate | 32 // content of the dialogs is determined by the delegate |
| 33 // (WebDialogDelegate), but is basically a file URL along with a | 33 // (ui::WebDialogDelegate), but is basically a file URL along with a |
| 34 // JSON input string. The HTML is supposed to show a UI to the user and is | 34 // JSON input string. The HTML is supposed to show a UI to the user and is |
| 35 // expected to send back a JSON file as a return value. | 35 // expected to send back a JSON file as a return value. |
| 36 // | 36 // |
| 37 //////////////////////////////////////////////////////////////////////////////// | 37 //////////////////////////////////////////////////////////////////////////////// |
| 38 // | 38 // |
| 39 // TODO(akalin): Make WebDialogView contain an WebDialogWebContentsDelegate | 39 // TODO(akalin): Make WebDialogView contain an WebDialogWebContentsDelegate |
| 40 // instead of inheriting from it to avoid violating the "no multiple | 40 // instead of inheriting from it to avoid violating the "no multiple |
| 41 // inheritance" rule. | 41 // inheritance" rule. |
| 42 // TODO(beng): This class should not depend on Browser or Profile, only | 42 // TODO(beng): This class should not depend on Browser or Profile, only |
| 43 // content::BrowserContext. | 43 // content::BrowserContext. |
| 44 class WebDialogView | 44 class WebDialogView |
| 45 : public views::ClientView, | 45 : public views::ClientView, |
| 46 public WebDialogWebContentsDelegate, | 46 public WebDialogWebContentsDelegate, |
| 47 public WebDialogDelegate, | 47 public ui::WebDialogDelegate, |
| 48 public views::WidgetDelegate, | 48 public views::WidgetDelegate, |
| 49 public TabRenderWatcher::Delegate { | 49 public TabRenderWatcher::Delegate { |
| 50 public: | 50 public: |
| 51 WebDialogView(Profile* profile, | 51 WebDialogView(Profile* profile, |
| 52 Browser* browser, | 52 Browser* browser, |
| 53 WebDialogDelegate* delegate); | 53 ui::WebDialogDelegate* delegate); |
| 54 virtual ~WebDialogView(); | 54 virtual ~WebDialogView(); |
| 55 | 55 |
| 56 // For testing. | 56 // For testing. |
| 57 content::WebContents* web_contents(); | 57 content::WebContents* web_contents(); |
| 58 | 58 |
| 59 // Overridden from views::ClientView: | 59 // Overridden from views::ClientView: |
| 60 virtual gfx::Size GetPreferredSize() OVERRIDE; | 60 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 61 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) | 61 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) |
| 62 OVERRIDE; | 62 OVERRIDE; |
| 63 virtual void ViewHierarchyChanged(bool is_add, | 63 virtual void ViewHierarchyChanged(bool is_add, |
| 64 views::View* parent, | 64 views::View* parent, |
| 65 views::View* child) OVERRIDE; | 65 views::View* child) OVERRIDE; |
| 66 virtual bool CanClose() OVERRIDE; | 66 virtual bool CanClose() OVERRIDE; |
| 67 | 67 |
| 68 // Overridden from views::WidgetDelegate: | 68 // Overridden from views::WidgetDelegate: |
| 69 virtual bool CanResize() const OVERRIDE; | 69 virtual bool CanResize() const OVERRIDE; |
| 70 virtual ui::ModalType GetModalType() const OVERRIDE; | 70 virtual ui::ModalType GetModalType() const OVERRIDE; |
| 71 virtual string16 GetWindowTitle() const OVERRIDE; | 71 virtual string16 GetWindowTitle() const OVERRIDE; |
| 72 virtual std::string GetWindowName() const OVERRIDE; | 72 virtual std::string GetWindowName() const OVERRIDE; |
| 73 virtual void WindowClosing() OVERRIDE; | 73 virtual void WindowClosing() OVERRIDE; |
| 74 virtual views::View* GetContentsView() OVERRIDE; | 74 virtual views::View* GetContentsView() OVERRIDE; |
| 75 virtual ClientView* CreateClientView(views::Widget* widget) OVERRIDE; | 75 virtual ClientView* CreateClientView(views::Widget* widget) OVERRIDE; |
| 76 virtual views::View* GetInitiallyFocusedView() OVERRIDE; | 76 virtual views::View* GetInitiallyFocusedView() OVERRIDE; |
| 77 virtual bool ShouldShowWindowTitle() const OVERRIDE; | 77 virtual bool ShouldShowWindowTitle() const OVERRIDE; |
| 78 virtual views::Widget* GetWidget() OVERRIDE; | 78 virtual views::Widget* GetWidget() OVERRIDE; |
| 79 virtual const views::Widget* GetWidget() const OVERRIDE; | 79 virtual const views::Widget* GetWidget() const OVERRIDE; |
| 80 | 80 |
| 81 // Overridden from WebDialogDelegate: | 81 // Overridden from ui::WebDialogDelegate: |
| 82 virtual ui::ModalType GetDialogModalType() const OVERRIDE; | 82 virtual ui::ModalType GetDialogModalType() const OVERRIDE; |
| 83 virtual string16 GetDialogTitle() const OVERRIDE; | 83 virtual string16 GetDialogTitle() const OVERRIDE; |
| 84 virtual GURL GetDialogContentURL() const OVERRIDE; | 84 virtual GURL GetDialogContentURL() const OVERRIDE; |
| 85 virtual void GetWebUIMessageHandlers( | 85 virtual void GetWebUIMessageHandlers( |
| 86 std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE; | 86 std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE; |
| 87 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; | 87 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; |
| 88 virtual void GetMinimumDialogSize(gfx::Size* size) const OVERRIDE; | 88 virtual void GetMinimumDialogSize(gfx::Size* size) const OVERRIDE; |
| 89 virtual std::string GetDialogArgs() const OVERRIDE; | 89 virtual std::string GetDialogArgs() const OVERRIDE; |
| 90 virtual void OnDialogShown( | 90 virtual void OnDialogShown( |
| 91 content::WebUI* webui, | 91 content::WebUI* webui, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // until the property is removed. | 130 // until the property is removed. |
| 131 bool initialized_; | 131 bool initialized_; |
| 132 | 132 |
| 133 // Watches for WebContents rendering. | 133 // Watches for WebContents rendering. |
| 134 scoped_ptr<TabRenderWatcher> tab_watcher_; | 134 scoped_ptr<TabRenderWatcher> tab_watcher_; |
| 135 | 135 |
| 136 // This view is a delegate to the HTML content since it needs to get notified | 136 // This view is a delegate to the HTML content since it needs to get notified |
| 137 // about when the dialog is closing. For all other actions (besides dialog | 137 // about when the dialog is closing. For all other actions (besides dialog |
| 138 // closing) we delegate to the creator of this view, which we keep track of | 138 // closing) we delegate to the creator of this view, which we keep track of |
| 139 // using this variable. | 139 // using this variable. |
| 140 WebDialogDelegate* delegate_; | 140 ui::WebDialogDelegate* delegate_; |
| 141 | 141 |
| 142 // Controls lifetime of dialog. | 142 // Controls lifetime of dialog. |
| 143 scoped_ptr<WebDialogController> dialog_controller_; | 143 scoped_ptr<WebDialogController> dialog_controller_; |
| 144 | 144 |
| 145 views::WebView* web_view_; | 145 views::WebView* web_view_; |
| 146 | 146 |
| 147 DISALLOW_COPY_AND_ASSIGN(WebDialogView); | 147 DISALLOW_COPY_AND_ASSIGN(WebDialogView); |
| 148 }; | 148 }; |
| 149 | 149 |
| 150 #endif // CHROME_BROWSER_UI_VIEWS_WEB_DIALOG_VIEW_H_ | 150 #endif // CHROME_BROWSER_UI_VIEWS_WEB_DIALOG_VIEW_H_ |
| OLD | NEW |