| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" | 5 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/extensions/event_router.h" | 9 #include "chrome/browser/extensions/event_router.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/extensions/extension_system.h" | 11 #include "chrome/browser/extensions/extension_system.h" |
| 12 #include "chrome/browser/extensions/extension_util.h" |
| 12 #include "chrome/browser/extensions/window_controller.h" | 13 #include "chrome/browser/extensions/window_controller.h" |
| 13 #include "chrome/browser/extensions/window_controller_list.h" | 14 #include "chrome/browser/extensions/window_controller_list.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/extensions/api/windows.h" | 16 #include "chrome/common/extensions/api/windows.h" |
| 16 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
| 17 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
| 18 | 19 |
| 19 #if defined(TOOLKIT_GTK) | 20 #if defined(TOOLKIT_GTK) |
| 20 #include "ui/base/x/active_window_watcher_x.h" | 21 #include "ui/base/x/active_window_watcher_x.h" |
| 21 #endif | 22 #endif |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 static void WillDispatchWindowFocusedEvent(Profile* new_active_profile, | 109 static void WillDispatchWindowFocusedEvent(Profile* new_active_profile, |
| 109 int window_id, | 110 int window_id, |
| 110 Profile* profile, | 111 Profile* profile, |
| 111 const Extension* extension, | 112 const Extension* extension, |
| 112 base::ListValue* event_args) { | 113 base::ListValue* event_args) { |
| 113 // When switching between windows in the default and incognito profiles, | 114 // When switching between windows in the default and incognito profiles, |
| 114 // dispatch WINDOW_ID_NONE to extensions whose profile lost focus that | 115 // dispatch WINDOW_ID_NONE to extensions whose profile lost focus that |
| 115 // can't see the new focused window across the incognito boundary. | 116 // can't see the new focused window across the incognito boundary. |
| 116 // See crbug.com/46610. | 117 // See crbug.com/46610. |
| 117 if (new_active_profile && new_active_profile != profile && | 118 if (new_active_profile && new_active_profile != profile && |
| 118 !extensions::ExtensionSystem::Get(profile)->extension_service()-> | 119 !extension_util::CanCrossIncognito( |
| 119 CanCrossIncognito(extension)) { | 120 extension, |
| 121 extensions::ExtensionSystem::Get(profile)->extension_service())) { |
| 120 event_args->Clear(); | 122 event_args->Clear(); |
| 121 event_args->Append(new base::FundamentalValue( | 123 event_args->Append(new base::FundamentalValue( |
| 122 extension_misc::kUnknownWindowId)); | 124 extension_misc::kUnknownWindowId)); |
| 123 } else { | 125 } else { |
| 124 event_args->Clear(); | 126 event_args->Clear(); |
| 125 event_args->Append(new base::FundamentalValue(window_id)); | 127 event_args->Append(new base::FundamentalValue(window_id)); |
| 126 } | 128 } |
| 127 } | 129 } |
| 128 | 130 |
| 129 void WindowsEventRouter::OnActiveWindowChanged( | 131 void WindowsEventRouter::OnActiveWindowChanged( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 153 | 155 |
| 154 void WindowsEventRouter::DispatchEvent(const std::string& event_name, | 156 void WindowsEventRouter::DispatchEvent(const std::string& event_name, |
| 155 Profile* profile, | 157 Profile* profile, |
| 156 scoped_ptr<base::ListValue> args) { | 158 scoped_ptr<base::ListValue> args) { |
| 157 scoped_ptr<Event> event(new Event(event_name, args.Pass())); | 159 scoped_ptr<Event> event(new Event(event_name, args.Pass())); |
| 158 event->restrict_to_profile = profile; | 160 event->restrict_to_profile = profile; |
| 159 ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass()); | 161 ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass()); |
| 160 } | 162 } |
| 161 | 163 |
| 162 } // namespace extensions | 164 } // namespace extensions |
| OLD | NEW |