Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(709)

Side by Side Diff: chrome/common/extensions/command.cc

Issue 10834106: Implement Keybinding for script badges. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/common/extensions/command.h" 5 #include "chrome/common/extensions/command.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_split.h" 9 #include "base/string_split.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 iter->second); 224 iter->second);
225 return false; 225 return false;
226 } 226 }
227 227
228 if (iter->first == key) { 228 if (iter->first == key) {
229 // This platform is our platform, so grab this key. 229 // This platform is our platform, so grab this key.
230 accelerator_ = accelerator; 230 accelerator_ = accelerator;
231 command_name_ = command_name; 231 command_name_ = command_name;
232 232
233 if (command_name != 233 if (command_name !=
234 extension_manifest_values::kPageActionKeybindingEvent && 234 extension_manifest_values::kPageActionCommandEvent &&
235 command_name != 235 command_name !=
236 extension_manifest_values::kBrowserActionKeybindingEvent) { 236 extension_manifest_values::kBrowserActionCommandEvent &&
237 command_name !=
238 extension_manifest_values::kScriptBadgeCommandEvent) {
237 if (!command->GetString(keys::kDescription, &description_) || 239 if (!command->GetString(keys::kDescription, &description_) ||
238 description_.empty()) { 240 description_.empty()) {
239 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( 241 *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
240 errors::kInvalidKeyBindingDescription, 242 errors::kInvalidKeyBindingDescription,
241 base::IntToString(index)); 243 base::IntToString(index));
242 return false; 244 return false;
243 } 245 }
244 } 246 }
245 } 247 }
246 } 248 }
247 return true; 249 return true;
248 } 250 }
249 251
250 DictionaryValue* Command::ToValue(const Extension* extension, 252 DictionaryValue* Command::ToValue(const Extension* extension,
251 bool active) const { 253 bool active) const {
252 DictionaryValue* extension_data = new DictionaryValue(); 254 DictionaryValue* extension_data = new DictionaryValue();
253 255
254 string16 command_description; 256 string16 command_description;
255 if (command_name() == values::kBrowserActionKeybindingEvent || 257 if (command_name() == values::kBrowserActionCommandEvent ||
256 command_name() == values::kPageActionKeybindingEvent) { 258 command_name() == values::kPageActionCommandEvent ||
259 command_name() == values::kScriptBadgeCommandEvent) {
257 command_description = 260 command_description =
258 l10n_util::GetStringUTF16(IDS_EXTENSION_COMMANDS_GENERIC_ACTIVATE); 261 l10n_util::GetStringUTF16(IDS_EXTENSION_COMMANDS_GENERIC_ACTIVATE);
259 } else { 262 } else {
260 command_description = description(); 263 command_description = description();
261 } 264 }
262 extension_data->SetString("description", command_description); 265 extension_data->SetString("description", command_description);
263 extension_data->SetBoolean("active", active); 266 extension_data->SetBoolean("active", active);
264 extension_data->SetString("keybinding", accelerator().GetShortcutText()); 267 extension_data->SetString("keybinding", accelerator().GetShortcutText());
265 extension_data->SetString("command_name", command_name()); 268 extension_data->SetString("command_name", command_name());
266 extension_data->SetString("extension_id", extension->id()); 269 extension_data->SetString("extension_id", extension->id());
267 270
268 return extension_data; 271 return extension_data;
269 } 272 }
270 273
271 } // namespace extensions 274 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698