diff options
Diffstat (limited to 'chrome/browser/views/extensions')
6 files changed, 52 insertions, 36 deletions
diff --git a/chrome/browser/views/extensions/extension_install_prompt.cc b/chrome/browser/views/extensions/extension_install_prompt.cc index f75b557..5cf1e7b 100644 --- a/chrome/browser/views/extensions/extension_install_prompt.cc +++ b/chrome/browser/views/extensions/extension_install_prompt.cc @@ -9,6 +9,7 @@ #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/extensions/extension_install_ui.h" +#include "chrome/browser/views/window.h" #include "chrome/common/extensions/extension.h" #include "grit/generated_resources.h" #include "views/controls/button/checkbox.h" @@ -35,8 +36,10 @@ const int kIconSize = 69; class InstallDialogContent : public views::View, public views::DialogDelegate { public: InstallDialogContent(ExtensionInstallUI::Delegate* delegate, - Extension* extension, SkBitmap* icon, ExtensionInstallUI::PromptType type) - : delegate_(delegate), icon_(NULL), type_(type) { + const Extension* extension, + SkBitmap* icon, + ExtensionInstallUI::PromptType type) + : delegate_(delegate), icon_(NULL), type_(type) { // Scale down to icon size, but allow smaller icons (don't scale up). gfx::Size size(icon->width(), icon->height()); if (size.width() > kIconSize || size.height() > kIconSize) @@ -141,7 +144,10 @@ class InstallDialogContent : public views::View, public views::DialogDelegate { // static void ExtensionInstallUI::ShowExtensionInstallUIPromptImpl( - Profile* profile, Delegate* delegate, Extension* extension, SkBitmap* icon, + Profile* profile, + Delegate* delegate, + const Extension* extension, + SkBitmap* icon, PromptType type) { Browser* browser = BrowserList::GetLastActiveWithProfile(profile); if (!browser) { @@ -155,7 +161,7 @@ void ExtensionInstallUI::ShowExtensionInstallUIPromptImpl( return; } - views::Window::CreateChromeWindow(window->GetNativeHandle(), gfx::Rect(), + browser::CreateViewsWindow(window->GetNativeHandle(), gfx::Rect(), new InstallDialogContent(delegate, extension, icon, type))->Show(); } diff --git a/chrome/browser/views/extensions/extension_install_prompt2.cc b/chrome/browser/views/extensions/extension_install_prompt2.cc index 467ae20..ba9631e 100644 --- a/chrome/browser/views/extensions/extension_install_prompt2.cc +++ b/chrome/browser/views/extensions/extension_install_prompt2.cc @@ -58,7 +58,7 @@ class InstallDialogContent2 : public views::View, public views::DialogDelegate { public: InstallDialogContent2(ExtensionInstallUI::Delegate* delegate, - Extension* extension, + const Extension* extension, SkBitmap* icon, const std::vector<string16>& permissions); @@ -109,7 +109,7 @@ class InstallDialogContent2 InstallDialogContent2::InstallDialogContent2( - ExtensionInstallUI::Delegate* delegate, Extension* extension, + ExtensionInstallUI::Delegate* delegate, const Extension* extension, SkBitmap* icon, const std::vector<string16>& permissions) : delegate_(delegate), icon_(NULL), @@ -292,7 +292,8 @@ void InstallDialogContent2::Layout() { // static void ExtensionInstallUI::ShowExtensionInstallUIPrompt2Impl( - Profile* profile, Delegate* delegate, Extension* extension, SkBitmap* icon, + Profile* profile, Delegate* delegate, const Extension* extension, + SkBitmap* icon, const std::vector<string16>& permissions) { #if defined(OS_CHROMEOS) // Use a normal browser window as parent on ChromeOS. diff --git a/chrome/browser/views/extensions/extension_installed_bubble.cc b/chrome/browser/views/extensions/extension_installed_bubble.cc index 4997ac6..8cb9397 100644 --- a/chrome/browser/views/extensions/extension_installed_bubble.cc +++ b/chrome/browser/views/extensions/extension_installed_bubble.cc @@ -69,7 +69,7 @@ const int kAnimationWaitMaxRetry = 10; class InstalledBubbleContent : public views::View, public views::ButtonListener { public: - InstalledBubbleContent(Extension* extension, + InstalledBubbleContent(const Extension* extension, ExtensionInstalledBubble::BubbleType type, SkBitmap* icon) : info_bubble_(NULL), @@ -241,12 +241,13 @@ class InstalledBubbleContent : public views::View, DISALLOW_COPY_AND_ASSIGN(InstalledBubbleContent); }; -void ExtensionInstalledBubble::Show(Extension *extension, Browser *browser, +void ExtensionInstalledBubble::Show(const Extension* extension, + Browser *browser, SkBitmap icon) { new ExtensionInstalledBubble(extension, browser, icon); } -ExtensionInstalledBubble::ExtensionInstalledBubble(Extension *extension, +ExtensionInstalledBubble::ExtensionInstalledBubble(const Extension* extension, Browser *browser, SkBitmap icon) : extension_(extension), @@ -272,20 +273,26 @@ ExtensionInstalledBubble::ExtensionInstalledBubble(Extension *extension, // be sure that a BrowserAction or PageAction has had views created which we // can inspect for the purpose of previewing of pointing to them. registrar_.Add(this, NotificationType::EXTENSION_LOADED, - NotificationService::AllSources()); + Source<Profile>(browser->profile())); + registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, + Source<Profile>(browser->profile())); } void ExtensionInstalledBubble::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { if (type == NotificationType::EXTENSION_LOADED) { - Extension* extension = Details<Extension>(details).ptr(); + const Extension* extension = Details<const Extension>(details).ptr(); if (extension == extension_) { animation_wait_retries_ = 0; // PostTask to ourself to allow all EXTENSION_LOADED Observers to run. MessageLoopForUI::current()->PostTask(FROM_HERE, NewRunnableMethod(this, &ExtensionInstalledBubble::ShowInternal)); } + } else if (type == NotificationType::EXTENSION_UNLOADED) { + const Extension* extension = Details<const Extension>(details).ptr(); + if (extension == extension_) + extension_ = NULL; } else { NOTREACHED() << L"Received unexpected notification"; } @@ -354,25 +361,27 @@ void ExtensionInstalledBubble::ShowInternal() { // InfoBubbleDelegate void ExtensionInstalledBubble::InfoBubbleClosing(InfoBubble* info_bubble, bool closed_by_escape) { - if (type_ == PAGE_ACTION) { - BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow( - browser_->window()->GetNativeHandle()); - browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( - extension_->page_action(), - false); // preview_enabled - } else if (type_ == EXTENSION_APP) { - if (bubble_content_->create_shortcut()) { - ShellIntegration::ShortcutInfo shortcut_info; - shortcut_info.url = extension_->GetFullLaunchURL(); - shortcut_info.extension_id = UTF8ToUTF16(extension_->id()); - shortcut_info.title = UTF8ToUTF16(extension_->name()); - shortcut_info.description = UTF8ToUTF16(extension_->description()); - shortcut_info.favicon = icon_; - shortcut_info.create_on_desktop = true; - shortcut_info.create_in_applications_menu = false; - shortcut_info.create_in_quick_launch_bar = false; - web_app::CreateShortcut(browser_->profile()->GetPath(), shortcut_info, - NULL); + if (extension_) { + if (type_ == PAGE_ACTION) { + BrowserView* browser_view = BrowserView::GetBrowserViewForNativeWindow( + browser_->window()->GetNativeHandle()); + browser_view->GetLocationBarView()->SetPreviewEnabledPageAction( + extension_->page_action(), + false); // preview_enabled + } else if (type_ == EXTENSION_APP) { + if (bubble_content_->create_shortcut()) { + ShellIntegration::ShortcutInfo shortcut_info; + shortcut_info.url = extension_->GetFullLaunchURL(); + shortcut_info.extension_id = UTF8ToUTF16(extension_->id()); + shortcut_info.title = UTF8ToUTF16(extension_->name()); + shortcut_info.description = UTF8ToUTF16(extension_->description()); + shortcut_info.favicon = icon_; + shortcut_info.create_on_desktop = true; + shortcut_info.create_in_applications_menu = false; + shortcut_info.create_in_quick_launch_bar = false; + web_app::CreateShortcut(browser_->profile()->GetPath(), shortcut_info, + NULL); + } } } diff --git a/chrome/browser/views/extensions/extension_installed_bubble.h b/chrome/browser/views/extensions/extension_installed_bubble.h index 81c12a6..a35f820 100644 --- a/chrome/browser/views/extensions/extension_installed_bubble.h +++ b/chrome/browser/views/extensions/extension_installed_bubble.h @@ -44,13 +44,13 @@ class ExtensionInstalledBubble // the extension has loaded. |extension| is the installed extension. |browser| // is the browser window which will host the bubble. |icon| is the install // icon of the extension. - static void Show(Extension *extension, Browser *browser, SkBitmap icon); + static void Show(const Extension* extension, Browser *browser, SkBitmap icon); private: friend class base::RefCountedThreadSafe<ExtensionInstalledBubble>; // Private ctor. Registers a listener for EXTENSION_LOADED. - ExtensionInstalledBubble(Extension *extension, Browser *browser, + ExtensionInstalledBubble(const Extension* extension, Browser *browser, SkBitmap icon); ~ExtensionInstalledBubble() {} @@ -69,7 +69,7 @@ class ExtensionInstalledBubble virtual bool CloseOnEscape() { return true; } virtual bool FadeInOnShow() { return true; } - Extension* extension_; + const Extension* extension_; Browser* browser_; SkBitmap icon_; NotificationRegistrar registrar_; diff --git a/chrome/browser/views/extensions/extension_view.cc b/chrome/browser/views/extensions/extension_view.cc index 4ba38ca..fcace1a 100644 --- a/chrome/browser/views/extensions/extension_view.cc +++ b/chrome/browser/views/extensions/extension_view.cc @@ -39,7 +39,7 @@ ExtensionView::~ExtensionView() { CleanUp(); } -Extension* ExtensionView::extension() const { +const Extension* ExtensionView::extension() const { return host_->extension(); } diff --git a/chrome/browser/views/extensions/extension_view.h b/chrome/browser/views/extensions/extension_view.h index 6eded74..037c2e8 100644 --- a/chrome/browser/views/extensions/extension_view.h +++ b/chrome/browser/views/extensions/extension_view.h @@ -36,7 +36,7 @@ class ExtensionView : public views::NativeViewHost { ExtensionHost* host() const { return host_; } Browser* browser() const { return browser_; } - Extension* extension() const; + const Extension* extension() const; RenderViewHost* render_view_host() const; void DidStopLoading(); void SetIsClipped(bool is_clipped); |
