| 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_HTML_DIALOG_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_HTML_DIALOG_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_HTML_DIALOG_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_HTML_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_first_render_watcher.h" | 14 #include "chrome/browser/tab_render_watcher.h" |
| 15 #include "chrome/browser/ui/views/dom_view.h" | 15 #include "chrome/browser/ui/views/dom_view.h" |
| 16 #include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" | 16 #include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" |
| 17 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 17 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
| 18 #include "ui/gfx/size.h" | 18 #include "ui/gfx/size.h" |
| 19 #include "ui/views/widget/widget_delegate.h" | 19 #include "ui/views/widget/widget_delegate.h" |
| 20 | 20 |
| 21 class Browser; | 21 class Browser; |
| 22 class HtmlDialogController; | 22 class HtmlDialogController; |
| 23 class Profile; | 23 class Profile; |
| 24 | 24 |
| 25 //////////////////////////////////////////////////////////////////////////////// | 25 //////////////////////////////////////////////////////////////////////////////// |
| 26 // | 26 // |
| 27 // HtmlDialogView is a view used to display an HTML dialog to the user. The | 27 // HtmlDialogView is a view used to display an HTML dialog to the user. The |
| 28 // content of the dialogs is determined by the delegate | 28 // content of the dialogs is determined by the delegate |
| 29 // (HtmlDialogUIDelegate), but is basically a file URL along with a | 29 // (HtmlDialogUIDelegate), but is basically a file URL along with a |
| 30 // JSON input string. The HTML is supposed to show a UI to the user and is | 30 // JSON input string. The HTML is supposed to show a UI to the user and is |
| 31 // expected to send back a JSON file as a return value. | 31 // expected to send back a JSON file as a return value. |
| 32 // | 32 // |
| 33 //////////////////////////////////////////////////////////////////////////////// | 33 //////////////////////////////////////////////////////////////////////////////// |
| 34 // | 34 // |
| 35 // TODO(akalin): Make HtmlDialogView contain an HtmlDialogTabContentsDelegate | 35 // TODO(akalin): Make HtmlDialogView contain an HtmlDialogTabContentsDelegate |
| 36 // instead of inheriting from it to avoid violating the "no multiple | 36 // instead of inheriting from it to avoid violating the "no multiple |
| 37 // inheritance" rule. | 37 // inheritance" rule. |
| 38 class HtmlDialogView | 38 class HtmlDialogView |
| 39 : public DOMView, | 39 : public DOMView, |
| 40 public HtmlDialogTabContentsDelegate, | 40 public HtmlDialogTabContentsDelegate, |
| 41 public HtmlDialogUIDelegate, | 41 public HtmlDialogUIDelegate, |
| 42 public views::WidgetDelegate, | 42 public views::WidgetDelegate, |
| 43 public TabFirstRenderWatcher::Delegate { | 43 public TabRenderWatcher::Delegate { |
| 44 public: | 44 public: |
| 45 HtmlDialogView(Profile* profile, | 45 HtmlDialogView(Profile* profile, |
| 46 Browser* browser, | 46 Browser* browser, |
| 47 HtmlDialogUIDelegate* delegate); | 47 HtmlDialogUIDelegate* delegate); |
| 48 virtual ~HtmlDialogView(); | 48 virtual ~HtmlDialogView(); |
| 49 | 49 |
| 50 // Initializes the contents of the dialog (the DOMView and the callbacks). | 50 // Initializes the contents of the dialog (the DOMView and the callbacks). |
| 51 void InitDialog(); | 51 void InitDialog(); |
| 52 | 52 |
| 53 // Overridden from views::View: | 53 // Overridden from views::View: |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 content::WebContents* new_contents, | 96 content::WebContents* new_contents, |
| 97 WindowOpenDisposition disposition, | 97 WindowOpenDisposition disposition, |
| 98 const gfx::Rect& initial_pos, | 98 const gfx::Rect& initial_pos, |
| 99 bool user_gesture) OVERRIDE; | 99 bool user_gesture) OVERRIDE; |
| 100 virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE; | 100 virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE; |
| 101 | 101 |
| 102 protected: | 102 protected: |
| 103 // Register accelerators for this dialog. | 103 // Register accelerators for this dialog. |
| 104 virtual void RegisterDialogAccelerators(); | 104 virtual void RegisterDialogAccelerators(); |
| 105 | 105 |
| 106 // TabFirstRenderWatcher::Delegate implementation. | 106 // TabRenderWatcher::Delegate implementation. |
| 107 virtual void OnRenderHostCreated(RenderViewHost* host) OVERRIDE; | 107 virtual void OnRenderHostCreated(RenderViewHost* host) OVERRIDE; |
| 108 virtual void OnTabMainFrameLoaded() OVERRIDE; | 108 virtual void OnTabMainFrameLoaded() OVERRIDE; |
| 109 virtual void OnTabMainFrameFirstRender() OVERRIDE; | 109 virtual void OnTabMainFrameRender() OVERRIDE; |
| 110 | 110 |
| 111 private: | 111 private: |
| 112 FRIEND_TEST_ALL_PREFIXES(HtmlDialogBrowserTest, WebContentRendered); | 112 FRIEND_TEST_ALL_PREFIXES(HtmlDialogBrowserTest, WebContentRendered); |
| 113 | 113 |
| 114 // Whether the view is initialized. That is, dialog acceleartors is registered | 114 // Whether the view is initialized. That is, dialog acceleartors is registered |
| 115 // and FreezeUpdates property is set to prevent WM from showing the window | 115 // and FreezeUpdates property is set to prevent WM from showing the window |
| 116 // until the property is removed. | 116 // until the property is removed. |
| 117 bool initialized_; | 117 bool initialized_; |
| 118 | 118 |
| 119 // Watches for TabContents rendering. | 119 // Watches for TabContents rendering. |
| 120 scoped_ptr<TabFirstRenderWatcher> tab_watcher_; | 120 scoped_ptr<TabRenderWatcher> tab_watcher_; |
| 121 | 121 |
| 122 // This view is a delegate to the HTML content since it needs to get notified | 122 // This view is a delegate to the HTML content since it needs to get notified |
| 123 // about when the dialog is closing. For all other actions (besides dialog | 123 // about when the dialog is closing. For all other actions (besides dialog |
| 124 // closing) we delegate to the creator of this view, which we keep track of | 124 // closing) we delegate to the creator of this view, which we keep track of |
| 125 // using this variable. | 125 // using this variable. |
| 126 HtmlDialogUIDelegate* delegate_; | 126 HtmlDialogUIDelegate* delegate_; |
| 127 | 127 |
| 128 // Controls lifetime of dialog. | 128 // Controls lifetime of dialog. |
| 129 scoped_ptr<HtmlDialogController> dialog_controller_; | 129 scoped_ptr<HtmlDialogController> dialog_controller_; |
| 130 | 130 |
| 131 DISALLOW_COPY_AND_ASSIGN(HtmlDialogView); | 131 DISALLOW_COPY_AND_ASSIGN(HtmlDialogView); |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 #endif // CHROME_BROWSER_UI_VIEWS_HTML_DIALOG_VIEW_H_ | 134 #endif // CHROME_BROWSER_UI_VIEWS_HTML_DIALOG_VIEW_H_ |
| OLD | NEW |