OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/first_run.h" | 5 #include "chrome/browser/first_run/first_run.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 #include "chrome/browser/extensions/updater/extension_updater.h" | 21 #include "chrome/browser/extensions/updater/extension_updater.h" |
22 #include "chrome/browser/first_run/first_run_dialog.h" | 22 #include "chrome/browser/first_run/first_run_dialog.h" |
23 #include "chrome/browser/first_run/first_run_import_observer.h" | 23 #include "chrome/browser/first_run/first_run_import_observer.h" |
24 #include "chrome/browser/first_run/first_run_internal.h" | 24 #include "chrome/browser/first_run/first_run_internal.h" |
25 #include "chrome/browser/google/google_util.h" | 25 #include "chrome/browser/google/google_util.h" |
26 #include "chrome/browser/importer/external_process_importer_host.h" | 26 #include "chrome/browser/importer/external_process_importer_host.h" |
27 #include "chrome/browser/importer/importer_host.h" | 27 #include "chrome/browser/importer/importer_host.h" |
28 #include "chrome/browser/importer/importer_list.h" | 28 #include "chrome/browser/importer/importer_list.h" |
29 #include "chrome/browser/importer/importer_progress_dialog.h" | 29 #include "chrome/browser/importer/importer_progress_dialog.h" |
30 #include "chrome/browser/importer/importer_progress_observer.h" | 30 #include "chrome/browser/importer/importer_progress_observer.h" |
31 #include "chrome/browser/importer/profile_writer.h" | |
31 #include "chrome/browser/process_singleton.h" | 32 #include "chrome/browser/process_singleton.h" |
32 #include "chrome/browser/profiles/profile_manager.h" | 33 #include "chrome/browser/profiles/profile_manager.h" |
33 #include "chrome/browser/search_engines/template_url_service.h" | 34 #include "chrome/browser/search_engines/template_url_service.h" |
34 #include "chrome/browser/search_engines/template_url_service_factory.h" | 35 #include "chrome/browser/search_engines/template_url_service_factory.h" |
35 #include "chrome/browser/shell_integration.h" | 36 #include "chrome/browser/shell_integration.h" |
36 #include "chrome/browser/ui/browser.h" | 37 #include "chrome/browser/ui/browser.h" |
37 #include "chrome/browser/ui/browser_finder.h" | 38 #include "chrome/browser/ui/browser_finder.h" |
38 #include "chrome/browser/ui/global_error/global_error_service.h" | 39 #include "chrome/browser/ui/global_error/global_error_service.h" |
39 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 40 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
40 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 41 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 14 matching lines...) Expand all Loading... | |
55 #include "content/public/browser/user_metrics.h" | 56 #include "content/public/browser/user_metrics.h" |
56 #include "content/public/browser/web_contents.h" | 57 #include "content/public/browser/web_contents.h" |
57 #include "google_apis/gaia/gaia_auth_util.h" | 58 #include "google_apis/gaia/gaia_auth_util.h" |
58 #include "googleurl/src/gurl.h" | 59 #include "googleurl/src/gurl.h" |
59 | 60 |
60 using content::UserMetricsAction; | 61 using content::UserMetricsAction; |
61 | 62 |
62 namespace { | 63 namespace { |
63 | 64 |
64 // Flags for functions of similar name. | 65 // Flags for functions of similar name. |
65 bool should_show_welcome_page_ = false; | 66 bool g_should_show_welcome_page = false; |
66 bool should_do_autofill_personal_data_manager_first_run_ = false; | 67 bool g_should_do_autofill_personal_data_manager_first_run = false; |
67 | 68 |
68 // Flags indicating whether a first-run profile auto import was performed, and | 69 // This class acts as an observer for the ImporterProgressObserver::ImportEnded |
69 // whether the importer process exited successfully. | 70 // callback. When the import process is started, certain errors may cause |
70 bool did_perform_profile_import = false; | 71 // ImportEnded() to be called synchronously, but the typical case is that |
71 bool profile_import_exited_successfully = false; | 72 // ImportEnded() is called asynchronously. Thus we have to handle both cases. |
73 class ImportEndedObserver : public importer::ImporterProgressObserver { | |
74 public: | |
75 ImportEndedObserver() : ended_(false), | |
76 should_quit_message_loop_(false) {} | |
77 virtual ~ImportEndedObserver() {} | |
78 | |
79 // importer::ImporterProgressObserver: | |
80 virtual void ImportStarted() OVERRIDE {} | |
81 virtual void ImportItemStarted(importer::ImportItem item) OVERRIDE {} | |
82 virtual void ImportItemEnded(importer::ImportItem item) OVERRIDE {} | |
83 virtual void ImportEnded() OVERRIDE { | |
84 ended_ = true; | |
85 if (should_quit_message_loop_) | |
86 MessageLoop::current()->Quit(); | |
Joao da Silva
2013/03/12 13:32:05
#include "base/message_loop.h"
gab
2013/03/25 16:00:43
Done.
| |
87 } | |
88 | |
89 void set_should_quit_message_loop() { | |
90 should_quit_message_loop_ = true; | |
91 } | |
92 | |
93 bool ended() { | |
Joao da Silva
2013/03/12 13:32:05
nit: const method
gab
2013/03/25 16:00:43
Note that this is a pure move from first_run_posix
| |
94 return ended_; | |
95 } | |
96 | |
97 private: | |
98 // Set if the import has ended. | |
99 bool ended_; | |
100 | |
101 // Set by the client (via set_should_quit_message_loop) if, when the import | |
102 // ends, this class should quit the message loop. | |
103 bool should_quit_message_loop_; | |
104 }; | |
72 | 105 |
73 // Helper class that performs delayed first-run tasks that need more of the | 106 // Helper class that performs delayed first-run tasks that need more of the |
74 // chrome infrastructure to be up and running before they can be attempted. | 107 // chrome infrastructure to be up and running before they can be attempted. |
75 class FirstRunDelayedTasks : public content::NotificationObserver { | 108 class FirstRunDelayedTasks : public content::NotificationObserver { |
76 public: | 109 public: |
77 enum Tasks { | 110 enum Tasks { |
78 NO_TASK, | 111 NO_TASK, |
79 INSTALL_EXTENSIONS | 112 INSTALL_EXTENSIONS |
80 }; | 113 }; |
81 | 114 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 return ProfileManager::GetProfilePrefsPath(default_pref_dir); | 175 return ProfileManager::GetProfilePrefsPath(default_pref_dir); |
143 } | 176 } |
144 | 177 |
145 // Sets the |items| bitfield according to whether the import data specified by | 178 // Sets the |items| bitfield according to whether the import data specified by |
146 // |import_type| should be be auto imported or not. | 179 // |import_type| should be be auto imported or not. |
147 void SetImportItem(PrefService* user_prefs, | 180 void SetImportItem(PrefService* user_prefs, |
148 const char* pref_path, | 181 const char* pref_path, |
149 int import_items, | 182 int import_items, |
150 int dont_import_items, | 183 int dont_import_items, |
151 importer::ImportItem import_type, | 184 importer::ImportItem import_type, |
152 int& items) { | 185 int* items) { |
153 // Work out whether an item is to be imported according to what is specified | 186 // Work out whether an item is to be imported according to what is specified |
154 // in master preferences. | 187 // in master preferences. |
155 bool should_import = false; | 188 bool should_import = false; |
156 bool master_pref_set = | 189 bool master_pref_set = |
157 ((import_items | dont_import_items) & import_type) != 0; | 190 ((import_items | dont_import_items) & import_type) != 0; |
158 bool master_pref = ((import_items & ~dont_import_items) & import_type) != 0; | 191 bool master_pref = ((import_items & ~dont_import_items) & import_type) != 0; |
159 | 192 |
160 if (import_type == importer::HISTORY || | 193 if (import_type == importer::HISTORY || |
161 ((import_type != importer::FAVORITES) && | 194 ((import_type != importer::FAVORITES) && |
162 first_run::internal::IsOrganicFirstRun())) { | 195 first_run::internal::IsOrganicFirstRun())) { |
(...skipping 13 matching lines...) Expand all Loading... | |
176 // preference is set, but a corresponding recommended policy is set, import | 209 // preference is set, but a corresponding recommended policy is set, import |
177 // item according to recommended policy. If both a master preference and a | 210 // item according to recommended policy. If both a master preference and a |
178 // recommended policy is set, the master preference wins. If neither | 211 // recommended policy is set, the master preference wins. If neither |
179 // recommended nor managed policies are set, import item according to what we | 212 // recommended nor managed policies are set, import item according to what we |
180 // worked out above. | 213 // worked out above. |
181 if (master_pref_set) | 214 if (master_pref_set) |
182 user_prefs->SetBoolean(pref_path, should_import); | 215 user_prefs->SetBoolean(pref_path, should_import); |
183 | 216 |
184 if (!user_prefs->FindPreference(pref_path)->IsDefaultValue()) { | 217 if (!user_prefs->FindPreference(pref_path)->IsDefaultValue()) { |
185 if (user_prefs->GetBoolean(pref_path)) | 218 if (user_prefs->GetBoolean(pref_path)) |
186 items |= import_type; | 219 *items |= import_type; |
187 } else { // no policy (recommended or managed) is set | 220 } else { // no policy (recommended or managed) is set |
188 if (should_import) | 221 if (should_import) |
189 items |= import_type; | 222 *items |= import_type; |
190 } | 223 } |
191 | 224 |
192 user_prefs->ClearPref(pref_path); | 225 user_prefs->ClearPref(pref_path); |
193 } | 226 } |
194 | 227 |
195 // Imports bookmarks from an html file. The path to the file is provided in | 228 // Imports bookmarks from an html file. The path to the file is provided in |
196 // the command line. | 229 // the command line. |
197 int ImportFromFile(Profile* profile, const CommandLine& cmdline) { | 230 int ImportFromFile(Profile* profile, const CommandLine& cmdline) { |
198 base::FilePath file_path = | 231 base::FilePath file_path = |
199 cmdline.GetSwitchValuePath(switches::kImportFromFile); | 232 cmdline.GetSwitchValuePath(switches::kImportFromFile); |
(...skipping 29 matching lines...) Expand all Loading... | |
229 std::vector<GURL>* ret) { | 262 std::vector<GURL>* ret) { |
230 ret->resize(src.size()); | 263 ret->resize(src.size()); |
231 std::transform(src.begin(), src.end(), ret->begin(), &UrlFromString); | 264 std::transform(src.begin(), src.end(), ret->begin(), &UrlFromString); |
232 } | 265 } |
233 | 266 |
234 } // namespace | 267 } // namespace |
235 | 268 |
236 namespace first_run { | 269 namespace first_run { |
237 namespace internal { | 270 namespace internal { |
238 | 271 |
272 bool g_did_perform_profile_import = false; | |
273 bool g_profile_import_exited_successfully = false; | |
274 | |
239 FirstRunState first_run_ = FIRST_RUN_UNKNOWN; | 275 FirstRunState first_run_ = FIRST_RUN_UNKNOWN; |
240 | 276 |
241 static base::LazyInstance<base::FilePath> master_prefs_path_for_testing | 277 static base::LazyInstance<base::FilePath> master_prefs_path_for_testing |
242 = LAZY_INSTANCE_INITIALIZER; | 278 = LAZY_INSTANCE_INITIALIZER; |
243 | 279 |
244 installer::MasterPreferences* | 280 installer::MasterPreferences* |
245 LoadMasterPrefs(base::FilePath* master_prefs_path) { | 281 LoadMasterPrefs(base::FilePath* master_prefs_path) { |
246 if (!master_prefs_path_for_testing.Get().empty()) | 282 if (!master_prefs_path_for_testing.Get().empty()) |
247 *master_prefs_path = master_prefs_path_for_testing.Get(); | 283 *master_prefs_path = master_prefs_path_for_testing.Get(); |
248 else | 284 else |
(...skipping 17 matching lines...) Expand all Loading... | |
266 return false; | 302 return false; |
267 | 303 |
268 // The master prefs are regular prefs so we can just copy the file | 304 // The master prefs are regular prefs so we can just copy the file |
269 // to the default place and they just work. | 305 // to the default place and they just work. |
270 return file_util::CopyFile(master_prefs_path, user_prefs); | 306 return file_util::CopyFile(master_prefs_path, user_prefs); |
271 } | 307 } |
272 | 308 |
273 void SetupMasterPrefsFromInstallPrefs( | 309 void SetupMasterPrefsFromInstallPrefs( |
274 const installer::MasterPreferences& install_prefs, | 310 const installer::MasterPreferences& install_prefs, |
275 MasterPrefs* out_prefs) { | 311 MasterPrefs* out_prefs) { |
312 ConvertStringVectorToGURLVector( | |
313 install_prefs.GetFirstRunTabs(), &out_prefs->new_tabs); | |
314 | |
315 install_prefs.GetInt(installer::master_preferences::kDistroPingDelay, | |
316 &out_prefs->ping_delay); | |
317 | |
276 bool value = false; | 318 bool value = false; |
277 if (install_prefs.GetBool( | 319 if (install_prefs.GetBool( |
278 installer::master_preferences::kDistroImportSearchPref, &value)) { | 320 installer::master_preferences::kDistroImportSearchPref, &value)) { |
279 if (value) { | 321 if (value) { |
280 out_prefs->do_import_items |= importer::SEARCH_ENGINES; | 322 out_prefs->do_import_items |= importer::SEARCH_ENGINES; |
281 } else { | 323 } else { |
282 out_prefs->dont_import_items |= importer::SEARCH_ENGINES; | 324 out_prefs->dont_import_items |= importer::SEARCH_ENGINES; |
283 } | 325 } |
284 } | 326 } |
285 | 327 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 &value) && value) { | 373 &value) && value) { |
332 out_prefs->make_chrome_default = true; | 374 out_prefs->make_chrome_default = true; |
333 } | 375 } |
334 | 376 |
335 if (install_prefs.GetBool( | 377 if (install_prefs.GetBool( |
336 installer::master_preferences::kSuppressFirstRunDefaultBrowserPrompt, | 378 installer::master_preferences::kSuppressFirstRunDefaultBrowserPrompt, |
337 &value) && value) { | 379 &value) && value) { |
338 out_prefs->suppress_first_run_default_browser_prompt = true; | 380 out_prefs->suppress_first_run_default_browser_prompt = true; |
339 } | 381 } |
340 | 382 |
383 install_prefs.GetString( | |
384 installer::master_preferences::kDistroImportBookmarksFromFilePref, | |
385 &out_prefs->import_bookmarks_path); | |
386 | |
341 out_prefs->variations_seed = install_prefs.GetVariationsSeed(); | 387 out_prefs->variations_seed = install_prefs.GetVariationsSeed(); |
342 } | 388 } |
343 | 389 |
344 void SetDefaultBrowser(installer::MasterPreferences* install_prefs){ | 390 void SetDefaultBrowser(installer::MasterPreferences* install_prefs){ |
345 // Even on the first run we only allow for the user choice to take effect if | 391 // Even on the first run we only allow for the user choice to take effect if |
346 // no policy has been set by the admin. | 392 // no policy has been set by the admin. |
347 if (!g_browser_process->local_state()->IsManagedPreference( | 393 if (!g_browser_process->local_state()->IsManagedPreference( |
348 prefs::kDefaultBrowserSettingEnabled)) { | 394 prefs::kDefaultBrowserSettingEnabled)) { |
349 bool value = false; | 395 bool value = false; |
350 if (install_prefs->GetBool( | 396 if (install_prefs->GetBool( |
351 installer::master_preferences::kMakeChromeDefaultForUser, | 397 installer::master_preferences::kMakeChromeDefaultForUser, |
352 &value) && value) { | 398 &value) && value) { |
353 ShellIntegration::SetAsDefaultBrowser(); | 399 ShellIntegration::SetAsDefaultBrowser(); |
354 } | 400 } |
355 } else { | 401 } else { |
356 if (g_browser_process->local_state()->GetBoolean( | 402 if (g_browser_process->local_state()->GetBoolean( |
357 prefs::kDefaultBrowserSettingEnabled)) { | 403 prefs::kDefaultBrowserSettingEnabled)) { |
358 ShellIntegration::SetAsDefaultBrowser(); | 404 ShellIntegration::SetAsDefaultBrowser(); |
359 } | 405 } |
360 } | 406 } |
361 } | 407 } |
362 | 408 |
363 void SetRLZPref(first_run::MasterPrefs* out_prefs, | 409 bool ImportSettings(Profile* profile, |
364 installer::MasterPreferences* install_prefs) { | 410 scoped_refptr<ImporterHost> importer_host, |
365 if (!install_prefs->GetInt(installer::master_preferences::kDistroPingDelay, | 411 scoped_refptr<ImporterList> importer_list, |
366 &out_prefs->ping_delay)) { | 412 int items_to_import) { |
367 // Default value in case master preferences is missing or corrupt, | 413 const importer::SourceProfile& source_profile = |
368 // or ping_delay is missing. | 414 importer_list->GetSourceProfileAt(0); |
369 out_prefs->ping_delay = 90; | 415 |
416 // Ensure that importers aren't requested to import items that they do not | |
417 // support. If there is no overlap, skip. | |
418 items_to_import &= source_profile.services_supported; | |
419 if (items_to_import == 0) | |
420 return true; | |
421 | |
422 scoped_ptr<ImportEndedObserver> observer(new ImportEndedObserver); | |
423 importer_host->SetObserver(observer.get()); | |
424 importer_host->StartImportSettings(source_profile, | |
425 profile, | |
426 items_to_import, | |
427 new ProfileWriter(profile), | |
428 true); | |
429 // If the import process has not errored out, block on it. | |
430 if (!observer->ended()) { | |
431 observer->set_should_quit_message_loop(); | |
432 MessageLoop::current()->Run(); | |
370 } | 433 } |
434 | |
435 // Unfortunately there's no success/fail signal in ImporterHost. | |
cpu_(ooo_6.6-7.5)
2013/03/11 20:54:20
don't we watch the process handle and get the exit
gab
2013/03/12 12:32:19
That's a pure copy/paste from first_run_posix.cc;
| |
436 return true; | |
371 } | 437 } |
372 | 438 |
373 // -- Platform-specific functions -- | 439 // -- Platform-specific functions -- |
374 | 440 |
375 #if !defined(OS_LINUX) && !defined(OS_BSD) | 441 #if !defined(OS_LINUX) && !defined(OS_BSD) |
376 bool IsOrganicFirstRun() { | 442 bool IsOrganicFirstRun() { |
377 std::string brand; | 443 std::string brand; |
378 google_util::GetBrand(&brand); | 444 google_util::GetBrand(&brand); |
379 return google_util::IsOrganicFirstRun(brand); | 445 return google_util::IsOrganicFirstRun(brand); |
380 } | 446 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
455 prefs::kShowFirstRunBubbleOption) != FIRST_RUN_BUBBLE_SUPPRESS) { | 521 prefs::kShowFirstRunBubbleOption) != FIRST_RUN_BUBBLE_SUPPRESS) { |
456 // Set the new state as long as the bubble wasn't explicitly suppressed | 522 // Set the new state as long as the bubble wasn't explicitly suppressed |
457 // already. | 523 // already. |
458 local_state->SetInteger(prefs::kShowFirstRunBubbleOption, | 524 local_state->SetInteger(prefs::kShowFirstRunBubbleOption, |
459 show_bubble_option); | 525 show_bubble_option); |
460 } | 526 } |
461 return true; | 527 return true; |
462 } | 528 } |
463 | 529 |
464 void SetShouldShowWelcomePage() { | 530 void SetShouldShowWelcomePage() { |
465 should_show_welcome_page_ = true; | 531 g_should_show_welcome_page = true; |
466 } | 532 } |
467 | 533 |
468 bool ShouldShowWelcomePage() { | 534 bool ShouldShowWelcomePage() { |
469 bool retval = should_show_welcome_page_; | 535 bool retval = g_should_show_welcome_page; |
470 should_show_welcome_page_ = false; | 536 g_should_show_welcome_page = false; |
471 return retval; | 537 return retval; |
472 } | 538 } |
473 | 539 |
474 void SetShouldDoPersonalDataManagerFirstRun() { | 540 void SetShouldDoPersonalDataManagerFirstRun() { |
475 should_do_autofill_personal_data_manager_first_run_ = true; | 541 g_should_do_autofill_personal_data_manager_first_run = true; |
476 } | 542 } |
477 | 543 |
478 bool ShouldDoPersonalDataManagerFirstRun() { | 544 bool ShouldDoPersonalDataManagerFirstRun() { |
479 bool retval = should_do_autofill_personal_data_manager_first_run_; | 545 bool retval = g_should_do_autofill_personal_data_manager_first_run; |
480 should_do_autofill_personal_data_manager_first_run_ = false; | 546 g_should_do_autofill_personal_data_manager_first_run = false; |
481 return retval; | 547 return retval; |
482 } | 548 } |
483 | 549 |
484 void LogFirstRunMetric(FirstRunBubbleMetric metric) { | 550 void LogFirstRunMetric(FirstRunBubbleMetric metric) { |
485 UMA_HISTOGRAM_ENUMERATION("FirstRun.SearchEngineBubble", metric, | 551 UMA_HISTOGRAM_ENUMERATION("FirstRun.SearchEngineBubble", metric, |
486 NUM_FIRST_RUN_BUBBLE_METRICS); | 552 NUM_FIRST_RUN_BUBBLE_METRICS); |
487 } | 553 } |
488 | 554 |
489 namespace { | 555 namespace { |
490 CommandLine* GetExtraArgumentsInstance() { | 556 CommandLine* GetExtraArgumentsInstance() { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
587 #if defined(OS_CHROMEOS) | 653 #if defined(OS_CHROMEOS) |
588 // Chrome OS has its own out-of-box-experience code. Create the sentinel to | 654 // Chrome OS has its own out-of-box-experience code. Create the sentinel to |
589 // mark the fact that we've run once but skip the full first-run flow. | 655 // mark the fact that we've run once but skip the full first-run flow. |
590 CreateSentinel(); | 656 CreateSentinel(); |
591 return SKIP_FIRST_RUN_TASKS; | 657 return SKIP_FIRST_RUN_TASKS; |
592 #endif | 658 #endif |
593 | 659 |
594 base::FilePath master_prefs_path; | 660 base::FilePath master_prefs_path; |
595 scoped_ptr<installer::MasterPreferences> | 661 scoped_ptr<installer::MasterPreferences> |
596 install_prefs(internal::LoadMasterPrefs(&master_prefs_path)); | 662 install_prefs(internal::LoadMasterPrefs(&master_prefs_path)); |
597 if (!install_prefs.get()) | |
598 return DO_FIRST_RUN_TASKS; | |
599 | 663 |
600 ConvertStringVectorToGURLVector( | 664 // Default value in case master preferences is missing or corrupt, |
601 install_prefs->GetFirstRunTabs(), &out_prefs->new_tabs); | 665 // or ping_delay is missing. |
666 out_prefs->ping_delay = 90; | |
667 if (install_prefs.get()) { | |
668 if (!internal::ShowPostInstallEULAIfNeeded(install_prefs.get())) | |
669 return EULA_EXIT_NOW; | |
602 | 670 |
603 internal::SetRLZPref(out_prefs, install_prefs.get()); | 671 if (!internal::CopyPrefFile(user_data_dir, master_prefs_path)) |
cpu_(ooo_6.6-7.5)
2013/03/11 20:56:05
where did the rlz stuff go?
gab
2013/03/12 12:32:19
Down in SetupMasterPrefsFromInstallPrefs() beside
Joao da Silva
2013/03/12 13:32:05
SetRLZPref() used to happen before potentially ret
gab
2013/03/25 16:00:43
Returning EULA_EXIT_NOW means the user refused the
| |
672 DLOG(ERROR) << "Failed to copy master_preferences to user data dir."; | |
604 | 673 |
605 if (!internal::ShowPostInstallEULAIfNeeded(install_prefs.get())) | 674 DoDelayedInstallExtensionsIfNeeded(install_prefs.get()); |
606 return EULA_EXIT_NOW; | |
607 | 675 |
608 if (!internal::CopyPrefFile(user_data_dir, master_prefs_path)) | 676 internal::SetupMasterPrefsFromInstallPrefs(*install_prefs, out_prefs); |
609 DLOG(ERROR) << "Failed to copy master_preferences to user data dir."; | |
610 | 677 |
611 DoDelayedInstallExtensionsIfNeeded(install_prefs.get()); | 678 internal::SetDefaultBrowser(install_prefs.get()); |
679 } | |
612 | 680 |
613 internal::SetupMasterPrefsFromInstallPrefs(*install_prefs, out_prefs); | 681 internal::SetImportPreferencesAndLaunchImport(out_prefs); |
614 | |
615 internal::SetImportPreferencesAndLaunchImport(out_prefs, install_prefs.get()); | |
616 internal::SetDefaultBrowser(install_prefs.get()); | |
617 | 682 |
618 return DO_FIRST_RUN_TASKS; | 683 return DO_FIRST_RUN_TASKS; |
619 } | 684 } |
620 | 685 |
621 void AutoImport( | 686 void AutoImport( |
622 Profile* profile, | 687 Profile* profile, |
623 bool homepage_defined, | 688 bool homepage_defined, |
624 int import_items, | 689 int import_items, |
625 int dont_import_items, | 690 int dont_import_items, |
626 ProcessSingleton* process_singleton) { | 691 ProcessSingleton* process_singleton) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
673 } | 738 } |
674 } | 739 } |
675 | 740 |
676 PrefService* user_prefs = profile->GetPrefs(); | 741 PrefService* user_prefs = profile->GetPrefs(); |
677 | 742 |
678 SetImportItem(user_prefs, | 743 SetImportItem(user_prefs, |
679 prefs::kImportHistory, | 744 prefs::kImportHistory, |
680 import_items, | 745 import_items, |
681 dont_import_items, | 746 dont_import_items, |
682 importer::HISTORY, | 747 importer::HISTORY, |
683 items); | 748 &items); |
684 SetImportItem(user_prefs, | 749 SetImportItem(user_prefs, |
685 prefs::kImportHomepage, | 750 prefs::kImportHomepage, |
686 import_items, | 751 import_items, |
687 dont_import_items, | 752 dont_import_items, |
688 importer::HOME_PAGE, | 753 importer::HOME_PAGE, |
689 items); | 754 &items); |
690 SetImportItem(user_prefs, | 755 SetImportItem(user_prefs, |
691 prefs::kImportSearchEngine, | 756 prefs::kImportSearchEngine, |
692 import_items, | 757 import_items, |
693 dont_import_items, | 758 dont_import_items, |
694 importer::SEARCH_ENGINES, | 759 importer::SEARCH_ENGINES, |
695 items); | 760 &items); |
696 SetImportItem(user_prefs, | 761 SetImportItem(user_prefs, |
697 prefs::kImportBookmarks, | 762 prefs::kImportBookmarks, |
698 import_items, | 763 import_items, |
699 dont_import_items, | 764 dont_import_items, |
700 importer::FAVORITES, | 765 importer::FAVORITES, |
701 items); | 766 &items); |
702 | 767 |
703 profile_import_exited_successfully = | 768 internal::g_profile_import_exited_successfully = |
704 internal::ImportSettings(profile, importer_host, importer_list, items); | 769 internal::ImportSettings(profile, importer_host, importer_list, items); |
705 DCHECK(profile_import_exited_successfully); | 770 DCHECK(internal::g_profile_import_exited_successfully); |
706 } | 771 } |
707 | 772 |
708 content::RecordAction(UserMetricsAction("FirstRunDef_Accept")); | 773 content::RecordAction(UserMetricsAction("FirstRunDef_Accept")); |
709 | 774 |
710 process_singleton->Unlock(); | 775 process_singleton->Unlock(); |
711 first_run::CreateSentinel(); | |
712 #endif // !defined(USE_AURA) | 776 #endif // !defined(USE_AURA) |
713 did_perform_profile_import = true; | 777 internal::g_did_perform_profile_import = true; |
714 } | 778 } |
715 | 779 |
716 void DoPostImportTasks(Profile* profile, bool make_chrome_default) { | 780 void DoPostImportTasks(Profile* profile, bool make_chrome_default) { |
717 if (make_chrome_default && | 781 if (make_chrome_default && |
718 ShellIntegration::CanSetAsDefaultBrowser() == | 782 ShellIntegration::CanSetAsDefaultBrowser() == |
719 ShellIntegration::SET_DEFAULT_UNATTENDED) { | 783 ShellIntegration::SET_DEFAULT_UNATTENDED) { |
720 ShellIntegration::SetAsDefaultBrowser(); | 784 ShellIntegration::SetAsDefaultBrowser(); |
721 } | 785 } |
722 | 786 |
723 #if !defined(USE_AURA) | 787 #if !defined(USE_AURA) |
(...skipping 14 matching lines...) Expand all Loading... | |
738 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); | 802 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); |
739 SetShouldShowWelcomePage(); | 803 SetShouldShowWelcomePage(); |
740 SetShouldDoPersonalDataManagerFirstRun(); | 804 SetShouldDoPersonalDataManagerFirstRun(); |
741 #endif // !defined(USE_AURA) | 805 #endif // !defined(USE_AURA) |
742 | 806 |
743 internal::DoPostImportPlatformSpecificTasks(); | 807 internal::DoPostImportPlatformSpecificTasks(); |
744 } | 808 } |
745 | 809 |
746 bool DidPerformProfileImport(bool* exited_successfully) { | 810 bool DidPerformProfileImport(bool* exited_successfully) { |
747 if (exited_successfully) | 811 if (exited_successfully) |
748 *exited_successfully = profile_import_exited_successfully; | 812 *exited_successfully = internal::g_profile_import_exited_successfully; |
749 return did_perform_profile_import; | 813 return internal::g_did_perform_profile_import; |
750 } | 814 } |
751 | 815 |
752 } // namespace first_run | 816 } // namespace first_run |
OLD | NEW |