| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 #else | 152 #else |
| 153 #error Unsupported | 153 #error Unsupported |
| 154 #endif | 154 #endif |
| 155 | 155 |
| 156 AppWindowRegistry* registry = AppWindowRegistry::Get(profile_); | 156 AppWindowRegistry* registry = AppWindowRegistry::Get(profile_); |
| 157 for (AppWindow* app_window : registry->app_windows()) | 157 for (AppWindow* app_window : registry->app_windows()) |
| 158 AddAppWindow(app_window); | 158 AddAppWindow(app_window); |
| 159 } | 159 } |
| 160 | 160 |
| 161 WindowsEventRouter::~WindowsEventRouter() { | 161 WindowsEventRouter::~WindowsEventRouter() { |
| 162 #if !defined(OS_MACOSX) | 162 #if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX) |
| 163 views::WidgetFocusManager::GetInstance()->RemoveFocusChangeListener(this); | 163 views::WidgetFocusManager::GetInstance()->RemoveFocusChangeListener(this); |
| 164 #endif | 164 #endif |
| 165 } | 165 } |
| 166 | 166 |
| 167 void WindowsEventRouter::OnAppWindowAdded(extensions::AppWindow* app_window) { | 167 void WindowsEventRouter::OnAppWindowAdded(extensions::AppWindow* app_window) { |
| 168 if (!profile_->IsSameProfile( | 168 if (!profile_->IsSameProfile( |
| 169 Profile::FromBrowserContext(app_window->browser_context()))) | 169 Profile::FromBrowserContext(app_window->browser_context()))) |
| 170 return; | 170 return; |
| 171 AddAppWindow(app_window); | 171 AddAppWindow(app_window); |
| 172 } | 172 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 if (!profile_->IsSameProfile(window_controller->profile())) | 207 if (!profile_->IsSameProfile(window_controller->profile())) |
| 208 return; | 208 return; |
| 209 | 209 |
| 210 int window_id = window_controller->GetWindowId(); | 210 int window_id = window_controller->GetWindowId(); |
| 211 std::unique_ptr<base::ListValue> args(new base::ListValue()); | 211 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
| 212 args->AppendInteger(window_id); | 212 args->AppendInteger(window_id); |
| 213 DispatchEvent(events::WINDOWS_ON_REMOVED, windows::OnRemoved::kEventName, | 213 DispatchEvent(events::WINDOWS_ON_REMOVED, windows::OnRemoved::kEventName, |
| 214 window_controller, std::move(args)); | 214 window_controller, std::move(args)); |
| 215 } | 215 } |
| 216 | 216 |
| 217 #if !defined(OS_MACOSX) | 217 #if defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX) |
| 218 void WindowsEventRouter::OnNativeFocusChanged(gfx::NativeView focused_now) { | 218 void WindowsEventRouter::OnNativeFocusChanged(gfx::NativeView focused_now) { |
| 219 if (!focused_now) | 219 if (!focused_now) |
| 220 OnActiveWindowChanged(nullptr); | 220 OnActiveWindowChanged(nullptr); |
| 221 } | 221 } |
| 222 #endif | 222 #endif |
| 223 | 223 |
| 224 void WindowsEventRouter::Observe( | 224 void WindowsEventRouter::Observe( |
| 225 int type, | 225 int type, |
| 226 const content::NotificationSource& source, | 226 const content::NotificationSource& source, |
| 227 const content::NotificationDetails& details) { | 227 const content::NotificationDetails& details) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 return EventRouter::Get(profile_)->HasEventListener(event_name); | 276 return EventRouter::Get(profile_)->HasEventListener(event_name); |
| 277 } | 277 } |
| 278 | 278 |
| 279 void WindowsEventRouter::AddAppWindow(extensions::AppWindow* app_window) { | 279 void WindowsEventRouter::AddAppWindow(extensions::AppWindow* app_window) { |
| 280 std::unique_ptr<AppWindowController> controller(new AppWindowController( | 280 std::unique_ptr<AppWindowController> controller(new AppWindowController( |
| 281 app_window, base::WrapUnique(new AppBaseWindow(app_window)), profile_)); | 281 app_window, base::WrapUnique(new AppBaseWindow(app_window)), profile_)); |
| 282 app_windows_[app_window->session_id().id()] = std::move(controller); | 282 app_windows_[app_window->session_id().id()] = std::move(controller); |
| 283 } | 283 } |
| 284 | 284 |
| 285 } // namespace extensions | 285 } // namespace extensions |
| OLD | NEW |