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

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

Issue 3223010: Add search engine selection dialog for Mac.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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
« no previous file with comments | « chrome/browser/first_run/first_run.h ('k') | chrome/browser/first_run/first_run_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 // TODO(port): move more code in back from the first_run_win.cc module. 9 // TODO(port): move more code in back from the first_run_win.cc module.
10 10
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 void FirstRunImportObserver::RunLoop() { 454 void FirstRunImportObserver::RunLoop() {
455 loop_running_ = true; 455 loop_running_ = true;
456 MessageLoop::current()->Run(); 456 MessageLoop::current()->Run();
457 } 457 }
458 458
459 void FirstRunImportObserver::Finish() { 459 void FirstRunImportObserver::Finish() {
460 if (loop_running_) 460 if (loop_running_)
461 MessageLoop::current()->Quit(); 461 MessageLoop::current()->Quit();
462 } 462 }
463 463
464 // TODO(avi): port the relevant pieces and enable this.
465 #if !defined(OS_MACOSX)
466 // static 464 // static
467 void FirstRun::AutoImport( 465 void FirstRun::AutoImport(
468 Profile* profile, 466 Profile* profile,
469 bool homepage_defined, 467 bool homepage_defined,
470 int import_items, 468 int import_items,
471 int dont_import_items, 469 int dont_import_items,
472 bool search_engine_experiment, 470 bool search_engine_experiment,
473 bool randomize_search_engine_experiment, 471 bool randomize_search_engine_experiment,
474 bool make_chrome_default, 472 bool make_chrome_default,
475 ProcessSingleton* process_singleton) { 473 ProcessSingleton* process_singleton) {
476 // We need to avoid dispatching new tabs when we are importing because 474 // We need to avoid dispatching new tabs when we are importing because
477 // that will lead to data corruption or a crash. Because there is no UI for 475 // that will lead to data corruption or a crash. Because there is no UI for
478 // the import process, we pass NULL as the window to bring to the foreground 476 // the import process, we pass NULL as the window to bring to the foreground
479 // when a CopyData message comes in; this causes the message to be silently 477 // when a CopyData message comes in; this causes the message to be silently
480 // discarded, which is the correct behavior during the import process. 478 // discarded, which is the correct behavior during the import process.
481 process_singleton->Lock(NULL); 479 process_singleton->Lock(NULL);
482 480
483 PlatformSetup(); 481 PlatformSetup();
484 482
485 FilePath local_state_path; 483 FilePath local_state_path;
486 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path); 484 PathService::Get(chrome::FILE_LOCAL_STATE, &local_state_path);
487 bool local_state_file_exists = file_util::PathExists(local_state_path); 485 bool local_state_file_exists = file_util::PathExists(local_state_path);
488 486
489 scoped_refptr<ImporterHost> importer_host; 487 scoped_refptr<ImporterHost> importer_host;
490 importer_host = new ImporterHost(); 488 // TODO(csilv,mirandac): Out-of-process import has only been qualified on
489 // MacOS X, so we will only use it on that platform since it is required.
490 // Remove this conditional logic once oop import is qualified for
491 // Linux/Windows. http://crbug.com/22142
492 #if defined(OS_MACOSX)
493 importer_host = new ExternalProcessImporterHost;
494 #else
495 importer_host = new ImporterHost;
496 #endif
491 // Do import if there is an available profile for us to import. 497 // Do import if there is an available profile for us to import.
492 if (importer_host->GetAvailableProfileCount() > 0) { 498 if (importer_host->GetAvailableProfileCount() > 0) {
493 // Don't show the warning dialog if import fails. 499 // Don't show the warning dialog if import fails.
494 importer_host->set_headless(); 500 importer_host->set_headless();
495 int items = 0; 501 int items = 0;
496 502
497 // History is always imported unless turned off in master_preferences. 503 // History is always imported unless turned off in master_preferences.
498 if (!(dont_import_items & importer::HISTORY)) 504 if (!(dont_import_items & importer::HISTORY))
499 items = items | importer::HISTORY; 505 items = items | importer::HISTORY;
500 // Home page is imported in organic builds only unless turned off or 506 // Home page is imported in organic builds only unless turned off or
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 ShellIntegration::SetAsDefaultBrowser(); 546 ShellIntegration::SetAsDefaultBrowser();
541 547
542 FirstRun::SetShowFirstRunBubblePref(true); 548 FirstRun::SetShowFirstRunBubblePref(true);
543 // Set the first run bubble to minimal. 549 // Set the first run bubble to minimal.
544 FirstRun::SetMinimalFirstRunBubblePref(); 550 FirstRun::SetMinimalFirstRunBubblePref();
545 FirstRun::SetShowWelcomePagePref(); 551 FirstRun::SetShowWelcomePagePref();
546 552
547 process_singleton->Unlock(); 553 process_singleton->Unlock();
548 FirstRun::CreateSentinel(); 554 FirstRun::CreateSentinel();
549 } 555 }
550 #endif // !defined(OS_MACOSX) 556
557 #if defined(OS_POSIX)
558 namespace {
559
560 // This class acts as an observer for the ImporterHost::Observer::ImportEnded
561 // callback. When the import process is started, certain errors may cause
562 // ImportEnded() to be called synchronously, but the typical case is that
563 // ImportEnded() is called asynchronously. Thus we have to handle both cases.
564 class ImportEndedObserver : public ImporterHost::Observer {
565 public:
566 ImportEndedObserver() : ended_(false),
567 should_quit_message_loop_(false) {}
568 virtual ~ImportEndedObserver() {}
569
570 virtual void ImportItemStarted(importer::ImportItem item) {}
571 virtual void ImportItemEnded(importer::ImportItem item) {}
572 virtual void ImportStarted() {}
573 virtual void ImportEnded() {
574 ended_ = true;
575 if (should_quit_message_loop_)
576 MessageLoop::current()->Quit();
577 }
578
579 void set_should_quit_message_loop() {
580 should_quit_message_loop_ = true;
581 }
582
583 bool ended() {
584 return ended_;
585 }
586
587 private:
588 // Set if the import has ended.
589 bool ended_;
590
591 // Set by the client (via set_should_quit_message_loop) if, when the import
592 // ends, this class should quit the message loop.
593 bool should_quit_message_loop_;
594 };
595
596 } // namespace
597
598 // static
599 bool FirstRun::ImportSettings(Profile* profile,
600 scoped_refptr<ImporterHost> importer_host,
601 int items_to_import) {
602 const ProfileInfo& source_profile = importer_host->GetSourceProfileInfoAt(0);
603
604 // Ensure that importers aren't requested to import items that they do not
605 // support.
606 items_to_import &= source_profile.services_supported;
607
608 scoped_ptr<ImportEndedObserver> observer(new ImportEndedObserver);
609 importer_host->SetObserver(observer.get());
610 importer_host->StartImportSettings(source_profile,
611 profile,
612 items_to_import,
613 new ProfileWriter(profile),
614 true);
615 // If the import process has not errored out, block on it.
616 if (!observer->ended()) {
617 observer->set_should_quit_message_loop();
618 MessageLoop::current()->Run();
619 }
620
621 // Unfortunately there's no success/fail signal in ImporterHost.
622 return true;
623 }
624
625 #endif // OS_POSIX
OLDNEW
« no previous file with comments | « chrome/browser/first_run/first_run.h ('k') | chrome/browser/first_run/first_run_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698