Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / active_tab_permission_granter.cc
index ecedd34..1a67167 100644 (file)
@@ -4,18 +4,11 @@
 
 #include "chrome/browser/extensions/active_tab_permission_granter.h"
 
-#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/extensions/extension_service.h"
 #include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/sessions/session_id.h"
 #include "content/public/browser/navigation_details.h"
 #include "content/public/browser/navigation_entry.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/browser/notification_source.h"
-#include "content/public/browser/render_process_host.h"
 #include "content/public/browser/web_contents.h"
-#include "extensions/browser/extension_system.h"
-#include "extensions/common/extension.h"
+#include "extensions/browser/extension_registry.h"
 #include "extensions/common/extension_messages.h"
 #include "extensions/common/permissions/permission_set.h"
 #include "extensions/common/permissions/permissions_data.h"
@@ -27,16 +20,21 @@ using content::WebContentsObserver;
 namespace extensions {
 
 ActiveTabPermissionGranter::ActiveTabPermissionGranter(
-    content::WebContents* web_contents, int tab_id, Profile* profile)
-    : WebContentsObserver(web_contents), tab_id_(tab_id) {
-  registrar_.Add(this,
-                 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
-                 content::Source<Profile>(profile));
+    content::WebContents* web_contents,
+    int tab_id,
+    Profile* profile)
+    : WebContentsObserver(web_contents),
+      tab_id_(tab_id),
+      extension_registry_observer_(this) {
+  extension_registry_observer_.Add(ExtensionRegistry::Get(profile));
 }
 
 ActiveTabPermissionGranter::~ActiveTabPermissionGranter() {}
 
 void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) {
+  // Active tab grant request implies there was a user gesture.
+  web_contents()->UserGestureDone();
+
   if (granted_extensions_.Contains(extension->id()))
     return;
 
@@ -85,18 +83,14 @@ void ActiveTabPermissionGranter::DidNavigateMainFrame(
   ClearActiveExtensionsAndNotify();
 }
 
-void ActiveTabPermissionGranter::WebContentsDestroyed(
-    content::WebContents* web_contents) {
+void ActiveTabPermissionGranter::WebContentsDestroyed() {
   ClearActiveExtensionsAndNotify();
 }
 
-void ActiveTabPermissionGranter::Observe(
-    int type,
-    const content::NotificationSource& source,
-    const content::NotificationDetails& details) {
-  DCHECK_EQ(type, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED);
-  const Extension* extension =
-      content::Details<UnloadedExtensionInfo>(details)->extension;
+void ActiveTabPermissionGranter::OnExtensionUnloaded(
+    content::BrowserContext* browser_context,
+    const Extension* extension,
+    UnloadedExtensionInfo::Reason reason) {
   // Note: don't need to clear the permissions (nor tell the renderer about it)
   // because it's being unloaded anyway.
   granted_extensions_.Remove(extension->id());