| 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
| 9 #include <string> | 10 #include <string> |
| 10 | 11 |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/scoped_observer.h" | 13 #include "base/scoped_observer.h" |
| 14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 15 #include "chrome/browser/extensions/window_controller_list_observer.h" | 15 #include "chrome/browser/extensions/window_controller_list_observer.h" |
| 16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 18 #include "extensions/browser/app_window/app_window_registry.h" | 18 #include "extensions/browser/app_window/app_window_registry.h" |
| 19 #include "extensions/browser/extension_event_histogram_value.h" | 19 #include "extensions/browser/extension_event_histogram_value.h" |
| 20 | 20 |
| 21 #if !defined(OS_MACOSX) | 21 #if !defined(OS_MACOSX) |
| 22 #include "ui/views/focus/widget_focus_manager.h" | 22 #include "ui/views/focus/widget_focus_manager.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 #endif | 66 #endif |
| 67 | 67 |
| 68 // content::NotificationObserver. | 68 // content::NotificationObserver. |
| 69 void Observe(int type, | 69 void Observe(int type, |
| 70 const content::NotificationSource& source, | 70 const content::NotificationSource& source, |
| 71 const content::NotificationDetails& details) override; | 71 const content::NotificationDetails& details) override; |
| 72 | 72 |
| 73 void DispatchEvent(events::HistogramValue histogram_value, | 73 void DispatchEvent(events::HistogramValue histogram_value, |
| 74 const std::string& event_name, | 74 const std::string& event_name, |
| 75 WindowController* window_controller, | 75 WindowController* window_controller, |
| 76 scoped_ptr<base::ListValue> args); | 76 std::unique_ptr<base::ListValue> args); |
| 77 bool HasEventListener(const std::string& event_name); | 77 bool HasEventListener(const std::string& event_name); |
| 78 void AddAppWindow(extensions::AppWindow* app_window); | 78 void AddAppWindow(extensions::AppWindow* app_window); |
| 79 | 79 |
| 80 content::NotificationRegistrar registrar_; | 80 content::NotificationRegistrar registrar_; |
| 81 | 81 |
| 82 // The main profile that owns this event router. | 82 // The main profile that owns this event router. |
| 83 Profile* profile_; | 83 Profile* profile_; |
| 84 | 84 |
| 85 // The profile the currently focused window belongs to; either the main or | 85 // The profile the currently focused window belongs to; either the main or |
| 86 // incognito profile or NULL (none of the above). We remember this in order | 86 // incognito profile or NULL (none of the above). We remember this in order |
| 87 // to correctly handle focus changes between non-OTR and OTR windows. | 87 // to correctly handle focus changes between non-OTR and OTR windows. |
| 88 Profile* focused_profile_; | 88 Profile* focused_profile_; |
| 89 | 89 |
| 90 // The currently focused window. We keep this so as to avoid sending multiple | 90 // The currently focused window. We keep this so as to avoid sending multiple |
| 91 // windows.onFocusChanged events with the same windowId. | 91 // windows.onFocusChanged events with the same windowId. |
| 92 int focused_window_id_; | 92 int focused_window_id_; |
| 93 | 93 |
| 94 using AppWindowMap = std::map<int, scoped_ptr<AppWindowController>>; | 94 using AppWindowMap = std::map<int, std::unique_ptr<AppWindowController>>; |
| 95 // Map of application windows, the key to the session of the app window. | 95 // Map of application windows, the key to the session of the app window. |
| 96 AppWindowMap app_windows_; | 96 AppWindowMap app_windows_; |
| 97 | 97 |
| 98 // Observed AppWindowRegistry. | 98 // Observed AppWindowRegistry. |
| 99 ScopedObserver<AppWindowRegistry, AppWindowRegistry::Observer> | 99 ScopedObserver<AppWindowRegistry, AppWindowRegistry::Observer> |
| 100 observed_app_registry_; | 100 observed_app_registry_; |
| 101 | 101 |
| 102 // Observed WindowControllerList. | 102 // Observed WindowControllerList. |
| 103 ScopedObserver<WindowControllerList, WindowControllerListObserver> | 103 ScopedObserver<WindowControllerList, WindowControllerListObserver> |
| 104 observed_controller_list_; | 104 observed_controller_list_; |
| 105 | 105 |
| 106 DISALLOW_COPY_AND_ASSIGN(WindowsEventRouter); | 106 DISALLOW_COPY_AND_ASSIGN(WindowsEventRouter); |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 } // namespace extensions | 109 } // namespace extensions |
| 110 | 110 |
| 111 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ | 111 #endif // CHROME_BROWSER_EXTENSIONS_API_TABS_WINDOWS_EVENT_ROUTER_H_ |
| OLD | NEW |