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

Side by Side Diff: chrome/browser/extensions/api/commands/command_service_browsertest.cc

Issue 2777063003: Stop passing raw pointers to base::Value API in c/b/chromeos and c/b/extensions (Closed)
Patch Set: Fix SupervisedUserWhitelistInstaller Created 3 years, 8 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
OLDNEW
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 "build/build_config.h" 5 #include "build/build_config.h"
jdoerrie 2017/04/06 14:25:50 #include <utility> #include "base/memory/ptr_util
vabr (Chromium) 2017/04/07 20:40:40 Done.
6 #include "chrome/browser/extensions/api/commands/command_service.h" 6 #include "chrome/browser/extensions/api/commands/command_service.h"
7 #include "chrome/browser/extensions/extension_apitest.h" 7 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/common/pref_names.h" 9 #include "chrome/common/pref_names.h"
10 #include "components/prefs/scoped_user_pref_update.h" 10 #include "components/prefs/scoped_user_pref_update.h"
11 #include "content/public/test/browser_test.h" 11 #include "content/public/test/browser_test.h"
12 #include "content/public/test/test_utils.h" 12 #include "content/public/test/test_utils.h"
13 #include "extensions/common/manifest_constants.h" 13 #include "extensions/common/manifest_constants.h"
14 14
15 namespace { 15 namespace {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 ASSERT_TRUE(extension); 103 ASSERT_TRUE(extension);
104 104
105 DictionaryPrefUpdate updater(browser()->profile()->GetPrefs(), 105 DictionaryPrefUpdate updater(browser()->profile()->GetPrefs(),
106 prefs::kExtensionCommands); 106 prefs::kExtensionCommands);
107 base::DictionaryValue* bindings = updater.Get(); 107 base::DictionaryValue* bindings = updater.Get();
108 108
109 // Simulate command |toggle-feature| has been assigned with a shortcut on 109 // Simulate command |toggle-feature| has been assigned with a shortcut on
110 // another platform. 110 // another platform.
111 std::string anotherPlatformKey = GetAnotherCommandPlatform() + ":Alt+G"; 111 std::string anotherPlatformKey = GetAnotherCommandPlatform() + ":Alt+G";
112 const char kNamedCommandName[] = "toggle-feature"; 112 const char kNamedCommandName[] = "toggle-feature";
113 base::DictionaryValue* keybinding = new base::DictionaryValue(); 113 auto keybinding = base::MakeUnique<base::DictionaryValue>();
114 keybinding->SetString("extension", extension->id()); 114 keybinding->SetString("extension", extension->id());
115 keybinding->SetString("command_name", kNamedCommandName); 115 keybinding->SetString("command_name", kNamedCommandName);
116 keybinding->SetBoolean("global", false); 116 keybinding->SetBoolean("global", false);
117 bindings->Set(anotherPlatformKey, keybinding); 117 bindings->Set(anotherPlatformKey, std::move(keybinding));
118 118
119 CommandService* command_service = CommandService::Get(browser()->profile()); 119 CommandService* command_service = CommandService::Get(browser()->profile());
120 command_service->RemoveKeybindingPrefs(extension->id(), kNamedCommandName); 120 command_service->RemoveKeybindingPrefs(extension->id(), kNamedCommandName);
121 121
122 // 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
123 // another platform should always remained. 123 // another platform should always remained.
124 EXPECT_TRUE(bindings->HasKey(anotherPlatformKey)); 124 EXPECT_TRUE(bindings->HasKey(anotherPlatformKey));
125 } 125 }
126 126
127 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
412 &command_map)); 412 &command_map));
413 413
414 ASSERT_EQ(1u, command_map.count(kBasicNamedCommand)); 414 ASSERT_EQ(1u, command_map.count(kBasicNamedCommand));
415 Command command = command_map[kBasicNamedCommand]; 415 Command command = command_map[kBasicNamedCommand];
416 EXPECT_EQ(kBasicNamedKeybinding, 416 EXPECT_EQ(kBasicNamedKeybinding,
417 Command::AcceleratorToString(command.accelerator())); 417 Command::AcceleratorToString(command.accelerator()));
418 } 418 }
419 } 419 }
420 420
421 } // namespace extensions 421 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698