summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-05 18:33:58 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-05 18:33:58 +0000
commit68f07912b7f633dd5257a55b195903aeefda5811 (patch)
treecf8e2807517cc5792cfa8e9af2af9021ff619cbf /chrome
parent34cec8d81015da03ed6c2b781800ac31488aa121 (diff)
downloadchromium_src-68f07912b7f633dd5257a55b195903aeefda5811.zip
chromium_src-68f07912b7f633dd5257a55b195903aeefda5811.tar.gz
chromium_src-68f07912b7f633dd5257a55b195903aeefda5811.tar.bz2
extensions_ui: update "active views" for popups & TabContents
This creates notifications when ExtensionFunctionDispatcher is created and destroyed. This mirrors the creation of any extension view. extensions_ui now listens to this to update it's list of active views. BUG=28423 Review URL: http://codereview.chromium.org/669028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40755 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.cc16
-rw-r--r--chrome/browser/extensions/extension_function_dispatcher.h5
-rw-r--r--chrome/browser/extensions/extensions_ui.cc17
-rw-r--r--chrome/common/notification_type.h12
4 files changed, 48 insertions, 2 deletions
diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc
index 8f868eb..445a867 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.cc
+++ b/chrome/browser/extensions/extension_function_dispatcher.cc
@@ -265,7 +265,9 @@ ExtensionFunctionDispatcher::ExtensionFunctionDispatcher(
RenderViewHost* render_view_host,
Delegate* delegate,
const GURL& url)
- : render_view_host_(render_view_host),
+ : ALLOW_THIS_IN_INITIALIZER_LIST(
+ profile_(render_view_host->process()->profile())),
+ render_view_host_(render_view_host),
delegate_(delegate),
url_(url),
ALLOW_THIS_IN_INITIALIZER_LIST(peer_(new Peer(this))) {
@@ -295,11 +297,21 @@ ExtensionFunctionDispatcher::ExtensionFunctionDispatcher(
extension->url(), extension->host_permissions()));
render_view_host->Send(new ViewMsg_Extension_ExtensionSetIncognitoEnabled(
extension->id(), incognito_enabled));
+
+ NotificationService::current()->Notify(
+ NotificationType::EXTENSION_FUNCTION_DISPATCHER_CREATED,
+ Source<Profile>(profile_),
+ Details<ExtensionFunctionDispatcher>(this));
}
ExtensionFunctionDispatcher::~ExtensionFunctionDispatcher() {
all_instances()->erase(this);
peer_->dispatcher_ = NULL;
+
+ NotificationService::current()->Notify(
+ NotificationType::EXTENSION_FUNCTION_DISPATCHER_DESTROYED,
+ Source<Profile>(profile_),
+ Details<ExtensionFunctionDispatcher>(this));
}
Browser* ExtensionFunctionDispatcher::GetBrowser(bool include_incognito) {
@@ -381,7 +393,7 @@ void ExtensionFunctionDispatcher::HandleBadMessage(ExtensionFunction* api) {
}
Profile* ExtensionFunctionDispatcher::profile() {
- return render_view_host_->process()->profile();
+ return profile_;
}
gfx::NativeWindow ExtensionFunctionDispatcher::GetFrameNativeWindow() {
diff --git a/chrome/browser/extensions/extension_function_dispatcher.h b/chrome/browser/extensions/extension_function_dispatcher.h
index 1bdfca2..af62063 100644
--- a/chrome/browser/extensions/extension_function_dispatcher.h
+++ b/chrome/browser/extensions/extension_function_dispatcher.h
@@ -135,6 +135,11 @@ class ExtensionFunctionDispatcher {
RenderViewHost* render_view_host() { return render_view_host_; }
private:
+ // We need to keep a pointer to the profile because we use it in the dtor
+ // in sending EXTENSION_FUNCTION_DISPATCHER_DESTROYED, but by that point
+ // the render_view_host_ has been deleted.
+ Profile* profile_;
+
RenderViewHost* render_view_host_;
Delegate* delegate_;
diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc
index c43fb30..bd0c70a 100644
--- a/chrome/browser/extensions/extensions_ui.cc
+++ b/chrome/browser/extensions/extensions_ui.cc
@@ -20,6 +20,7 @@
#include "chrome/browser/extensions/crx_installer.h"
#include "chrome/browser/extensions/extension_disabled_infobar_delegate.h"
#include "chrome/browser/extensions/extension_function_dispatcher.h"
+#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_message_service.h"
#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/extensions/extension_updater.h"
@@ -355,6 +356,11 @@ void ExtensionsDOMHandler::OnIconsLoaded(DictionaryValue* json) {
NotificationService::AllSources());
registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED,
NotificationService::AllSources());
+ registrar_.Add(this, NotificationType::EXTENSION_FUNCTION_DISPATCHER_CREATED,
+ NotificationService::AllSources());
+ registrar_.Add(this,
+ NotificationType::EXTENSION_FUNCTION_DISPATCHER_DESTROYED,
+ NotificationService::AllSources());
}
ExtensionResource ExtensionsDOMHandler::PickExtensionIcon(
@@ -646,6 +652,8 @@ void ExtensionsDOMHandler::Observe(NotificationType type,
case NotificationType::EXTENSION_UNLOADED:
case NotificationType::EXTENSION_UNLOADED_DISABLED:
case NotificationType::EXTENSION_UPDATE_DISABLED:
+ case NotificationType::EXTENSION_FUNCTION_DISPATCHER_CREATED:
+ case NotificationType::EXTENSION_FUNCTION_DISPATCHER_DESTROYED:
if (dom_ui_->tab_contents())
HandleRequestExtensionsData(NULL);
break;
@@ -769,6 +777,15 @@ std::vector<ExtensionPage> ExtensionsDOMHandler::GetActivePagesForExtension(
all_instances->begin(); iter != all_instances->end(); ++iter) {
RenderViewHost* view = (*iter)->render_view_host();
if ((*iter)->extension_id() == extension_id && view) {
+ // We avoid adding views which are contained in popups to this list
+ // because clicking the link would cause the popup to loose focus and
+ // close. Instead, we display text that tells the developer to
+ // right-click on popups to inspect them.
+ if ((*iter)->GetExtensionHost() &&
+ (ViewType::EXTENSION_POPUP ==
+ (*iter)->GetExtensionHost()->extension_host_type()))
+ continue;
+
result.push_back(ExtensionPage((*iter)->url(),
view->process()->id(),
view->routing_id()));
diff --git a/chrome/common/notification_type.h b/chrome/common/notification_type.h
index ef3c0f9..700ffb1 100644
--- a/chrome/common/notification_type.h
+++ b/chrome/common/notification_type.h
@@ -713,6 +713,18 @@ class NotificationType {
// Same as above, but for a disabled extension.
EXTENSION_UNLOADED_DISABLED,
+ // Sent after a new ExtensionFunctionDispatcher is created. The details are
+ // an ExtensionFunctionDispatcher* and the source is a Profile*. This is
+ // similar in timing to EXTENSION_HOST_CREATED, but also fires when an
+ // extension view which is hosted in TabContents* is created.
+ EXTENSION_FUNCTION_DISPATCHER_CREATED,
+
+ // Sent before an ExtensionHost is destroyed. The details are
+ // an ExtensionFunctionDispatcher* and the source is a Profile*. This is
+ // similar in timing to EXTENSION_HOST_DESTROYED, but also fires when an
+ // extension view which is hosted in TabContents* is destroyed.
+ EXTENSION_FUNCTION_DISPATCHER_DESTROYED,
+
// Sent after a new ExtensionHost is created. The details are
// an ExtensionHost* and the source is an ExtensionProcessManager*.
EXTENSION_HOST_CREATED,