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

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

Issue 6835022: Broke ARM compile. (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
« no previous file with comments | « chrome/browser/first_run/try_chrome_dialog_view.h ('k') | chrome/browser/first_run/upgrade.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 18 matching lines...) Expand all
29 const wchar_t kHelpCenterUrl[] = 29 const wchar_t kHelpCenterUrl[] =
30 L"https://www.google.com/support/chrome/bin/answer.py?answer=150752"; 30 L"https://www.google.com/support/chrome/bin/answer.py?answer=150752";
31 31
32 } // namespace 32 } // namespace
33 33
34 TryChromeDialogView::TryChromeDialogView(size_t version) 34 TryChromeDialogView::TryChromeDialogView(size_t version)
35 : version_(version), 35 : version_(version),
36 popup_(NULL), 36 popup_(NULL),
37 try_chrome_(NULL), 37 try_chrome_(NULL),
38 kill_chrome_(NULL), 38 kill_chrome_(NULL),
39 result_(upgrade_util::COUNT) { 39 result_(Upgrade::COUNT) {
40 } 40 }
41 41
42 TryChromeDialogView::~TryChromeDialogView() { 42 TryChromeDialogView::~TryChromeDialogView() {
43 } 43 }
44 44
45 upgrade_util::TryResult TryChromeDialogView::ShowModal( 45 Upgrade::TryResult TryChromeDialogView::ShowModal(
46 ProcessSingleton* process_singleton) { 46 ProcessSingleton* process_singleton) {
47 using views::GridLayout; 47 using views::GridLayout;
48 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 48 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
49 49
50 views::ImageView* icon = new views::ImageView(); 50 views::ImageView* icon = new views::ImageView();
51 icon->SetImage(*rb.GetBitmapNamed(IDR_PRODUCT_ICON_32)); 51 icon->SetImage(*rb.GetBitmapNamed(IDR_PRODUCT_ICON_32));
52 gfx::Size icon_size = icon->GetPreferredSize(); 52 gfx::Size icon_size = icon->GetPreferredSize();
53 53
54 // An approximate window size. After Layout() we'll get better bounds. 54 // An approximate window size. After Layout() we'll get better bounds.
55 views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP); 55 views::Widget::CreateParams params(views::Widget::CreateParams::TYPE_POPUP);
56 params.can_activate = true; 56 params.can_activate = true;
57 popup_ = views::Widget::CreateWidget(params); 57 popup_ = views::Widget::CreateWidget(params);
58 if (!popup_) { 58 if (!popup_) {
59 NOTREACHED(); 59 NOTREACHED();
60 return upgrade_util::DIALOG_ERROR; 60 return Upgrade::DIALOG_ERROR;
61 } 61 }
62 62
63 gfx::Rect pos(310, 160); 63 gfx::Rect pos(310, 160);
64 popup_->Init(NULL, pos); 64 popup_->Init(NULL, pos);
65 65
66 views::RootView* root_view = popup_->GetRootView(); 66 views::RootView* root_view = popup_->GetRootView();
67 // The window color is a tiny bit off-white. 67 // The window color is a tiny bit off-white.
68 root_view->set_background( 68 root_view->set_background(
69 views::Background::CreateSolidBackground(0xfc, 0xfc, 0xfc)); 69 views::Background::CreateSolidBackground(0xfc, 0xfc, 0xfc));
70 70
71 views::GridLayout* layout = views::GridLayout::CreatePanel(root_view); 71 views::GridLayout* layout = views::GridLayout::CreatePanel(root_view);
72 if (!layout) { 72 if (!layout) {
73 NOTREACHED(); 73 NOTREACHED();
74 return upgrade_util::DIALOG_ERROR; 74 return Upgrade::DIALOG_ERROR;
75 } 75 }
76 root_view->SetLayoutManager(layout); 76 root_view->SetLayoutManager(layout);
77 77
78 views::ColumnSet* columns; 78 views::ColumnSet* columns;
79 // First row: [icon][pad][text][button]. 79 // First row: [icon][pad][text][button].
80 columns = layout->AddColumnSet(0); 80 columns = layout->AddColumnSet(0);
81 columns->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0, 81 columns->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
82 GridLayout::FIXED, icon_size.width(), 82 GridLayout::FIXED, icon_size.width(),
83 icon_size.height()); 83 icon_size.height());
84 columns->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); 84 columns->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing);
(...skipping 29 matching lines...) Expand all
114 columns->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 114 columns->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
115 GridLayout::USE_PREF, 0, 0); 115 GridLayout::USE_PREF, 0, 0);
116 // First row views. 116 // First row views.
117 layout->StartRow(0, 0); 117 layout->StartRow(0, 0);
118 layout->AddView(icon); 118 layout->AddView(icon);
119 119
120 // Find out what experiment we are conducting. 120 // Find out what experiment we are conducting.
121 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 121 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
122 if (!dist) { 122 if (!dist) {
123 NOTREACHED() << "Cannot determine browser distribution"; 123 NOTREACHED() << "Cannot determine browser distribution";
124 return upgrade_util::DIALOG_ERROR; 124 return Upgrade::DIALOG_ERROR;
125 } 125 }
126 BrowserDistribution::UserExperiment experiment; 126 BrowserDistribution::UserExperiment experiment;
127 if (!dist->GetExperimentDetails(&experiment, version_) || 127 if (!dist->GetExperimentDetails(&experiment, version_) ||
128 !experiment.heading) { 128 !experiment.heading) {
129 NOTREACHED() << "Cannot determine which headline to show."; 129 NOTREACHED() << "Cannot determine which headline to show.";
130 return upgrade_util::DIALOG_ERROR; 130 return Upgrade::DIALOG_ERROR;
131 } 131 }
132 string16 heading = l10n_util::GetStringUTF16(experiment.heading); 132 string16 heading = l10n_util::GetStringUTF16(experiment.heading);
133 views::Label* label = new views::Label(heading); 133 views::Label* label = new views::Label(heading);
134 label->SetFont(rb.GetFont(ResourceBundle::MediumBoldFont)); 134 label->SetFont(rb.GetFont(ResourceBundle::MediumBoldFont));
135 label->SetMultiLine(true); 135 label->SetMultiLine(true);
136 label->SizeToFit(200); 136 label->SizeToFit(200);
137 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 137 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
138 layout->AddView(label); 138 layout->AddView(label);
139 // The close button is custom. 139 // The close button is custom.
140 views::ImageButton* close_button = new views::ImageButton(this); 140 views::ImageButton* close_button = new views::ImageButton(this);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 popup_->Show(); 195 popup_->Show();
196 MessageLoop::current()->Run(); 196 MessageLoop::current()->Run();
197 process_singleton->Unlock(); 197 process_singleton->Unlock();
198 return result_; 198 return result_;
199 } 199 }
200 200
201 void TryChromeDialogView::ButtonPressed(views::Button* sender, 201 void TryChromeDialogView::ButtonPressed(views::Button* sender,
202 const views::Event& event) { 202 const views::Event& event) {
203 if (sender->tag() == BT_CLOSE_BUTTON) { 203 if (sender->tag() == BT_CLOSE_BUTTON) {
204 // The user pressed cancel or the [x] button. 204 // The user pressed cancel or the [x] button.
205 result_ = upgrade_util::NOT_NOW; 205 result_ = Upgrade::NOT_NOW;
206 } else if (!try_chrome_) { 206 } else if (!try_chrome_) {
207 // We don't have radio buttons, the user pressed ok. 207 // We don't have radio buttons, the user pressed ok.
208 result_ = upgrade_util::TRY_CHROME; 208 result_ = Upgrade::TRY_CHROME;
209 } else { 209 } else {
210 // The outcome is according to the selected ratio button. 210 // The outcome is according to the selected ratio button.
211 result_ = try_chrome_->checked() ? upgrade_util::TRY_CHROME : 211 result_ = try_chrome_->checked() ? Upgrade::TRY_CHROME :
212 upgrade_util::UNINSTALL_CHROME; 212 Upgrade::UNINSTALL_CHROME;
213 } 213 }
214 popup_->Close(); 214 popup_->Close();
215 MessageLoop::current()->Quit(); 215 MessageLoop::current()->Quit();
216 } 216 }
217 217
218 void TryChromeDialogView::LinkActivated(views::Link* source, int event_flags) { 218 void TryChromeDialogView::LinkActivated(views::Link* source, int event_flags) {
219 ::ShellExecuteW(NULL, L"open", kHelpCenterUrl, NULL, NULL, SW_SHOW); 219 ::ShellExecuteW(NULL, L"open", kHelpCenterUrl, NULL, NULL, SW_SHOW);
220 } 220 }
221 221
222 gfx::Rect TryChromeDialogView::ComputeWindowPosition(int width, 222 gfx::Rect TryChromeDialogView::ComputeWindowPosition(int width,
(...skipping 17 matching lines...) Expand all
240 240
241 void TryChromeDialogView::SetToastRegion(HWND window, int w, int h) { 241 void TryChromeDialogView::SetToastRegion(HWND window, int w, int h) {
242 static const POINT polygon[] = { 242 static const POINT polygon[] = {
243 {0, 4}, {1, 2}, {2, 1}, {4, 0}, // Left side. 243 {0, 4}, {1, 2}, {2, 1}, {4, 0}, // Left side.
244 {w-4, 0}, {w-2, 1}, {w-1, 2}, {w, 4}, // Right side. 244 {w-4, 0}, {w-2, 1}, {w-1, 2}, {w, 4}, // Right side.
245 {w, h}, {0, h} 245 {w, h}, {0, h}
246 }; 246 };
247 HRGN region = ::CreatePolygonRgn(polygon, arraysize(polygon), WINDING); 247 HRGN region = ::CreatePolygonRgn(polygon, arraysize(polygon), WINDING);
248 ::SetWindowRgn(window, region, FALSE); 248 ::SetWindowRgn(window, region, FALSE);
249 } 249 }
OLDNEW
« no previous file with comments | « chrome/browser/first_run/try_chrome_dialog_view.h ('k') | chrome/browser/first_run/upgrade.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698