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 11 matching lines...) Expand all Loading... | |
22 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
23 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
24 #include "chrome/browser/extensions/updater/extension_updater.h" | 24 #include "chrome/browser/extensions/updater/extension_updater.h" |
25 #include "chrome/browser/first_run/first_run_dialog.h" | 25 #include "chrome/browser/first_run/first_run_dialog.h" |
26 #include "chrome/browser/first_run/first_run_internal.h" | 26 #include "chrome/browser/first_run/first_run_internal.h" |
27 #include "chrome/browser/google/google_util.h" | 27 #include "chrome/browser/google/google_util.h" |
28 #include "chrome/browser/importer/external_process_importer_host.h" | 28 #include "chrome/browser/importer/external_process_importer_host.h" |
29 #include "chrome/browser/importer/importer_host.h" | 29 #include "chrome/browser/importer/importer_host.h" |
30 #include "chrome/browser/importer/importer_list.h" | 30 #include "chrome/browser/importer/importer_list.h" |
31 #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" | |
32 #include "chrome/browser/process_singleton.h" | 33 #include "chrome/browser/process_singleton.h" |
33 #include "chrome/browser/profiles/profile_manager.h" | 34 #include "chrome/browser/profiles/profile_manager.h" |
34 #include "chrome/browser/search_engines/template_url_service.h" | 35 #include "chrome/browser/search_engines/template_url_service.h" |
35 #include "chrome/browser/search_engines/template_url_service_factory.h" | 36 #include "chrome/browser/search_engines/template_url_service_factory.h" |
36 #include "chrome/browser/shell_integration.h" | 37 #include "chrome/browser/shell_integration.h" |
37 #include "chrome/browser/signin/signin_manager.h" | 38 #include "chrome/browser/signin/signin_manager.h" |
38 #include "chrome/browser/signin/signin_manager_factory.h" | 39 #include "chrome/browser/signin/signin_manager_factory.h" |
39 #include "chrome/browser/signin/signin_tracker.h" | 40 #include "chrome/browser/signin/signin_tracker.h" |
40 #include "chrome/browser/ui/browser.h" | 41 #include "chrome/browser/ui/browser.h" |
41 #include "chrome/browser/ui/browser_finder.h" | 42 #include "chrome/browser/ui/browser_finder.h" |
(...skipping 20 matching lines...) Expand all Loading... | |
62 #include "google_apis/gaia/gaia_auth_util.h" | 63 #include "google_apis/gaia/gaia_auth_util.h" |
63 #include "googleurl/src/gurl.h" | 64 #include "googleurl/src/gurl.h" |
64 | 65 |
65 using content::UserMetricsAction; | 66 using content::UserMetricsAction; |
66 | 67 |
67 namespace { | 68 namespace { |
68 | 69 |
69 // How long to delay showing the first run bubble (in milliseconds). | 70 // How long to delay showing the first run bubble (in milliseconds). |
70 const int kFirstRunBubbleDelayMs = 200; | 71 const int kFirstRunBubbleDelayMs = 200; |
71 | 72 |
73 // A bitfield formed from values in AutoImportState to record the state of | |
74 // AutoImport. This is used in testing to verify import startup actions that | |
75 // occur before an observer can be registered in the test. | |
76 int g_auto_import_state = first_run::AUTO_IMPORT_NONE; | |
Miranda Callahan
2013/04/24 15:16:40
should this be uint16 if it's a bitfield?
gab
2013/04/24 20:24:59
Done.
| |
77 | |
72 // Flags for functions of similar name. | 78 // Flags for functions of similar name. |
73 bool g_should_show_welcome_page = false; | 79 bool g_should_show_welcome_page = false; |
74 bool g_should_do_autofill_personal_data_manager_first_run = false; | 80 bool g_should_do_autofill_personal_data_manager_first_run = false; |
75 | 81 |
76 // Flags indicating whether a first-run profile auto import was performed, and | 82 // This class acts as an observer for the ImporterProgressObserver::ImportEnded |
gab
2013/04/18 21:51:18
Moved from first_run_internal
| |
77 // whether the importer process exited successfully. | 83 // callback. When the import process is started, certain errors may cause |
78 bool did_perform_profile_import = false; | 84 // ImportEnded() to be called synchronously, but the typical case is that |
79 bool profile_import_exited_successfully = false; | 85 // ImportEnded() is called asynchronously. Thus we have to handle both cases. |
86 class ImportEndedObserver : public importer::ImporterProgressObserver { | |
87 public: | |
88 ImportEndedObserver() : ended_(false), | |
89 should_quit_message_loop_(false) {} | |
90 virtual ~ImportEndedObserver() {} | |
91 | |
92 // importer::ImporterProgressObserver: | |
93 virtual void ImportStarted() OVERRIDE {} | |
94 virtual void ImportItemStarted(importer::ImportItem item) OVERRIDE {} | |
95 virtual void ImportItemEnded(importer::ImportItem item) OVERRIDE {} | |
96 virtual void ImportEnded() OVERRIDE { | |
97 ended_ = true; | |
98 if (should_quit_message_loop_) | |
99 MessageLoop::current()->Quit(); | |
100 } | |
101 | |
102 void set_should_quit_message_loop() { | |
103 should_quit_message_loop_ = true; | |
104 } | |
105 | |
106 bool ended() const { | |
107 return ended_; | |
108 } | |
109 | |
110 private: | |
111 // Set if the import has ended. | |
112 bool ended_; | |
113 | |
114 // Set by the client (via set_should_quit_message_loop) if, when the import | |
115 // ends, this class should quit the message loop. | |
cpu_(ooo_6.6-7.5)
2013/04/23 23:36:04
remove obvious comment.
gab
2013/04/24 20:24:59
Done.
| |
116 bool should_quit_message_loop_; | |
117 }; | |
80 | 118 |
81 // Helper class that performs delayed first-run tasks that need more of the | 119 // Helper class that performs delayed first-run tasks that need more of the |
82 // chrome infrastructure to be up and running before they can be attempted. | 120 // chrome infrastructure to be up and running before they can be attempted. |
83 class FirstRunDelayedTasks : public content::NotificationObserver { | 121 class FirstRunDelayedTasks : public content::NotificationObserver { |
84 public: | 122 public: |
85 enum Tasks { | 123 enum Tasks { |
86 NO_TASK, | 124 NO_TASK, |
87 INSTALL_EXTENSIONS | 125 INSTALL_EXTENSIONS |
88 }; | 126 }; |
89 | 127 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 if (user_prefs->GetBoolean(pref_path)) | 230 if (user_prefs->GetBoolean(pref_path)) |
193 *items |= import_type; | 231 *items |= import_type; |
194 } else { // no policy (recommended or managed) is set | 232 } else { // no policy (recommended or managed) is set |
195 if (should_import) | 233 if (should_import) |
196 *items |= import_type; | 234 *items |= import_type; |
197 } | 235 } |
198 | 236 |
199 user_prefs->ClearPref(pref_path); | 237 user_prefs->ClearPref(pref_path); |
200 } | 238 } |
201 | 239 |
202 // Imports bookmarks from an html file. The path to the file is provided in | 240 // Launches the import, via |importer_host|, from |source_profile| into |
203 // the command line. | 241 // |target_profile| for the items specified in the |items_to_import| bitfield. |
204 void ImportFromFile(Profile* profile, const CommandLine& cmdline) { | 242 // This may be done in a separate process depending on the platform, but it will |
205 base::FilePath file_path = | 243 // always block until done. |
206 cmdline.GetSwitchValuePath(switches::kImportFromFile); | 244 void ImportFromSourceProfile(scoped_refptr<ImporterHost> importer_host, |
207 if (file_path.empty()) { | 245 const importer::SourceProfile& source_profile, |
208 NOTREACHED(); | 246 Profile* target_profile, |
209 return; | 247 uint16 items_to_import) { |
210 } | 248 ImportEndedObserver observer; |
211 scoped_refptr<ImporterHost> importer_host(new ImporterHost); | |
212 importer_host->set_headless(); | |
213 | |
214 importer::SourceProfile source_profile; | |
215 source_profile.importer_type = importer::TYPE_BOOKMARKS_FILE; | |
216 source_profile.source_path = file_path; | |
217 | |
218 first_run::internal::ImportEndedObserver observer; | |
219 importer_host->SetObserver(&observer); | 249 importer_host->SetObserver(&observer); |
220 importer_host->StartImportSettings( | 250 importer_host->StartImportSettings(source_profile, |
221 source_profile, profile, importer::FAVORITES, new ProfileWriter(profile)); | 251 target_profile, |
252 items_to_import, | |
253 new ProfileWriter(target_profile)); | |
222 // If the import process has not errored out, block on it. | 254 // If the import process has not errored out, block on it. |
223 if (!observer.ended()) { | 255 if (!observer.ended()) { |
224 observer.set_should_quit_message_loop(); | 256 observer.set_should_quit_message_loop(); |
225 MessageLoop::current()->Run(); | 257 MessageLoop::current()->Run(); |
226 } | 258 } |
227 } | 259 } |
228 | 260 |
261 // Imports bookmarks from an html file whose path is provided by | |
262 // |import_bookmarks_path|. | |
263 void ImportFromFile(Profile* profile, | |
264 scoped_refptr<ImporterHost> file_importer_host, | |
tapted
2013/04/24 08:08:35
nit: indenting
gab
2013/04/24 20:24:59
Done.
| |
265 const std::string& import_bookmarks_path) { | |
266 importer::SourceProfile source_profile; | |
267 source_profile.importer_type = importer::TYPE_BOOKMARKS_FILE; | |
268 | |
269 const base::FilePath::StringType& import_bookmarks_path_str = | |
270 #if defined(OS_WIN) | |
271 UTF8ToUTF16(import_bookmarks_path); | |
272 #else | |
273 import_bookmarks_path; | |
274 #endif | |
275 source_profile.source_path = base::FilePath(import_bookmarks_path_str); | |
276 | |
277 ImportFromSourceProfile(file_importer_host, source_profile, profile, | |
278 importer::FAVORITES); | |
279 g_auto_import_state |= first_run::AUTO_IMPORT_BOOKMARKS_FILE_IMPORTED; | |
280 } | |
281 | |
282 // Imports settings from the first profile in |importer_list|. | |
283 void ImportSettings(Profile* profile, | |
gab
2013/04/18 21:51:18
Moved from first_run_posix.cc (and tweaked some mo
| |
284 scoped_refptr<ImporterHost> importer_host, | |
285 scoped_refptr<ImporterList> importer_list, | |
286 int items_to_import) { | |
287 const importer::SourceProfile& source_profile = | |
288 importer_list->GetSourceProfileAt(0); | |
289 | |
290 // Ensure that importers aren't requested to import items that they do not | |
291 // support. If there is no overlap, skip. | |
292 items_to_import &= source_profile.services_supported; | |
293 if (items_to_import == 0) | |
294 return; | |
295 | |
296 ImportFromSourceProfile(importer_host, source_profile, profile, | |
297 items_to_import); | |
298 g_auto_import_state |= first_run::AUTO_IMPORT_PROFILE_IMPORTED; | |
299 } | |
300 | |
229 GURL UrlFromString(const std::string& in) { | 301 GURL UrlFromString(const std::string& in) { |
230 return GURL(in); | 302 return GURL(in); |
231 } | 303 } |
232 | 304 |
233 void ConvertStringVectorToGURLVector( | 305 void ConvertStringVectorToGURLVector( |
234 const std::vector<std::string>& src, | 306 const std::vector<std::string>& src, |
235 std::vector<GURL>* ret) { | 307 std::vector<GURL>* ret) { |
236 ret->resize(src.size()); | 308 ret->resize(src.size()); |
237 std::transform(src.begin(), src.end(), ret->begin(), &UrlFromString); | 309 std::transform(src.begin(), src.end(), ret->begin(), &UrlFromString); |
238 } | 310 } |
239 | 311 |
240 } // namespace | 312 } // namespace |
241 | 313 |
242 namespace first_run { | 314 namespace first_run { |
243 namespace internal { | 315 namespace internal { |
244 | 316 |
245 FirstRunState first_run_ = FIRST_RUN_UNKNOWN; | 317 FirstRunState first_run_ = FIRST_RUN_UNKNOWN; |
246 | 318 |
247 static base::LazyInstance<base::FilePath> master_prefs_path_for_testing | 319 static base::LazyInstance<base::FilePath> master_prefs_path_for_testing |
248 = LAZY_INSTANCE_INITIALIZER; | 320 = LAZY_INSTANCE_INITIALIZER; |
249 | 321 |
250 // TODO(gab): This will go back inline above when it is moved to first_run.cc | |
251 // (see TODO above), but needs to be separate for now to satisfy clang error: | |
252 // "[chromium-style] virtual methods with non-empty bodies shouldn't be declared | |
253 // inline". | |
254 void ImportEndedObserver::ImportEnded() { | |
255 ended_ = true; | |
256 if (should_quit_message_loop_) | |
257 MessageLoop::current()->Quit(); | |
258 } | |
259 | |
260 installer::MasterPreferences* | 322 installer::MasterPreferences* |
261 LoadMasterPrefs(base::FilePath* master_prefs_path) { | 323 LoadMasterPrefs(base::FilePath* master_prefs_path) { |
262 if (!master_prefs_path_for_testing.Get().empty()) | 324 if (!master_prefs_path_for_testing.Get().empty()) |
263 *master_prefs_path = master_prefs_path_for_testing.Get(); | 325 *master_prefs_path = master_prefs_path_for_testing.Get(); |
264 else | 326 else |
265 *master_prefs_path = base::FilePath(MasterPrefsPath()); | 327 *master_prefs_path = base::FilePath(MasterPrefsPath()); |
266 if (master_prefs_path->empty()) | 328 if (master_prefs_path->empty()) |
267 return NULL; | 329 return NULL; |
268 installer::MasterPreferences* install_prefs = | 330 installer::MasterPreferences* install_prefs = |
269 new installer::MasterPreferences(*master_prefs_path); | 331 new installer::MasterPreferences(*master_prefs_path); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 &value) && value) { | 415 &value) && value) { |
354 out_prefs->make_chrome_default = true; | 416 out_prefs->make_chrome_default = true; |
355 } | 417 } |
356 | 418 |
357 if (install_prefs.GetBool( | 419 if (install_prefs.GetBool( |
358 installer::master_preferences::kSuppressFirstRunDefaultBrowserPrompt, | 420 installer::master_preferences::kSuppressFirstRunDefaultBrowserPrompt, |
359 &value) && value) { | 421 &value) && value) { |
360 out_prefs->suppress_first_run_default_browser_prompt = true; | 422 out_prefs->suppress_first_run_default_browser_prompt = true; |
361 } | 423 } |
362 | 424 |
425 install_prefs.GetString( | |
426 installer::master_preferences::kDistroImportBookmarksFromFilePref, | |
tapted
2013/04/24 08:08:35
nit: indenting
gab
2013/04/24 20:24:59
Done.
| |
427 &out_prefs->import_bookmarks_path); | |
428 | |
363 out_prefs->variations_seed = install_prefs.GetVariationsSeed(); | 429 out_prefs->variations_seed = install_prefs.GetVariationsSeed(); |
364 | 430 |
365 install_prefs.GetString( | 431 install_prefs.GetString( |
366 installer::master_preferences::kDistroSuppressDefaultBrowserPromptPref, | 432 installer::master_preferences::kDistroSuppressDefaultBrowserPromptPref, |
367 &out_prefs->suppress_default_browser_prompt_for_version); | 433 &out_prefs->suppress_default_browser_prompt_for_version); |
368 } | 434 } |
369 | 435 |
370 void SetDefaultBrowser(installer::MasterPreferences* install_prefs){ | 436 void SetDefaultBrowser(installer::MasterPreferences* install_prefs){ |
371 // Even on the first run we only allow for the user choice to take effect if | 437 // Even on the first run we only allow for the user choice to take effect if |
372 // no policy has been set by the admin. | 438 // no policy has been set by the admin. |
(...skipping 16 matching lines...) Expand all Loading... | |
389 // -- Platform-specific functions -- | 455 // -- Platform-specific functions -- |
390 | 456 |
391 #if !defined(OS_LINUX) && !defined(OS_BSD) | 457 #if !defined(OS_LINUX) && !defined(OS_BSD) |
392 bool IsOrganicFirstRun() { | 458 bool IsOrganicFirstRun() { |
393 std::string brand; | 459 std::string brand; |
394 google_util::GetBrand(&brand); | 460 google_util::GetBrand(&brand); |
395 return google_util::IsOrganicFirstRun(brand); | 461 return google_util::IsOrganicFirstRun(brand); |
396 } | 462 } |
397 #endif | 463 #endif |
398 | 464 |
399 int ImportBookmarkFromFileIfNeeded(Profile* profile, | |
400 const CommandLine& cmdline) { | |
401 if (cmdline.HasSwitch(switches::kImportFromFile)) { | |
402 // Silently import preset bookmarks from file. | |
403 // This is an OEM scenario. | |
404 ImportFromFile(profile, cmdline); | |
405 } | |
406 // ImportBookmarkFromFileIfNeeded() will go away as part of | |
407 // http://crbug.com/219419, so it is fine to hardcode |true| for now. | |
408 return true; | |
409 } | |
410 | |
411 } // namespace internal | 465 } // namespace internal |
412 } // namespace first_run | 466 } // namespace first_run |
413 | 467 |
414 namespace first_run { | 468 namespace first_run { |
415 | 469 |
416 MasterPrefs::MasterPrefs() | 470 MasterPrefs::MasterPrefs() |
417 : ping_delay(0), | 471 : ping_delay(0), |
418 homepage_defined(false), | 472 homepage_defined(false), |
419 do_import_items(0), | 473 do_import_items(0), |
420 dont_import_items(0), | 474 dont_import_items(0), |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 bool retval = g_should_do_autofill_personal_data_manager_first_run; | 550 bool retval = g_should_do_autofill_personal_data_manager_first_run; |
497 g_should_do_autofill_personal_data_manager_first_run = false; | 551 g_should_do_autofill_personal_data_manager_first_run = false; |
498 return retval; | 552 return retval; |
499 } | 553 } |
500 | 554 |
501 void LogFirstRunMetric(FirstRunBubbleMetric metric) { | 555 void LogFirstRunMetric(FirstRunBubbleMetric metric) { |
502 UMA_HISTOGRAM_ENUMERATION("FirstRun.SearchEngineBubble", metric, | 556 UMA_HISTOGRAM_ENUMERATION("FirstRun.SearchEngineBubble", metric, |
503 NUM_FIRST_RUN_BUBBLE_METRICS); | 557 NUM_FIRST_RUN_BUBBLE_METRICS); |
504 } | 558 } |
505 | 559 |
506 namespace { | |
507 CommandLine* GetExtraArgumentsInstance() { | |
508 CR_DEFINE_STATIC_LOCAL(CommandLine, arguments, (CommandLine::NoProgram())); | |
509 return &arguments; | |
510 } | |
511 } // namespace | |
512 | |
513 void SetExtraArgumentsForImportProcess(const CommandLine& arguments) { | |
514 GetExtraArgumentsInstance()->AppendArguments(arguments, false); | |
515 } | |
516 | |
517 const CommandLine& GetExtraArgumentsForImportProcess() { | |
518 return *GetExtraArgumentsInstance(); | |
519 } | |
520 | |
521 // static | 560 // static |
522 void FirstRunBubbleLauncher::ShowFirstRunBubbleSoon() { | 561 void FirstRunBubbleLauncher::ShowFirstRunBubbleSoon() { |
523 SetShowFirstRunBubblePref(FIRST_RUN_BUBBLE_SHOW); | 562 SetShowFirstRunBubblePref(FIRST_RUN_BUBBLE_SHOW); |
524 // This FirstRunBubbleLauncher instance will manage its own lifetime. | 563 // This FirstRunBubbleLauncher instance will manage its own lifetime. |
525 new FirstRunBubbleLauncher(); | 564 new FirstRunBubbleLauncher(); |
526 } | 565 } |
527 | 566 |
528 FirstRunBubbleLauncher::FirstRunBubbleLauncher() | 567 FirstRunBubbleLauncher::FirstRunBubbleLauncher() |
529 : browser_(NULL) { | 568 : browser_(NULL) { |
530 BrowserList::AddObserver(this); | 569 BrowserList::AddObserver(this); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
661 if (!internal::ShowPostInstallEULAIfNeeded(install_prefs.get())) | 700 if (!internal::ShowPostInstallEULAIfNeeded(install_prefs.get())) |
662 return EULA_EXIT_NOW; | 701 return EULA_EXIT_NOW; |
663 | 702 |
664 if (!internal::CopyPrefFile(user_data_dir, master_prefs_path)) | 703 if (!internal::CopyPrefFile(user_data_dir, master_prefs_path)) |
665 DLOG(ERROR) << "Failed to copy master_preferences to user data dir."; | 704 DLOG(ERROR) << "Failed to copy master_preferences to user data dir."; |
666 | 705 |
667 DoDelayedInstallExtensionsIfNeeded(install_prefs.get()); | 706 DoDelayedInstallExtensionsIfNeeded(install_prefs.get()); |
668 | 707 |
669 internal::SetupMasterPrefsFromInstallPrefs(*install_prefs, out_prefs); | 708 internal::SetupMasterPrefsFromInstallPrefs(*install_prefs, out_prefs); |
670 | 709 |
671 internal::SetImportPreferencesAndLaunchImport(out_prefs, | |
672 install_prefs.get()); | |
673 | |
674 internal::SetDefaultBrowser(install_prefs.get()); | 710 internal::SetDefaultBrowser(install_prefs.get()); |
675 } | 711 } |
676 | 712 |
677 return DO_FIRST_RUN_TASKS; | 713 return DO_FIRST_RUN_TASKS; |
678 } | 714 } |
679 | 715 |
680 void AutoImport( | 716 void AutoImport( |
681 Profile* profile, | 717 Profile* profile, |
682 bool homepage_defined, | 718 bool homepage_defined, |
683 int import_items, | 719 int import_items, |
684 int dont_import_items, | 720 int dont_import_items, |
721 const std::string& import_bookmarks_path, | |
685 ProcessSingleton* process_singleton) { | 722 ProcessSingleton* process_singleton) { |
686 #if !defined(USE_AURA) | 723 #if !defined(USE_AURA) |
687 // We need to avoid dispatching new tabs when we are importing because | 724 // We need to avoid dispatching new tabs when we are importing because |
688 // that will lead to data corruption or a crash. Because there is no UI for | 725 // that will lead to data corruption or a crash. Because there is no UI for |
689 // the import process, we pass NULL as the window to bring to the foreground | 726 // the import process, we pass NULL as the window to bring to the foreground |
690 // when a CopyData message comes in; this causes the message to be silently | 727 // when a CopyData message comes in; this causes the message to be silently |
691 // discarded, which is the correct behavior during the import process. | 728 // discarded, which is the correct behavior during the import process. |
692 process_singleton->Lock(NULL); | 729 process_singleton->Lock(NULL); |
693 | 730 |
694 scoped_refptr<ImporterHost> importer_host; | 731 scoped_refptr<ImporterHost> importer_host; |
695 // TODO(csilv,mirandac): Out-of-process import has only been qualified on | 732 // TODO(csilv,mirandac): Out-of-process import has only been qualified on |
696 // MacOS X, so we will only use it on that platform since it is required. | 733 // MacOS X and Windows, so we will only use it on those platforms. |
697 // Remove this conditional logic once oop import is qualified for | 734 // Linux still uses the in-process import (http://crbug.com/56816). |
698 // Linux/Windows. http://crbug.com/22142 | 735 #if defined(OS_MACOSX) || defined(OS_WIN) |
699 #if defined(OS_MACOSX) | |
700 importer_host = new ExternalProcessImporterHost; | 736 importer_host = new ExternalProcessImporterHost; |
701 #else | 737 #else |
702 importer_host = new ImporterHost; | 738 importer_host = new ImporterHost; |
703 #endif | 739 #endif |
704 | 740 |
705 base::FilePath local_state_path; | 741 base::FilePath local_state_path; |
706 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); | 742 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); |
707 bool local_state_file_exists = file_util::PathExists(local_state_path); | 743 bool local_state_file_exists = file_util::PathExists(local_state_path); |
708 | 744 |
709 scoped_refptr<ImporterList> importer_list(new ImporterList(NULL)); | 745 scoped_refptr<ImporterList> importer_list(new ImporterList(NULL)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
752 dont_import_items, | 788 dont_import_items, |
753 importer::SEARCH_ENGINES, | 789 importer::SEARCH_ENGINES, |
754 &items); | 790 &items); |
755 SetImportItem(user_prefs, | 791 SetImportItem(user_prefs, |
756 prefs::kImportBookmarks, | 792 prefs::kImportBookmarks, |
757 import_items, | 793 import_items, |
758 dont_import_items, | 794 dont_import_items, |
759 importer::FAVORITES, | 795 importer::FAVORITES, |
760 &items); | 796 &items); |
761 | 797 |
762 profile_import_exited_successfully = | 798 ImportSettings(profile, importer_host, importer_list, items); |
763 internal::ImportSettings(profile, importer_host, importer_list, items); | 799 } |
764 DCHECK(profile_import_exited_successfully); | 800 |
801 if (!import_bookmarks_path.empty()) { | |
802 scoped_refptr<ImporterHost> file_importer_host; | |
803 // TODO(gab): Make Linux use OOP import as well (http://crbug.com/56816) and | |
804 // get rid of these ugly ifdefs. | |
805 #if defined(OS_MACOSX) || defined(OS_WIN) | |
806 file_importer_host = new ExternalProcessImporterHost; | |
807 #else | |
808 file_importer_host = new ImporterHost; | |
809 #endif | |
810 file_importer_host->set_headless(); | |
811 | |
812 ImportFromFile(profile, file_importer_host, import_bookmarks_path); | |
765 } | 813 } |
766 | 814 |
767 content::RecordAction(UserMetricsAction("FirstRunDef_Accept")); | 815 content::RecordAction(UserMetricsAction("FirstRunDef_Accept")); |
768 | 816 |
769 process_singleton->Unlock(); | 817 process_singleton->Unlock(); |
770 #endif // !defined(USE_AURA) | 818 #endif // !defined(USE_AURA) |
771 did_perform_profile_import = true; | 819 g_auto_import_state |= AUTO_IMPORT_CALLED; |
772 } | 820 } |
773 | 821 |
774 void DoPostImportTasks(Profile* profile, bool make_chrome_default) { | 822 void DoPostImportTasks(Profile* profile, bool make_chrome_default) { |
775 if (make_chrome_default && | 823 if (make_chrome_default && |
776 ShellIntegration::CanSetAsDefaultBrowser() == | 824 ShellIntegration::CanSetAsDefaultBrowser() == |
777 ShellIntegration::SET_DEFAULT_UNATTENDED) { | 825 ShellIntegration::SET_DEFAULT_UNATTENDED) { |
778 ShellIntegration::SetAsDefaultBrowser(); | 826 ShellIntegration::SetAsDefaultBrowser(); |
779 } | 827 } |
780 | 828 |
781 #if !defined(USE_AURA) | 829 #if !defined(USE_AURA) |
(...skipping 12 matching lines...) Expand all Loading... | |
794 TemplateURLServiceFactory::GetForProfile(profile); | 842 TemplateURLServiceFactory::GetForProfile(profile); |
795 if (template_url && template_url->GetDefaultSearchProvider()) | 843 if (template_url && template_url->GetDefaultSearchProvider()) |
796 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); | 844 FirstRunBubbleLauncher::ShowFirstRunBubbleSoon(); |
797 SetShouldShowWelcomePage(); | 845 SetShouldShowWelcomePage(); |
798 SetShouldDoPersonalDataManagerFirstRun(); | 846 SetShouldDoPersonalDataManagerFirstRun(); |
799 #endif // !defined(USE_AURA) | 847 #endif // !defined(USE_AURA) |
800 | 848 |
801 internal::DoPostImportPlatformSpecificTasks(); | 849 internal::DoPostImportPlatformSpecificTasks(); |
802 } | 850 } |
803 | 851 |
804 bool DidPerformProfileImport(bool* exited_successfully) { | 852 int GetAutoImportState() { |
805 if (exited_successfully) | 853 return g_auto_import_state; |
806 *exited_successfully = profile_import_exited_successfully; | |
807 return did_perform_profile_import; | |
808 } | 854 } |
809 | 855 |
810 } // namespace first_run | 856 } // namespace first_run |
OLD | NEW |