Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / api / tabs / windows_event_router.cc
index adc9a07..e3d2113 100644 (file)
@@ -6,9 +6,7 @@
 
 #include "base/values.h"
 #include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/extensions/event_router.h"
 #include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/extension_system.h"
 #include "chrome/browser/extensions/extension_util.h"
 #include "chrome/browser/extensions/window_controller.h"
 #include "chrome/browser/extensions/window_controller_list.h"
 #include "chrome/common/extensions/api/windows.h"
 #include "chrome/common/extensions/extension_constants.h"
 #include "content/public/browser/notification_service.h"
+#include "extensions/browser/event_router.h"
+#include "extensions/browser/extension_system.h"
 
 #if defined(TOOLKIT_GTK)
 #include "ui/base/x/active_window_watcher_x.h"
 #endif
 
+using content::BrowserContext;
+
 namespace extensions {
 
 namespace windows = extensions::api::windows;
@@ -106,19 +108,17 @@ void WindowsEventRouter::Observe(
 #endif
 }
 
-static void WillDispatchWindowFocusedEvent(Profile* new_active_profile,
+static void WillDispatchWindowFocusedEvent(BrowserContext* new_active_context,
                                            int window_id,
-                                           Profile* profile,
+                                           BrowserContext* context,
                                            const Extension* extension,
                                            base::ListValue* event_args) {
   // When switching between windows in the default and incognito profiles,
   // dispatch WINDOW_ID_NONE to extensions whose profile lost focus that
   // can't see the new focused window across the incognito boundary.
   // See crbug.com/46610.
-  if (new_active_profile && new_active_profile != profile &&
-      !extension_util::CanCrossIncognito(
-          extension,
-          extensions::ExtensionSystem::Get(profile)->extension_service())) {
+  if (new_active_context && new_active_context != context &&
+      !util::CanCrossIncognito(extension, context)) {
     event_args->Clear();
     event_args->Append(new base::FundamentalValue(
         extension_misc::kUnknownWindowId));
@@ -149,7 +149,9 @@ void WindowsEventRouter::OnActiveWindowChanged(
   scoped_ptr<Event> event(new Event(windows::OnFocusChanged::kEventName,
                                     make_scoped_ptr(new base::ListValue())));
   event->will_dispatch_callback =
-      base::Bind(&WillDispatchWindowFocusedEvent, window_profile, window_id);
+      base::Bind(&WillDispatchWindowFocusedEvent,
+                 static_cast<BrowserContext*>(window_profile),
+                 window_id);
   ExtensionSystem::Get(profile_)->event_router()->BroadcastEvent(event.Pass());
 }
 
@@ -157,7 +159,7 @@ void WindowsEventRouter::DispatchEvent(const std::string& event_name,
                                       Profile* profile,
                                       scoped_ptr<base::ListValue> args) {
   scoped_ptr<Event> event(new Event(event_name, args.Pass()));
-  event->restrict_to_profile = profile;
+  event->restrict_to_browser_context = profile;
   ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass());
 }