diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-10 16:36:23 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-10 16:36:23 +0000 |
commit | 3b4a0d3345176796b254f37a293ae13e48e10876 (patch) | |
tree | ba3bccb4462e7063674c6e98ca336719d3d6091c /chrome/browser/importer | |
parent | 95ccdbd5f5fd174249a00b5c4404d3e897ee67a9 (diff) | |
download | chromium_src-3b4a0d3345176796b254f37a293ae13e48e10876.zip chromium_src-3b4a0d3345176796b254f37a293ae13e48e10876.tar.gz chromium_src-3b4a0d3345176796b254f37a293ae13e48e10876.tar.bz2 |
Remove browser::FindLastActiveWithProfile call in importer code. There are many ways to create an ImporterHost, but only when it's created from the webui do we give the option to import from Google Toolbar. In that case, pass the Browser* directly.
BUG=129187
Review URL: https://chromiumcodereview.appspot.com/10750018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145890 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/importer')
-rw-r--r-- | chrome/browser/importer/importer_host.cc | 15 | ||||
-rw-r--r-- | chrome/browser/importer/importer_host.h | 12 |
2 files changed, 21 insertions, 6 deletions
diff --git a/chrome/browser/importer/importer_host.cc b/chrome/browser/importer/importer_host.cc index 4003c76..1485dca 100644 --- a/chrome/browser/importer/importer_host.cc +++ b/chrome/browser/importer/importer_host.cc @@ -20,7 +20,6 @@ #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_service.h" #include "chrome/browser/search_engines/template_url_service_factory.h" -#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/simple_message_box.h" #include "chrome/common/chrome_notification_types.h" @@ -40,7 +39,9 @@ ImporterHost::ImporterHost() importer_(NULL), headless_(false), parent_window_(NULL), + browser_(NULL), observer_(NULL) { + BrowserList::AddObserver(this); } void ImporterHost::ShowWarningDialog() { @@ -163,10 +164,8 @@ void ImporterHost::OnGoogleGAIACookieChecked(bool result) { chrome::MESSAGE_BOX_TYPE_INFORMATION); GURL url("https://accounts.google.com/ServiceLogin"); - DCHECK(profile_); - Browser* browser = browser::FindLastActiveWithProfile(profile_); - if (browser) - chrome::AddSelectedTabWithURL(browser, url, + if (browser_) + chrome::AddSelectedTabWithURL(browser_, url, content::PAGE_TRANSITION_TYPED); MessageLoop::current()->PostTask(FROM_HERE, base::Bind( @@ -184,6 +183,7 @@ void ImporterHost::Cancel() { } ImporterHost::~ImporterHost() { + BrowserList::RemoveObserver(this); if (NULL != importer_) importer_->Release(); @@ -266,3 +266,8 @@ void ImporterHost::Observe(int type, registrar_.RemoveAll(); InvokeTaskIfDone(); } + +void ImporterHost::OnBrowserRemoved(Browser* browser) { + if (browser_ == browser) + browser_ = NULL; +} diff --git a/chrome/browser/importer/importer_host.h b/chrome/browser/importer/importer_host.h index 18235eb..359f1d2 100644 --- a/chrome/browser/importer/importer_host.h +++ b/chrome/browser/importer/importer_host.h @@ -14,6 +14,7 @@ #include "chrome/browser/bookmarks/base_bookmark_model_observer.h" #include "chrome/browser/importer/importer_data_types.h" #include "chrome/browser/importer/profile_writer.h" +#include "chrome/browser/ui/browser_list.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" #include "ui/gfx/native_widget_types.h" @@ -31,7 +32,8 @@ class ImporterProgressObserver; // the import process is done, ImporterHost deletes itself. class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>, public BaseBookmarkModelObserver, - public content::NotificationObserver { + public content::NotificationObserver, + public BrowserList::Observer { public: ImporterHost(); @@ -63,6 +65,8 @@ class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>, parent_window_ = parent_window; } + void set_browser(Browser* browser) { browser_ = browser; } + // Starts the process of importing the settings and data depending on what the // user selected. // |source_profile| - importer profile to import. @@ -139,6 +143,9 @@ class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>, const content::NotificationSource& source, const content::NotificationDetails& details) OVERRIDE; + // BrowserList::Observer + virtual void OnBrowserRemoved(Browser* browser) OVERRIDE; + // The task is the process of importing settings from other browsers. base::Closure task_; @@ -152,6 +159,9 @@ class ImporterHost : public base::RefCountedThreadSafe<ImporterHost>, // warning dialog). gfx::NativeWindow parent_window_; + // Used to add a new tab if we need the user to sign in. + Browser* browser_; + // The observer that we need to notify about changes in the import process. importer::ImporterProgressObserver* observer_; |