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

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

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

Powered by Google App Engine
This is Rietveld 408576698