summaryrefslogtreecommitdiffstats
path: root/extensions/browser/app_window
diff options
context:
space:
mode:
authorlimasdf <limasdf@gmail.com>2015-02-26 16:35:06 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-27 00:36:35 +0000
commite0f061b57e95d691453225d60770b34a38af805f (patch)
tree6fb7aad9c2b3f023e4f47b9b495961fff6417423 /extensions/browser/app_window
parent68c881e69be3e05f19783d6c5310ea43375d2383 (diff)
downloadchromium_src-e0f061b57e95d691453225d60770b34a38af805f.zip
chromium_src-e0f061b57e95d691453225d60770b34a38af805f.tar.gz
chromium_src-e0f061b57e95d691453225d60770b34a38af805f.tar.bz2
Use ExtensionRegistryObserver instead of deprecated notification.
These two should be done together. To make ProcessManager::OnExtesnionUnloaded call AppRestoreService::OnAppStop() first. and then AppWindow::OnExtensionUnloaded should be called. BUG=411568, 419375 Review URL: https://codereview.chromium.org/953413002 Cr-Commit-Position: refs/heads/master@{#318350}
Diffstat (limited to 'extensions/browser/app_window')
-rw-r--r--extensions/browser/app_window/app_window.cc56
-rw-r--r--extensions/browser/app_window/app_window.h24
2 files changed, 30 insertions, 50 deletions
diff --git a/extensions/browser/app_window/app_window.cc b/extensions/browser/app_window/app_window.cc
index 83f2971..a508074 100644
--- a/extensions/browser/app_window/app_window.cc
+++ b/extensions/browser/app_window/app_window.cc
@@ -16,10 +16,6 @@
#include "content/public/browser/browser_context.h"
#include "content/public/browser/invalidate_type.h"
#include "content/public/browser/navigation_entry.h"
-#include "content/public/browser/notification_details.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/browser/notification_source.h"
-#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_dispatcher_host.h"
#include "content/public/browser/web_contents.h"
@@ -312,20 +308,7 @@ void AppWindow::Init(const GURL& url,
OnNativeWindowChanged();
- // When the render view host is changed, the native window needs to know
- // about it in case it has any setup to do to make the renderer appear
- // properly. In particular, on Windows, the view's clickthrough region needs
- // to be set[
- ExtensionsBrowserClient* client = ExtensionsBrowserClient::Get();
- registrar_.Add(this,
- NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
- content::Source<content::BrowserContext>(
- client->GetOriginalContext(browser_context_)));
- // Update the app menu if an ephemeral app becomes installed.
- registrar_.Add(this,
- NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED,
- content::Source<content::BrowserContext>(
- client->GetOriginalContext(browser_context_)));
+ ExtensionRegistry::Get(browser_context_)->AddObserver(this);
// Close when the browser process is exiting.
app_delegate_->SetTerminatingCallback(
@@ -347,6 +330,7 @@ void AppWindow::Init(const GURL& url,
}
AppWindow::~AppWindow() {
+ ExtensionRegistry::Get(browser_context_)->RemoveObserver(this);
}
void AppWindow::RequestMediaAccessPermission(
@@ -964,30 +948,22 @@ bool AppWindow::IsFullscreenForTabOrPending(const content::WebContents* source)
return IsHtmlApiFullscreen();
}
-void AppWindow::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- switch (type) {
- case NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
- const Extension* unloaded_extension =
- content::Details<UnloadedExtensionInfo>(details)->extension;
- if (extension_id_ == unloaded_extension->id())
- native_app_window_->Close();
- break;
- }
- case NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED: {
- const Extension* installed_extension =
- content::Details<const InstalledExtensionInfo>(details)->extension;
- DCHECK(installed_extension);
- if (installed_extension->id() == extension_id())
- native_app_window_->UpdateShelfMenu();
- break;
- }
- default:
- NOTREACHED() << "Received unexpected notification";
- }
+void AppWindow::OnExtensionUnloaded(BrowserContext* browser_context,
+ const Extension* extension,
+ UnloadedExtensionInfo::Reason reason) {
+ if (extension_id_ == extension->id())
+ native_app_window_->Close();
}
+void AppWindow::OnExtensionWillBeInstalled(
+ BrowserContext* browser_context,
+ const Extension* extension,
+ bool is_update,
+ bool from_ephemeral,
+ const std::string& old_name) {
+ if (extension->id() == extension_id())
+ native_app_window_->UpdateShelfMenu();
+}
void AppWindow::SetWebContentsBlocked(content::WebContents* web_contents,
bool blocked) {
app_delegate_->SetWebContentsBlocked(web_contents, blocked);
diff --git a/extensions/browser/app_window/app_window.h b/extensions/browser/app_window/app_window.h
index 8d6ffea..c7abf3d 100644
--- a/extensions/browser/app_window/app_window.h
+++ b/extensions/browser/app_window/app_window.h
@@ -13,11 +13,10 @@
#include "components/sessions/session_id.h"
#include "components/web_modal/popup_manager.h"
#include "components/web_modal/web_contents_modal_dialog_manager_delegate.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#include "extensions/browser/extension_icon_image.h"
+#include "extensions/browser/extension_registry_observer.h"
#include "ui/base/ui_base_types.h" // WindowShowState
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/image/image.h"
@@ -43,6 +42,7 @@ namespace extensions {
class AppDelegate;
class AppWebContentsHelper;
class Extension;
+class ExtensionRegistry;
class NativeAppWindow;
class PlatformAppBrowserTest;
class WindowController;
@@ -82,11 +82,11 @@ class AppWindowContents {
// AppWindow is the type of window used by platform apps. App windows
// have a WebContents but none of the chrome of normal browser windows.
-class AppWindow : public content::NotificationObserver,
- public content::WebContentsDelegate,
+class AppWindow : public content::WebContentsDelegate,
public content::WebContentsObserver,
public web_modal::WebContentsModalDialogManagerDelegate,
- public IconImage::Observer {
+ public IconImage::Observer,
+ public ExtensionRegistryObserver {
public:
enum WindowType {
WINDOW_TYPE_DEFAULT = 1 << 0, // Default app window.
@@ -413,10 +413,15 @@ class AppWindow : public content::NotificationObserver,
void RenderViewCreated(content::RenderViewHost* render_view_host) override;
void DidFirstVisuallyNonEmptyPaint() override;
- // content::NotificationObserver implementation.
- void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) override;
+ // ExtensionRegistryObserver implementation.
+ void OnExtensionUnloaded(content::BrowserContext* browser_context,
+ const Extension* extension,
+ UnloadedExtensionInfo::Reason reason) override;
+ void OnExtensionWillBeInstalled(content::BrowserContext* browser_context,
+ const Extension* extension,
+ bool is_update,
+ bool from_ephemeral,
+ const std::string& old_name) override;
// web_modal::WebContentsModalDialogManagerDelegate implementation.
void SetWebContentsBlocked(content::WebContents* web_contents,
@@ -488,7 +493,6 @@ class AppWindow : public content::NotificationObserver,
const SessionID session_id_;
WindowType window_type_;
- content::NotificationRegistrar registrar_;
// Icon shown in the task bar.
gfx::Image app_icon_;