OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser.h" | 9 #include "chrome/browser/browser.h" |
10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 } | 130 } |
131 | 131 |
132 initialized_ = true; | 132 initialized_ = true; |
133 } | 133 } |
134 | 134 |
135 ExtensionBrowserEventRouter::ExtensionBrowserEventRouter() | 135 ExtensionBrowserEventRouter::ExtensionBrowserEventRouter() |
136 : initialized_(false), | 136 : initialized_(false), |
137 focused_window_id_(extension_misc::kUnknownWindowId), | 137 focused_window_id_(extension_misc::kUnknownWindowId), |
138 profile_(NULL) { } | 138 profile_(NULL) { } |
139 | 139 |
| 140 ExtensionBrowserEventRouter::~ExtensionBrowserEventRouter() {} |
| 141 |
140 void ExtensionBrowserEventRouter::OnBrowserAdded(const Browser* browser) { | 142 void ExtensionBrowserEventRouter::OnBrowserAdded(const Browser* browser) { |
141 RegisterForBrowserNotifications(browser); | 143 RegisterForBrowserNotifications(browser); |
142 } | 144 } |
143 | 145 |
144 void ExtensionBrowserEventRouter::RegisterForBrowserNotifications( | 146 void ExtensionBrowserEventRouter::RegisterForBrowserNotifications( |
145 const Browser* browser) { | 147 const Browser* browser) { |
146 // Start listening to TabStripModel events for this browser. | 148 // Start listening to TabStripModel events for this browser. |
147 browser->tabstrip_model()->AddObserver(this); | 149 browser->tabstrip_model()->AddObserver(this); |
148 | 150 |
149 // If this is a new window, it isn't ready at this point, so we register to be | 151 // If this is a new window, it isn't ready at this point, so we register to be |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 void ExtensionBrowserEventRouter::BrowserActionExecuted( | 486 void ExtensionBrowserEventRouter::BrowserActionExecuted( |
485 Profile* profile, const std::string& extension_id, Browser* browser) { | 487 Profile* profile, const std::string& extension_id, Browser* browser) { |
486 TabContents* tab_contents = NULL; | 488 TabContents* tab_contents = NULL; |
487 int tab_id = 0; | 489 int tab_id = 0; |
488 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) | 490 if (!ExtensionTabUtil::GetDefaultTab(browser, &tab_contents, &tab_id)) |
489 return; | 491 return; |
490 std::string event_name = ExtensionEventRouter::GetPerExtensionEventName( | 492 std::string event_name = ExtensionEventRouter::GetPerExtensionEventName( |
491 "browserAction.onClicked", extension_id); | 493 "browserAction.onClicked", extension_id); |
492 DispatchEventWithTab(profile, event_name.c_str(), tab_contents); | 494 DispatchEventWithTab(profile, event_name.c_str(), tab_contents); |
493 } | 495 } |
OLD | NEW |