diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-15 21:50:01 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-15 21:50:01 +0000 |
commit | 32fc4ff7d286f7a6ee80d969672cdadaa8d3e8d0 (patch) | |
tree | c7e59d81962c173d61083003c07819c2805fd042 /chrome/browser/extensions | |
parent | 080245fa243e0c04ccea332660d3058f710a090c (diff) | |
download | chromium_src-32fc4ff7d286f7a6ee80d969672cdadaa8d3e8d0.zip chromium_src-32fc4ff7d286f7a6ee80d969672cdadaa8d3e8d0.tar.gz chromium_src-32fc4ff7d286f7a6ee80d969672cdadaa8d3e8d0.tar.bz2 |
Remove BrowserList::GetLastActive from extensions install dialog code by plumbing through the Browser window. In two places (file_manager_util.cc and download_crx_util.cc) there is no context so I left those with FindLastActiveWithProfile for now.
BUG=129187
Review URL: https://chromiumcodereview.appspot.com/10548057
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142489 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
24 files changed, 90 insertions, 88 deletions
diff --git a/chrome/browser/extensions/api/permissions/permissions_api.cc b/chrome/browser/extensions/api/permissions/permissions_api.cc index 0af5db5..747a74e 100644 --- a/chrome/browser/extensions/api/permissions/permissions_api.cc +++ b/chrome/browser/extensions/api/permissions/permissions_api.cc @@ -203,7 +203,7 @@ bool RequestPermissionsFunction::RunImpl() { InstallUIAbort(true); } else { CHECK_EQ(DO_NOT_SKIP, auto_confirm_for_tests); - install_ui_.reset(new ExtensionInstallPrompt(profile())); + install_ui_.reset(new ExtensionInstallPrompt(GetCurrentBrowser())); install_ui_->ConfirmPermissions( this, GetExtension(), requested_permissions_.get()); } diff --git a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc index 00f7e85..b6d32f2 100644 --- a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc +++ b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc @@ -197,7 +197,7 @@ bool InstallBundleFunction::RunImpl() { if (!ReadBundleInfo(extensions, &items)) return false; - bundle_ = new BundleInstaller(profile(), items); + bundle_ = new BundleInstaller(GetCurrentBrowser(), items); AddRef(); // Balanced in OnBundleInstallCompleted / OnBundleInstallCanceled. @@ -228,7 +228,6 @@ bool InstallBundleFunction::ReadBundleInfo(ListValue* extensions, void InstallBundleFunction::OnBundleInstallApproved() { bundle_->CompleteInstall( &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), - GetCurrentBrowser(), this); } @@ -367,7 +366,7 @@ void BeginInstallWithManifestFunction::OnWebstoreParseSuccess( return; } - install_prompt_.reset(new ExtensionInstallPrompt(profile())); + install_prompt_.reset(new ExtensionInstallPrompt(GetCurrentBrowser())); install_prompt_->ConfirmWebstoreInstall(this, dummy_extension_, &icon_); // Control flow finishes up in InstallUIProceed or InstallUIAbort. } diff --git a/chrome/browser/extensions/bundle_installer.cc b/chrome/browser/extensions/bundle_installer.cc index 5cfa4f0..ffd5f1f 100644 --- a/chrome/browser/extensions/bundle_installer.cc +++ b/chrome/browser/extensions/bundle_installer.cc @@ -16,6 +16,7 @@ #include "chrome/browser/extensions/extension_install_dialog.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_finder.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_manifest_constants.h" @@ -100,11 +101,11 @@ string16 BundleInstaller::Item::GetNameForDisplay() { return l10n_util::GetStringFUTF16(IDS_EXTENSION_PERMISSION_LINE, name); } -BundleInstaller::BundleInstaller(Profile* profile, +BundleInstaller::BundleInstaller(Browser* browser, const BundleInstaller::ItemList& items) : approved_(false), - browser_(NULL), - profile_(profile), + browser_(browser), + profile_(browser->profile()), delegate_(NULL) { BrowserList::AddObserver(this); for (size_t i = 0; i < items.size(); ++i) { @@ -134,11 +135,9 @@ void BundleInstaller::PromptForApproval(Delegate* delegate) { } void BundleInstaller::CompleteInstall(NavigationController* controller, - Browser* browser, Delegate* delegate) { CHECK(approved_); - browser_ = browser; delegate_ = delegate; AddRef(); // Balanced in ReportComplete(); @@ -267,7 +266,13 @@ void BundleInstaller::ShowPrompt() { } else if (g_auto_approve_for_test == ABORT) { InstallUIAbort(true); } else { - install_ui_.reset(new ExtensionInstallPrompt(profile_)); + Browser* browser = browser_; + if (!browser) { + // The browser that we got initially could have gone away during our + // thread hopping. + browser = browser::FindLastActiveWithProfile(profile_); + } + install_ui_.reset(new ExtensionInstallPrompt(browser)); install_ui_->ConfirmBundleInstall(this, permissions); } } diff --git a/chrome/browser/extensions/bundle_installer.h b/chrome/browser/extensions/bundle_installer.h index 168581e..05262a9 100644 --- a/chrome/browser/extensions/bundle_installer.h +++ b/chrome/browser/extensions/bundle_installer.h @@ -76,7 +76,7 @@ class BundleInstaller : public WebstoreInstallHelper::Delegate, typedef std::vector<Item> ItemList; - BundleInstaller(Profile* profile, const ItemList& items); + BundleInstaller(Browser* browser, const ItemList& items); // Returns true if the user has approved the bundle's permissions. bool approved() const { return approved_; } @@ -97,7 +97,6 @@ class BundleInstaller : public WebstoreInstallHelper::Delegate, // the specified |browser|. // Note: the |delegate| must stay alive until receiving the callback. void CompleteInstall(content::NavigationController* controller, - Browser* browser, Delegate* delegate); // We change the headings in the install prompt and installed bubble depending diff --git a/chrome/browser/extensions/crx_installer_browsertest.cc b/chrome/browser/extensions/crx_installer_browsertest.cc index 18c321f..6ecf682 100644 --- a/chrome/browser/extensions/crx_installer_browsertest.cc +++ b/chrome/browser/extensions/crx_installer_browsertest.cc @@ -27,8 +27,8 @@ namespace { class MockInstallPrompt : public ExtensionInstallPrompt { public: - explicit MockInstallPrompt(Profile* profile) : - ExtensionInstallPrompt(profile), + explicit MockInstallPrompt(Browser* browser) : + ExtensionInstallPrompt(browser), did_succeed_(false), confirmation_requested_(false) {} @@ -68,8 +68,7 @@ class ExtensionCrxInstallerTest : public ExtensionBrowserTest { bool DidWhitelistInstallPrompt(const std::string& ext_relpath, const std::string& id) { ExtensionService* service = browser()->profile()->GetExtensionService(); - MockInstallPrompt* mock_install_prompt = - new MockInstallPrompt(browser()->profile()); + MockInstallPrompt* mock_install_prompt = new MockInstallPrompt(browser()); FilePath ext_path = test_data_dir_.AppendASCII(ext_relpath); std::string error; @@ -153,7 +152,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PackAndInstallExtension) { std::string crx_path_string(crx_path.value().begin(), crx_path.value().end()); GURL url = GURL(std::string("file:///").append(crx_path_string)); - MockInstallPrompt* mock_prompt = new MockInstallPrompt(browser()->profile()); + MockInstallPrompt* mock_prompt = new MockInstallPrompt(browser()); download_crx_util::SetMockInstallPromptForTesting(mock_prompt); LOG(ERROR) << "PackAndInstallExtension: Getting download manager"; @@ -186,8 +185,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, MAYBE_AllowOffStore) { const bool kTestData[] = {false, true}; for (size_t i = 0; i < arraysize(kTestData); ++i) { - MockInstallPrompt* mock_prompt = - new MockInstallPrompt(browser()->profile()); + MockInstallPrompt* mock_prompt = new MockInstallPrompt(browser()); scoped_refptr<CrxInstaller> crx_installer( CrxInstaller::Create(service, mock_prompt)); crx_installer->set_install_cause( diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc index 9444001..50365fe 100644 --- a/chrome/browser/extensions/extension_browsertest.cc +++ b/chrome/browser/extensions/extension_browsertest.cc @@ -245,8 +245,8 @@ class MockAbortExtensionInstallPrompt : public ExtensionInstallPrompt { class MockAutoConfirmExtensionInstallPrompt : public ExtensionInstallPrompt { public: - explicit MockAutoConfirmExtensionInstallPrompt(Profile* profile) : - ExtensionInstallPrompt(profile) {} + explicit MockAutoConfirmExtensionInstallPrompt(Browser* browser) : + ExtensionInstallPrompt(browser) {} // Proceed without confirmation prompt. virtual void ConfirmInstall(Delegate* delegate, const Extension* extension) { @@ -258,8 +258,7 @@ const Extension* ExtensionBrowserTest::InstallExtensionFromWebstore( const FilePath& path, int expected_change) { return InstallOrUpdateExtension("", path, INSTALL_UI_TYPE_NONE, - expected_change, browser()->profile(), - true); + expected_change, browser(), true); } const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( @@ -268,7 +267,7 @@ const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( InstallUIType ui_type, int expected_change) { return InstallOrUpdateExtension(id, path, ui_type, expected_change, - browser()->profile(), false); + browser(), false); } const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( @@ -276,9 +275,9 @@ const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( const FilePath& path, InstallUIType ui_type, int expected_change, - Profile* profile, + Browser* browser, bool from_webstore) { - ExtensionService* service = profile->GetExtensionService(); + ExtensionService* service = browser->profile()->GetExtensionService(); service->set_show_extensions_prompts(false); size_t num_before = service->extensions()->size(); @@ -287,9 +286,9 @@ const Extension* ExtensionBrowserTest::InstallOrUpdateExtension( if (ui_type == INSTALL_UI_TYPE_CANCEL) install_ui = new MockAbortExtensionInstallPrompt(); else if (ui_type == INSTALL_UI_TYPE_NORMAL) - install_ui = new ExtensionInstallPrompt(profile); + install_ui = new ExtensionInstallPrompt(browser); else if (ui_type == INSTALL_UI_TYPE_AUTO_CONFIRM) - install_ui = new MockAutoConfirmExtensionInstallPrompt(profile); + install_ui = new MockAutoConfirmExtensionInstallPrompt(browser); // TODO(tessamac): Update callers to always pass an unpacked extension // and then always pack the extension here. diff --git a/chrome/browser/extensions/extension_browsertest.h b/chrome/browser/extensions/extension_browsertest.h index 3c2c7ab..30d345d 100644 --- a/chrome/browser/extensions/extension_browsertest.h +++ b/chrome/browser/extensions/extension_browsertest.h @@ -92,9 +92,9 @@ class ExtensionBrowserTest const extensions::Extension* InstallExtensionWithUIAutoConfirm( const FilePath& path, int expected_change, - Profile* profile) { + Browser* browser) { return InstallOrUpdateExtension("", path, INSTALL_UI_TYPE_AUTO_CONFIRM, - expected_change, profile, false); + expected_change, browser, false); } // Begins install process but simulates a user cancel. @@ -187,7 +187,7 @@ class ExtensionBrowserTest const FilePath& path, InstallUIType ui_type, int expected_change, - Profile* profile, + Browser* browser, bool from_webstore); bool WaitForExtensionViewsToLoad(); diff --git a/chrome/browser/extensions/extension_disabled_ui.cc b/chrome/browser/extensions/extension_disabled_ui.cc index 7a023a4..344a233 100644 --- a/chrome/browser/extensions/extension_disabled_ui.cc +++ b/chrome/browser/extensions/extension_disabled_ui.cc @@ -71,7 +71,7 @@ class ExtensionDisabledDialogDelegate : public ExtensionInstallPrompt::Delegate, public base::RefCountedThreadSafe<ExtensionDisabledDialogDelegate> { public: - ExtensionDisabledDialogDelegate(Profile* profile, + ExtensionDisabledDialogDelegate(Browser* browser, ExtensionService* service, const Extension* extension); @@ -92,13 +92,13 @@ class ExtensionDisabledDialogDelegate }; ExtensionDisabledDialogDelegate::ExtensionDisabledDialogDelegate( - Profile* profile, + Browser* browser, ExtensionService* service, const Extension* extension) : service_(service), extension_(extension) { AddRef(); // Balanced in Proceed or Abort. - install_ui_.reset(new ExtensionInstallPrompt(profile)); + install_ui_.reset(new ExtensionInstallPrompt(browser)); install_ui_->ConfirmReEnable(this, extension_); } @@ -256,8 +256,7 @@ void ExtensionDisabledGlobalError::OnBubbleViewDidClose(Browser* browser) { void ExtensionDisabledGlobalError::BubbleViewAcceptButtonPressed( Browser* browser) { - new ExtensionDisabledDialogDelegate(service_->profile(), service_, - extension_); + new ExtensionDisabledDialogDelegate(browser, service_, extension_); } void ExtensionDisabledGlobalError::BubbleViewCancelButtonPressed( @@ -318,10 +317,10 @@ void AddExtensionDisabledError(ExtensionService* service, AddGlobalError(new ExtensionDisabledGlobalError(service, extension)); } -void ShowExtensionDisabledDialog(ExtensionService* service, Profile* profile, +void ShowExtensionDisabledDialog(ExtensionService* service, Browser* browser, const Extension* extension) { // This object manages its own lifetime. - new ExtensionDisabledDialogDelegate(profile, service, extension); + new ExtensionDisabledDialogDelegate(browser, service, extension); } } // namespace extensions diff --git a/chrome/browser/extensions/extension_disabled_ui.h b/chrome/browser/extensions/extension_disabled_ui.h index 1899cf3..b5a66c60 100644 --- a/chrome/browser/extensions/extension_disabled_ui.h +++ b/chrome/browser/extensions/extension_disabled_ui.h @@ -6,8 +6,8 @@ #define CHROME_BROWSER_EXTENSIONS_EXTENSION_DISABLED_UI_H_ #pragma once +class Browser; class ExtensionService; -class Profile; namespace extensions { @@ -19,7 +19,7 @@ void AddExtensionDisabledError(ExtensionService* service, const Extension* extension); // Shows the extension install dialog. -void ShowExtensionDisabledDialog(ExtensionService* service, Profile* profile, +void ShowExtensionDisabledDialog(ExtensionService* service, Browser* browser, const Extension* extension); } // namespace extensions diff --git a/chrome/browser/extensions/extension_install_dialog.cc b/chrome/browser/extensions/extension_install_dialog.cc index 3f40064..10bd82c 100644 --- a/chrome/browser/extensions/extension_install_dialog.cc +++ b/chrome/browser/extensions/extension_install_dialog.cc @@ -59,7 +59,7 @@ AutoConfirmForTest CheckAutoConfirmCommandLineSwitch() { } // namespace -void ShowExtensionInstallDialog(Profile* profile, +void ShowExtensionInstallDialog(Browser* browser, ExtensionInstallPrompt::Delegate* delegate, const ExtensionInstallPrompt::Prompt& prompt) { AutoConfirmForTest auto_confirm = CheckAutoConfirmCommandLineSwitch(); @@ -67,5 +67,5 @@ void ShowExtensionInstallDialog(Profile* profile, DoAutoConfirm(auto_confirm, delegate); return; } - ShowExtensionInstallDialogImpl(profile, delegate, prompt); + ShowExtensionInstallDialogImpl(browser, delegate, prompt); } diff --git a/chrome/browser/extensions/extension_install_dialog.h b/chrome/browser/extensions/extension_install_dialog.h index 77d84ed..b9db0cd 100644 --- a/chrome/browser/extensions/extension_install_dialog.h +++ b/chrome/browser/extensions/extension_install_dialog.h @@ -12,19 +12,19 @@ #include "base/string16.h" #include "chrome/browser/extensions/extension_install_prompt.h" -class Profile; +class Browser; namespace base { class DictionaryValue; } -void ShowExtensionInstallDialog(Profile* profile, +void ShowExtensionInstallDialog(Browser* browser, ExtensionInstallPrompt::Delegate* delegate, const ExtensionInstallPrompt::Prompt& prompt); // The implementations of this function are platform-specific. void ShowExtensionInstallDialogImpl( - Profile* profile, + Browser* browser, ExtensionInstallPrompt::Delegate* delegate, const ExtensionInstallPrompt::Prompt& prompt); diff --git a/chrome/browser/extensions/extension_install_prompt.cc b/chrome/browser/extensions/extension_install_prompt.cc index 9ac5870..14729f0 100644 --- a/chrome/browser/extensions/extension_install_prompt.cc +++ b/chrome/browser/extensions/extension_install_prompt.cc @@ -17,6 +17,7 @@ #include "chrome/browser/extensions/extension_install_dialog.h" #include "chrome/browser/extensions/extension_install_ui.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/tab_contents/tab_contents.h" #include "chrome/common/chrome_switches.h" @@ -237,11 +238,11 @@ scoped_refptr<Extension> error); } -ExtensionInstallPrompt::ExtensionInstallPrompt(Profile* profile) - : profile_(profile), +ExtensionInstallPrompt::ExtensionInstallPrompt(Browser* browser) + : browser_(browser), ui_loop_(MessageLoop::current()), extension_(NULL), - install_ui_(ExtensionInstallUI::Create(profile)), + install_ui_(ExtensionInstallUI::Create(browser)), delegate_(NULL), prompt_(UNSET_PROMPT_TYPE), prompt_type_(UNSET_PROMPT_TYPE), @@ -394,12 +395,12 @@ void ExtensionInstallPrompt::ShowConfirmation() { case INSTALL_PROMPT: { prompt_.set_extension(extension_); prompt_.set_icon(gfx::Image(icon_)); - ShowExtensionInstallDialog(profile_, delegate_, prompt_); + ShowExtensionInstallDialog(browser_, delegate_, prompt_); break; } case BUNDLE_INSTALL_PROMPT: { prompt_.set_bundle(bundle_); - ShowExtensionInstallDialog(profile_, delegate_, prompt_); + ShowExtensionInstallDialog(browser_, delegate_, prompt_); break; } default: diff --git a/chrome/browser/extensions/extension_install_prompt.h b/chrome/browser/extensions/extension_install_prompt.h index a77c2dc..bac327d 100644 --- a/chrome/browser/extensions/extension_install_prompt.h +++ b/chrome/browser/extensions/extension_install_prompt.h @@ -19,10 +19,10 @@ #include "ui/gfx/image/image_skia.h" #include "ui/gfx/native_widget_types.h" +class Browser; class ExtensionInstallUI; class ExtensionPermissionSet; class MessageLoop; -class Profile; class InfoBarDelegate; namespace base { @@ -149,7 +149,7 @@ class ExtensionInstallPrompt : public ImageLoadingTracker::Observer { const std::string& localized_description, std::string* error); - explicit ExtensionInstallPrompt(Profile* profile); + explicit ExtensionInstallPrompt(Browser* browser); virtual ~ExtensionInstallPrompt(); ExtensionInstallUI* install_ui() const { return install_ui_.get(); } @@ -231,7 +231,7 @@ class ExtensionInstallPrompt : public ImageLoadingTracker::Observer { // Shows the actual UI (the icon should already be loaded). void ShowConfirmation(); - Profile* profile_; + Browser* browser_; MessageLoop* ui_loop_; // The extensions installation icon. diff --git a/chrome/browser/extensions/extension_install_ui.h b/chrome/browser/extensions/extension_install_ui.h index b908259..e5fabbe 100644 --- a/chrome/browser/extensions/extension_install_ui.h +++ b/chrome/browser/extensions/extension_install_ui.h @@ -12,7 +12,6 @@ #include "base/string16.h" class Browser; -class Profile; class SkBitmap; namespace extensions { @@ -24,7 +23,7 @@ class ExtensionWebstorePrivateApiTest; // around extension installation. class ExtensionInstallUI { public: - static ExtensionInstallUI* Create(Profile* profile); + static ExtensionInstallUI* Create(Browser* browser); virtual ~ExtensionInstallUI(); diff --git a/chrome/browser/extensions/extension_install_ui_android.cc b/chrome/browser/extensions/extension_install_ui_android.cc index f67c67d..027ec93 100644 --- a/chrome/browser/extensions/extension_install_ui_android.cc +++ b/chrome/browser/extensions/extension_install_ui_android.cc @@ -20,7 +20,7 @@ void ExtensionInstallUIAndroid::SetSkipPostInstallUI(bool skip_ui) { } // static -ExtensionInstallUI* ExtensionInstallUI::Create(Profile* profile) { +ExtensionInstallUI* ExtensionInstallUI::Create(Browser* browser) { NOTIMPLEMENTED(); return NULL; } diff --git a/chrome/browser/extensions/extension_install_ui_browsertest.cc b/chrome/browser/extensions/extension_install_ui_browsertest.cc index cd67eb9..c739b23 100644 --- a/chrome/browser/extensions/extension_install_ui_browsertest.cc +++ b/chrome/browser/extensions/extension_install_ui_browsertest.cc @@ -64,8 +64,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, // Install theme once and undo to verify we go back to default theme. FilePath theme_crx = PackExtension(test_data_dir_.AppendASCII("theme")); - ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( - theme_crx, 1, browser()->profile())); + ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(theme_crx, 1, browser())); const Extension* theme = GetTheme(); ASSERT_TRUE(theme); std::string theme_id = theme->id(); @@ -76,13 +75,11 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, // We set the |expected_change| to zero in these 'InstallExtensionWithUI' // calls since the theme has already been installed above and this is an // overinstall to set the active theme. - ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( - theme_crx, 0, browser()->profile())); + ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(theme_crx, 0, browser())); theme = GetTheme(); ASSERT_TRUE(theme); ASSERT_EQ(theme_id, theme->id()); - ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( - theme_crx, 0, browser()->profile())); + ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(theme_crx, 0, browser())); theme = GetTheme(); ASSERT_TRUE(theme); ASSERT_EQ(theme_id, theme->id()); @@ -96,16 +93,14 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, // Install first theme. FilePath theme_path = test_data_dir_.AppendASCII("theme"); - ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( - theme_path, 1, browser()->profile())); + ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(theme_path, 1, browser())); const Extension* theme = GetTheme(); ASSERT_TRUE(theme); std::string theme_id = theme->id(); // Then install second theme. FilePath theme_path2 = test_data_dir_.AppendASCII("theme2"); - ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( - theme_path2, 1, browser()->profile())); + ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(theme_path2, 1, browser())); const Extension* theme2 = GetTheme(); ASSERT_TRUE(theme2); EXPECT_FALSE(theme_id == theme2->id()); @@ -120,8 +115,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, int num_tabs = browser()->tab_count(); FilePath app_dir = test_data_dir_.AppendASCII("app"); - ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(app_dir, 1, - browser()->profile())); + ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(app_dir, 1, browser())); if (NewTabUI::ShouldShowApps()) { EXPECT_EQ(num_tabs + 1, browser()->tab_count()); @@ -145,7 +139,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, FilePath app_dir = test_data_dir_.AppendASCII("app"); ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(app_dir, 1, - incognito_profile)); + incognito_browser)); EXPECT_EQ(num_incognito_tabs, incognito_browser->tab_count()); if (NewTabUI::ShouldShowApps()) { diff --git a/chrome/browser/extensions/extension_install_ui_default.cc b/chrome/browser/extensions/extension_install_ui_default.cc index db426be..a3b0cda 100644 --- a/chrome/browser/extensions/extension_install_ui_default.cc +++ b/chrome/browser/extensions/extension_install_ui_default.cc @@ -44,13 +44,14 @@ bool disable_failure_ui_for_tests = false; } // namespace -ExtensionInstallUIDefault::ExtensionInstallUIDefault(Profile* profile) - : profile_(profile), +ExtensionInstallUIDefault::ExtensionInstallUIDefault(Browser* browser) + : browser_(browser), skip_post_install_ui_(false), previous_using_native_theme_(false), use_app_installed_bubble_(false) { // Remember the current theme in case the user presses undo. - if (profile) { + if (browser) { + Profile* profile = browser->profile(); const Extension* previous_theme = ThemeServiceFactory::GetThemeForProfile(profile); if (previous_theme) @@ -70,13 +71,13 @@ void ExtensionInstallUIDefault::OnInstallSuccess(const Extension* extension, if (extension->is_theme()) { ShowThemeInfoBar(previous_theme_id_, previous_using_native_theme_, - extension, profile_); + extension, browser_->profile()); return; } // Extensions aren't enabled by default in incognito so we confirm // the install in a normal window. - Profile* current_profile = profile_->GetOriginalProfile(); + Profile* current_profile = browser_->profile()->GetOriginalProfile(); Browser* browser = browser::FindOrCreateTabbedBrowser(current_profile); if (browser->tab_count() == 0) browser->AddBlankTab(true); @@ -104,7 +105,7 @@ void ExtensionInstallUIDefault::OnInstallFailure(const string16& error) { if (disable_failure_ui_for_tests || skip_post_install_ui_) return; - Browser* browser = browser::FindLastActiveWithProfile(profile_); + Browser* browser = browser::FindLastActiveWithProfile(browser_->profile()); browser::ShowMessageBox(browser ? browser->window()->GetNativeWindow() : NULL, l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALL_FAILURE_TITLE), error, browser::MESSAGE_BOX_TYPE_WARNING); @@ -178,8 +179,8 @@ InfoBarDelegate* ExtensionInstallUIDefault::GetNewThemeInstalledInfoBarDelegate( } // static -ExtensionInstallUI* ExtensionInstallUI::Create(Profile* profile) { - return new ExtensionInstallUIDefault(profile); +ExtensionInstallUI* ExtensionInstallUI::Create(Browser* browser) { + return new ExtensionInstallUIDefault(browser); } // static diff --git a/chrome/browser/extensions/extension_install_ui_default.h b/chrome/browser/extensions/extension_install_ui_default.h index ff2f87c..6c872be 100644 --- a/chrome/browser/extensions/extension_install_ui_default.h +++ b/chrome/browser/extensions/extension_install_ui_default.h @@ -9,11 +9,12 @@ #include "chrome/browser/extensions/extension_install_ui.h" class InfoBarDelegate; +class Profile; class TabContents; class ExtensionInstallUIDefault : public ExtensionInstallUI { public: - explicit ExtensionInstallUIDefault(Profile* profile); + explicit ExtensionInstallUIDefault(Browser* browser); virtual ~ExtensionInstallUIDefault(); // ExtensionInstallUI implementation: @@ -39,7 +40,7 @@ class ExtensionInstallUIDefault : public ExtensionInstallUI { const std::string& previous_theme_id, bool previous_using_native_theme); - Profile* profile_; + Browser* browser_; // Whether or not to show the default UI after completing the installation. bool skip_post_install_ui_; diff --git a/chrome/browser/extensions/extension_management_api.cc b/chrome/browser/extensions/extension_management_api.cc index ac85975..dcc0274 100644 --- a/chrome/browser/extensions/extension_management_api.cc +++ b/chrome/browser/extensions/extension_management_api.cc @@ -407,7 +407,7 @@ bool SetEnabledFunction::RunImpl() { return false; } AddRef(); // Matched in InstallUIProceed/InstallUIAbort - install_prompt_.reset(new ExtensionInstallPrompt(profile_)); + install_prompt_.reset(new ExtensionInstallPrompt(GetCurrentBrowser())); install_prompt_->ConfirmReEnable(this, extension); return true; } diff --git a/chrome/browser/extensions/extension_management_browsertest.cc b/chrome/browser/extensions/extension_management_browsertest.cc index 25773a5..a9d0898 100644 --- a/chrome/browser/extensions/extension_management_browsertest.cc +++ b/chrome/browser/extensions/extension_management_browsertest.cc @@ -119,7 +119,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, InstallRequiresConfirm) { // And the install should succeed when the permissions are accepted. ASSERT_TRUE(InstallExtensionWithUIAutoConfirm( - test_data_dir_.AppendASCII("good.crx"), 1, browser()->profile())); + test_data_dir_.AppendASCII("good.crx"), 1, browser())); UninstallExtension(id); } diff --git a/chrome/browser/extensions/extension_navigation_observer.cc b/chrome/browser/extensions/extension_navigation_observer.cc index d54eb45..620c2e6 100644 --- a/chrome/browser/extensions/extension_navigation_observer.cc +++ b/chrome/browser/extensions/extension_navigation_observer.cc @@ -5,6 +5,8 @@ #include "chrome/browser/extensions/extension_navigation_observer.h" #include "chrome/browser/extensions/extension_service.h" +#include "chrome/browser/ui/browser.h" +#include "chrome/browser/ui/browser_finder.h" #include "chrome/browser/profiles/profile.h" #include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_entry.h" @@ -73,7 +75,8 @@ void ExtensionNavigationObserver::PromptToEnableExtensionIfNecessary( in_progress_prompt_extension_id_ = extension->id(); in_progress_prompt_navigation_controller_ = nav_controller; - extension_install_prompt_.reset(new ExtensionInstallPrompt(profile_)); + Browser* browser = browser::FindBrowserForController(nav_controller, NULL); + extension_install_prompt_.reset(new ExtensionInstallPrompt(browser)); extension_install_prompt_->ConfirmReEnable(this, extension); } } diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index 61aedb6..710643b 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -576,9 +576,10 @@ bool ExtensionService::UpdateExtension( // We want a silent install only for non-pending extensions and // pending extensions that have install_silently set. + Browser* browser = browser::FindLastActiveWithProfile(profile_); ExtensionInstallPrompt* client = (!pending_extension_info || pending_extension_info->install_silently()) ? - NULL : new ExtensionInstallPrompt(profile_); + NULL : new ExtensionInstallPrompt(browser); scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(this, client)); installer->set_expected_id(id); @@ -1804,7 +1805,7 @@ void ExtensionService::UnloadExtension( // Clean up runtime data. extension_runtime_data_.erase(extension_id); - if (disabled_extensions_.Contains(extension->id())) { +if (disabled_extensions_.Contains(extension->id())) { UnloadedExtensionInfo details(extension, reason); details.already_disabled = true; disabled_extensions_.Remove(extension->id()); diff --git a/chrome/browser/extensions/unpacked_installer.cc b/chrome/browser/extensions/unpacked_installer.cc index b73d7bc..e9c04b7 100644 --- a/chrome/browser/extensions/unpacked_installer.cc +++ b/chrome/browser/extensions/unpacked_installer.cc @@ -11,6 +11,7 @@ #include "chrome/browser/extensions/extension_prefs.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/permissions_updater.h" +#include "chrome/browser/ui/browser_finder.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_file_util.h" #include "chrome/common/string_ordinal.h" @@ -48,8 +49,9 @@ SimpleExtensionLoadPrompt::SimpleExtensionLoadPrompt( base::WeakPtr<ExtensionService> extension_service, const Extension* extension) : service_weak_(extension_service), - install_ui_(new ExtensionInstallPrompt(profile)), extension_(extension) { + Browser* browser = browser::FindLastActiveWithProfile(profile); + install_ui_.reset(new ExtensionInstallPrompt(browser)); } SimpleExtensionLoadPrompt::~SimpleExtensionLoadPrompt() { diff --git a/chrome/browser/extensions/webstore_inline_installer.cc b/chrome/browser/extensions/webstore_inline_installer.cc index 8d085e8..f97aed0 100644 --- a/chrome/browser/extensions/webstore_inline_installer.cc +++ b/chrome/browser/extensions/webstore_inline_installer.cc @@ -14,6 +14,7 @@ #include "chrome/browser/extensions/extension_install_dialog.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/browser_finder.h" #include "chrome/common/chrome_utility_messages.h" #include "chrome/common/extensions/extension.h" #include "chrome/common/extensions/extension_constants.h" @@ -341,8 +342,8 @@ void WebstoreInlineInstaller::OnWebstoreParseSuccess( manifest_.reset(manifest); icon_ = icon; - Profile* profile = Profile::FromBrowserContext( - web_contents()->GetBrowserContext()); + Browser* browser = browser::FindBrowserWithWebContents(web_contents()); + CHECK(browser); ExtensionInstallPrompt::Prompt prompt( ExtensionInstallPrompt::INLINE_INSTALL_PROMPT); @@ -358,7 +359,7 @@ void WebstoreInlineInstaller::OnWebstoreParseSuccess( return; } - install_ui_.reset(new ExtensionInstallPrompt(profile)); + install_ui_.reset(new ExtensionInstallPrompt(browser)); install_ui_->ConfirmInlineInstall(this, dummy_extension_, &icon_, prompt); // Control flow finishes up in InstallUIProceed or InstallUIAbort. } |