diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/first_run.cc | 23 | ||||
-rw-r--r-- | chrome/browser/first_run.h | 2 | ||||
-rw-r--r-- | chrome/browser/importer/importer.cc | 11 | ||||
-rw-r--r-- | chrome/browser/importer/importer.h | 3 | ||||
-rw-r--r-- | chrome/browser/views/first_run_customize_view.cc | 6 | ||||
-rw-r--r-- | chrome/browser/views/first_run_view.cc | 5 |
6 files changed, 34 insertions, 16 deletions
diff --git a/chrome/browser/first_run.cc b/chrome/browser/first_run.cc index dd8182d..6291585 100644 --- a/chrome/browser/first_run.cc +++ b/chrome/browser/first_run.cc @@ -291,7 +291,10 @@ bool FirstRun::ProcessMasterPreferences( if (import_items) { // There is something to import from the default browser. This launches // the importer process and blocks until done or until it fails. - if (!FirstRun::ImportSettings(NULL, 0, import_items, NULL)) { + ImporterHost importer_host; + if (!FirstRun::ImportSettings(NULL, + importer_host.GetSourceProfileInfoAt(0).browser_type, + import_items, NULL)) { LOG(WARNING) << "silent import failed"; } } @@ -498,17 +501,17 @@ class FirstRunImportObserver : public ImportObserver { DISALLOW_EVIL_CONSTRUCTORS(FirstRunImportObserver); }; -std::wstring EncodeImportParams(int browser, int options, HWND window) { - return StringPrintf(L"%d@%d@%d", browser, options, window); +std::wstring EncodeImportParams(int browser_type, int options, HWND window) { + return StringPrintf(L"%d@%d@%d", browser_type, options, window); } bool DecodeImportParams(const std::wstring& encoded, - int* browser, int* options, HWND* window) { + int* browser_type, int* options, HWND* window) { std::vector<std::wstring> v; SplitString(encoded, L'@', &v); if (v.size() != 3) return false; - *browser = static_cast<int>(StringToInt64(v[0])); + *browser_type = static_cast<int>(StringToInt64(v[0])); *options = static_cast<int>(StringToInt64(v[1])); *window = reinterpret_cast<HWND>(StringToInt64(v[2])); return true; @@ -516,7 +519,7 @@ bool DecodeImportParams(const std::wstring& encoded, } // namespace -bool FirstRun::ImportSettings(Profile* profile, int browser, +bool FirstRun::ImportSettings(Profile* profile, int browser_type, int items_to_import, HWND parent_window) { const CommandLine& cmdline = *CommandLine::ForCurrentProcess(); CommandLine import_cmd(cmdline.program()); @@ -535,7 +538,7 @@ bool FirstRun::ImportSettings(Profile* profile, int browser, g_browser_process->GetApplicationLocale()); import_cmd.CommandLine::AppendSwitchWithValue(switches::kImport, - EncodeImportParams(browser, items_to_import, parent_window)); + EncodeImportParams(browser_type, items_to_import, parent_window)); // Time to launch the process that is going to do the import. base::ProcessHandle import_process; @@ -566,10 +569,10 @@ int FirstRun::ImportNow(Profile* profile, const CommandLine& cmdline) { NOTREACHED(); return false; } - int browser = 0; + int browser_type = 0; int items_to_import = 0; HWND parent_window = NULL; - if (!DecodeImportParams(import_info, &browser, &items_to_import, + if (!DecodeImportParams(import_info, &browser_type, &items_to_import, &parent_window)) { NOTREACHED(); return false; @@ -587,7 +590,7 @@ int FirstRun::ImportNow(Profile* profile, const CommandLine& cmdline) { parent_window, items_to_import, importer_host, - importer_host->GetSourceProfileInfoAt(browser), + importer_host->GetSourceProfileInfoForBrowserType(browser_type), profile, &observer, true); diff --git a/chrome/browser/first_run.h b/chrome/browser/first_run.h index 8a8a3eb..bc73622 100644 --- a/chrome/browser/first_run.h +++ b/chrome/browser/first_run.h @@ -39,7 +39,7 @@ class FirstRun { static bool RemoveSentinel(); // Imports settings in a separate process. It spawns a second dedicated // browser process that just does the import with the import progress UI. - static bool ImportSettings(Profile* profile, int browser, + static bool ImportSettings(Profile* profile, int browser_type, int items_to_import, gfx::NativeView parent_window); // Import browser items in this process. The browser and the items to diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc index 7710c83..370ec9e 100644 --- a/chrome/browser/importer/importer.cc +++ b/chrome/browser/importer/importer.cc @@ -630,6 +630,17 @@ const ProfileInfo& ImporterHost::GetSourceProfileInfoAt(int index) const { return *source_profiles_[index]; } +const ProfileInfo& ImporterHost::GetSourceProfileInfoForBrowserType( + int browser_type) const { + int size = source_profiles_.size(); + for (int i = 0; i < size; i++) { + if (source_profiles_[i]->browser_type == browser_type) + return *source_profiles_[i]; + } + NOTREACHED(); + return *(new ProfileInfo()); +} + void ImporterHost::DetectSourceProfiles() { #if defined(OS_WIN) // The order in which detect is called determines the order diff --git a/chrome/browser/importer/importer.h b/chrome/browser/importer/importer.h index 46ce03e..765df3c 100644 --- a/chrome/browser/importer/importer.h +++ b/chrome/browser/importer/importer.h @@ -271,6 +271,9 @@ class ImporterHost : public base::RefCounted<ImporterHost>, // passed to StartImportSettings(). const ProfileInfo& GetSourceProfileInfoAt(int index) const; + // Returns the ProfileInfo with the given browser type + const ProfileInfo& GetSourceProfileInfoForBrowserType(int browser_type) const; + private: // If we're not waiting on any model to finish loading, invokes the task_. void InvokeTaskIfDone(); diff --git a/chrome/browser/views/first_run_customize_view.cc b/chrome/browser/views/first_run_customize_view.cc index a4dbe5d..9b12d57 100644 --- a/chrome/browser/views/first_run_customize_view.cc +++ b/chrome/browser/views/first_run_customize_view.cc @@ -199,9 +199,9 @@ bool FirstRunCustomizeView::Accept() { UserMetrics::RecordAction(L"FirstRunCustom_No_Import", profile_); } else { int browser_selected = import_from_combo_->GetSelectedItem(); - FirstRun::ImportSettings(profile_, browser_selected, - GetDefaultImportItems(), - window()->GetNativeWindow()); + FirstRun::ImportSettings(profile_, + importer_host_->GetSourceProfileInfoAt(browser_selected).browser_type, + GetDefaultImportItems(), window()->GetNativeWindow()); } if (default_browser_->checked()) SetDefaultBrowser(); diff --git a/chrome/browser/views/first_run_view.cc b/chrome/browser/views/first_run_view.cc index 0c94020..198e253 100644 --- a/chrome/browser/views/first_run_view.cc +++ b/chrome/browser/views/first_run_view.cc @@ -181,8 +181,9 @@ bool FirstRunView::Accept() { if (default_browser_->checked()) SetDefaultBrowser(); // Index 0 is the default browser. - FirstRun::ImportSettings(profile_, 0, GetDefaultImportItems(), - window()->GetNativeWindow()); + FirstRun::ImportSettings(profile_, + importer_host_->GetSourceProfileInfoAt(0).browser_type, + GetDefaultImportItems(), window()->GetNativeWindow()); UserMetrics::RecordAction(L"FirstRunDef_Accept", profile_); return true; |