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_toolstrip_api.h" | 5 #include "chrome/browser/extensions/extension_toolstrip_api.h" |
6 | 6 |
7 #include "base/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/browser/browser.h" | 9 #include "chrome/browser/browser.h" |
10 #include "chrome/browser/extensions/extension_host.h" | 10 #include "chrome/browser/extensions/extension_host.h" |
11 #include "chrome/browser/extensions/extension_message_service.h" | 11 #include "chrome/browser/extensions/extension_message_service.h" |
12 #include "chrome/browser/extensions/extension_shelf_model.h" | 12 #include "chrome/browser/extensions/extension_shelf_model.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/profile.h" | 14 #include "chrome/browser/profile.h" |
15 | 15 |
16 namespace extension_toolstrip_api_events { | 16 namespace extension_toolstrip_api_events { |
17 const char kOnToolstripExpanded[] = "toolstrip.onExpanded.%d"; | 17 const char kOnToolstripExpanded[] = "toolstrip.onExpanded.%d"; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 return true; | 124 return true; |
125 } | 125 } |
126 | 126 |
127 // static | 127 // static |
128 void ToolstripEventRouter::DispatchEvent(Profile *profile, | 128 void ToolstripEventRouter::DispatchEvent(Profile *profile, |
129 int routing_id, | 129 int routing_id, |
130 const char *event_name, | 130 const char *event_name, |
131 const Value& json) { | 131 const Value& json) { |
132 if (profile->GetExtensionMessageService()) { | 132 if (profile->GetExtensionMessageService()) { |
133 std::string json_args; | 133 std::string json_args; |
134 JSONWriter::Write(&json, false, &json_args); | 134 base::JSONWriter::Write(&json, false, &json_args); |
135 std::string full_event_name = StringPrintf(event_name, routing_id); | 135 std::string full_event_name = StringPrintf(event_name, routing_id); |
136 profile->GetExtensionMessageService()-> | 136 profile->GetExtensionMessageService()-> |
137 DispatchEventToRenderers(full_event_name, json_args); | 137 DispatchEventToRenderers(full_event_name, json_args); |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 // static | 141 // static |
142 void ToolstripEventRouter::OnToolstripExpanded(Profile* profile, | 142 void ToolstripEventRouter::OnToolstripExpanded(Profile* profile, |
143 int routing_id, | 143 int routing_id, |
144 const GURL &url, | 144 const GURL &url, |
(...skipping 11 matching lines...) Expand all Loading... |
156 void ToolstripEventRouter::OnToolstripCollapsed(Profile* profile, | 156 void ToolstripEventRouter::OnToolstripCollapsed(Profile* profile, |
157 int routing_id, | 157 int routing_id, |
158 const GURL &url) { | 158 const GURL &url) { |
159 ListValue args; | 159 ListValue args; |
160 DictionaryValue* obj = new DictionaryValue(); | 160 DictionaryValue* obj = new DictionaryValue(); |
161 if (!url.is_empty()) | 161 if (!url.is_empty()) |
162 obj->SetString(keys::kUrlKey, url.spec()); | 162 obj->SetString(keys::kUrlKey, url.spec()); |
163 args.Append(obj); | 163 args.Append(obj); |
164 DispatchEvent(profile, routing_id, events::kOnToolstripCollapsed, args); | 164 DispatchEvent(profile, routing_id, events::kOnToolstripCollapsed, args); |
165 } | 165 } |
OLD | NEW |