Chromium Code Reviews| 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/tabs_windows_api.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "chrome/browser/extensions/api/tabs/tabs_event_router.h" | 8 #include "chrome/browser/extensions/api/tabs/tabs_event_router.h" |
| 9 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" | 9 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 event_router->RegisterObserver(this, api::tabs::OnAttached::kEventName); | 34 event_router->RegisterObserver(this, api::tabs::OnAttached::kEventName); |
| 35 event_router->RegisterObserver(this, api::tabs::OnRemoved::kEventName); | 35 event_router->RegisterObserver(this, api::tabs::OnRemoved::kEventName); |
| 36 event_router->RegisterObserver(this, api::tabs::OnReplaced::kEventName); | 36 event_router->RegisterObserver(this, api::tabs::OnReplaced::kEventName); |
| 37 event_router->RegisterObserver(this, api::tabs::OnZoomChange::kEventName); | 37 event_router->RegisterObserver(this, api::tabs::OnZoomChange::kEventName); |
| 38 | 38 |
| 39 // Windows API Events. | 39 // Windows API Events. |
| 40 event_router->RegisterObserver(this, api::windows::OnCreated::kEventName); | 40 event_router->RegisterObserver(this, api::windows::OnCreated::kEventName); |
| 41 event_router->RegisterObserver(this, api::windows::OnRemoved::kEventName); | 41 event_router->RegisterObserver(this, api::windows::OnRemoved::kEventName); |
| 42 event_router->RegisterObserver(this, | 42 event_router->RegisterObserver(this, |
| 43 api::windows::OnFocusChanged::kEventName); | 43 api::windows::OnFocusChanged::kEventName); |
| 44 | |
| 45 // We listen to windows events right from the beginning because we | |
| 46 // have to create a WindowController for each AppWindow. | |
| 47 windows_event_router(); | |
|
dcheng
2015/06/29 18:15:49
Construct this directly in the initializer list in
llandwerlin-old
2015/06/30 10:20:47
Done.
| |
| 44 } | 48 } |
| 45 | 49 |
| 46 TabsWindowsAPI::~TabsWindowsAPI() { | 50 TabsWindowsAPI::~TabsWindowsAPI() { |
| 47 } | 51 } |
| 48 | 52 |
| 49 // static | 53 // static |
| 50 TabsWindowsAPI* TabsWindowsAPI::Get(content::BrowserContext* context) { | 54 TabsWindowsAPI* TabsWindowsAPI::Get(content::BrowserContext* context) { |
| 51 return BrowserContextKeyedAPIFactory<TabsWindowsAPI>::Get(context); | 55 return BrowserContextKeyedAPIFactory<TabsWindowsAPI>::Get(context); |
| 52 } | 56 } |
| 53 | 57 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 73 g_factory = LAZY_INSTANCE_INITIALIZER; | 77 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 74 | 78 |
| 75 BrowserContextKeyedAPIFactory<TabsWindowsAPI>* | 79 BrowserContextKeyedAPIFactory<TabsWindowsAPI>* |
| 76 TabsWindowsAPI::GetFactoryInstance() { | 80 TabsWindowsAPI::GetFactoryInstance() { |
| 77 return g_factory.Pointer(); | 81 return g_factory.Pointer(); |
| 78 } | 82 } |
| 79 | 83 |
| 80 void TabsWindowsAPI::OnListenerAdded(const EventListenerInfo& details) { | 84 void TabsWindowsAPI::OnListenerAdded(const EventListenerInfo& details) { |
| 81 // Initialize the event routers. | 85 // Initialize the event routers. |
| 82 tabs_event_router(); | 86 tabs_event_router(); |
| 83 windows_event_router(); | 87 windows_event_router()->DispatchEvents(); |
| 84 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 88 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
| 85 } | 89 } |
| 86 | 90 |
| 87 } // namespace extensions | 91 } // namespace extensions |
| OLD | NEW |