OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_browser_event_router.h" | 5 #include "chrome/browser/extensions/extension_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/extension_event_names.h" | 9 #include "chrome/browser/extensions/extension_event_names.h" |
10 #include "chrome/browser/extensions/extension_event_router.h" | 10 #include "chrome/browser/extensions/extension_event_router.h" |
11 #include "chrome/browser/extensions/extension_page_actions_module_constants.h" | 11 #include "chrome/browser/extensions/extension_page_actions_module_constants.h" |
12 #include "chrome/browser/extensions/extension_tab_util.h" | 12 #include "chrome/browser/extensions/extension_tab_util.h" |
13 #include "chrome/browser/extensions/extension_tabs_module_constants.h" | 13 #include "chrome/browser/extensions/extension_tabs_module_constants.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/tabs/tab_strip_model.h" | 15 #include "chrome/browser/tabs/tab_strip_model.h" |
16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
18 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
19 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
20 #include "chrome/common/extensions/extension_constants.h" | 20 #include "chrome/common/extensions/extension_constants.h" |
21 #include "content/browser/tab_contents/navigation_entry.h" | 21 #include "content/browser/tab_contents/navigation_entry.h" |
22 #include "content/browser/tab_contents/tab_contents.h" | 22 #include "content/browser/tab_contents/tab_contents.h" |
23 #include "content/common/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
24 | 24 |
25 namespace events = extension_event_names; | 25 namespace events = extension_event_names; |
26 namespace tab_keys = extension_tabs_module_constants; | 26 namespace tab_keys = extension_tabs_module_constants; |
27 namespace page_action_keys = extension_page_actions_module_constants; | 27 namespace page_action_keys = extension_page_actions_module_constants; |
28 | 28 |
29 ExtensionBrowserEventRouter::TabEntry::TabEntry() | 29 ExtensionBrowserEventRouter::TabEntry::TabEntry() |
30 : complete_waiting_on_load_(false), | 30 : complete_waiting_on_load_(false), |
31 url_() { | 31 url_() { |
32 } | 32 } |
33 | 33 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 return; | 68 return; |
69 BrowserList::AddObserver(this); | 69 BrowserList::AddObserver(this); |
70 #if defined(TOOLKIT_VIEWS) | 70 #if defined(TOOLKIT_VIEWS) |
71 views::WidgetFocusManager::GetInstance()->AddFocusChangeListener(this); | 71 views::WidgetFocusManager::GetInstance()->AddFocusChangeListener(this); |
72 #elif defined(TOOLKIT_GTK) | 72 #elif defined(TOOLKIT_GTK) |
73 ui::ActiveWindowWatcherX::AddObserver(this); | 73 ui::ActiveWindowWatcherX::AddObserver(this); |
74 #elif defined(OS_MACOSX) | 74 #elif defined(OS_MACOSX) |
75 // Needed for when no suitable window can be passed to an extension as the | 75 // Needed for when no suitable window can be passed to an extension as the |
76 // currently focused window. | 76 // currently focused window. |
77 registrar_.Add(this, content::NOTIFICATION_NO_KEY_WINDOW, | 77 registrar_.Add(this, content::NOTIFICATION_NO_KEY_WINDOW, |
78 NotificationService::AllSources()); | 78 content::NotificationService::AllSources()); |
79 #endif | 79 #endif |
80 | 80 |
81 // Init() can happen after the browser is running, so catch up with any | 81 // Init() can happen after the browser is running, so catch up with any |
82 // windows that already exist. | 82 // windows that already exist. |
83 for (BrowserList::const_iterator iter = BrowserList::begin(); | 83 for (BrowserList::const_iterator iter = BrowserList::begin(); |
84 iter != BrowserList::end(); ++iter) { | 84 iter != BrowserList::end(); ++iter) { |
85 RegisterForBrowserNotifications(*iter); | 85 RegisterForBrowserNotifications(*iter); |
86 | 86 |
87 // Also catch up our internal bookkeeping of tab entries. | 87 // Also catch up our internal bookkeeping of tab entries. |
88 Browser* browser = *iter; | 88 Browser* browser = *iter; |
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 | 624 |
625 void ExtensionBrowserEventRouter::BrowserActionExecuted( | 625 void ExtensionBrowserEventRouter::BrowserActionExecuted( |
626 Profile* profile, const std::string& extension_id, Browser* browser) { | 626 Profile* profile, const std::string& extension_id, Browser* browser) { |
627 TabContentsWrapper* tab_contents = NULL; | 627 TabContentsWrapper* tab_contents = NULL; |
628 int tab_id = 0; | 628 int tab_id = 0; |
629 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) | 629 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) |
630 return; | 630 return; |
631 DispatchEventWithTab(profile, extension_id, "browserAction.onClicked", | 631 DispatchEventWithTab(profile, extension_id, "browserAction.onClicked", |
632 tab_contents->tab_contents(), true); | 632 tab_contents->tab_contents(), true); |
633 } | 633 } |
OLD | NEW |