| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <utility> | |
| 6 | |
| 7 #include "base/memory/ptr_util.h" | |
| 8 #include "base/values.h" | |
| 9 #include "build/build_config.h" | 5 #include "build/build_config.h" |
| 10 #include "chrome/browser/extensions/api/commands/command_service.h" | 6 #include "chrome/browser/extensions/api/commands/command_service.h" |
| 11 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 13 #include "chrome/common/pref_names.h" | 9 #include "chrome/common/pref_names.h" |
| 14 #include "components/prefs/scoped_user_pref_update.h" | 10 #include "components/prefs/scoped_user_pref_update.h" |
| 15 #include "content/public/test/browser_test.h" | 11 #include "content/public/test/browser_test.h" |
| 16 #include "content/public/test/test_utils.h" | 12 #include "content/public/test/test_utils.h" |
| 17 #include "extensions/common/manifest_constants.h" | 13 #include "extensions/common/manifest_constants.h" |
| 18 | 14 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 ASSERT_TRUE(extension); | 103 ASSERT_TRUE(extension); |
| 108 | 104 |
| 109 DictionaryPrefUpdate updater(browser()->profile()->GetPrefs(), | 105 DictionaryPrefUpdate updater(browser()->profile()->GetPrefs(), |
| 110 prefs::kExtensionCommands); | 106 prefs::kExtensionCommands); |
| 111 base::DictionaryValue* bindings = updater.Get(); | 107 base::DictionaryValue* bindings = updater.Get(); |
| 112 | 108 |
| 113 // Simulate command |toggle-feature| has been assigned with a shortcut on | 109 // Simulate command |toggle-feature| has been assigned with a shortcut on |
| 114 // another platform. | 110 // another platform. |
| 115 std::string anotherPlatformKey = GetAnotherCommandPlatform() + ":Alt+G"; | 111 std::string anotherPlatformKey = GetAnotherCommandPlatform() + ":Alt+G"; |
| 116 const char kNamedCommandName[] = "toggle-feature"; | 112 const char kNamedCommandName[] = "toggle-feature"; |
| 117 auto keybinding = base::MakeUnique<base::DictionaryValue>(); | 113 base::DictionaryValue* keybinding = new base::DictionaryValue(); |
| 118 keybinding->SetString("extension", extension->id()); | 114 keybinding->SetString("extension", extension->id()); |
| 119 keybinding->SetString("command_name", kNamedCommandName); | 115 keybinding->SetString("command_name", kNamedCommandName); |
| 120 keybinding->SetBoolean("global", false); | 116 keybinding->SetBoolean("global", false); |
| 121 bindings->Set(anotherPlatformKey, std::move(keybinding)); | 117 bindings->Set(anotherPlatformKey, keybinding); |
| 122 | 118 |
| 123 CommandService* command_service = CommandService::Get(browser()->profile()); | 119 CommandService* command_service = CommandService::Get(browser()->profile()); |
| 124 command_service->RemoveKeybindingPrefs(extension->id(), kNamedCommandName); | 120 command_service->RemoveKeybindingPrefs(extension->id(), kNamedCommandName); |
| 125 | 121 |
| 126 // Removal of keybinding preference should be platform-specific, so the key on | 122 // Removal of keybinding preference should be platform-specific, so the key on |
| 127 // another platform should always remained. | 123 // another platform should always remained. |
| 128 EXPECT_TRUE(bindings->HasKey(anotherPlatformKey)); | 124 EXPECT_TRUE(bindings->HasKey(anotherPlatformKey)); |
| 129 } | 125 } |
| 130 | 126 |
| 131 IN_PROC_BROWSER_TEST_F(CommandServiceTest, | 127 IN_PROC_BROWSER_TEST_F(CommandServiceTest, |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 &command_map)); | 412 &command_map)); |
| 417 | 413 |
| 418 ASSERT_EQ(1u, command_map.count(kBasicNamedCommand)); | 414 ASSERT_EQ(1u, command_map.count(kBasicNamedCommand)); |
| 419 Command command = command_map[kBasicNamedCommand]; | 415 Command command = command_map[kBasicNamedCommand]; |
| 420 EXPECT_EQ(kBasicNamedKeybinding, | 416 EXPECT_EQ(kBasicNamedKeybinding, |
| 421 Command::AcceleratorToString(command.accelerator())); | 417 Command::AcceleratorToString(command.accelerator())); |
| 422 } | 418 } |
| 423 } | 419 } |
| 424 | 420 |
| 425 } // namespace extensions | 421 } // namespace extensions |
| OLD | NEW |