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

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

Issue 10201016: Conflict detection for Extension Keybinding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Addressed comments Created 8 years, 7 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
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/extension.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 errors::kInvalidKeyBinding, 324 errors::kInvalidKeyBinding,
325 base::IntToString(index), 325 base::IntToString(index),
326 platform_key, 326 platform_key,
327 shortcut); 327 shortcut);
328 return ui::Accelerator(); 328 return ui::Accelerator();
329 } 329 }
330 330
331 return ui::Accelerator(key, shift, ctrl, alt); 331 return ui::Accelerator(key, shift, ctrl, alt);
332 } 332 }
333 333
334 // static
335 std::string Extension::ExtensionKeybinding::KeybindingPlatform() {
336 #if defined(OS_WIN)
337 return values::kKeybindingPlatformWin;
338 #elif defined(OS_MACOSX)
339 return values::kKeybindingPlatformMac;
340 #elif defined(OS_CHROMEOS)
341 return values::kKeybindingPlatformChromeOs;
342 #elif defined(OS_LINUX)
343 return values::kKeybindingPlatformLinux;
344 #else
345 return "";
346 #endif
347 }
348
334 bool Extension::ExtensionKeybinding::Parse(DictionaryValue* command, 349 bool Extension::ExtensionKeybinding::Parse(DictionaryValue* command,
335 const std::string& command_name, 350 const std::string& command_name,
336 int index, 351 int index,
337 string16* error) { 352 string16* error) {
338 DCHECK(!command_name.empty()); 353 DCHECK(!command_name.empty());
339 354
340 // We'll build up a map of platform-to-shortcut suggestions. 355 // We'll build up a map of platform-to-shortcut suggestions.
341 std::map<const std::string, std::string> suggestions; 356 std::map<const std::string, std::string> suggestions;
342 357
343 // First try to parse the |suggested_key| as a dictionary. 358 // First try to parse the |suggested_key| as a dictionary.
(...skipping 28 matching lines...) Expand all
372 } else { 387 } else {
373 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( 388 *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
374 errors::kInvalidKeyBinding, 389 errors::kInvalidKeyBinding,
375 base::IntToString(index), 390 base::IntToString(index),
376 keys::kSuggestedKey, 391 keys::kSuggestedKey,
377 "Missing"); 392 "Missing");
378 return false; 393 return false;
379 } 394 }
380 } 395 }
381 396
382 std::string platform = 397 std::string platform = KeybindingPlatform();
383 #if defined(OS_WIN)
384 values::kKeybindingPlatformWin;
385 #elif defined(OS_MACOSX)
386 values::kKeybindingPlatformMac;
387 #elif defined(OS_CHROMEOS)
388 values::kKeybindingPlatformChromeOs;
389 #elif defined(OS_LINUX)
390 values::kKeybindingPlatformLinux;
391 #else
392 "";
393 #endif
394
395 std::string key = platform; 398 std::string key = platform;
396 if (suggestions.find(key) == suggestions.end()) 399 if (suggestions.find(key) == suggestions.end())
397 key = values::kKeybindingPlatformDefault; 400 key = values::kKeybindingPlatformDefault;
398 if (suggestions.find(key) == suggestions.end()) { 401 if (suggestions.find(key) == suggestions.end()) {
399 *error = ExtensionErrorUtils::FormatErrorMessageUTF16( 402 *error = ExtensionErrorUtils::FormatErrorMessageUTF16(
400 errors::kInvalidKeyBindingMissingPlatform, 403 errors::kInvalidKeyBindingMissingPlatform,
401 base::IntToString(index), 404 base::IntToString(index),
402 keys::kSuggestedKey, 405 keys::kSuggestedKey,
403 platform); 406 platform);
404 return false; // No platform specified and no fallback. Bail. 407 return false; // No platform specified and no fallback. Bail.
(...skipping 3315 matching lines...) Expand 10 before | Expand all | Expand 10 after
3720 already_disabled(false), 3723 already_disabled(false),
3721 extension(extension) {} 3724 extension(extension) {}
3722 3725
3723 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo( 3726 UpdatedExtensionPermissionsInfo::UpdatedExtensionPermissionsInfo(
3724 const Extension* extension, 3727 const Extension* extension,
3725 const ExtensionPermissionSet* permissions, 3728 const ExtensionPermissionSet* permissions,
3726 Reason reason) 3729 Reason reason)
3727 : reason(reason), 3730 : reason(reason),
3728 extension(extension), 3731 extension(extension),
3729 permissions(permissions) {} 3732 permissions(permissions) {}
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension.h ('k') | chrome/common/pref_names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698