OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_writer.h" | 7 #include "base/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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 return changed_properties; | 78 return changed_properties; |
79 } | 79 } |
80 | 80 |
81 ExtensionBrowserEventRouter* ExtensionBrowserEventRouter::GetInstance() { | 81 ExtensionBrowserEventRouter* ExtensionBrowserEventRouter::GetInstance() { |
82 return Singleton<ExtensionBrowserEventRouter>::get(); | 82 return Singleton<ExtensionBrowserEventRouter>::get(); |
83 } | 83 } |
84 | 84 |
85 static void DispatchEvent(Profile* profile, | 85 static void DispatchEvent(Profile* profile, |
86 const char* event_name, | 86 const char* event_name, |
87 const std::string json_args) { | 87 const std::string json_args) { |
88 ExtensionMessageService::GetInstance(profile->GetRequestContext())-> | 88 if (profile->GetExtensionMessageService()) { |
89 DispatchEventToRenderers(event_name, json_args); | 89 profile->GetExtensionMessageService()-> |
| 90 DispatchEventToRenderers(event_name, json_args); |
| 91 } |
90 } | 92 } |
91 | 93 |
92 static void DispatchSimpleBrowserEvent(Profile* profile, | 94 static void DispatchSimpleBrowserEvent(Profile* profile, |
93 const int window_id, | 95 const int window_id, |
94 const char* event_name) { | 96 const char* event_name) { |
95 ListValue args; | 97 ListValue args; |
96 args.Append(Value::CreateIntegerValue(window_id)); | 98 args.Append(Value::CreateIntegerValue(window_id)); |
97 | 99 |
98 std::string json_args; | 100 std::string json_args; |
99 JSONWriter::Write(&args, false, &json_args); | 101 JSONWriter::Write(&args, false, &json_args); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 object_args->Set(tab_keys::kDataKey, data); | 345 object_args->Set(tab_keys::kDataKey, data); |
344 | 346 |
345 args.Append(object_args); | 347 args.Append(object_args); |
346 | 348 |
347 std::string json_args; | 349 std::string json_args; |
348 JSONWriter::Write(&args, false, &json_args); | 350 JSONWriter::Write(&args, false, &json_args); |
349 | 351 |
350 std::string event_name = extension_id + std::string("/") + page_action_id; | 352 std::string event_name = extension_id + std::string("/") + page_action_id; |
351 DispatchEvent(profile, event_name.c_str(), json_args); | 353 DispatchEvent(profile, event_name.c_str(), json_args); |
352 } | 354 } |
OLD | NEW |