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/browser_event_router.h" | 5 #include "chrome/browser/extensions/browser_event_router.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_
api_constants.h" | 9 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_
api_constants.h" |
10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
11 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" | 11 #include "chrome/browser/extensions/api/tabs/tabs_windows_api.h" |
12 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" | 12 #include "chrome/browser/extensions/api/tabs/windows_event_router.h" |
13 #include "chrome/browser/extensions/event_names.h" | 13 #include "chrome/browser/extensions/event_names.h" |
14 #include "chrome/browser/extensions/extension_action.h" | 14 #include "chrome/browser/extensions/extension_action.h" |
15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
16 #include "chrome/browser/extensions/extension_system.h" | 16 #include "chrome/browser/extensions/extension_system.h" |
17 #include "chrome/browser/extensions/extension_tab_util.h" | 17 #include "chrome/browser/extensions/extension_tab_util.h" |
18 #include "chrome/browser/extensions/window_controller.h" | 18 #include "chrome/browser/extensions/window_controller.h" |
19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 21 #include "chrome/browser/ui/browser_iterator.h" |
21 #include "chrome/browser/ui/browser_list.h" | 22 #include "chrome/browser/ui/browser_list.h" |
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
23 #include "chrome/common/extensions/api/extension_action/action_info.h" | 24 #include "chrome/common/extensions/api/extension_action/action_info.h" |
24 #include "chrome/common/extensions/extension_constants.h" | 25 #include "chrome/common/extensions/extension_constants.h" |
25 #include "content/public/browser/navigation_controller.h" | 26 #include "content/public/browser/navigation_controller.h" |
26 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
27 #include "content/public/browser/notification_types.h" | 28 #include "content/public/browser/notification_types.h" |
28 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
29 | 30 |
30 namespace events = extensions::event_names; | 31 namespace events = extensions::event_names; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 } | 75 } |
75 | 76 |
76 BrowserEventRouter::BrowserEventRouter(Profile* profile) | 77 BrowserEventRouter::BrowserEventRouter(Profile* profile) |
77 : profile_(profile) { | 78 : profile_(profile) { |
78 DCHECK(!profile->IsOffTheRecord()); | 79 DCHECK(!profile->IsOffTheRecord()); |
79 | 80 |
80 BrowserList::AddObserver(this); | 81 BrowserList::AddObserver(this); |
81 | 82 |
82 // Init() can happen after the browser is running, so catch up with any | 83 // Init() can happen after the browser is running, so catch up with any |
83 // windows that already exist. | 84 // windows that already exist. |
84 for (BrowserList::const_iterator iter = BrowserList::begin(); | 85 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
85 iter != BrowserList::end(); ++iter) { | 86 RegisterForBrowserNotifications(*it); |
86 RegisterForBrowserNotifications(*iter); | |
87 | 87 |
88 // Also catch up our internal bookkeeping of tab entries. | 88 // Also catch up our internal bookkeeping of tab entries. |
89 Browser* browser = *iter; | 89 Browser* browser = *it; |
90 if (browser->tab_strip_model()) { | 90 if (browser->tab_strip_model()) { |
91 for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { | 91 for (int i = 0; i < browser->tab_strip_model()->count(); ++i) { |
92 WebContents* contents = browser->tab_strip_model()->GetWebContentsAt(i); | 92 WebContents* contents = browser->tab_strip_model()->GetWebContentsAt(i); |
93 int tab_id = ExtensionTabUtil::GetTabId(contents); | 93 int tab_id = ExtensionTabUtil::GetTabId(contents); |
94 tab_entries_[tab_id] = TabEntry(); | 94 tab_entries_[tab_id] = TabEntry(); |
95 } | 95 } |
96 } | 96 } |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 | 608 |
609 DispatchEventToExtension(profile, | 609 DispatchEventToExtension(profile, |
610 extension_action.extension_id(), | 610 extension_action.extension_id(), |
611 event_name, | 611 event_name, |
612 args.Pass(), | 612 args.Pass(), |
613 EventRouter::USER_GESTURE_ENABLED); | 613 EventRouter::USER_GESTURE_ENABLED); |
614 } | 614 } |
615 } | 615 } |
616 | 616 |
617 } // namespace extensions | 617 } // namespace extensions |
OLD | NEW |