OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/first_run_view.h" | 5 #include "chrome/browser/views/first_run_view.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/win_util.h" | 9 #include "base/win_util.h" |
10 #include "chrome/browser/importer/importer.h" | 10 #include "chrome/browser/importer/importer.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 // Adds a bullet glyph to a string. | 33 // Adds a bullet glyph to a string. |
34 std::wstring AddBullet(const std::wstring& text) { | 34 std::wstring AddBullet(const std::wstring& text) { |
35 std::wstring btext(L" " + text); | 35 std::wstring btext(L" " + text); |
36 return btext.insert(0, 1, L'\u2022'); | 36 return btext.insert(0, 1, L'\u2022'); |
37 } | 37 } |
38 | 38 |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 FirstRunView::FirstRunView(Profile* profile, bool homepage_defined, | 41 FirstRunView::FirstRunView(Profile* profile, bool homepage_defined, |
42 int import_items, int dont_import_items, | 42 int import_items, int dont_import_items, |
43 bool search_engine_experiment) | 43 bool search_engine_experiment, |
| 44 bool randomize_search_engine_experiment) |
44 : FirstRunViewBase(profile, homepage_defined, import_items, | 45 : FirstRunViewBase(profile, homepage_defined, import_items, |
45 dont_import_items, search_engine_experiment), | 46 dont_import_items, search_engine_experiment, |
| 47 randomize_search_engine_experiment), |
46 welcome_label_(NULL), | 48 welcome_label_(NULL), |
47 actions_label_(NULL), | 49 actions_label_(NULL), |
48 actions_import_(NULL), | 50 actions_import_(NULL), |
49 actions_shorcuts_(NULL), | 51 actions_shorcuts_(NULL), |
50 customize_link_(NULL), | 52 customize_link_(NULL), |
51 customize_selected_(false), | 53 customize_selected_(false), |
52 accepted_(false) { | 54 accepted_(false) { |
53 importer_host_ = new ImporterHost(); | 55 importer_host_ = new ImporterHost(); |
54 SetupControls(); | 56 SetupControls(); |
55 } | 57 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 views::Window::CreateChromeWindow( | 181 views::Window::CreateChromeWindow( |
180 window()->GetNativeWindow(), | 182 window()->GetNativeWindow(), |
181 gfx::Rect(), | 183 gfx::Rect(), |
182 new FirstRunCustomizeView(profile_, | 184 new FirstRunCustomizeView(profile_, |
183 importer_host_, | 185 importer_host_, |
184 this, | 186 this, |
185 default_browser_ && default_browser_->checked(), | 187 default_browser_ && default_browser_->checked(), |
186 homepage_defined_, | 188 homepage_defined_, |
187 import_items_, | 189 import_items_, |
188 dont_import_items_, | 190 dont_import_items_, |
189 search_engine_experiment_))->Show(); | 191 search_engine_experiment_, |
| 192 randomize_search_engine_experiment_))->Show(); |
190 } | 193 } |
191 | 194 |
192 void FirstRunView::OpenSearchEngineDialog() { | 195 void FirstRunView::OpenSearchEngineDialog(bool randomize) { |
193 views::Window::CreateChromeWindow( | 196 views::Window::CreateChromeWindow( |
194 window()->GetNativeWindow(), | 197 window()->GetNativeWindow(), |
195 gfx::Rect(), | 198 gfx::Rect(), |
196 new FirstRunSearchEngineView(this, | 199 new FirstRunSearchEngineView(this, |
197 profile_))->Show(); | 200 profile_, |
| 201 randomize))->Show(); |
198 } | 202 } |
199 | 203 |
200 void FirstRunView::LinkActivated(views::Link* source, int event_flags) { | 204 void FirstRunView::LinkActivated(views::Link* source, int event_flags) { |
201 OpenCustomizeDialog(); | 205 OpenCustomizeDialog(); |
202 } | 206 } |
203 | 207 |
204 std::wstring FirstRunView::GetWindowTitle() const { | 208 std::wstring FirstRunView::GetWindowTitle() const { |
205 return l10n_util::GetString(IDS_FIRSTRUN_DLG_TITLE); | 209 return l10n_util::GetString(IDS_FIRSTRUN_DLG_TITLE); |
206 } | 210 } |
207 | 211 |
(...skipping 14 matching lines...) Expand all Loading... |
222 // Index 0 is the default browser. | 226 // Index 0 is the default browser. |
223 FirstRun::ImportSettings(profile_, | 227 FirstRun::ImportSettings(profile_, |
224 importer_host_->GetSourceProfileInfoAt(0).browser_type, | 228 importer_host_->GetSourceProfileInfoAt(0).browser_type, |
225 GetImportItems(), window()->GetNativeWindow()); | 229 GetImportItems(), window()->GetNativeWindow()); |
226 UserMetrics::RecordAction(UserMetricsAction("FirstRunDef_Accept"), profile_); | 230 UserMetrics::RecordAction(UserMetricsAction("FirstRunDef_Accept"), profile_); |
227 if (default_browser_ && default_browser_->checked()) | 231 if (default_browser_ && default_browser_->checked()) |
228 SetDefaultBrowser(); | 232 SetDefaultBrowser(); |
229 | 233 |
230 // Launch the search engine dialog. | 234 // Launch the search engine dialog. |
231 if (search_engine_experiment_) { | 235 if (search_engine_experiment_) { |
232 OpenSearchEngineDialog(); | 236 OpenSearchEngineDialog(randomize_search_engine_experiment_); |
233 // Leave without shutting down; we'll observe the search engine dialog and | 237 // Leave without shutting down; we'll observe the search engine dialog and |
234 // shut down after it closes. | 238 // shut down after it closes. |
235 return false; | 239 return false; |
236 } | 240 } |
237 | 241 |
238 accepted_ = true; | 242 accepted_ = true; |
239 FirstRunComplete(); | 243 FirstRunComplete(); |
240 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 244 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
241 return true; | 245 return true; |
242 } | 246 } |
243 | 247 |
244 bool FirstRunView::Cancel() { | 248 bool FirstRunView::Cancel() { |
245 UserMetrics::RecordAction(UserMetricsAction("FirstRunDef_Cancel"), profile_); | 249 UserMetrics::RecordAction(UserMetricsAction("FirstRunDef_Cancel"), profile_); |
246 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 250 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
247 return true; | 251 return true; |
248 } | 252 } |
249 | 253 |
250 // Notification from the customize dialog that the user accepted. Since all | 254 // Notification from the customize dialog that the user accepted. Since all |
251 // the work is done there we have nothing else to do. | 255 // the work is done there we have nothing else to do. |
252 void FirstRunView::CustomizeAccepted() { | 256 void FirstRunView::CustomizeAccepted() { |
253 if (search_engine_experiment_) { | 257 if (search_engine_experiment_) { |
254 OpenSearchEngineDialog(); | 258 OpenSearchEngineDialog(randomize_search_engine_experiment_); |
255 // We'll shut down after search engine has been chosen. | 259 // We'll shut down after search engine has been chosen. |
256 return; | 260 return; |
257 } | 261 } |
258 accepted_ = true; | 262 accepted_ = true; |
259 FirstRunComplete(); | 263 FirstRunComplete(); |
260 window()->Close(); | 264 window()->Close(); |
261 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 265 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
262 } | 266 } |
263 | 267 |
264 // Notification from the customize dialog that the user cancelled. | 268 // Notification from the customize dialog that the user cancelled. |
265 void FirstRunView::CustomizeCanceled() { | 269 void FirstRunView::CustomizeCanceled() { |
266 UserMetrics::RecordAction(UserMetricsAction("FirstRunCustom_Cancel"), | 270 UserMetrics::RecordAction(UserMetricsAction("FirstRunCustom_Cancel"), |
267 profile_); | 271 profile_); |
268 } | 272 } |
269 | 273 |
270 void FirstRunView::SearchEngineChosen(const TemplateURL* default_search) { | 274 void FirstRunView::SearchEngineChosen(const TemplateURL* default_search) { |
271 // default_search may be NULL if the user closed the search view without | 275 // default_search may be NULL if the user closed the search view without |
272 // making a choice, or if a choice was made through the KeywordEditor. | 276 // making a choice, or if a choice was made through the KeywordEditor. |
273 if (default_search) | 277 if (default_search) |
274 profile_->GetTemplateURLModel()->SetDefaultSearchProvider(default_search); | 278 profile_->GetTemplateURLModel()->SetDefaultSearchProvider(default_search); |
275 accepted_ = true; | 279 accepted_ = true; |
276 FirstRunComplete(); | 280 FirstRunComplete(); |
277 window()->Close(); | 281 window()->Close(); |
278 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 282 MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
279 } | 283 } |
280 | 284 |
OLD | NEW |