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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/keyboard_handler.cc

Issue 2392693002: Rewrite simple uses of base::ListValue::Append(base::Value*) on CrOS. (Closed)
Patch Set: MakeUnique Created 4 years, 2 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) 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/browser/ui/webui/options/chromeos/keyboard_handler.h" 5 #include "chrome/browser/ui/webui/options/chromeos/keyboard_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory>
10 #include <utility>
11
9 #include "ash/common/new_window_delegate.h" 12 #include "ash/common/new_window_delegate.h"
10 #include "ash/common/wm_shell.h" 13 #include "ash/common/wm_shell.h"
11 #include "base/bind.h" 14 #include "base/bind.h"
12 #include "base/bind_helpers.h" 15 #include "base/bind_helpers.h"
13 #include "base/command_line.h" 16 #include "base/command_line.h"
14 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ptr_util.h"
15 #include "base/values.h" 19 #include "base/values.h"
16 #include "chrome/grit/generated_resources.h" 20 #include "chrome/grit/generated_resources.h"
17 #include "chromeos/chromeos_switches.h" 21 #include "chromeos/chromeos_switches.h"
18 #include "content/public/browser/web_ui.h" 22 #include "content/public/browser/web_ui.h"
19 #include "ui/base/ime/chromeos/ime_keyboard.h" 23 #include "ui/base/ime/chromeos/ime_keyboard.h"
20 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/events/devices/input_device_manager.h" 25 #include "ui/events/devices/input_device_manager.h"
22 26
23 namespace { 27 namespace {
24 const struct ModifierKeysSelectItem { 28 const struct ModifierKeysSelectItem {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 localized_strings->SetString("showKeyboardShortcuts", 137 localized_strings->SetString("showKeyboardShortcuts",
134 l10n_util::GetStringUTF16( 138 l10n_util::GetStringUTF16(
135 IDS_OPTIONS_SETTINGS_SHOW_KEYBOARD_SHORTCUTS)); 139 IDS_OPTIONS_SETTINGS_SHOW_KEYBOARD_SHORTCUTS));
136 140
137 for (size_t i = 0; i < arraysize(kDataValuesNames); ++i) { 141 for (size_t i = 0; i < arraysize(kDataValuesNames); ++i) {
138 base::ListValue* list_value = new base::ListValue(); 142 base::ListValue* list_value = new base::ListValue();
139 for (size_t j = 0; j < arraysize(kModifierKeysSelectItems); ++j) { 143 for (size_t j = 0; j < arraysize(kModifierKeysSelectItems); ++j) {
140 const input_method::ModifierKey value = 144 const input_method::ModifierKey value =
141 kModifierKeysSelectItems[j].value; 145 kModifierKeysSelectItems[j].value;
142 const int message_id = kModifierKeysSelectItems[j].message_id; 146 const int message_id = kModifierKeysSelectItems[j].message_id;
143 base::ListValue* option = new base::ListValue(); 147 auto option = base::MakeUnique<base::ListValue>();
144 option->Append(new base::FundamentalValue(value)); 148 option->AppendInteger(value);
145 option->Append(new base::StringValue(l10n_util::GetStringUTF16( 149 option->AppendString(l10n_util::GetStringUTF16(message_id));
146 message_id))); 150 list_value->Append(std::move(option));
147 list_value->Append(option);
148 } 151 }
149 localized_strings->Set(kDataValuesNames[i], list_value); 152 localized_strings->Set(kDataValuesNames[i], list_value);
150 } 153 }
151 } 154 }
152 155
153 void KeyboardHandler::InitializePage() { 156 void KeyboardHandler::InitializePage() {
154 bool has_diamond_key = base::CommandLine::ForCurrentProcess()->HasSwitch( 157 bool has_diamond_key = base::CommandLine::ForCurrentProcess()->HasSwitch(
155 chromeos::switches::kHasChromeOSDiamondKey); 158 chromeos::switches::kHasChromeOSDiamondKey);
156 const base::FundamentalValue show_diamond_key_options(has_diamond_key); 159 const base::FundamentalValue show_diamond_key_options(has_diamond_key);
157 160
(...skipping 21 matching lines...) Expand all
179 } 182 }
180 183
181 void KeyboardHandler::UpdateCapsLockOptions() const { 184 void KeyboardHandler::UpdateCapsLockOptions() const {
182 const base::FundamentalValue show_caps_lock_options(HasExternalKeyboard()); 185 const base::FundamentalValue show_caps_lock_options(HasExternalKeyboard());
183 web_ui()->CallJavascriptFunctionUnsafe( 186 web_ui()->CallJavascriptFunctionUnsafe(
184 "options.KeyboardOverlay.showCapsLockOptions", show_caps_lock_options); 187 "options.KeyboardOverlay.showCapsLockOptions", show_caps_lock_options);
185 } 188 }
186 189
187 } // namespace options 190 } // namespace options
188 } // namespace chromeos 191 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698