| 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/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/extensions/extension_window_controller.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/tabs/tab_strip_model.h" | 16 #include "chrome/browser/tabs/tab_strip_model.h" |
| 16 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 18 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
| 19 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
| 20 #include "chrome/common/extensions/extension_constants.h" | 21 #include "chrome/common/extensions/extension_constants.h" |
| 21 #include "content/public/browser/navigation_controller.h" | 22 #include "content/public/browser/navigation_controller.h" |
| 22 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 WebContents* contents) { | 165 WebContents* contents) { |
| 165 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 166 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 166 content::Source<NavigationController>(&contents->GetController())); | 167 content::Source<NavigationController>(&contents->GetController())); |
| 167 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 168 registrar_.Remove(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 168 content::Source<WebContents>(contents)); | 169 content::Source<WebContents>(contents)); |
| 169 } | 170 } |
| 170 | 171 |
| 171 void ExtensionBrowserEventRouter::OnBrowserWindowReady(const Browser* browser) { | 172 void ExtensionBrowserEventRouter::OnBrowserWindowReady(const Browser* browser) { |
| 172 ListValue args; | 173 ListValue args; |
| 173 | 174 |
| 174 DictionaryValue* window_dictionary = ExtensionTabUtil::CreateWindowValue( | 175 DCHECK(browser->extension_window_controller()); |
| 175 browser, false); | 176 DictionaryValue* window_dictionary = |
| 177 browser->extension_window_controller()->CreateWindowValue(); |
| 176 args.Append(window_dictionary); | 178 args.Append(window_dictionary); |
| 177 | 179 |
| 178 std::string json_args; | 180 std::string json_args; |
| 179 base::JSONWriter::Write(&args, false, &json_args); | 181 base::JSONWriter::Write(&args, false, &json_args); |
| 180 | 182 |
| 181 DispatchEvent(browser->profile(), events::kOnWindowCreated, json_args); | 183 DispatchEvent(browser->profile(), events::kOnWindowCreated, json_args); |
| 182 } | 184 } |
| 183 | 185 |
| 184 void ExtensionBrowserEventRouter::OnBrowserRemoved(const Browser* browser) { | 186 void ExtensionBrowserEventRouter::OnBrowserRemoved(const Browser* browser) { |
| 185 if (!profile_->IsSameProfile(browser->profile())) | 187 if (!profile_->IsSameProfile(browser->profile())) |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 ListValue args; | 663 ListValue args; |
| 662 args.Append(Value::CreateStringValue(command)); | 664 args.Append(Value::CreateStringValue(command)); |
| 663 std::string json_args; | 665 std::string json_args; |
| 664 base::JSONWriter::Write(&args, false, &json_args); | 666 base::JSONWriter::Write(&args, false, &json_args); |
| 665 | 667 |
| 666 DispatchEventToExtension(profile, | 668 DispatchEventToExtension(profile, |
| 667 extension_id, | 669 extension_id, |
| 668 "experimental.keybinding.onCommand", | 670 "experimental.keybinding.onCommand", |
| 669 json_args); | 671 json_args); |
| 670 } | 672 } |
| OLD | NEW |