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

Side by Side Diff: chrome/browser/chromeos/login/login_html_dialog.cc

Issue 8774022: Converting BubbleWindow uses, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Doesn't build... just a checkpoint for this work, might change approach. Created 9 years 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 #include "chrome/browser/chromeos/login/login_html_dialog.h" 5 #include "chrome/browser/chromeos/login/login_html_dialog.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/chromeos/frame/bubble_frame_view.h"
9 #include "chrome/browser/chromeos/frame/bubble_window.h"
10 #include "chrome/browser/chromeos/login/helper.h" 8 #include "chrome/browser/chromeos/login/helper.h"
11 #include "chrome/browser/profiles/profile_manager.h" 9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/ui/browser_dialogs.h"
12 #include "chrome/browser/ui/views/html_dialog_view.h" 11 #include "chrome/browser/ui/views/html_dialog_view.h"
13 #include "content/public/browser/notification_source.h" 12 #include "chrome/browser/ui/views/window.h"
14 #include "content/public/browser/notification_types.h"
15 #include "ui/gfx/native_widget_types.h"
16 #include "ui/gfx/rect.h"
17 #include "ui/gfx/size.h"
18 #include "ui/views/widget/widget.h"
19 13
20 namespace chromeos { 14 namespace chromeos {
21 15
22 namespace { 16 namespace {
23 17
24 // Default width/height ratio of screen size. 18 // Default width/height ratio of screen size.
25 const double kDefaultWidthRatio = 0.6; 19 const double kDefaultWidthRatio = 0.6;
26 const double kDefaultHeightRatio = 0.6; 20 const double kDefaultHeightRatio = 0.6;
27 21
28 } // namespace 22 } // namespace
29 23
30 /////////////////////////////////////////////////////////////////////////////// 24 ///////////////////////////////////////////////////////////////////////////////
31 // LoginHtmlDialog, public: 25 // LoginHtmlDialog, public:
32 26
33 void LoginHtmlDialog::Delegate::OnDialogClosed() { 27 void LoginHtmlDialog::Delegate::OnDialogClosed() {
34 } 28 }
35 29
36 LoginHtmlDialog::LoginHtmlDialog(Delegate* delegate, 30 LoginHtmlDialog::LoginHtmlDialog(Delegate* delegate,
37 gfx::NativeWindow parent_window, 31 gfx::NativeWindow parent_window,
38 const std::wstring& title, 32 const std::wstring& title,
39 const GURL& url, 33 const GURL& url)
40 Style style)
41 : delegate_(delegate), 34 : delegate_(delegate),
42 parent_window_(parent_window), 35 parent_window_(parent_window),
43 title_(WideToUTF16Hack(title)), 36 title_(WideToUTF16Hack(title)),
44 url_(url), 37 url_(url),
45 style_(style),
46 bubble_frame_view_(NULL),
47 is_open_(false) { 38 is_open_(false) {
48 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size())); 39 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size()));
49 width_ = static_cast<int>(kDefaultWidthRatio * screen_bounds.width()); 40 width_ = static_cast<int>(kDefaultWidthRatio * screen_bounds.width());
50 height_ = static_cast<int>(kDefaultHeightRatio * screen_bounds.height()); 41 height_ = static_cast<int>(kDefaultHeightRatio * screen_bounds.height());
51 } 42 }
52 43
53 LoginHtmlDialog::~LoginHtmlDialog() { 44 LoginHtmlDialog::~LoginHtmlDialog() {
54 delegate_ = NULL; 45 delegate_ = NULL;
55 } 46 }
56 47
57 void LoginHtmlDialog::Show() { 48 void LoginHtmlDialog::Show() {
49 Profile* profile = ProfileManager::GetDefaultProfile();
58 HtmlDialogView* html_view = 50 HtmlDialogView* html_view =
59 new HtmlDialogView(ProfileManager::GetDefaultProfile(), this); 51 new HtmlDialogView(ProfileManager::GetDefaultProfile(), this);
60 #if defined(USE_AURA) 52 // TODO(msw): Respect style? Support Throbber if actually used...
61 // TODO(saintlou): Until the new Bubble have been landed. 53 browser::ShowHtmlDialog(parent_window_, profile, html_view, STYLE_FLUSH);
62 views::Widget::CreateWindowWithParent(html_view, parent_window_);
63 html_view->InitDialog();
64 #else
65 if (style_ & STYLE_BUBBLE) {
66 views::Widget* bubble_window = BubbleWindow::Create(parent_window_,
67 static_cast<DialogStyle>(STYLE_XBAR | STYLE_THROBBER),
68 html_view);
69 bubble_frame_view_ = static_cast<BubbleFrameView*>(
70 bubble_window->non_client_view()->frame_view());
71 } else {
72 views::Widget::CreateWindowWithParent(html_view, parent_window_);
73 }
74 html_view->InitDialog();
75 if (bubble_frame_view_) {
76 bubble_frame_view_->StartThrobber();
77 notification_registrar_.Add(
78 this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
79 content::Source<TabContents>(
80 html_view->dom_contents()->tab_contents()));
81 }
82 #endif
83 html_view->GetWidget()->Show();
84 is_open_ = true; 54 is_open_ = true;
85 } 55 }
86 56
87 void LoginHtmlDialog::SetDialogSize(int width, int height) { 57 void LoginHtmlDialog::SetDialogSize(int width, int height) {
88 DCHECK(width >= 0 && height >= 0); 58 DCHECK(width >= 0 && height >= 0);
89 width_ = width; 59 width_ = width;
90 height_ = height; 60 height_ = height;
91 } 61 }
92 62
93 /////////////////////////////////////////////////////////////////////////////// 63 ///////////////////////////////////////////////////////////////////////////////
(...skipping 18 matching lines...) Expand all
112 void LoginHtmlDialog::GetDialogSize(gfx::Size* size) const { 82 void LoginHtmlDialog::GetDialogSize(gfx::Size* size) const {
113 size->SetSize(width_, height_); 83 size->SetSize(width_, height_);
114 } 84 }
115 85
116 std::string LoginHtmlDialog::GetDialogArgs() const { 86 std::string LoginHtmlDialog::GetDialogArgs() const {
117 return std::string(); 87 return std::string();
118 } 88 }
119 89
120 void LoginHtmlDialog::OnDialogClosed(const std::string& json_retval) { 90 void LoginHtmlDialog::OnDialogClosed(const std::string& json_retval) {
121 is_open_ = false; 91 is_open_ = false;
122 notification_registrar_.RemoveAll();
123 if (delegate_) 92 if (delegate_)
124 delegate_->OnDialogClosed(); 93 delegate_->OnDialogClosed();
125 } 94 }
126 95
127 void LoginHtmlDialog::OnCloseContents(TabContents* source, 96 void LoginHtmlDialog::OnCloseContents(TabContents* source,
128 bool* out_close_dialog) { 97 bool* out_close_dialog) {
129 if (out_close_dialog) 98 if (out_close_dialog)
130 *out_close_dialog = true; 99 *out_close_dialog = true;
131 } 100 }
132 101
133 bool LoginHtmlDialog::ShouldShowDialogTitle() const { 102 bool LoginHtmlDialog::ShouldShowDialogTitle() const {
134 return true; 103 return true;
135 } 104 }
136 105
137 bool LoginHtmlDialog::HandleContextMenu(const ContextMenuParams& params) { 106 bool LoginHtmlDialog::HandleContextMenu(const ContextMenuParams& params) {
138 // Disable context menu. 107 // Disable context menu.
139 return true; 108 return true;
140 } 109 }
141 110
142 void LoginHtmlDialog::Observe(int type,
143 const content::NotificationSource& source,
144 const content::NotificationDetails& details) {
145 DCHECK(type == content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME);
146 #if defined(USE_AURA)
147 // TODO(saintlou): Do we need a throbber for Aura?
148 NOTIMPLEMENTED();
149 #else
150 if (bubble_frame_view_)
151 bubble_frame_view_->StopThrobber();
152 #endif
153 }
154
155 } // namespace chromeos 111 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/login_html_dialog.h ('k') | chrome/browser/chromeos/login/proxy_settings_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698