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

Side by Side Diff: chrome/browser/first_run/try_chrome_dialog_view.cc

Issue 6881107: Rework the way Widget::Init works: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 months 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/first_run/try_chrome_dialog_view.h" 5 #include "chrome/browser/first_run/try_chrome_dialog_view.h"
6 6
7 #include <shellapi.h> 7 #include <shellapi.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 TryChromeDialogView::Result TryChromeDialogView::ShowModal( 59 TryChromeDialogView::Result TryChromeDialogView::ShowModal(
60 ProcessSingleton* process_singleton) { 60 ProcessSingleton* process_singleton) {
61 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 61 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
62 62
63 views::ImageView* icon = new views::ImageView(); 63 views::ImageView* icon = new views::ImageView();
64 icon->SetImage(*rb.GetBitmapNamed(IDR_PRODUCT_ICON_32)); 64 icon->SetImage(*rb.GetBitmapNamed(IDR_PRODUCT_ICON_32));
65 gfx::Size icon_size = icon->GetPreferredSize(); 65 gfx::Size icon_size = icon->GetPreferredSize();
66 66
67 // An approximate window size. After Layout() we'll get better bounds. 67 // An approximate window size. After Layout() we'll get better bounds.
68 views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); 68 popup_ = views::Widget::CreateWidget();
69 params.can_activate = true;
70 popup_ = views::Widget::CreateWidget(params);
71 if (!popup_) { 69 if (!popup_) {
72 NOTREACHED(); 70 NOTREACHED();
73 return DIALOG_ERROR; 71 return DIALOG_ERROR;
74 } 72 }
75 73
76 gfx::Rect pos(310, 160); 74 views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP);
77 popup_->Init(NULL, pos); 75 params.can_activate = true;
76 params.bounds = gfx::Rect(310, 160);
77 popup_->Init(params);
78 78
79 views::RootView* root_view = popup_->GetRootView(); 79 views::RootView* root_view = popup_->GetRootView();
80 // The window color is a tiny bit off-white. 80 // The window color is a tiny bit off-white.
81 root_view->set_background( 81 root_view->set_background(
82 views::Background::CreateSolidBackground(0xfc, 0xfc, 0xfc)); 82 views::Background::CreateSolidBackground(0xfc, 0xfc, 0xfc));
83 83
84 views::GridLayout* layout = views::GridLayout::CreatePanel(root_view); 84 views::GridLayout* layout = views::GridLayout::CreatePanel(root_view);
85 if (!layout) { 85 if (!layout) {
86 NOTREACHED(); 86 NOTREACHED();
87 return DIALOG_ERROR; 87 return DIALOG_ERROR;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 // Fifth row views. 187 // Fifth row views.
188 layout->StartRowWithPadding(0, 4, 0, 10); 188 layout->StartRowWithPadding(0, 4, 0, 10);
189 views::Link* link = new views::Link(why_this); 189 views::Link* link = new views::Link(why_this);
190 link->set_listener(this); 190 link->set_listener(this);
191 layout->AddView(link); 191 layout->AddView(link);
192 192
193 // We resize the window according to the layout manager. This takes into 193 // We resize the window according to the layout manager. This takes into
194 // account the differences between XP and Vista fonts and buttons. 194 // account the differences between XP and Vista fonts and buttons.
195 layout->Layout(root_view); 195 layout->Layout(root_view);
196 gfx::Size preferred = layout->GetPreferredSize(root_view); 196 gfx::Size preferred = layout->GetPreferredSize(root_view);
197 pos = ComputeWindowPosition(preferred.width(), preferred.height(), 197 gfx::Rect pos = ComputeWindowPosition(preferred.width(), preferred.height(),
198 base::i18n::IsRTL()); 198 base::i18n::IsRTL());
199 popup_->SetBounds(pos); 199 popup_->SetBounds(pos);
200 200
201 // Carve the toast shape into the window. 201 // Carve the toast shape into the window.
202 SetToastRegion(popup_->GetNativeView(), 202 SetToastRegion(popup_->GetNativeView(),
203 preferred.width(), preferred.height()); 203 preferred.width(), preferred.height());
204 204
205 // Time to show the window in a modal loop. We don't want this chrome 205 // Time to show the window in a modal loop. We don't want this chrome
206 // instance trying to serve WM_COPYDATA requests, as we'll surely crash. 206 // instance trying to serve WM_COPYDATA requests, as we'll surely crash.
207 process_singleton->Lock(popup_->GetNativeView()); 207 process_singleton->Lock(popup_->GetNativeView());
208 popup_->Show(); 208 popup_->Show();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // The outcome is according to the selected ratio button. 252 // The outcome is according to the selected ratio button.
253 result_ = try_chrome_->checked() ? TRY_CHROME : UNINSTALL_CHROME; 253 result_ = try_chrome_->checked() ? TRY_CHROME : UNINSTALL_CHROME;
254 } 254 }
255 popup_->Close(); 255 popup_->Close();
256 MessageLoop::current()->Quit(); 256 MessageLoop::current()->Quit();
257 } 257 }
258 258
259 void TryChromeDialogView::LinkClicked(views::Link* source, int event_flags) { 259 void TryChromeDialogView::LinkClicked(views::Link* source, int event_flags) {
260 ::ShellExecuteW(NULL, L"open", kHelpCenterUrl, NULL, NULL, SW_SHOW); 260 ::ShellExecuteW(NULL, L"open", kHelpCenterUrl, NULL, NULL, SW_SHOW);
261 } 261 }
OLDNEW
« no previous file with comments | « chrome/browser/external_tab_container_win.cc ('k') | chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698