| 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_names.h" | 9 #include "chrome/browser/extensions/event_names.h" |
| 10 #include "chrome/browser/extensions/event_router.h" | 10 #include "chrome/browser/extensions/event_router.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 args.Pass()); | 65 args.Pass()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void WindowsEventRouter::OnWindowControllerRemoved( | 68 void WindowsEventRouter::OnWindowControllerRemoved( |
| 69 WindowController* window_controller) { | 69 WindowController* window_controller) { |
| 70 if (!profile_->IsSameProfile(window_controller->profile())) | 70 if (!profile_->IsSameProfile(window_controller->profile())) |
| 71 return; | 71 return; |
| 72 | 72 |
| 73 int window_id = window_controller->GetWindowId(); | 73 int window_id = window_controller->GetWindowId(); |
| 74 scoped_ptr<base::ListValue> args(new base::ListValue()); | 74 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 75 args->Append(Value::CreateIntegerValue(window_id)); | 75 args->Append(new base::FundamentalValue(window_id)); |
| 76 DispatchEvent(event_names::kOnWindowRemoved, window_controller->profile(), | 76 DispatchEvent(event_names::kOnWindowRemoved, window_controller->profile(), |
| 77 args.Pass()); | 77 args.Pass()); |
| 78 } | 78 } |
| 79 | 79 |
| 80 #if defined(TOOLKIT_VIEWS) | 80 #if defined(TOOLKIT_VIEWS) |
| 81 void WindowsEventRouter::OnNativeFocusChange( | 81 void WindowsEventRouter::OnNativeFocusChange( |
| 82 gfx::NativeView focused_before, | 82 gfx::NativeView focused_before, |
| 83 gfx::NativeView focused_now) { | 83 gfx::NativeView focused_now) { |
| 84 if (!focused_now) | 84 if (!focused_now) |
| 85 OnActiveWindowChanged(NULL); | 85 OnActiveWindowChanged(NULL); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 110 const Extension* extension, | 110 const Extension* extension, |
| 111 base::ListValue* event_args) { | 111 base::ListValue* event_args) { |
| 112 // When switching between windows in the default and incognito profiles, | 112 // When switching between windows in the default and incognito profiles, |
| 113 // dispatch WINDOW_ID_NONE to extensions whose profile lost focus that | 113 // dispatch WINDOW_ID_NONE to extensions whose profile lost focus that |
| 114 // can't see the new focused window across the incognito boundary. | 114 // can't see the new focused window across the incognito boundary. |
| 115 // See crbug.com/46610. | 115 // See crbug.com/46610. |
| 116 if (new_active_profile && new_active_profile != profile && | 116 if (new_active_profile && new_active_profile != profile && |
| 117 !extensions::ExtensionSystem::Get(profile)->extension_service()-> | 117 !extensions::ExtensionSystem::Get(profile)->extension_service()-> |
| 118 CanCrossIncognito(extension)) { | 118 CanCrossIncognito(extension)) { |
| 119 event_args->Clear(); | 119 event_args->Clear(); |
| 120 event_args->Append(Value::CreateIntegerValue( | 120 event_args->Append(new base::FundamentalValue( |
| 121 extension_misc::kUnknownWindowId)); | 121 extension_misc::kUnknownWindowId)); |
| 122 } else { | 122 } else { |
| 123 event_args->Clear(); | 123 event_args->Clear(); |
| 124 event_args->Append(Value::CreateIntegerValue(window_id)); | 124 event_args->Append(new base::FundamentalValue(window_id)); |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 void WindowsEventRouter::OnActiveWindowChanged( | 128 void WindowsEventRouter::OnActiveWindowChanged( |
| 129 WindowController* window_controller) { | 129 WindowController* window_controller) { |
| 130 Profile* window_profile = NULL; | 130 Profile* window_profile = NULL; |
| 131 int window_id = extension_misc::kUnknownWindowId; | 131 int window_id = extension_misc::kUnknownWindowId; |
| 132 if (window_controller && | 132 if (window_controller && |
| 133 profile_->IsSameProfile(window_controller->profile())) { | 133 profile_->IsSameProfile(window_controller->profile())) { |
| 134 window_profile = window_controller->profile(); | 134 window_profile = window_controller->profile(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 152 | 152 |
| 153 void WindowsEventRouter::DispatchEvent(const char* event_name, | 153 void WindowsEventRouter::DispatchEvent(const char* event_name, |
| 154 Profile* profile, | 154 Profile* profile, |
| 155 scoped_ptr<base::ListValue> args) { | 155 scoped_ptr<base::ListValue> args) { |
| 156 scoped_ptr<Event> event(new Event(event_name, args.Pass())); | 156 scoped_ptr<Event> event(new Event(event_name, args.Pass())); |
| 157 event->restrict_to_profile = profile; | 157 event->restrict_to_profile = profile; |
| 158 ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass()); | 158 ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass()); |
| 159 } | 159 } |
| 160 | 160 |
| 161 } // namespace extensions | 161 } // namespace extensions |
| OLD | NEW |