Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: chrome/browser/ui/views/html_dialog_view.h

Issue 8417005: Share TabFirstRenderWatcher with HtmlDialogView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/tab_first_render_watcher.h"
13 #include "chrome/browser/ui/views/dom_view.h" 14 #include "chrome/browser/ui/views/dom_view.h"
14 #include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h" 15 #include "chrome/browser/ui/webui/html_dialog_tab_contents_delegate.h"
15 #include "chrome/browser/ui/webui/html_dialog_ui.h" 16 #include "chrome/browser/ui/webui/html_dialog_ui.h"
16 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h"
18 #include "ui/gfx/size.h" 17 #include "ui/gfx/size.h"
19 #include "views/widget/widget_delegate.h" 18 #include "views/widget/widget_delegate.h"
20 19
21 class Browser; 20 class Browser;
22 21
23 //////////////////////////////////////////////////////////////////////////////// 22 ////////////////////////////////////////////////////////////////////////////////
24 // 23 //
25 // HtmlDialogView is a view used to display an HTML dialog to the user. The 24 // HtmlDialogView is a view used to display an HTML dialog to the user. The
26 // content of the dialogs is determined by the delegate 25 // content of the dialogs is determined by the delegate
27 // (HtmlDialogUIDelegate), but is basically a file URL along with a 26 // (HtmlDialogUIDelegate), but is basically a file URL along with a
28 // JSON input string. The HTML is supposed to show a UI to the user and is 27 // JSON input string. The HTML is supposed to show a UI to the user and is
29 // expected to send back a JSON file as a return value. 28 // expected to send back a JSON file as a return value.
30 // 29 //
31 //////////////////////////////////////////////////////////////////////////////// 30 ////////////////////////////////////////////////////////////////////////////////
32 // 31 //
33 // TODO(akalin): Make HtmlDialogView contain an HtmlDialogTabContentsDelegate 32 // TODO(akalin): Make HtmlDialogView contain an HtmlDialogTabContentsDelegate
34 // instead of inheriting from it to avoid violating the "no multiple 33 // instead of inheriting from it to avoid violating the "no multiple
35 // inheritance" rule. 34 // inheritance" rule.
36 class HtmlDialogView 35 class HtmlDialogView
37 : public DOMView, 36 : public DOMView,
38 public HtmlDialogTabContentsDelegate, 37 public HtmlDialogTabContentsDelegate,
39 public HtmlDialogUIDelegate, 38 public HtmlDialogUIDelegate,
40 public views::WidgetDelegate, 39 public views::WidgetDelegate,
41 public content::NotificationObserver { 40 public TabFirstRenderWatcher::Delegate {
42 public: 41 public:
43 HtmlDialogView(Profile* profile, HtmlDialogUIDelegate* delegate); 42 HtmlDialogView(Profile* profile, HtmlDialogUIDelegate* delegate);
44 virtual ~HtmlDialogView(); 43 virtual ~HtmlDialogView();
45 44
46 // Initializes the contents of the dialog (the DOMView and the callbacks). 45 // Initializes the contents of the dialog (the DOMView and the callbacks).
47 void InitDialog(); 46 void InitDialog();
48 47
49 // Overridden from views::View: 48 // Overridden from views::View:
50 virtual gfx::Size GetPreferredSize() OVERRIDE; 49 virtual gfx::Size GetPreferredSize() OVERRIDE;
51 virtual bool AcceleratorPressed(const views::Accelerator& accelerator) 50 virtual bool AcceleratorPressed(const views::Accelerator& accelerator)
(...skipping 25 matching lines...) Expand all
77 OVERRIDE; 76 OVERRIDE;
78 virtual bool ShouldShowDialogTitle() const OVERRIDE; 77 virtual bool ShouldShowDialogTitle() const OVERRIDE;
79 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE; 78 virtual bool HandleContextMenu(const ContextMenuParams& params) OVERRIDE;
80 79
81 // Overridden from TabContentsDelegate: 80 // Overridden from TabContentsDelegate:
82 virtual void MoveContents(TabContents* source, const gfx::Rect& pos) OVERRIDE; 81 virtual void MoveContents(TabContents* source, const gfx::Rect& pos) OVERRIDE;
83 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) 82 virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event)
84 OVERRIDE; 83 OVERRIDE;
85 virtual void CloseContents(TabContents* source) OVERRIDE; 84 virtual void CloseContents(TabContents* source) OVERRIDE;
86 85
87 // Overridden from content::NotificationObserver
88 virtual void Observe(int type,
89 const content::NotificationSource& source,
90 const content::NotificationDetails& details) OVERRIDE;
91
92 protected: 86 protected:
93 // Register accelerators for this dialog. 87 // Register accelerators for this dialog.
94 virtual void RegisterDialogAccelerators(); 88 virtual void RegisterDialogAccelerators();
95 89
96 private: 90 private:
97 FRIEND_TEST_ALL_PREFIXES(HtmlDialogBrowserTest, TestStateTransition); 91 FRIEND_TEST_ALL_PREFIXES(HtmlDialogBrowserTest, TestStateTransition);
98 92
99 // A state used to ensure that we show the window only after the 93 // TabFirstRenderWatcher::Delegate implementation.
100 // renderer painted the full page. 94 virtual void OnRenderHostCreated(RenderViewHost* host) OVERRIDE {}
101 enum DialogState { 95 virtual void OnTabMainFrameLoaded() OVERRIDE {}
102 NONE, 96 virtual void OnTabMainFrameFirstRender() OVERRIDE;
103 INITIALIZED, // FreezeUpdates property is set to prevent WM from showing 97
104 // the window until the property is remoevd. 98 // Whether the view is initialized. That is, dialog acceleartors is registered
105 LOADED, // Renderer loaded the page. 99 // and FreezeUpdates property is set to prevent WM from showing the window
106 PAINTED, // 1st paint event after the page is loaded. 100 // until the property is removed.
107 // FreezeUpdates property is removed to tell WM to shows 101 bool initialized_;
108 // the window.
109 };
110 DialogState state_;
111 102
112 // This view is a delegate to the HTML content since it needs to get notified 103 // This view is a delegate to the HTML content since it needs to get notified
113 // about when the dialog is closing. For all other actions (besides dialog 104 // about when the dialog is closing. For all other actions (besides dialog
114 // closing) we delegate to the creator of this view, which we keep track of 105 // closing) we delegate to the creator of this view, which we keep track of
115 // using this variable. 106 // using this variable.
116 HtmlDialogUIDelegate* delegate_; 107 HtmlDialogUIDelegate* delegate_;
117 108
118 content::NotificationRegistrar notification_registrar_;
119
120 DISALLOW_COPY_AND_ASSIGN(HtmlDialogView); 109 DISALLOW_COPY_AND_ASSIGN(HtmlDialogView);
121 }; 110 };
122 111
123 #endif // CHROME_BROWSER_UI_VIEWS_HTML_DIALOG_VIEW_H_ 112 #endif // CHROME_BROWSER_UI_VIEWS_HTML_DIALOG_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698