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/extension_service.h" | 21 #include "chrome/browser/extensions/extension_service.h" |
22 #include "chrome/browser/extensions/updater/extension_updater.h" | 22 #include "chrome/browser/extensions/updater/extension_updater.h" |
23 #include "chrome/browser/first_run/first_run_dialog.h" | 23 #include "chrome/browser/first_run/first_run_dialog.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_observer.h" | 29 #include "chrome/browser/importer/importer_progress_observer.h" |
30 #include "chrome/browser/importer/importer_type.h" | 30 #include "chrome/browser/importer/importer_type.h" |
| 31 #include "chrome/browser/importer/profile_writer.h" |
31 #include "chrome/browser/profiles/profile_manager.h" | 32 #include "chrome/browser/profiles/profile_manager.h" |
32 #include "chrome/browser/search_engines/template_url_service.h" | 33 #include "chrome/browser/search_engines/template_url_service.h" |
33 #include "chrome/browser/search_engines/template_url_service_factory.h" | 34 #include "chrome/browser/search_engines/template_url_service_factory.h" |
34 #include "chrome/browser/shell_integration.h" | 35 #include "chrome/browser/shell_integration.h" |
35 #include "chrome/browser/signin/signin_manager.h" | 36 #include "chrome/browser/signin/signin_manager.h" |
36 #include "chrome/browser/signin/signin_manager_factory.h" | 37 #include "chrome/browser/signin/signin_manager_factory.h" |
37 #include "chrome/browser/signin/signin_tracker.h" | 38 #include "chrome/browser/signin/signin_tracker.h" |
38 #include "chrome/browser/ui/browser.h" | 39 #include "chrome/browser/ui/browser.h" |
39 #include "chrome/browser/ui/browser_finder.h" | 40 #include "chrome/browser/ui/browser_finder.h" |
40 #include "chrome/browser/ui/global_error/global_error_service.h" | 41 #include "chrome/browser/ui/global_error/global_error_service.h" |
(...skipping 15 matching lines...) Expand all Loading... |
56 #include "content/public/browser/notification_types.h" | 57 #include "content/public/browser/notification_types.h" |
57 #include "content/public/browser/user_metrics.h" | 58 #include "content/public/browser/user_metrics.h" |
58 #include "content/public/browser/web_contents.h" | 59 #include "content/public/browser/web_contents.h" |
59 #include "google_apis/gaia/gaia_auth_util.h" | 60 #include "google_apis/gaia/gaia_auth_util.h" |
60 #include "googleurl/src/gurl.h" | 61 #include "googleurl/src/gurl.h" |
61 | 62 |
62 using content::UserMetricsAction; | 63 using content::UserMetricsAction; |
63 | 64 |
64 namespace { | 65 namespace { |
65 | 66 |
| 67 // A bitfield formed from values in AutoImportState to record the state of |
| 68 // AutoImport. This is used in testing to verify import startup actions that |
| 69 // occur before an observer can be registered in the test. |
| 70 uint16 g_auto_import_state = first_run::AUTO_IMPORT_NONE; |
| 71 |
66 // Flags for functions of similar name. | 72 // Flags for functions of similar name. |
67 bool g_should_show_welcome_page = false; | 73 bool g_should_show_welcome_page = false; |
68 bool g_should_do_autofill_personal_data_manager_first_run = false; | 74 bool g_should_do_autofill_personal_data_manager_first_run = false; |
69 | 75 |
70 // Flags indicating whether a first-run profile auto import was performed, and | 76 // This class acts as an observer for the ImporterProgressObserver::ImportEnded |
71 // whether the importer process exited successfully. | 77 // callback. When the import process is started, certain errors may cause |
72 bool did_perform_profile_import = false; | 78 // ImportEnded() to be called synchronously, but the typical case is that |
73 bool profile_import_exited_successfully = false; | 79 // ImportEnded() is called asynchronously. Thus we have to handle both cases. |
| 80 class ImportEndedObserver : public importer::ImporterProgressObserver { |
| 81 public: |
| 82 ImportEndedObserver() : ended_(false), |
| 83 should_quit_message_loop_(false) {} |
| 84 virtual ~ImportEndedObserver() {} |
| 85 |
| 86 // importer::ImporterProgressObserver: |
| 87 virtual void ImportStarted() OVERRIDE {} |
| 88 virtual void ImportItemStarted(importer::ImportItem item) OVERRIDE {} |
| 89 virtual void ImportItemEnded(importer::ImportItem item) OVERRIDE {} |
| 90 virtual void ImportEnded() OVERRIDE { |
| 91 ended_ = true; |
| 92 if (should_quit_message_loop_) |
| 93 MessageLoop::current()->Quit(); |
| 94 } |
| 95 |
| 96 void set_should_quit_message_loop() { |
| 97 should_quit_message_loop_ = true; |
| 98 } |
| 99 |
| 100 bool ended() const { |
| 101 return ended_; |
| 102 } |
| 103 |
| 104 private: |
| 105 // Set if the import has ended. |
| 106 bool ended_; |
| 107 |
| 108 bool should_quit_message_loop_; |
| 109 }; |
74 | 110 |
75 // Helper class that performs delayed first-run tasks that need more of the | 111 // Helper class that performs delayed first-run tasks that need more of the |
76 // chrome infrastructure to be up and running before they can be attempted. | 112 // chrome infrastructure to be up and running before they can be attempted. |
77 class FirstRunDelayedTasks : public content::NotificationObserver { | 113 class FirstRunDelayedTasks : public content::NotificationObserver { |
78 public: | 114 public: |
79 enum Tasks { | 115 enum Tasks { |
80 NO_TASK, | 116 NO_TASK, |
81 INSTALL_EXTENSIONS | 117 INSTALL_EXTENSIONS |
82 }; | 118 }; |
83 | 119 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 if (user_prefs->GetBoolean(pref_path)) | 222 if (user_prefs->GetBoolean(pref_path)) |
187 *items |= import_type; | 223 *items |= import_type; |
188 } else { // no policy (recommended or managed) is set | 224 } else { // no policy (recommended or managed) is set |
189 if (should_import) | 225 if (should_import) |
190 *items |= import_type; | 226 *items |= import_type; |
191 } | 227 } |
192 | 228 |
193 user_prefs->ClearPref(pref_path); | 229 user_prefs->ClearPref(pref_path); |
194 } | 230 } |
195 | 231 |
196 // Imports bookmarks from an html file. The path to the file is provided in | 232 // Launches the import, via |importer_host|, from |source_profile| into |
197 // the command line. | 233 // |target_profile| for the items specified in the |items_to_import| bitfield. |
198 void ImportFromFile(Profile* profile, const CommandLine& cmdline) { | 234 // This may be done in a separate process depending on the platform, but it will |
199 base::FilePath file_path = | 235 // always block until done. |
200 cmdline.GetSwitchValuePath(switches::kImportFromFile); | 236 void ImportFromSourceProfile(scoped_refptr<ImporterHost> importer_host, |
201 if (file_path.empty()) { | 237 const importer::SourceProfile& source_profile, |
202 NOTREACHED(); | 238 Profile* target_profile, |
203 return; | 239 uint16 items_to_import) { |
204 } | 240 ImportEndedObserver observer; |
205 scoped_refptr<ImporterHost> importer_host(new ImporterHost); | |
206 importer_host->set_headless(); | |
207 | |
208 importer::SourceProfile source_profile; | |
209 source_profile.importer_type = importer::TYPE_BOOKMARKS_FILE; | |
210 source_profile.source_path = file_path; | |
211 | |
212 first_run::internal::ImportEndedObserver observer; | |
213 importer_host->SetObserver(&observer); | 241 importer_host->SetObserver(&observer); |
214 importer_host->StartImportSettings( | 242 importer_host->StartImportSettings(source_profile, |
215 source_profile, profile, importer::FAVORITES, new ProfileWriter(profile)); | 243 target_profile, |
| 244 items_to_import, |
| 245 new ProfileWriter(target_profile)); |
216 // If the import process has not errored out, block on it. | 246 // If the import process has not errored out, block on it. |
217 if (!observer.ended()) { | 247 if (!observer.ended()) { |
218 observer.set_should_quit_message_loop(); | 248 observer.set_should_quit_message_loop(); |
219 MessageLoop::current()->Run(); | 249 MessageLoop::current()->Run(); |
220 } | 250 } |
221 } | 251 } |
222 | 252 |
| 253 // Imports bookmarks from an html file whose path is provided by |
| 254 // |import_bookmarks_path|. |
| 255 void ImportFromFile(Profile* profile, |
| 256 scoped_refptr<ImporterHost> file_importer_host, |
| 257 const std::string& import_bookmarks_path) { |
| 258 importer::SourceProfile source_profile; |
| 259 source_profile.importer_type = importer::TYPE_BOOKMARKS_FILE; |
| 260 |
| 261 const base::FilePath::StringType& import_bookmarks_path_str = |
| 262 #if defined(OS_WIN) |
| 263 UTF8ToUTF16(import_bookmarks_path); |
| 264 #else |
| 265 import_bookmarks_path; |
| 266 #endif |
| 267 source_profile.source_path = base::FilePath(import_bookmarks_path_str); |
| 268 |
| 269 ImportFromSourceProfile(file_importer_host, source_profile, profile, |
| 270 importer::FAVORITES); |
| 271 g_auto_import_state |= first_run::AUTO_IMPORT_BOOKMARKS_FILE_IMPORTED; |
| 272 } |
| 273 |
| 274 // Imports settings from the first profile in |importer_list|. |
| 275 void ImportSettings(Profile* profile, |
| 276 scoped_refptr<ImporterHost> importer_host, |
| 277 scoped_refptr<ImporterList> importer_list, |
| 278 int items_to_import) { |
| 279 const importer::SourceProfile& source_profile = |
| 280 importer_list->GetSourceProfileAt(0); |
| 281 |
| 282 // Ensure that importers aren't requested to import items that they do not |
| 283 // support. If there is no overlap, skip. |
| 284 items_to_import &= source_profile.services_supported; |
| 285 if (items_to_import == 0) |
| 286 return; |
| 287 |
| 288 ImportFromSourceProfile(importer_host, source_profile, profile, |
| 289 items_to_import); |
| 290 g_auto_import_state |= first_run::AUTO_IMPORT_PROFILE_IMPORTED; |
| 291 } |
| 292 |
223 GURL UrlFromString(const std::string& in) { | 293 GURL UrlFromString(const std::string& in) { |
224 return GURL(in); | 294 return GURL(in); |
225 } | 295 } |
226 | 296 |
227 void ConvertStringVectorToGURLVector( | 297 void ConvertStringVectorToGURLVector( |
228 const std::vector<std::string>& src, | 298 const std::vector<std::string>& src, |
229 std::vector<GURL>* ret) { | 299 std::vector<GURL>* ret) { |
230 ret->resize(src.size()); | 300 ret->resize(src.size()); |
231 std::transform(src.begin(), src.end(), ret->begin(), &UrlFromString); | 301 std::transform(src.begin(), src.end(), ret->begin(), &UrlFromString); |
232 } | 302 } |
233 | 303 |
234 } // namespace | 304 } // namespace |
235 | 305 |
236 namespace first_run { | 306 namespace first_run { |
237 namespace internal { | 307 namespace internal { |
238 | 308 |
239 FirstRunState first_run_ = FIRST_RUN_UNKNOWN; | 309 FirstRunState first_run_ = FIRST_RUN_UNKNOWN; |
240 | 310 |
241 static base::LazyInstance<base::FilePath> master_prefs_path_for_testing | 311 static base::LazyInstance<base::FilePath> master_prefs_path_for_testing |
242 = LAZY_INSTANCE_INITIALIZER; | 312 = LAZY_INSTANCE_INITIALIZER; |
243 | 313 |
244 // TODO(gab): This will go back inline above when it is moved to first_run.cc | |
245 // (see TODO above), but needs to be separate for now to satisfy clang error: | |
246 // "[chromium-style] virtual methods with non-empty bodies shouldn't be declared | |
247 // inline". | |
248 void ImportEndedObserver::ImportEnded() { | |
249 ended_ = true; | |
250 if (should_quit_message_loop_) | |
251 MessageLoop::current()->Quit(); | |
252 } | |
253 | |
254 installer::MasterPreferences* | 314 installer::MasterPreferences* |
255 LoadMasterPrefs(base::FilePath* master_prefs_path) { | 315 LoadMasterPrefs(base::FilePath* master_prefs_path) { |
256 if (!master_prefs_path_for_testing.Get().empty()) | 316 if (!master_prefs_path_for_testing.Get().empty()) |
257 *master_prefs_path = master_prefs_path_for_testing.Get(); | 317 *master_prefs_path = master_prefs_path_for_testing.Get(); |
258 else | 318 else |
259 *master_prefs_path = base::FilePath(MasterPrefsPath()); | 319 *master_prefs_path = base::FilePath(MasterPrefsPath()); |
260 if (master_prefs_path->empty()) | 320 if (master_prefs_path->empty()) |
261 return NULL; | 321 return NULL; |
262 installer::MasterPreferences* install_prefs = | 322 installer::MasterPreferences* install_prefs = |
263 new installer::MasterPreferences(*master_prefs_path); | 323 new installer::MasterPreferences(*master_prefs_path); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 &value) && value) { | 407 &value) && value) { |
348 out_prefs->make_chrome_default = true; | 408 out_prefs->make_chrome_default = true; |
349 } | 409 } |
350 | 410 |
351 if (install_prefs.GetBool( | 411 if (install_prefs.GetBool( |
352 installer::master_preferences::kSuppressFirstRunDefaultBrowserPrompt, | 412 installer::master_preferences::kSuppressFirstRunDefaultBrowserPrompt, |
353 &value) && value) { | 413 &value) && value) { |
354 out_prefs->suppress_first_run_default_browser_prompt = true; | 414 out_prefs->suppress_first_run_default_browser_prompt = true; |
355 } | 415 } |
356 | 416 |
| 417 install_prefs.GetString( |
| 418 installer::master_preferences::kDistroImportBookmarksFromFilePref, |
| 419 &out_prefs->import_bookmarks_path); |
| 420 |
357 out_prefs->variations_seed = install_prefs.GetVariationsSeed(); | 421 out_prefs->variations_seed = install_prefs.GetVariationsSeed(); |
358 | 422 |
359 install_prefs.GetString( | 423 install_prefs.GetString( |
360 installer::master_preferences::kDistroSuppressDefaultBrowserPromptPref, | 424 installer::master_preferences::kDistroSuppressDefaultBrowserPromptPref, |
361 &out_prefs->suppress_default_browser_prompt_for_version); | 425 &out_prefs->suppress_default_browser_prompt_for_version); |
362 } | 426 } |
363 | 427 |
364 void SetDefaultBrowser(installer::MasterPreferences* install_prefs){ | 428 void SetDefaultBrowser(installer::MasterPreferences* install_prefs){ |
365 // Even on the first run we only allow for the user choice to take effect if | 429 // Even on the first run we only allow for the user choice to take effect if |
366 // no policy has been set by the admin. | 430 // no policy has been set by the admin. |
367 if (!g_browser_process->local_state()->IsManagedPreference( | 431 if (!g_browser_process->local_state()->IsManagedPreference( |
368 prefs::kDefaultBrowserSettingEnabled)) { | 432 prefs::kDefaultBrowserSettingEnabled)) { |
369 bool value = false; | 433 bool value = false; |
370 if (install_prefs->GetBool( | 434 if (install_prefs->GetBool( |
371 installer::master_preferences::kMakeChromeDefaultForUser, | 435 installer::master_preferences::kMakeChromeDefaultForUser, |
(...skipping 11 matching lines...) Expand all Loading... |
383 // -- Platform-specific functions -- | 447 // -- Platform-specific functions -- |
384 | 448 |
385 #if !defined(OS_LINUX) && !defined(OS_BSD) | 449 #if !defined(OS_LINUX) && !defined(OS_BSD) |
386 bool IsOrganicFirstRun() { | 450 bool IsOrganicFirstRun() { |
387 std::string brand; | 451 std::string brand; |
388 google_util::GetBrand(&brand); | 452 google_util::GetBrand(&brand); |
389 return google_util::IsOrganicFirstRun(brand); | 453 return google_util::IsOrganicFirstRun(brand); |
390 } | 454 } |
391 #endif | 455 #endif |
392 | 456 |
393 int ImportBookmarkFromFileIfNeeded(Profile* profile, | |
394 const CommandLine& cmdline) { | |
395 if (cmdline.HasSwitch(switches::kImportFromFile)) { | |
396 // Silently import preset bookmarks from file. | |
397 // This is an OEM scenario. | |
398 ImportFromFile(profile, cmdline); | |
399 } | |
400 // ImportBookmarkFromFileIfNeeded() will go away as part of | |
401 // http://crbug.com/219419, so it is fine to hardcode |true| for now. | |
402 return true; | |
403 } | |
404 | |
405 } // namespace internal | 457 } // namespace internal |
406 } // namespace first_run | 458 } // namespace first_run |
407 | 459 |
408 namespace first_run { | 460 namespace first_run { |
409 | 461 |
410 MasterPrefs::MasterPrefs() | 462 MasterPrefs::MasterPrefs() |
411 : ping_delay(0), | 463 : ping_delay(0), |
412 homepage_defined(false), | 464 homepage_defined(false), |
413 do_import_items(0), | 465 do_import_items(0), |
414 dont_import_items(0), | 466 dont_import_items(0), |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 bool retval = g_should_do_autofill_personal_data_manager_first_run; | 542 bool retval = g_should_do_autofill_personal_data_manager_first_run; |
491 g_should_do_autofill_personal_data_manager_first_run = false; | 543 g_should_do_autofill_personal_data_manager_first_run = false; |
492 return retval; | 544 return retval; |
493 } | 545 } |
494 | 546 |
495 void LogFirstRunMetric(FirstRunBubbleMetric metric) { | 547 void LogFirstRunMetric(FirstRunBubbleMetric metric) { |
496 UMA_HISTOGRAM_ENUMERATION("FirstRun.SearchEngineBubble", metric, | 548 UMA_HISTOGRAM_ENUMERATION("FirstRun.SearchEngineBubble", metric, |
497 NUM_FIRST_RUN_BUBBLE_METRICS); | 549 NUM_FIRST_RUN_BUBBLE_METRICS); |
498 } | 550 } |
499 | 551 |
500 namespace { | |
501 CommandLine* GetExtraArgumentsInstance() { | |
502 CR_DEFINE_STATIC_LOCAL(CommandLine, arguments, (CommandLine::NoProgram())); | |
503 return &arguments; | |
504 } | |
505 } // namespace | |
506 | |
507 void SetExtraArgumentsForImportProcess(const CommandLine& arguments) { | |
508 GetExtraArgumentsInstance()->AppendArguments(arguments, false); | |
509 } | |
510 | |
511 const CommandLine& GetExtraArgumentsForImportProcess() { | |
512 return *GetExtraArgumentsInstance(); | |
513 } | |
514 | |
515 // static | 552 // static |
516 void FirstRunBubbleLauncher::ShowFirstRunBubbleSoon() { | 553 void FirstRunBubbleLauncher::ShowFirstRunBubbleSoon() { |
517 SetShowFirstRunBubblePref(FIRST_RUN_BUBBLE_SHOW); | 554 SetShowFirstRunBubblePref(FIRST_RUN_BUBBLE_SHOW); |
518 // This FirstRunBubbleLauncher instance will manage its own lifetime. | 555 // This FirstRunBubbleLauncher instance will manage its own lifetime. |
519 new FirstRunBubbleLauncher(); | 556 new FirstRunBubbleLauncher(); |
520 } | 557 } |
521 | 558 |
522 FirstRunBubbleLauncher::FirstRunBubbleLauncher() { | 559 FirstRunBubbleLauncher::FirstRunBubbleLauncher() { |
523 registrar_.Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 560 registrar_.Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
524 content::NotificationService::AllSources()); | 561 content::NotificationService::AllSources()); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 if (!internal::ShowPostInstallEULAIfNeeded(install_prefs.get())) | 663 if (!internal::ShowPostInstallEULAIfNeeded(install_prefs.get())) |
627 return EULA_EXIT_NOW; | 664 return EULA_EXIT_NOW; |
628 | 665 |
629 if (!internal::CopyPrefFile(user_data_dir, master_prefs_path)) | 666 if (!internal::CopyPrefFile(user_data_dir, master_prefs_path)) |
630 DLOG(ERROR) << "Failed to copy master_preferences to user data dir."; | 667 DLOG(ERROR) << "Failed to copy master_preferences to user data dir."; |
631 | 668 |
632 DoDelayedInstallExtensionsIfNeeded(install_prefs.get()); | 669 DoDelayedInstallExtensionsIfNeeded(install_prefs.get()); |
633 | 670 |
634 internal::SetupMasterPrefsFromInstallPrefs(*install_prefs, out_prefs); | 671 internal::SetupMasterPrefsFromInstallPrefs(*install_prefs, out_prefs); |
635 | 672 |
636 internal::SetImportPreferencesAndLaunchImport(out_prefs, | |
637 install_prefs.get()); | |
638 | |
639 internal::SetDefaultBrowser(install_prefs.get()); | 673 internal::SetDefaultBrowser(install_prefs.get()); |
640 } | 674 } |
641 | 675 |
642 return DO_FIRST_RUN_TASKS; | 676 return DO_FIRST_RUN_TASKS; |
643 } | 677 } |
644 | 678 |
645 void AutoImport( | 679 void AutoImport( |
646 Profile* profile, | 680 Profile* profile, |
647 bool homepage_defined, | 681 bool homepage_defined, |
648 int import_items, | 682 int import_items, |
649 int dont_import_items) { | 683 int dont_import_items, |
| 684 const std::string& import_bookmarks_path) { |
650 #if !defined(USE_AURA) | 685 #if !defined(USE_AURA) |
651 scoped_refptr<ImporterHost> importer_host; | 686 scoped_refptr<ImporterHost> importer_host; |
652 // TODO(csilv,mirandac): Out-of-process import has only been qualified on | 687 // TODO(csilv,mirandac): Out-of-process import has only been qualified on |
653 // MacOS X, so we will only use it on that platform since it is required. | 688 // MacOS X and Windows, so we will only use it on those platforms. |
654 // Remove this conditional logic once oop import is qualified for | 689 // Linux still uses the in-process import (http://crbug.com/56816). |
655 // Linux/Windows. http://crbug.com/22142 | 690 #if defined(OS_MACOSX) || defined(OS_WIN) |
656 #if defined(OS_MACOSX) | |
657 importer_host = new ExternalProcessImporterHost; | 691 importer_host = new ExternalProcessImporterHost; |
658 #else | 692 #else |
659 importer_host = new ImporterHost; | 693 importer_host = new ImporterHost; |
660 #endif | 694 #endif |
661 | 695 |
662 base::FilePath local_state_path; | 696 base::FilePath local_state_path; |
663 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); | 697 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); |
664 bool local_state_file_exists = file_util::PathExists(local_state_path); | 698 bool local_state_file_exists = file_util::PathExists(local_state_path); |
665 | 699 |
666 scoped_refptr<ImporterList> importer_list(new ImporterList(NULL)); | 700 scoped_refptr<ImporterList> importer_list(new ImporterList(NULL)); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 SetImportItem(user_prefs, | 746 SetImportItem(user_prefs, |
713 prefs::kImportBookmarks, | 747 prefs::kImportBookmarks, |
714 import_items, | 748 import_items, |
715 dont_import_items, | 749 dont_import_items, |
716 importer::FAVORITES, | 750 importer::FAVORITES, |
717 &items); | 751 &items); |
718 | 752 |
719 importer::LogImporterUseToMetrics( | 753 importer::LogImporterUseToMetrics( |
720 "AutoImport", importer_list->GetSourceProfileAt(0).importer_type); | 754 "AutoImport", importer_list->GetSourceProfileAt(0).importer_type); |
721 | 755 |
722 profile_import_exited_successfully = | 756 ImportSettings(profile, importer_host, importer_list, items); |
723 internal::ImportSettings(profile, importer_host, importer_list, items); | 757 } |
724 DCHECK(profile_import_exited_successfully); | 758 |
| 759 if (!import_bookmarks_path.empty()) { |
| 760 scoped_refptr<ImporterHost> file_importer_host; |
| 761 // TODO(gab): Make Linux use OOP import as well (http://crbug.com/56816) and |
| 762 // get rid of these ugly ifdefs. |
| 763 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 764 file_importer_host = new ExternalProcessImporterHost; |
| 765 #else |
| 766 file_importer_host = new ImporterHost; |
| 767 #endif |
| 768 file_importer_host->set_headless(); |
| 769 |
| 770 ImportFromFile(profile, file_importer_host, import_bookmarks_path); |
725 } | 771 } |
726 | 772 |
727 content::RecordAction(UserMetricsAction("FirstRunDef_Accept")); | 773 content::RecordAction(UserMetricsAction("FirstRunDef_Accept")); |
728 | 774 |
729 #endif // !defined(USE_AURA) | 775 #endif // !defined(USE_AURA) |
730 did_perform_profile_import = true; | 776 g_auto_import_state |= AUTO_IMPORT_CALLED; |
731 } | 777 } |
732 | 778 |
733 void DoPostImportTasks(Profile* profile, bool make_chrome_default) { | 779 void DoPostImportTasks(Profile* profile, bool make_chrome_default) { |
734 if (make_chrome_default && | 780 if (make_chrome_default && |
735 ShellIntegration::CanSetAsDefaultBrowser() == | 781 ShellIntegration::CanSetAsDefaultBrowser() == |
736 ShellIntegration::SET_DEFAULT_UNATTENDED) { | 782 ShellIntegration::SET_DEFAULT_UNATTENDED) { |
737 ShellIntegration::SetAsDefaultBrowser(); | 783 ShellIntegration::SetAsDefaultBrowser(); |
738 } | 784 } |
739 | 785 |
740 base::FilePath local_state_path; | 786 base::FilePath local_state_path; |
(...skipping 10 matching lines...) Expand all Loading... |
751 TemplateURLService* template_url = | 797 TemplateURLService* template_url = |
752 TemplateURLServiceFactory::GetForProfile(profile); | 798 TemplateURLServiceFactory::GetForProfile(profile); |
753 if (template_url && template_url->GetDefaultSearchProvider()) | 799 if (template_url && template_url->GetDefaultSearchProvider()) |
754 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); | 800 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); |
755 SetShouldShowWelcomePage(); | 801 SetShouldShowWelcomePage(); |
756 SetShouldDoPersonalDataManagerFirstRun(); | 802 SetShouldDoPersonalDataManagerFirstRun(); |
757 | 803 |
758 internal::DoPostImportPlatformSpecificTasks(); | 804 internal::DoPostImportPlatformSpecificTasks(); |
759 } | 805 } |
760 | 806 |
761 bool DidPerformProfileImport(bool* exited_successfully) { | 807 uint16 auto_import_state() { |
762 if (exited_successfully) | 808 return g_auto_import_state; |
763 *exited_successfully = profile_import_exited_successfully; | |
764 return did_perform_profile_import; | |
765 } | 809 } |
766 | 810 |
767 } // namespace first_run | 811 } // namespace first_run |
OLD | NEW |