diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-02 23:23:08 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-02 23:23:08 +0000 |
commit | 58d7bb5fc1d079213e852c28d0557f17907e8ba6 (patch) | |
tree | 8b527c3e7522ee5f8f51b0a788bf33095522302e /chrome | |
parent | a0798ecd866df57352c628ee6adf191a3fdc865e (diff) | |
download | chromium_src-58d7bb5fc1d079213e852c28d0557f17907e8ba6.zip chromium_src-58d7bb5fc1d079213e852c28d0557f17907e8ba6.tar.gz chromium_src-58d7bb5fc1d079213e852c28d0557f17907e8ba6.tar.bz2 |
importer: Factor out StartImportingWithUI() function in its own file.
- Move this function to importer_progress_dialog.h
- Rename it ShowImportProgressDialog.
- Put it under the importer namespace (so the callers can know where it comes from).
- Reorder the parameters to be more easy to read.
- Remove some using declarations.
BUG=None
TEST=importer unit tests and importing works as before.
Review URL: http://codereview.chromium.org/6597095
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76654 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
21 files changed, 205 insertions, 155 deletions
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 07e00b7..9c15ec5 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -3258,7 +3258,7 @@ void TestingAutomationProvider::ImportSettings(Browser* browser, DictionaryValue* args, IPC::Message* reply_message) { // Map from the json string passed over to the import item masks. - std::map<std::string, ImportItem> string_to_import_item; + std::map<std::string, importer::ImportItem> string_to_import_item; string_to_import_item["HISTORY"] = importer::HISTORY; string_to_import_item["FAVORITES"] = importer::FAVORITES; string_to_import_item["COOKIES"] = importer::COOKIES; diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc index 2cb6a45..51805a6 100644 --- a/chrome/browser/first_run/first_run.cc +++ b/chrome/browser/first_run/first_run.cc @@ -4,20 +4,13 @@ #include "chrome/browser/first_run/first_run.h" -#include "build/build_config.h" - -// TODO(port): move more code in back from the first_run_win.cc module. - -#if defined(OS_WIN) -#include "chrome/installer/util/google_update_settings.h" -#include "chrome/installer/util/install_util.h" -#endif - #include "base/command_line.h" #include "base/file_util.h" #include "base/path_service.h" #include "base/utf_string_conversions.h" +#include "build/build_config.h" #include "chrome/browser/importer/importer.h" +#include "chrome/browser/importer/importer_progress_dialog.h" #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/process_singleton.h" @@ -31,6 +24,12 @@ #include "chrome/installer/util/master_preferences_constants.h" #include "chrome/installer/util/util_constants.h" +// TODO(port): move more code in back from the first_run_win.cc module. +#if defined(OS_WIN) +#include "chrome/installer/util/google_update_settings.h" +#include "chrome/installer/util/install_util.h" +#endif + namespace { // The kSentinelFile file absence will tell us it is a first run. @@ -426,25 +425,25 @@ int FirstRun::ImportFromFile(Profile* profile, const CommandLine& cmdline) { return false; } scoped_refptr<ImporterHost> importer_host(new ImporterHost); - FirstRunImportObserver observer; + FirstRunImportObserver importer_observer; importer_host->set_headless(); - ProfileInfo profile_info; + importer::ProfileInfo profile_info; profile_info.browser_type = importer::BOOKMARKS_HTML; profile_info.source_path = file_path; - StartImportingWithUI( + importer::ShowImportProgressDialog( NULL, importer::FAVORITES, importer_host, + &importer_observer, profile_info, profile, - &observer, true); - observer.RunLoop(); - return observer.import_result(); + importer_observer.RunLoop(); + return importer_observer.import_result(); } // static @@ -680,7 +679,8 @@ bool FirstRun::ImportSettings(Profile* profile, scoped_refptr<ImporterHost> importer_host, scoped_refptr<ImporterList> importer_list, int items_to_import) { - const ProfileInfo& source_profile = importer_list->GetSourceProfileInfoAt(0); + const importer::ProfileInfo& source_profile = + importer_list->GetSourceProfileInfoAt(0); // Ensure that importers aren't requested to import items that they do not // support. diff --git a/chrome/browser/first_run/first_run_win.cc b/chrome/browser/first_run/first_run_win.cc index 4f3fe85..43047c40 100644 --- a/chrome/browser/first_run/first_run_win.cc +++ b/chrome/browser/first_run/first_run_win.cc @@ -25,6 +25,7 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_updater.h" #include "chrome/browser/importer/importer.h" +#include "chrome/browser/importer/importer_progress_dialog.h" #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/process_singleton.h" #include "chrome/browser/profiles/profile.h" @@ -550,7 +551,7 @@ int FirstRun::ImportFromBrowser(Profile* profile, return false; } scoped_refptr<ImporterHost> importer_host(new ImporterHost); - FirstRunImportObserver observer; + FirstRunImportObserver importer_observer; scoped_refptr<ImporterList> importer_list(new ImporterList); importer_list->DetectSourceProfilesHack(); @@ -560,16 +561,16 @@ int FirstRun::ImportFromBrowser(Profile* profile, if (skip_first_run_ui > 0) importer_host->set_headless(); - StartImportingWithUI( + importer::ShowImportProgressDialog( parent_window, static_cast<uint16>(items_to_import), importer_host, + &importer_observer, importer_list->GetSourceProfileInfoForBrowserType(browser_type), profile, - &observer, true); - observer.RunLoop(); - return observer.import_result(); + importer_observer.RunLoop(); + return importer_observer.import_result(); } // static diff --git a/chrome/browser/importer/ie_importer.cc b/chrome/browser/importer/ie_importer.cc index d10453c0..abdce9c 100644 --- a/chrome/browser/importer/ie_importer.cc +++ b/chrome/browser/importer/ie_importer.cc @@ -71,7 +71,10 @@ const GUID IEImporter::kPStoreAutocompleteGUID = {0xe161255a, 0x37c3, 0x11d2, const GUID IEImporter::kUnittestGUID = { 0xa79029d6, 0x753e, 0x4e27, {0xb8, 0x7, 0x3d, 0x46, 0xab, 0x15, 0x45, 0xdf}}; -void IEImporter::StartImport(const ProfileInfo& profile_info, +IEImporter::IEImporter() { +} + +void IEImporter::StartImport(const importer::ProfileInfo& profile_info, uint16 items, ImporterBridge* bridge) { bridge_ = bridge; @@ -112,6 +115,9 @@ void IEImporter::StartImport(const ProfileInfo& profile_info, bridge_->NotifyEnded(); } +IEImporter::~IEImporter() { +} + void IEImporter::ImportFavorites() { std::wstring path; diff --git a/chrome/browser/importer/ie_importer.h b/chrome/browser/importer/ie_importer.h index 68b7c23..d1fddb6 100644 --- a/chrome/browser/importer/ie_importer.h +++ b/chrome/browser/importer/ie_importer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -11,17 +11,17 @@ class IEImporter : public Importer { public: - IEImporter() {} + IEImporter(); - // Importer methods. - virtual void StartImport(const ProfileInfo& browser_info, + // Importer: + virtual void StartImport(const importer::ProfileInfo& browser_info, uint16 items, ImporterBridge* bridge); private: FRIEND_TEST_ALL_PREFIXES(ImporterTest, IEImporter); - virtual ~IEImporter() {} + virtual ~IEImporter(); void ImportFavorites(); void ImportHistory(); diff --git a/chrome/browser/importer/importer.h b/chrome/browser/importer/importer.h index 2c25cad..c807d95 100644 --- a/chrome/browser/importer/importer.h +++ b/chrome/browser/importer/importer.h @@ -9,11 +9,10 @@ #include <string> #include <vector> -#include "build/build_config.h" - #include "base/basictypes.h" #include "base/ref_counted.h" #include "base/scoped_ptr.h" +#include "build/build_config.h" #include "chrome/browser/bookmarks/bookmark_model_observer.h" #include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/importer/importer_list.h" @@ -23,31 +22,26 @@ #include "chrome/common/notification_registrar.h" #include "ui/gfx/native_widget_types.h" -using importer::ImportItem; -using importer::ProfileInfo; - class ExternalProcessImporterClient; +class FirefoxProfileLock; +class GURL; +class Importer; class ImporterBridge; class InProcessImporterBridge; -class GURL; class Profile; class Task; class TemplateURL; - struct IE7PasswordInfo; namespace history { -struct ImportedFavIconUsage; class URLRow; +struct ImportedFavIconUsage; } namespace webkit_glue { struct PasswordForm; } -class FirefoxProfileLock; -class Importer; - // This class hosts the importers. It enumerates profiles from other // browsers dynamically, and controls the process of importing. When // the import process is done, ImporterHost deletes itself. @@ -473,19 +467,4 @@ class Importer : public base::RefCountedThreadSafe<Importer> { DISALLOW_COPY_AND_ASSIGN(Importer); }; -class ImporterObserver; - -// Shows a UI for importing and begins importing the specified items from -// source_profile to target_profile. observer is notified when the process is -// complete, can be NULL. parent is the window to parent the UI to, can be NULL -// if there's nothing to parent to. first_run is true if it's invoked in the -// first run UI. -void StartImportingWithUI(gfx::NativeWindow parent_window, - uint16 items, - ImporterHost* coordinator, - const importer::ProfileInfo& source_profile, - Profile* target_profile, - ImporterObserver* observer, - bool first_run); - #endif // CHROME_BROWSER_IMPORTER_IMPORTER_H_ diff --git a/chrome/browser/importer/importer_data_types.h b/chrome/browser/importer/importer_data_types.h index 51376c8..fa2b328 100644 --- a/chrome/browser/importer/importer_data_types.h +++ b/chrome/browser/importer/importer_data_types.h @@ -51,7 +51,7 @@ struct ProfileInfo { ~ProfileInfo(); std::wstring description; - importer::ProfileType browser_type; + ProfileType browser_type; FilePath source_path; FilePath app_path; uint16 services_supported; // Bitmask of ImportItem. @@ -60,4 +60,3 @@ struct ProfileInfo { } // namespace importer #endif // CHROME_BROWSER_IMPORTER_IMPORTER_DATA_TYPES_H_ - diff --git a/chrome/browser/importer/importer_list.cc b/chrome/browser/importer/importer_list.cc index a47e9b4..121ec5f 100644 --- a/chrome/browser/importer/importer_list.cc +++ b/chrome/browser/importer/importer_list.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -32,7 +32,7 @@ namespace { #if defined(OS_WIN) void DetectIEProfiles(std::vector<importer::ProfileInfo*>* profiles) { // IE always exists and doesn't have multiple profiles. - ProfileInfo* ie = new ProfileInfo(); + importer::ProfileInfo* ie = new importer::ProfileInfo(); ie->description = UTF16ToWide(l10n_util::GetStringUTF16(IDS_IMPORT_FROM_IE)); ie->browser_type = importer::MS_IE; ie->source_path.clear(); diff --git a/chrome/browser/importer/importer_progress_dialog.h b/chrome/browser/importer/importer_progress_dialog.h new file mode 100644 index 0000000..d11df70 --- /dev/null +++ b/chrome/browser/importer/importer_progress_dialog.h @@ -0,0 +1,34 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_IMPORTER_IMPORTER_PROGRESS_DIALOG_H_ +#define CHROME_BROWSER_IMPORTER_IMPORTER_PROGRESS_DIALOG_H_ +#pragma once + +#include "ui/gfx/native_widget_types.h" + +class ImporterHost; +class ImporterObserver; +class Profile; + +namespace importer { + +struct ProfileInfo; + +// Shows an UI for importing and begins importing the specified |items| from +// |source_profile| to |target_profile|. |importer_observer| is notified when +// the process is complete, it can be NULL. |parent_window| is the window to +// parent the UI to, it can be NULL if there's nothing to parent to. |first_run| +// is true if it's invoked in the first run UI. +void ShowImportProgressDialog(gfx::NativeWindow parent_window, + uint16 items, + ImporterHost* importer_host, + ImporterObserver* importer_observer, + const ProfileInfo& source_profile, + Profile* target_profile, + bool first_run); + +} // namespace importer + +#endif // CHROME_BROWSER_IMPORTER_IMPORTER_PROGRESS_DIALOG_H_ diff --git a/chrome/browser/importer/importer_unittest.cc b/chrome/browser/importer/importer_unittest.cc index 4bbd161..193a13f 100644 --- a/chrome/browser/importer/importer_unittest.cc +++ b/chrome/browser/importer/importer_unittest.cc @@ -110,7 +110,7 @@ class ImporterTest : public testing::Test { } MessageLoop* loop = MessageLoop::current(); - ProfileInfo profile_info; + importer::ProfileInfo profile_info; profile_info.browser_type = FIREFOX3; profile_info.app_path = app_path_; profile_info.source_path = profile_path_; @@ -420,7 +420,7 @@ TEST_F(ImporterTest, IEImporter) { TestObserver* observer = new TestObserver(); host->SetObserver(observer); - ProfileInfo profile_info; + importer::ProfileInfo profile_info; profile_info.browser_type = MS_IE; profile_info.source_path = test_path_; @@ -699,7 +699,7 @@ TEST_F(ImporterTest, MAYBE(Firefox2Importer)) { scoped_refptr<ImporterHost> host(new ImporterHost); FirefoxObserver* observer = new FirefoxObserver(); host->SetObserver(observer); - ProfileInfo profile_info; + importer::ProfileInfo profile_info; profile_info.browser_type = FIREFOX2; profile_info.app_path = app_path_; profile_info.source_path = profile_path_; diff --git a/chrome/browser/ui/cocoa/importer/import_progress_dialog.mm b/chrome/browser/ui/cocoa/importer/import_progress_dialog.mm index e433abb..c185b31 100644 --- a/chrome/browser/ui/cocoa/importer/import_progress_dialog.mm +++ b/chrome/browser/ui/cocoa/importer/import_progress_dialog.mm @@ -154,13 +154,37 @@ NSString* keyForImportItem(importer::ImportItem item) { @end -void StartImportingWithUI(gfx::NativeWindow parent_window, - uint16 items, - ImporterHost* coordinator, - const importer::ProfileInfo& source_profile, - Profile* target_profile, - ImporterObserver* observer, - bool first_run) { +ImporterObserverBridge::ImporterObserverBridge( + ImportProgressDialogController* owner) + : owner_(owner) {} + +ImporterObserverBridge::~ImporterObserverBridge() {} + +void ImporterObserverBridge::ImportItemStarted(importer::ImportItem item) { + [owner_ ImportItemStarted:item]; +} + +void ImporterObserverBridge::ImportItemEnded(importer::ImportItem item) { + [owner_ ImportItemEnded:item]; +} + +void ImporterObserverBridge::ImportStarted() { + // Not needed for out of process import. +} + +void ImporterObserverBridge::ImportEnded() { + [owner_ ImportEnded]; +} + +namespace importer { + +void ShowImportProgressDialog(gfx::NativeWindow parent_window, + uint16 items, + ImporterHost* importer_host, + ImporterObserver* importer_observer, + const ProfileInfo& source_profile, + Profile* target_profile, + bool first_run) { DCHECK(items != 0); // Retrieve name of browser we're importing from and do a little dance to @@ -170,14 +194,14 @@ void StartImportingWithUI(gfx::NativeWindow parent_window, // progress_dialog_ is responsible for deleting itself. ImportProgressDialogController* progress_dialog_ = [[ImportProgressDialogController alloc] - initWithImporterHost:coordinator + initWithImporterHost:importer_host browserName:import_browser_name - observer:observer + observer:importer_observer itemsEnabled:items]; // Call is async. - coordinator->StartImportSettings(source_profile, target_profile, items, - new ProfileWriter(target_profile), - first_run); + importer_host->StartImportSettings( + source_profile, target_profile, items, new ProfileWriter(target_profile), + first_run); // Display the window while spinning a message loop. // For details on why we need a modal message loop see http://crbug.com/19169 @@ -192,24 +216,4 @@ void StartImportingWithUI(gfx::NativeWindow parent_window, [NSApp endModalSession:session]; } -ImporterObserverBridge::ImporterObserverBridge( - ImportProgressDialogController* owner) - : owner_(owner) {} - -ImporterObserverBridge::~ImporterObserverBridge() {} - -void ImporterObserverBridge::ImportItemStarted(importer::ImportItem item) { - [owner_ ImportItemStarted:item]; -} - -void ImporterObserverBridge::ImportItemEnded(importer::ImportItem item) { - [owner_ ImportItemEnded:item]; -} - -void ImporterObserverBridge::ImportStarted() { - // Not needed for out of process import. -} - -void ImporterObserverBridge::ImportEnded() { - [owner_ ImportEnded]; -} +} // namespace importer diff --git a/chrome/browser/ui/cocoa/importer/import_settings_dialog.mm b/chrome/browser/ui/cocoa/importer/import_settings_dialog.mm index b2fa69a..bba2a2c 100644 --- a/chrome/browser/ui/cocoa/importer/import_settings_dialog.mm +++ b/chrome/browser/ui/cocoa/importer/import_settings_dialog.mm @@ -9,6 +9,7 @@ #include "base/sys_string_conversions.h" #include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/importer/importer_list.h" +#include "chrome/browser/importer/importer_progress_dialog.h" #include "chrome/browser/profiles/profile.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util_mac.h" @@ -191,8 +192,9 @@ bool importSettingsDialogVisible = false; ImporterHost* importerHost = new ExternalProcessImporterHost; // Note that a side effect of the following call is to cause the // importerHost to be disposed once the import has completed. - StartImportingWithUI(nil, servicesToImport, importerHost, - sourceProfile, profile_, nil, false); + importer::ShowImportProgressDialog( + nil, servicesToImport, importerHost, nil, sourceProfile, profile_, + false); } } else { LOG(WARNING) << "There were no settings to import from '" diff --git a/chrome/browser/ui/gtk/importer/import_dialog_gtk.cc b/chrome/browser/ui/gtk/importer/import_dialog_gtk.cc index a0dbed7..6fa3108 100644 --- a/chrome/browser/ui/gtk/importer/import_dialog_gtk.cc +++ b/chrome/browser/ui/gtk/importer/import_dialog_gtk.cc @@ -8,6 +8,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/importer/importer_data_types.h" +#include "chrome/browser/importer/importer_progress_dialog.h" #include "chrome/browser/ui/gtk/gtk_util.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" @@ -144,11 +145,11 @@ void ImportDialogGtk::OnDialogResponse(GtkWidget* widget, int response) { if (items == 0) { ImportCompleted(); } else { - const ProfileInfo& source_profile = + const importer::ProfileInfo& source_profile = importer_list_->GetSourceProfileInfoAt( - gtk_combo_box_get_active(GTK_COMBO_BOX(combo_))); - StartImportingWithUI(parent_, items, importer_host_, - source_profile, profile_, this, false); + gtk_combo_box_get_active(GTK_COMBO_BOX(combo_))); + importer::ShowImportProgressDialog(parent_, items, importer_host_, this, + source_profile, profile_, false); } } else { ImportCanceled(); diff --git a/chrome/browser/ui/gtk/importer/import_progress_dialog_gtk.cc b/chrome/browser/ui/gtk/importer/import_progress_dialog_gtk.cc index 8b0cf90..72871e9 100644 --- a/chrome/browser/ui/gtk/importer/import_progress_dialog_gtk.cc +++ b/chrome/browser/ui/gtk/importer/import_progress_dialog_gtk.cc @@ -35,13 +35,17 @@ void ImportProgressDialogGtk::StartImport( GtkWindow* parent, uint16 items, ImporterHost* importer_host, + ImporterObserver* importer_observer, const importer::ProfileInfo& browser_profile, Profile* profile, - ImporterObserver* observer, bool first_run) { ImportProgressDialogGtk* dialog = new ImportProgressDialogGtk( - WideToUTF16(browser_profile.description), items, importer_host, observer, - parent, browser_profile.browser_type == importer::BOOKMARKS_HTML); + parent, + items, + importer_host, + importer_observer, + WideToUTF16(browser_profile.description), + browser_profile.browser_type == importer::BOOKMARKS_HTML); // In headless mode it means that we don't show the progress window, but it // still need it to exist. No user interaction will be required. @@ -52,16 +56,17 @@ void ImportProgressDialogGtk::StartImport( browser_profile, profile, items, new ProfileWriter(profile), first_run); } -ImportProgressDialogGtk::ImportProgressDialogGtk(const string16& source_profile, - uint16 items, - ImporterHost* importer_host, - ImporterObserver* observer, - GtkWindow* parent, - bool bookmarks_import) +ImportProgressDialogGtk::ImportProgressDialogGtk( + GtkWindow* parent, + uint16 items, + ImporterHost* importer_host, + ImporterObserver* importer_observer, + const string16& source_profile, + bool bookmarks_import) : parent_(parent), items_(items), importer_host_(importer_host), - importer_observer_(observer), + importer_observer_(importer_observer), importing_(true) { importer_host_->SetObserver(this); @@ -209,15 +214,19 @@ void ImportProgressDialogGtk::ImportEnded() { CloseDialog(); } -void StartImportingWithUI(GtkWindow* parent, - uint16 items, - ImporterHost* importer_host, - const importer::ProfileInfo& browser_profile, - Profile* profile, - ImporterObserver* observer, - bool first_run) { +namespace importer { + +void ShowImportProgressDialog(GtkWindow* parent, + uint16 items, + ImporterHost* importer_host, + ImporterObserver* importer_observer, + const ProfileInfo& browser_profile, + Profile* profile, + bool first_run) { DCHECK_NE(0, items); ImportProgressDialogGtk::StartImport( - parent, items, importer_host, browser_profile, profile, observer, + parent, items, importer_host, importer_observer, browser_profile, profile, first_run); } + +} // namespace importer diff --git a/chrome/browser/ui/gtk/importer/import_progress_dialog_gtk.h b/chrome/browser/ui/gtk/importer/import_progress_dialog_gtk.h index 951c492..1d6ee17 100644 --- a/chrome/browser/ui/gtk/importer/import_progress_dialog_gtk.h +++ b/chrome/browser/ui/gtk/importer/import_progress_dialog_gtk.h @@ -24,17 +24,17 @@ class ImportProgressDialogGtk : public ImporterHost::Observer { static void StartImport(GtkWindow* parent, uint16 items, ImporterHost* importer_host, - const ProfileInfo& browser_profile, + ImporterObserver* importer_observer, + const importer::ProfileInfo& browser_profile, Profile* profile, - ImporterObserver* observer, bool first_run); private: - ImportProgressDialogGtk(const string16& source_profile, + ImportProgressDialogGtk(GtkWindow* parent, uint16 items, ImporterHost* importer_host, - ImporterObserver* observer, - GtkWindow* parent, + ImporterObserver* importer_observer, + const string16& source_profile, bool bookmarks_import); virtual ~ImportProgressDialogGtk(); diff --git a/chrome/browser/ui/views/importer/importer_progress_view.cc b/chrome/browser/ui/views/importer/importer_progress_view.cc index 3b6ed54..a94900e 100644 --- a/chrome/browser/ui/views/importer/importer_progress_view.cc +++ b/chrome/browser/ui/views/importer/importer_progress_view.cc @@ -6,6 +6,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/importer/importer_observer.h" +#include "chrome/browser/importer/importer_progress_dialog.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" @@ -16,11 +17,11 @@ #include "views/layout/layout_constants.h" #include "views/window/window.h" -ImporterProgressView::ImporterProgressView(const std::wstring& source_name, +ImporterProgressView::ImporterProgressView(HWND parent_window, uint16 items, ImporterHost* importer_host, - ImporterObserver* observer, - HWND parent_window, + ImporterObserver* importer_observer, + const std::wstring& source_name, bool bookmarks_import) : state_bookmarks_(new views::CheckmarkThrobber), state_searches_(new views::CheckmarkThrobber), @@ -40,7 +41,7 @@ ImporterProgressView::ImporterProgressView(const std::wstring& source_name, parent_window_(parent_window), items_(items), importer_host_(importer_host), - importer_observer_(observer), + importer_observer_(importer_observer), importing_(true), bookmarks_import_(bookmarks_import) { std::wstring info_text = bookmarks_import ? @@ -278,19 +279,26 @@ void ImporterProgressView::ImportEnded() { importer_observer_->ImportCompleted(); } -void StartImportingWithUI(HWND parent_window, - uint16 items, - ImporterHost* importer_host, - const ProfileInfo& source_profile, - Profile* target_profile, - ImporterObserver* observer, - bool first_run) { +namespace importer { + +void ShowImportProgressDialog(HWND parent_window, + uint16 items, + ImporterHost* importer_host, + ImporterObserver* importer_observer, + const ProfileInfo& source_profile, + Profile* target_profile, + bool first_run) { DCHECK(items != 0); - ImporterProgressView* v = new ImporterProgressView( - source_profile.description, items, importer_host, observer, parent_window, + ImporterProgressView* progress_view = new ImporterProgressView( + parent_window, + items, + importer_host, + importer_observer, + source_profile.description, source_profile.browser_type == importer::BOOKMARKS_HTML); - views::Window* window = - views::Window::CreateChromeWindow(parent_window, gfx::Rect(), v); + + views::Window* window = views::Window::CreateChromeWindow( + parent_window, gfx::Rect(), progress_view); if (!importer_host->is_headless() && !first_run) window->Show(); @@ -299,3 +307,5 @@ void StartImportingWithUI(HWND parent_window, source_profile, target_profile, items, new ProfileWriter(target_profile), first_run); } + +} // namespace importer diff --git a/chrome/browser/ui/views/importer/importer_progress_view.h b/chrome/browser/ui/views/importer/importer_progress_view.h index b6cfc74..43b9b19 100644 --- a/chrome/browser/ui/views/importer/importer_progress_view.h +++ b/chrome/browser/ui/views/importer/importer_progress_view.h @@ -28,11 +28,11 @@ class ImporterProgressView : public views::View, // |items| is a bitmask of ImportItems being imported. // |bookmark_import| is true if we're importing bookmarks from a // bookmarks.html file. - ImporterProgressView(const std::wstring& source_name, + ImporterProgressView(HWND parent_window, uint16 items, ImporterHost* importer_host, - ImporterObserver* observer, - HWND parent_window, + ImporterObserver* importer_observer, + const std::wstring& source_name, bool bookmarks_import); virtual ~ImporterProgressView(); diff --git a/chrome/browser/ui/views/importer/importer_view.cc b/chrome/browser/ui/views/importer/importer_view.cc index edaf08d..48b91f5 100644 --- a/chrome/browser/ui/views/importer/importer_view.cc +++ b/chrome/browser/ui/views/importer/importer_view.cc @@ -10,6 +10,7 @@ #include "chrome/browser/browser_window.h" #include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/importer/importer_list.h" +#include "chrome/browser/importer/importer_progress_dialog.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "ui/base/l10n/l10n_util.h" @@ -25,9 +26,8 @@ using views::GridLayout; namespace browser { -// Declared in browser_dialogs.h so caller's don't have to depend on our header. -void ShowImporterView(views::Widget* parent, - Profile* profile) { +// Declared in browser_dialogs.h so callers don't have to depend on our header. +void ShowImporterView(views::Widget* parent, Profile* profile) { views::Window::CreateChromeWindow(parent->GetNativeView(), gfx::Rect(), new ImporterView(profile, importer::ALL))->Show(); } @@ -99,13 +99,16 @@ bool ImporterView::Accept() { if (!IsDialogButtonEnabled(MessageBoxFlags::DIALOGBUTTON_OK)) return false; - uint16 items = GetCheckedItems(); - int selected_index = profile_combobox_->selected_item(); - StartImportingWithUI(GetWidget()->GetNativeView(), items, - importer_host_.get(), - importer_list_->GetSourceProfileInfoAt(selected_index), - profile_, this, false); + importer::ShowImportProgressDialog( + GetWidget()->GetNativeView(), + GetCheckedItems(), + importer_host_.get(), + this, + importer_list_->GetSourceProfileInfoAt(selected_index), + profile_, + false); + // We return false here to prevent the window from being closed. We will be // notified back by our implementation of ImporterObserver when the import is // complete so that we can close ourselves. diff --git a/chrome/browser/ui/webui/options/import_data_handler.cc b/chrome/browser/ui/webui/options/import_data_handler.cc index 8f914e9..aaceaa1 100644 --- a/chrome/browser/ui/webui/options/import_data_handler.cc +++ b/chrome/browser/ui/webui/options/import_data_handler.cc @@ -87,7 +87,7 @@ void ImportDataHandler::ImportData(const ListValue* args) { selected_items |= importer::SEARCH_ENGINES; } - const ProfileInfo& source_profile = + const importer::ProfileInfo& source_profile = importer_list_->GetSourceProfileInfoAt(browser_index); uint16 supported_items = source_profile.services_supported; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 6b20d38..c8c1e07 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1230,6 +1230,8 @@ 'browser/importer/importer_messages.cc', 'browser/importer/importer_messages.h', 'browser/importer/importer_messages_internal.h', + 'browser/importer/importer_observer.h', + 'browser/importer/importer_progress_dialog.h', 'browser/importer/mork_reader.cc', 'browser/importer/mork_reader.h', 'browser/importer/nss_decryptor.cc', diff --git a/chrome/profile_import/profile_import_thread.cc b/chrome/profile_import/profile_import_thread.cc index f7a665b..d012d13 100644 --- a/chrome/profile_import/profile_import_thread.cc +++ b/chrome/profile_import/profile_import_thread.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -49,7 +49,7 @@ bool ProfileImportThread::OnControlMessageReceived(const IPC::Message& msg) { } void ProfileImportThread::OnImportStart( - const ProfileInfo& profile_info, + const importer::ProfileInfo& profile_info, int items, const DictionaryValue& localized_strings, bool import_to_bookmark_bar) { @@ -95,11 +95,11 @@ void ProfileImportThread::OnImportItemFinished(uint16 item) { NotifyEnded(); } -void ProfileImportThread::NotifyItemStarted(ImportItem item) { +void ProfileImportThread::NotifyItemStarted(importer::ImportItem item) { Send(new ProfileImportProcessHostMsg_ImportItem_Started(item)); } -void ProfileImportThread::NotifyItemEnded(ImportItem item) { +void ProfileImportThread::NotifyItemEnded(importer::ImportItem item) { Send(new ProfileImportProcessHostMsg_ImportItem_Finished(item)); } |