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 int 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 // Set by the client (via set_should_quit_message_loop) if, when the import | |
109 // ends, this class should quit the message loop. | |
110 bool should_quit_message_loop_; | |
111 }; | |
74 | 112 |
75 // Helper class that performs delayed first-run tasks that need more of the | 113 // 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. | 114 // chrome infrastructure to be up and running before they can be attempted. |
77 class FirstRunDelayedTasks : public content::NotificationObserver { | 115 class FirstRunDelayedTasks : public content::NotificationObserver { |
78 public: | 116 public: |
79 enum Tasks { | 117 enum Tasks { |
80 NO_TASK, | 118 NO_TASK, |
81 INSTALL_EXTENSIONS | 119 INSTALL_EXTENSIONS |
82 }; | 120 }; |
83 | 121 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 if (user_prefs->GetBoolean(pref_path)) | 224 if (user_prefs->GetBoolean(pref_path)) |
187 *items |= import_type; | 225 *items |= import_type; |
188 } else { // no policy (recommended or managed) is set | 226 } else { // no policy (recommended or managed) is set |
189 if (should_import) | 227 if (should_import) |
190 *items |= import_type; | 228 *items |= import_type; |
191 } | 229 } |
192 | 230 |
193 user_prefs->ClearPref(pref_path); | 231 user_prefs->ClearPref(pref_path); |
194 } | 232 } |
195 | 233 |
196 // Imports bookmarks from an html file. The path to the file is provided in | 234 // Launches the import, via |importer_host|, from |source_profile| into |
197 // the command line. | 235 // |target_profile| for the items specified in the |items_to_import| bitfield. |
198 void ImportFromFile(Profile* profile, const CommandLine& cmdline) { | 236 // This may be done in a separate process depending on the platform, but it will |
199 base::FilePath file_path = | 237 // always block until done. |
200 cmdline.GetSwitchValuePath(switches::kImportFromFile); | 238 void ImportFromSourceProfile(scoped_refptr<ImporterHost> importer_host, |
201 if (file_path.empty()) { | 239 const importer::SourceProfile& source_profile, |
202 NOTREACHED(); | 240 Profile* target_profile, |
203 return; | 241 uint16 items_to_import) { |
204 } | 242 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); | 243 importer_host->SetObserver(&observer); |
214 importer_host->StartImportSettings( | 244 importer_host->StartImportSettings(source_profile, |
215 source_profile, profile, importer::FAVORITES, new ProfileWriter(profile)); | 245 target_profile, |
246 items_to_import, | |
247 new ProfileWriter(target_profile)); | |
216 // If the import process has not errored out, block on it. | 248 // If the import process has not errored out, block on it. |
217 if (!observer.ended()) { | 249 if (!observer.ended()) { |
218 observer.set_should_quit_message_loop(); | 250 observer.set_should_quit_message_loop(); |
219 MessageLoop::current()->Run(); | 251 MessageLoop::current()->Run(); |
220 } | 252 } |
221 } | 253 } |
222 | 254 |
255 // Imports bookmarks from an html file whose path is provided by | |
256 // |import_bookmarks_path|. | |
257 void ImportFromFile(Profile* profile, | |
258 scoped_refptr<ImporterHost> file_importer_host, | |
259 const std::string& import_bookmarks_path) { | |
260 importer::SourceProfile source_profile; | |
261 source_profile.importer_type = importer::TYPE_BOOKMARKS_FILE; | |
262 | |
263 const base::FilePath::StringType& import_bookmarks_path_str = | |
264 #if defined(OS_WIN) | |
265 UTF8ToUTF16(import_bookmarks_path); | |
266 #else | |
267 import_bookmarks_path; | |
268 #endif | |
269 source_profile.source_path = base::FilePath(import_bookmarks_path_str); | |
270 | |
271 ImportFromSourceProfile(file_importer_host, source_profile, profile, | |
272 importer::FAVORITES); | |
273 g_auto_import_state |= first_run::AUTO_IMPORT_BOOKMARKS_FILE_IMPORTED; | |
274 } | |
275 | |
276 // Imports settings from the first profile in |importer_list|. | |
277 void ImportSettings(Profile* profile, | |
278 scoped_refptr<ImporterHost> importer_host, | |
279 scoped_refptr<ImporterList> importer_list, | |
280 int items_to_import) { | |
281 const importer::SourceProfile& source_profile = | |
282 importer_list->GetSourceProfileAt(0); | |
283 | |
284 // Ensure that importers aren't requested to import items that they do not | |
285 // support. If there is no overlap, skip. | |
286 items_to_import &= source_profile.services_supported; | |
287 if (items_to_import == 0) | |
288 return; | |
289 | |
290 ImportFromSourceProfile(importer_host, source_profile, profile, | |
291 items_to_import); | |
292 g_auto_import_state |= first_run::AUTO_IMPORT_PROFILE_IMPORTED; | |
293 } | |
294 | |
223 GURL UrlFromString(const std::string& in) { | 295 GURL UrlFromString(const std::string& in) { |
224 return GURL(in); | 296 return GURL(in); |
225 } | 297 } |
226 | 298 |
227 void ConvertStringVectorToGURLVector( | 299 void ConvertStringVectorToGURLVector( |
228 const std::vector<std::string>& src, | 300 const std::vector<std::string>& src, |
229 std::vector<GURL>* ret) { | 301 std::vector<GURL>* ret) { |
230 ret->resize(src.size()); | 302 ret->resize(src.size()); |
231 std::transform(src.begin(), src.end(), ret->begin(), &UrlFromString); | 303 std::transform(src.begin(), src.end(), ret->begin(), &UrlFromString); |
232 } | 304 } |
233 | 305 |
234 } // namespace | 306 } // namespace |
235 | 307 |
236 namespace first_run { | 308 namespace first_run { |
237 namespace internal { | 309 namespace internal { |
238 | 310 |
239 FirstRunState first_run_ = FIRST_RUN_UNKNOWN; | 311 FirstRunState first_run_ = FIRST_RUN_UNKNOWN; |
240 | 312 |
241 static base::LazyInstance<base::FilePath> master_prefs_path_for_testing | 313 static base::LazyInstance<base::FilePath> master_prefs_path_for_testing |
242 = LAZY_INSTANCE_INITIALIZER; | 314 = LAZY_INSTANCE_INITIALIZER; |
243 | 315 |
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* | 316 installer::MasterPreferences* |
255 LoadMasterPrefs(base::FilePath* master_prefs_path) { | 317 LoadMasterPrefs(base::FilePath* master_prefs_path) { |
256 if (!master_prefs_path_for_testing.Get().empty()) | 318 if (!master_prefs_path_for_testing.Get().empty()) |
257 *master_prefs_path = master_prefs_path_for_testing.Get(); | 319 *master_prefs_path = master_prefs_path_for_testing.Get(); |
258 else | 320 else |
259 *master_prefs_path = base::FilePath(MasterPrefsPath()); | 321 *master_prefs_path = base::FilePath(MasterPrefsPath()); |
260 if (master_prefs_path->empty()) | 322 if (master_prefs_path->empty()) |
261 return NULL; | 323 return NULL; |
262 installer::MasterPreferences* install_prefs = | 324 installer::MasterPreferences* install_prefs = |
263 new installer::MasterPreferences(*master_prefs_path); | 325 new installer::MasterPreferences(*master_prefs_path); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 &value) && value) { | 409 &value) && value) { |
348 out_prefs->make_chrome_default = true; | 410 out_prefs->make_chrome_default = true; |
349 } | 411 } |
350 | 412 |
351 if (install_prefs.GetBool( | 413 if (install_prefs.GetBool( |
352 installer::master_preferences::kSuppressFirstRunDefaultBrowserPrompt, | 414 installer::master_preferences::kSuppressFirstRunDefaultBrowserPrompt, |
353 &value) && value) { | 415 &value) && value) { |
354 out_prefs->suppress_first_run_default_browser_prompt = true; | 416 out_prefs->suppress_first_run_default_browser_prompt = true; |
355 } | 417 } |
356 | 418 |
419 install_prefs.GetString( | |
420 installer::master_preferences::kDistroImportBookmarksFromFilePref, | |
421 &out_prefs->import_bookmarks_path); | |
422 | |
357 out_prefs->variations_seed = install_prefs.GetVariationsSeed(); | 423 out_prefs->variations_seed = install_prefs.GetVariationsSeed(); |
358 | 424 |
359 install_prefs.GetString( | 425 install_prefs.GetString( |
360 installer::master_preferences::kDistroSuppressDefaultBrowserPromptPref, | 426 installer::master_preferences::kDistroSuppressDefaultBrowserPromptPref, |
361 &out_prefs->suppress_default_browser_prompt_for_version); | 427 &out_prefs->suppress_default_browser_prompt_for_version); |
362 } | 428 } |
363 | 429 |
364 void SetDefaultBrowser(installer::MasterPreferences* install_prefs){ | 430 void SetDefaultBrowser(installer::MasterPreferences* install_prefs){ |
365 // Even on the first run we only allow for the user choice to take effect if | 431 // 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. | 432 // no policy has been set by the admin. |
(...skipping 16 matching lines...) Expand all Loading... | |
383 // -- Platform-specific functions -- | 449 // -- Platform-specific functions -- |
384 | 450 |
385 #if !defined(OS_LINUX) && !defined(OS_BSD) | 451 #if !defined(OS_LINUX) && !defined(OS_BSD) |
386 bool IsOrganicFirstRun() { | 452 bool IsOrganicFirstRun() { |
387 std::string brand; | 453 std::string brand; |
388 google_util::GetBrand(&brand); | 454 google_util::GetBrand(&brand); |
389 return google_util::IsOrganicFirstRun(brand); | 455 return google_util::IsOrganicFirstRun(brand); |
390 } | 456 } |
391 #endif | 457 #endif |
392 | 458 |
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 | 459 } // namespace internal |
406 } // namespace first_run | 460 } // namespace first_run |
407 | 461 |
408 namespace first_run { | 462 namespace first_run { |
409 | 463 |
410 MasterPrefs::MasterPrefs() | 464 MasterPrefs::MasterPrefs() |
411 : ping_delay(0), | 465 : ping_delay(0), |
412 homepage_defined(false), | 466 homepage_defined(false), |
413 do_import_items(0), | 467 do_import_items(0), |
414 dont_import_items(0), | 468 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; | 544 bool retval = g_should_do_autofill_personal_data_manager_first_run; |
491 g_should_do_autofill_personal_data_manager_first_run = false; | 545 g_should_do_autofill_personal_data_manager_first_run = false; |
492 return retval; | 546 return retval; |
493 } | 547 } |
494 | 548 |
495 void LogFirstRunMetric(FirstRunBubbleMetric metric) { | 549 void LogFirstRunMetric(FirstRunBubbleMetric metric) { |
496 UMA_HISTOGRAM_ENUMERATION("FirstRun.SearchEngineBubble", metric, | 550 UMA_HISTOGRAM_ENUMERATION("FirstRun.SearchEngineBubble", metric, |
497 NUM_FIRST_RUN_BUBBLE_METRICS); | 551 NUM_FIRST_RUN_BUBBLE_METRICS); |
498 } | 552 } |
499 | 553 |
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 | 554 // static |
516 void FirstRunBubbleLauncher::ShowFirstRunBubbleSoon() { | 555 void FirstRunBubbleLauncher::ShowFirstRunBubbleSoon() { |
517 SetShowFirstRunBubblePref(FIRST_RUN_BUBBLE_SHOW); | 556 SetShowFirstRunBubblePref(FIRST_RUN_BUBBLE_SHOW); |
518 // This FirstRunBubbleLauncher instance will manage its own lifetime. | 557 // This FirstRunBubbleLauncher instance will manage its own lifetime. |
519 new FirstRunBubbleLauncher(); | 558 new FirstRunBubbleLauncher(); |
520 } | 559 } |
521 | 560 |
522 FirstRunBubbleLauncher::FirstRunBubbleLauncher() { | 561 FirstRunBubbleLauncher::FirstRunBubbleLauncher() { |
523 registrar_.Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 562 registrar_.Add(this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
524 content::NotificationService::AllSources()); | 563 content::NotificationService::AllSources()); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
626 if (!internal::ShowPostInstallEULAIfNeeded(install_prefs.get())) | 665 if (!internal::ShowPostInstallEULAIfNeeded(install_prefs.get())) |
627 return EULA_EXIT_NOW; | 666 return EULA_EXIT_NOW; |
628 | 667 |
629 if (!internal::CopyPrefFile(user_data_dir, master_prefs_path)) | 668 if (!internal::CopyPrefFile(user_data_dir, master_prefs_path)) |
630 DLOG(ERROR) << "Failed to copy master_preferences to user data dir."; | 669 DLOG(ERROR) << "Failed to copy master_preferences to user data dir."; |
631 | 670 |
632 DoDelayedInstallExtensionsIfNeeded(install_prefs.get()); | 671 DoDelayedInstallExtensionsIfNeeded(install_prefs.get()); |
633 | 672 |
634 internal::SetupMasterPrefsFromInstallPrefs(*install_prefs, out_prefs); | 673 internal::SetupMasterPrefsFromInstallPrefs(*install_prefs, out_prefs); |
635 | 674 |
636 internal::SetImportPreferencesAndLaunchImport(out_prefs, | |
637 install_prefs.get()); | |
638 | |
639 internal::SetDefaultBrowser(install_prefs.get()); | 675 internal::SetDefaultBrowser(install_prefs.get()); |
640 } | 676 } |
641 | 677 |
642 return DO_FIRST_RUN_TASKS; | 678 return DO_FIRST_RUN_TASKS; |
643 } | 679 } |
644 | 680 |
645 void AutoImport( | 681 void AutoImport( |
646 Profile* profile, | 682 Profile* profile, |
647 bool homepage_defined, | 683 bool homepage_defined, |
648 int import_items, | 684 int import_items, |
649 int dont_import_items) { | 685 int dont_import_items, |
686 const std::string& import_bookmarks_path) { | |
650 #if !defined(USE_AURA) | 687 #if !defined(USE_AURA) |
651 scoped_refptr<ImporterHost> importer_host; | 688 scoped_refptr<ImporterHost> importer_host; |
652 // TODO(csilv,mirandac): Out-of-process import has only been qualified on | 689 // 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. | 690 // MacOS X and Windows, so we will only use it on those platforms. |
654 // Remove this conditional logic once oop import is qualified for | 691 // Linux still uses the in-process import (http://crbug.com/56816). |
655 // Linux/Windows. http://crbug.com/22142 | 692 #if defined(OS_MACOSX) || defined(OS_WIN) |
656 #if defined(OS_MACOSX) | |
657 importer_host = new ExternalProcessImporterHost; | 693 importer_host = new ExternalProcessImporterHost; |
658 #else | 694 #else |
659 importer_host = new ImporterHost; | 695 importer_host = new ImporterHost; |
660 #endif | 696 #endif |
661 | 697 |
662 base::FilePath local_state_path; | 698 base::FilePath local_state_path; |
663 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); | 699 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); |
664 bool local_state_file_exists = file_util::PathExists(local_state_path); | 700 bool local_state_file_exists = file_util::PathExists(local_state_path); |
665 | 701 |
666 scoped_refptr<ImporterList> importer_list(new ImporterList(NULL)); | 702 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, | 748 SetImportItem(user_prefs, |
713 prefs::kImportBookmarks, | 749 prefs::kImportBookmarks, |
714 import_items, | 750 import_items, |
715 dont_import_items, | 751 dont_import_items, |
716 importer::FAVORITES, | 752 importer::FAVORITES, |
717 &items); | 753 &items); |
718 | 754 |
719 importer::LogImporterUseToMetrics( | 755 importer::LogImporterUseToMetrics( |
720 "AutoImport", importer_list->GetSourceProfileAt(0).importer_type); | 756 "AutoImport", importer_list->GetSourceProfileAt(0).importer_type); |
721 | 757 |
722 profile_import_exited_successfully = | 758 ImportSettings(profile, importer_host, importer_list, items); |
723 internal::ImportSettings(profile, importer_host, importer_list, items); | 759 } |
724 DCHECK(profile_import_exited_successfully); | 760 |
761 if (!import_bookmarks_path.empty()) { | |
762 scoped_refptr<ImporterHost> file_importer_host; | |
763 // TODO(gab): Make Linux use OOP import as well (http://crbug.com/56816) and | |
764 // get rid of these ugly ifdefs. | |
765 #if defined(OS_MACOSX) || defined(OS_WIN) | |
766 file_importer_host = new ExternalProcessImporterHost; | |
767 #else | |
768 file_importer_host = new ImporterHost; | |
769 #endif | |
770 file_importer_host->set_headless(); | |
771 | |
772 ImportFromFile(profile, file_importer_host, import_bookmarks_path); | |
725 } | 773 } |
726 | 774 |
727 content::RecordAction(UserMetricsAction("FirstRunDef_Accept")); | 775 content::RecordAction(UserMetricsAction("FirstRunDef_Accept")); |
728 | 776 |
729 #endif // !defined(USE_AURA) | 777 #endif // !defined(USE_AURA) |
730 did_perform_profile_import = true; | 778 g_auto_import_state |= AUTO_IMPORT_CALLED; |
731 } | 779 } |
732 | 780 |
733 void DoPostImportTasks(Profile* profile, bool make_chrome_default) { | 781 void DoPostImportTasks(Profile* profile, bool make_chrome_default) { |
734 if (make_chrome_default && | 782 if (make_chrome_default && |
735 ShellIntegration::CanSetAsDefaultBrowser() == | 783 ShellIntegration::CanSetAsDefaultBrowser() == |
736 ShellIntegration::SET_DEFAULT_UNATTENDED) { | 784 ShellIntegration::SET_DEFAULT_UNATTENDED) { |
737 ShellIntegration::SetAsDefaultBrowser(); | 785 ShellIntegration::SetAsDefaultBrowser(); |
738 } | 786 } |
739 | 787 |
740 base::FilePath local_state_path; | 788 base::FilePath local_state_path; |
(...skipping 10 matching lines...) Expand all Loading... | |
751 TemplateURLService* template_url = | 799 TemplateURLService* template_url = |
752 TemplateURLServiceFactory::GetForProfile(profile); | 800 TemplateURLServiceFactory::GetForProfile(profile); |
753 if (template_url && template_url->GetDefaultSearchProvider()) | 801 if (template_url && template_url->GetDefaultSearchProvider()) |
754 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); | 802 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); |
755 SetShouldShowWelcomePage(); | 803 SetShouldShowWelcomePage(); |
756 SetShouldDoPersonalDataManagerFirstRun(); | 804 SetShouldDoPersonalDataManagerFirstRun(); |
757 | 805 |
758 internal::DoPostImportPlatformSpecificTasks(); | 806 internal::DoPostImportPlatformSpecificTasks(); |
759 } | 807 } |
760 | 808 |
761 bool DidPerformProfileImport(bool* exited_successfully) { | 809 int GetAutoImportState() { |
Miranda Callahan
2013/04/24 15:16:40
This should probably just be called "g_auto_import
gab
2013/04/24 20:24:59
How about auto_import_state() to:
1) Not use the s
Miranda Callahan
2013/04/25 11:37:06
yes, that's even better. :-)
On 2013/04/24 20:24:
| |
762 if (exited_successfully) | 810 return g_auto_import_state; |
763 *exited_successfully = profile_import_exited_successfully; | |
764 return did_perform_profile_import; | |
765 } | 811 } |
766 | 812 |
767 } // namespace first_run | 813 } // namespace first_run |
OLD | NEW |