diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-03 00:24:02 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-03 00:24:02 +0000 |
commit | ae46c8c689131bcbb15cec249e543dc91d8a606c (patch) | |
tree | 2bf2793799e45875ad5f9681549c4d0982546d12 /chrome/browser | |
parent | c37683da5aa951af68da88e7cfa8c779fd2864a2 (diff) | |
download | chromium_src-ae46c8c689131bcbb15cec249e543dc91d8a606c.zip chromium_src-ae46c8c689131bcbb15cec249e543dc91d8a606c.tar.gz chromium_src-ae46c8c689131bcbb15cec249e543dc91d8a606c.tar.bz2 |
Importer: Remove ImporterList from ImporterHost and the pass-through methods.
Make callers of ImporterHost that need to enumerate source profiles create
ImporterList directly.
BUG=65638
TEST=none
Review URL: http://codereview.chromium.org/6334060
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@73556 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/automation/testing_automation_provider.cc | 26 | ||||
-rw-r--r-- | chrome/browser/automation/testing_automation_provider.h | 5 | ||||
-rw-r--r-- | chrome/browser/dom_ui/options/import_data_handler.cc | 6 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_bookmarks_module.cc | 22 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_bookmarks_module.h | 14 | ||||
-rw-r--r-- | chrome/browser/first_run/first_run.cc | 18 | ||||
-rw-r--r-- | chrome/browser/first_run/first_run.h | 3 | ||||
-rw-r--r-- | chrome/browser/first_run/first_run_win.cc | 10 | ||||
-rw-r--r-- | chrome/browser/importer/importer.cc | 29 | ||||
-rw-r--r-- | chrome/browser/importer/importer.h | 49 | ||||
-rw-r--r-- | chrome/browser/importer/importer_unittest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/import_dialog_gtk.cc | 14 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/import_dialog_gtk.h | 3 | ||||
-rw-r--r-- | chrome/browser/ui/views/importer_view.cc | 21 | ||||
-rw-r--r-- | chrome/browser/ui/views/importer_view.h | 4 |
15 files changed, 84 insertions, 146 deletions
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 2d86dda..5690dfc 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -166,16 +166,16 @@ TestingAutomationProvider::~TestingAutomationProvider() { } void TestingAutomationProvider::SourceProfilesLoaded() { - DCHECK_NE(static_cast<ImporterHost*>(NULL), importer_host_.get()); + DCHECK_NE(static_cast<ImporterList*>(NULL), importer_list_.get()); // Get the correct ProfileInfo based on the browser the user provided. importer::ProfileInfo profile_info; - int num_browsers = importer_host_->GetAvailableProfileCount(); + int num_browsers = importer_list_->GetAvailableProfileCount(); int i = 0; for ( ; i < num_browsers; i++) { - string16 name = WideToUTF16Hack(importer_host_->GetSourceProfileNameAt(i)); + string16 name = WideToUTF16Hack(importer_list_->GetSourceProfileNameAt(i)); if (name == import_settings_data_.browser_name) { - profile_info = importer_host_->GetSourceProfileInfoAt(i); + profile_info = importer_list_->GetSourceProfileInfoAt(i); break; } } @@ -186,16 +186,17 @@ void TestingAutomationProvider::SourceProfilesLoaded() { return; } - importer_host_->SetObserver( + scoped_refptr<ImporterHost> importer_host(new ImporterHost); + importer_host->SetObserver( new AutomationProviderImportSettingsObserver( this, import_settings_data_.reply_message)); Profile* profile = import_settings_data_.browser->profile(); - importer_host_->StartImportSettings(profile_info, - profile, - import_settings_data_.import_items, - new ProfileWriter(profile), - import_settings_data_.first_run); + importer_host->StartImportSettings(profile_info, + profile, + import_settings_data_.import_items, + new ProfileWriter(profile), + import_settings_data_.first_run); } void TestingAutomationProvider::Observe(NotificationType type, @@ -3166,9 +3167,10 @@ void TestingAutomationProvider::ImportSettings(Browser* browser, import_settings_data_.reply_message = reply_message; // The remaining functionality of importing settings is in - // SourceProfilesLoaded(), which is called by |importer_host_| once the source + // SourceProfilesLoaded(), which is called by |importer_list_| once the source // profiles are loaded. - importer_host_ = new ImporterHost(this); + importer_list_ = new ImporterList; + importer_list_->DetectSourceProfiles(this); } namespace { diff --git a/chrome/browser/automation/testing_automation_provider.h b/chrome/browser/automation/testing_automation_provider.h index 01d2fdc..e4a690c 100644 --- a/chrome/browser/automation/testing_automation_provider.h +++ b/chrome/browser/automation/testing_automation_provider.h @@ -17,7 +17,6 @@ #include "chrome/common/page_type.h" class DictionaryValue; -class ImporterHost; class TemplateURLModel; // This is an automation provider containing testing calls. @@ -830,8 +829,8 @@ class TestingAutomationProvider : public AutomationProvider, NotificationRegistrar registrar_; - // Used to import settings from browser profiles. - scoped_refptr<ImporterHost> importer_host_; + // Used to enumerate browser profiles. + scoped_refptr<ImporterList> importer_list_; // The stored data for the ImportSettings operation. ImportSettingsData import_settings_data_; diff --git a/chrome/browser/dom_ui/options/import_data_handler.cc b/chrome/browser/dom_ui/options/import_data_handler.cc index 4db124d..09cad9da 100644 --- a/chrome/browser/dom_ui/options/import_data_handler.cc +++ b/chrome/browser/dom_ui/options/import_data_handler.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. @@ -106,9 +106,9 @@ void ImportDataHandler::ImportData(const ListValue* args) { // conditional logic once oop import is qualified for Linux/Windows. // http://crbug.com/22142 #if defined(OS_MACOSX) - importer_host_ = new ExternalProcessImporterHost(this); + importer_host_ = new ExternalProcessImporterHost; #else - importer_host_ = new ImporterHost(this); + importer_host_ = new ImporterHost; #endif importer_host_->SetObserver(this); Profile* profile = dom_ui_->GetProfile(); diff --git a/chrome/browser/extensions/extension_bookmarks_module.cc b/chrome/browser/extensions/extension_bookmarks_module.cc index bab5412..619f332 100644 --- a/chrome/browser/extensions/extension_bookmarks_module.cc +++ b/chrome/browser/extensions/extension_bookmarks_module.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. @@ -802,21 +802,15 @@ bool ImportBookmarksFunction::RunImpl() { void ImportBookmarksFunction::FileSelected(const FilePath& path, int index, void* params) { - source_path_ = path; - importer_host_ = new ImporterHost(this); - // SourceProfilesLoaded() will be called once the Importer has loaded the list - // of source profiles. -} - -void ImportBookmarksFunction::SourceProfilesLoaded() { + scoped_refptr<ImporterHost> importer_host(new ImporterHost); importer::ProfileInfo profile_info; profile_info.browser_type = importer::BOOKMARKS_HTML; - profile_info.source_path = source_path_; - importer_host_->StartImportSettings(profile_info, - profile(), - importer::FAVORITES, - new ProfileWriter(profile()), - true); + profile_info.source_path = path; + importer_host->StartImportSettings(profile_info, + profile(), + importer::FAVORITES, + new ProfileWriter(profile()), + true); Release(); // Balanced in BookmarksIOFunction::SelectFile() } diff --git a/chrome/browser/extensions/extension_bookmarks_module.h b/chrome/browser/extensions/extension_bookmarks_module.h index 60e79f6..83a1c8d 100644 --- a/chrome/browser/extensions/extension_bookmarks_module.h +++ b/chrome/browser/extensions/extension_bookmarks_module.h @@ -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. @@ -191,23 +191,13 @@ class BookmarksIOFunction : public BookmarksFunction, scoped_refptr<SelectFileDialog> select_file_dialog_; }; -class ImportBookmarksFunction : public BookmarksIOFunction, - public ImporterList::Observer { +class ImportBookmarksFunction : public BookmarksIOFunction { public: // BookmarkManagerIOFunction implementation. virtual bool RunImpl(); virtual void FileSelected(const FilePath& path, int index, void* params); - // ImporterList::Observer implementation. - virtual void SourceProfilesLoaded(); - private: - // The selected file path used to import bookmarks from. - FilePath source_path_; - - // The ImporterHost used to import the bookmarks. - scoped_refptr<ImporterHost> importer_host_; - DECLARE_EXTENSION_FUNCTION_NAME("bookmarks.import"); }; diff --git a/chrome/browser/first_run/first_run.cc b/chrome/browser/first_run/first_run.cc index 5b7033e..e8514b8 100644 --- a/chrome/browser/first_run/first_run.cc +++ b/chrome/browser/first_run/first_run.cc @@ -281,9 +281,10 @@ bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir, if (out_prefs->do_import_items || !import_bookmarks_path.empty()) { // There is something to import from the default browser. This launches // the importer process and blocks until done or until it fails. - scoped_refptr<ImporterHost> importer_host = new ImporterHost(); + scoped_refptr<ImporterList> importer_list(new ImporterList); + importer_list->DetectSourceProfilesHack(); if (!FirstRun::ImportSettings(NULL, - importer_host->GetSourceProfileInfoAt(0).browser_type, + importer_list->GetSourceProfileInfoAt(0).browser_type, out_prefs->do_import_items, FilePath::FromWStringHack(UTF8ToWide(import_bookmarks_path)), true, NULL)) { @@ -422,7 +423,7 @@ int FirstRun::ImportFromFile(Profile* profile, const CommandLine& cmdline) { NOTREACHED(); return false; } - scoped_refptr<ImporterHost> importer_host(new ImporterHost()); + scoped_refptr<ImporterHost> importer_host(new ImporterHost); FirstRunImportObserver observer; importer_host->set_headless(); @@ -556,8 +557,12 @@ void FirstRun::AutoImport( #else importer_host = new ImporterHost; #endif + + scoped_refptr<ImporterList> importer_list(new ImporterList); + importer_list->DetectSourceProfilesHack(); + // Do import if there is an available profile for us to import. - if (importer_host->GetAvailableProfileCount() > 0) { + if (importer_list->GetAvailableProfileCount() > 0) { // Don't show the warning dialog if import fails. importer_host->set_headless(); int items = 0; @@ -590,7 +595,7 @@ void FirstRun::AutoImport( if (import_items & importer::FAVORITES) items = items | importer::FAVORITES; - ImportSettings(profile, importer_host, items); + ImportSettings(profile, importer_host, importer_list, items); } UserMetrics::RecordAction(UserMetricsAction("FirstRunDef_Accept")); @@ -666,8 +671,9 @@ class ImportEndedObserver : public ImporterHost::Observer { // static bool FirstRun::ImportSettings(Profile* profile, scoped_refptr<ImporterHost> importer_host, + scoped_refptr<ImporterList> importer_list, int items_to_import) { - const ProfileInfo& source_profile = importer_host->GetSourceProfileInfoAt(0); + const 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.h b/chrome/browser/first_run/first_run.h index 415753f..c0a31ba 100644 --- a/chrome/browser/first_run/first_run.h +++ b/chrome/browser/first_run/first_run.h @@ -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. @@ -122,6 +122,7 @@ class FirstRun { // success. static bool ImportSettings(Profile* profile, scoped_refptr<ImporterHost> importer_host, + scoped_refptr<ImporterList> importer_list, int items_to_import); // Sets the kShouldShowFirstRunBubble local state pref so that the browser diff --git a/chrome/browser/first_run/first_run_win.cc b/chrome/browser/first_run/first_run_win.cc index 635882e..b25f7ac 100644 --- a/chrome/browser/first_run/first_run_win.cc +++ b/chrome/browser/first_run/first_run_win.cc @@ -524,10 +524,11 @@ bool FirstRun::ImportSettings(Profile* profile, int browser_type, // static bool FirstRun::ImportSettings(Profile* profile, scoped_refptr<ImporterHost> importer_host, + scoped_refptr<ImporterList> importer_list, int items_to_import) { return ImportSettings( profile, - importer_host->GetSourceProfileInfoAt(0).browser_type, + importer_list->GetSourceProfileInfoAt(0).browser_type, items_to_import, FilePath(), false, NULL); } @@ -548,9 +549,12 @@ int FirstRun::ImportFromBrowser(Profile* profile, NOTREACHED(); return false; } - scoped_refptr<ImporterHost> importer_host = new ImporterHost(); + scoped_refptr<ImporterHost> importer_host(new ImporterHost); FirstRunImportObserver observer; + scoped_refptr<ImporterList> importer_list(new ImporterList); + importer_list->DetectSourceProfilesHack(); + // If |skip_first_run_ui|, we run in headless mode. This means that if // there is user action required the import is automatically canceled. if (skip_first_run_ui > 0) @@ -560,7 +564,7 @@ int FirstRun::ImportFromBrowser(Profile* profile, parent_window, static_cast<uint16>(items_to_import), importer_host, - importer_host->GetSourceProfileInfoForBrowserType(browser_type), + importer_list->GetSourceProfileInfoForBrowserType(browser_type), profile, &observer, true); diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc index bb3b237..b41efef 100644 --- a/chrome/browser/importer/importer.cc +++ b/chrome/browser/importer/importer.cc @@ -88,28 +88,10 @@ ImporterHost::ImporterHost() installed_bookmark_observer_(false), is_source_readable_(true), headless_(false), - parent_window_(NULL), - importer_list_(new ImporterList) { - importer_list_->DetectSourceProfilesHack(); -} - -ImporterHost::ImporterHost(ImporterList::Observer* observer) - : profile_(NULL), - observer_(NULL), - task_(NULL), - importer_(NULL), - waiting_for_bookmarkbar_model_(false), - installed_bookmark_observer_(false), - is_source_readable_(true), - headless_(false), - parent_window_(NULL), - importer_list_(new ImporterList) { - importer_list_->DetectSourceProfiles(observer); + parent_window_(NULL) { } ImporterHost::~ImporterHost() { - importer_list_->SetObserver(NULL); - if (NULL != importer_) importer_->Release(); @@ -329,15 +311,6 @@ ExternalProcessImporterHost::ExternalProcessImporterHost() import_process_launched_(false) { } -ExternalProcessImporterHost::ExternalProcessImporterHost( - ImporterList::Observer* observer) - : ImporterHost(observer), - items_(0), - import_to_bookmark_bar_(false), - cancelled_(false), - import_process_launched_(false) { -} - void ExternalProcessImporterHost::Loaded(BookmarkModel* model) { DCHECK(model->IsLoaded()); model->RemoveObserver(this); diff --git a/chrome/browser/importer/importer.h b/chrome/browser/importer/importer.h index e994036..7c53772 100644 --- a/chrome/browser/importer/importer.h +++ b/chrome/browser/importer/importer.h @@ -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. @@ -76,15 +76,8 @@ class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>, virtual ~Observer() {} }; - // DEPRECATED: Calls the synchronous version of - // ImporterList::DetectSourceProfiles. - // TODO(jhawkins): Remove this constructor once all callers are fixed. - // See http://crbug.com/65633 and http://crbug.com/65638. ImporterHost(); - // |observer| must not be NULL. - explicit ImporterHost(ImporterList::Observer* observer); - // BookmarkModelObserver implementation. virtual void Loaded(BookmarkModel* model); virtual void BookmarkNodeMoved(BookmarkModel* model, @@ -162,33 +155,6 @@ class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>, virtual void ImportItemEnded(importer::ImportItem item); virtual void ImportEnded(); - int GetAvailableProfileCount() const { - return importer_list_->GetAvailableProfileCount(); - } - - // Returns the name of the profile at the 'index' slot. The profiles are - // ordered such that the profile at index 0 is the likely default browser. - std::wstring GetSourceProfileNameAt(int index) const { - return importer_list_->GetSourceProfileNameAt(index); - } - - // Returns the ProfileInfo at the specified index. The ProfileInfo should be - // passed to StartImportSettings(). - const importer::ProfileInfo& GetSourceProfileInfoAt(int index) const { - return importer_list_->GetSourceProfileInfoAt(index); - } - - // Returns the ProfileInfo with the given browser type. - const importer::ProfileInfo& GetSourceProfileInfoForBrowserType( - int browser_type) const { - return importer_list_->GetSourceProfileInfoForBrowserType(browser_type); - } - - // Returns true if the source profiles have been loaded. - bool source_profiles_loaded() const { - return importer_list_->source_profiles_loaded(); - } - protected: friend class base::RefCountedThreadSafe<ImporterHost>; @@ -255,24 +221,15 @@ class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>, // complete. virtual void InvokeTaskIfDone(); - // Used to create an importer of the appropriate type. - scoped_refptr<ImporterList> importer_list_; - DISALLOW_COPY_AND_ASSIGN(ImporterHost); }; -// This class manages the import process. It creates the in-process half of -// the importer bridge and the external process importer client. +// This class manages the import process. It creates the in-process half of the +// importer bridge and the external process importer client. class ExternalProcessImporterHost : public ImporterHost { public: - // DEPRECATED: Calls the deprecated ImporterHost constructor. - // TODO(jhawkins): Remove this constructor once all callers are fixed. - // See http://crbug.com/65633 and http://crbug.com/65638. ExternalProcessImporterHost(); - // |observer| must not be NULL. - explicit ExternalProcessImporterHost(ImporterList::Observer* observer); - // Called when the BookmarkModel has finished loading. Calls InvokeTaskIfDone // to start importing. virtual void Loaded(BookmarkModel* model); diff --git a/chrome/browser/importer/importer_unittest.cc b/chrome/browser/importer/importer_unittest.cc index 2117619..cfca4de 100644 --- a/chrome/browser/importer/importer_unittest.cc +++ b/chrome/browser/importer/importer_unittest.cc @@ -114,7 +114,7 @@ class ImporterTest : public testing::Test { profile_info.browser_type = FIREFOX3; profile_info.app_path = app_path_; profile_info.source_path = profile_path_; - scoped_refptr<ImporterHost> host(new ImporterHost()); + scoped_refptr<ImporterHost> host(new ImporterHost); host->SetObserver(observer); int items = HISTORY | PASSWORDS | FAVORITES; if (import_search_plugins) @@ -416,7 +416,7 @@ TEST_F(ImporterTest, IEImporter) { // Starts to import the above settings. MessageLoop* loop = MessageLoop::current(); - scoped_refptr<ImporterHost> host = new ImporterHost(); + scoped_refptr<ImporterHost> host(new ImporterHost); TestObserver* observer = new TestObserver(); host->SetObserver(observer); @@ -696,7 +696,7 @@ TEST_F(ImporterTest, MAYBE(Firefox2Importer)) { ASSERT_TRUE(file_util::CopyDirectory(data_path, search_engine_path, false)); MessageLoop* loop = MessageLoop::current(); - scoped_refptr<ImporterHost> host(new ImporterHost()); + scoped_refptr<ImporterHost> host(new ImporterHost); FirefoxObserver* observer = new FirefoxObserver(); host->SetObserver(observer); ProfileInfo profile_info; diff --git a/chrome/browser/ui/gtk/import_dialog_gtk.cc b/chrome/browser/ui/gtk/import_dialog_gtk.cc index 10d77aa..4627cee 100644 --- a/chrome/browser/ui/gtk/import_dialog_gtk.cc +++ b/chrome/browser/ui/gtk/import_dialog_gtk.cc @@ -44,8 +44,12 @@ ImportDialogGtk::ImportDialogGtk(GtkWindow* parent, Profile* profile, int initial_state) : parent_(parent), profile_(profile), - importer_host_(new ImporterHost(this)), + importer_host_(new ImporterHost), + ALLOW_THIS_IN_INITIALIZER_LIST(importer_list_(new ImporterList)), initial_state_(initial_state) { + // Load the available source profiles. + importer_list_->DetectSourceProfiles(this); + // Build the dialog. std::string dialog_name = l10n_util::GetStringUTF8( IDS_IMPORT_SETTINGS_TITLE); @@ -150,12 +154,12 @@ ImportDialogGtk::~ImportDialogGtk() { void ImportDialogGtk::SourceProfilesLoaded() { // Detect any supported browsers that we can import from and fill // up the combo box. If none found, disable all controls except cancel. - int profiles_count = importer_host_->GetAvailableProfileCount(); + int profiles_count = importer_list_->GetAvailableProfileCount(); SetDialogControlsSensitive(profiles_count != 0); gtk_combo_box_remove_text(GTK_COMBO_BOX(combo_), 0); if (profiles_count > 0) { for (int i = 0; i < profiles_count; i++) { - std::wstring profile = importer_host_->GetSourceProfileNameAt(i); + std::wstring profile = importer_list_->GetSourceProfileNameAt(i); gtk_combo_box_append_text(GTK_COMBO_BOX(combo_), WideToUTF8(profile).c_str()); } @@ -175,9 +179,9 @@ void ImportDialogGtk::OnDialogResponse(GtkWidget* widget, int response) { ImportComplete(); } else { const ProfileInfo& source_profile = - importer_host_->GetSourceProfileInfoAt( + importer_list_->GetSourceProfileInfoAt( gtk_combo_box_get_active(GTK_COMBO_BOX(combo_))); - StartImportingWithUI(parent_, items, importer_host_.get(), + StartImportingWithUI(parent_, items, importer_host_, source_profile, profile_, this, false); } } else { diff --git a/chrome/browser/ui/gtk/import_dialog_gtk.h b/chrome/browser/ui/gtk/import_dialog_gtk.h index c7cf8b4..05ad215 100644 --- a/chrome/browser/ui/gtk/import_dialog_gtk.h +++ b/chrome/browser/ui/gtk/import_dialog_gtk.h @@ -78,6 +78,9 @@ class ImportDialogGtk : public ImportObserver, // Utility class that does the actual import. scoped_refptr<ImporterHost> importer_host_; + // Enumerates the source profiles. + scoped_refptr<ImporterList> importer_list_; + int initial_state_; // Helper object to manage accessibility metadata. diff --git a/chrome/browser/ui/views/importer_view.cc b/chrome/browser/ui/views/importer_view.cc index abb5ace..5e623752 100644 --- a/chrome/browser/ui/views/importer_view.cc +++ b/chrome/browser/ui/views/importer_view.cc @@ -9,6 +9,7 @@ #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/importer/importer_data_types.h" +#include "chrome/browser/importer/importer_list.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "ui/base/l10n/l10n_util.h" @@ -42,9 +43,11 @@ ImporterView::ImporterView(Profile* profile, int initial_state) passwords_checkbox_(NULL), search_engines_checkbox_(NULL), profile_(profile), - ALLOW_THIS_IN_INITIALIZER_LIST(importer_host_(new ImporterHost(this))), + importer_host_(new ImporterHost), + importer_list_(new ImporterList), initial_state_(initial_state) { DCHECK(profile); + importer_list_->DetectSourceProfiles(this); SetupControl(); } @@ -158,7 +161,7 @@ bool ImporterView::Accept() { int selected_index = profile_combobox_->selected_item(); StartImportingWithUI(GetWidget()->GetNativeView(), items, importer_host_.get(), - importer_host_->GetSourceProfileInfoAt(selected_index), + importer_list_->GetSourceProfileInfoAt(selected_index), profile_, this, false); // We return false here to prevent the window from being closed. We will be // notified back by our implementation of ImportObserver when the import is @@ -185,22 +188,22 @@ int ImporterView::GetItemCount() { string16 ImporterView::GetItemAt(int index) { DCHECK(importer_host_.get()); - if (!importer_host_->source_profiles_loaded()) + if (!importer_list_->source_profiles_loaded()) return l10n_util::GetStringUTF16(IDS_IMPORT_LOADING_PROFILES); else - return WideToUTF16Hack(importer_host_->GetSourceProfileNameAt(index)); + return WideToUTF16Hack(importer_list_->GetSourceProfileNameAt(index)); } void ImporterView::ItemChanged(views::Combobox* combobox, int prev_index, int new_index) { DCHECK(combobox); DCHECK(checkbox_items_.size() >= - static_cast<size_t>(importer_host_->GetAvailableProfileCount())); + static_cast<size_t>(importer_list_->GetAvailableProfileCount())); if (prev_index == new_index) return; - if (!importer_host_->source_profiles_loaded()) { + if (!importer_list_->source_profiles_loaded()) { SetCheckedItemsState(0); return; } @@ -210,7 +213,7 @@ void ImporterView::ItemChanged(views::Combobox* combobox, checkbox_items_[prev_index] = prev_items; // Enable/Disable the checkboxes for this Item - uint16 new_enabled_items = importer_host_->GetSourceProfileInfoAt( + uint16 new_enabled_items = importer_list_->GetSourceProfileInfoAt( new_index).services_supported; SetCheckedItemsState(new_enabled_items); @@ -220,9 +223,9 @@ void ImporterView::ItemChanged(views::Combobox* combobox, } void ImporterView::SourceProfilesLoaded() { - DCHECK(importer_host_->source_profiles_loaded()); + DCHECK(importer_list_->source_profiles_loaded()); checkbox_items_.resize( - importer_host_->GetAvailableProfileCount(), initial_state_); + importer_list_->GetAvailableProfileCount(), initial_state_); // Reload the profile combobox. profile_combobox_->ModelChanged(); diff --git a/chrome/browser/ui/views/importer_view.h b/chrome/browser/ui/views/importer_view.h index c120dbc..c1ed9b2 100644 --- a/chrome/browser/ui/views/importer_view.h +++ b/chrome/browser/ui/views/importer_view.h @@ -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. @@ -20,6 +20,7 @@ class Label; class Window; } +class ImporterList; class Profile; // ImporterView draws the dialog that allows the user to select what to @@ -97,6 +98,7 @@ class ImporterView : public views::View, views::Checkbox* search_engines_checkbox_; scoped_refptr<ImporterHost> importer_host_; + scoped_refptr<ImporterList> importer_list_; // Stores the state of the checked items associated with the position of the // selected item in the combo-box. |