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

Side by Side Diff: extensions/browser/api/device_permissions_prompt.cc

Issue 1103293004: Use ICU plural syntax in more place (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update comment in generated_strings.grd Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api/device_permissions_prompt.h" 5 #include "extensions/browser/api/device_permissions_prompt.h"
6 6
7 #include "base/scoped_observer.h" 7 #include "base/scoped_observer.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "device/core/device_client.h" 10 #include "device/core/device_client.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 UsbService* service = device::DeviceClient::Get()->GetUsbService(); 97 UsbService* service = device::DeviceClient::Get()->GetUsbService();
98 if (service && !service_observer_.IsObserving(service)) { 98 if (service && !service_observer_.IsObserving(service)) {
99 service->GetDevices( 99 service->GetDevices(
100 base::Bind(&UsbDevicePermissionsPrompt::OnDevicesEnumerated, this)); 100 base::Bind(&UsbDevicePermissionsPrompt::OnDevicesEnumerated, this));
101 service_observer_.Add(service); 101 service_observer_.Add(service);
102 } 102 }
103 } 103 }
104 } 104 }
105 105
106 base::string16 GetHeading() const override { 106 base::string16 GetHeading() const override {
107 return l10n_util::GetStringUTF16( 107 return l10n_util::GetPluralStringFUTF16(
108 multiple() ? IDS_USB_DEVICE_PERMISSIONS_PROMPT_TITLE_MULTIPLE 108 IDS_USB_DEVICE_PERMISSIONS_PROMPT_TITLE, devices_.size());
109 : IDS_USB_DEVICE_PERMISSIONS_PROMPT_TITLE_SINGLE);
110 } 109 }
111 110
112 void Dismissed() override { 111 void Dismissed() override {
113 DevicePermissionsManager* permissions_manager = 112 DevicePermissionsManager* permissions_manager =
114 DevicePermissionsManager::Get(browser_context()); 113 DevicePermissionsManager::Get(browser_context());
115 std::vector<scoped_refptr<UsbDevice>> devices; 114 std::vector<scoped_refptr<UsbDevice>> devices;
116 for (const DeviceInfo* device : devices_) { 115 for (const DeviceInfo* device : devices_) {
117 if (device->granted()) { 116 if (device->granted()) {
118 const UsbDeviceInfo* usb_device = 117 const UsbDeviceInfo* usb_device =
119 static_cast<const UsbDeviceInfo*>(device); 118 static_cast<const UsbDeviceInfo*>(device);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 content::BrowserContext* context, 189 content::BrowserContext* context,
191 bool multiple) 190 bool multiple)
192 : extension_(extension), browser_context_(context), multiple_(multiple) { 191 : extension_(extension), browser_context_(context), multiple_(multiple) {
193 } 192 }
194 193
195 void DevicePermissionsPrompt::Prompt::SetObserver(Observer* observer) { 194 void DevicePermissionsPrompt::Prompt::SetObserver(Observer* observer) {
196 observer_ = observer; 195 observer_ = observer;
197 } 196 }
198 197
199 base::string16 DevicePermissionsPrompt::Prompt::GetPromptMessage() const { 198 base::string16 DevicePermissionsPrompt::Prompt::GetPromptMessage() const {
199 // TODO(jungshik): Consider using the ICU syntax once bug 481734 is fixed.
200 return l10n_util::GetStringFUTF16(multiple_ 200 return l10n_util::GetStringFUTF16(multiple_
201 ? IDS_DEVICE_PERMISSIONS_PROMPT_MULTIPLE 201 ? IDS_DEVICE_PERMISSIONS_PROMPT_MULTIPLE
202 : IDS_DEVICE_PERMISSIONS_PROMPT_SINGLE, 202 : IDS_DEVICE_PERMISSIONS_PROMPT_SINGLE,
203 base::UTF8ToUTF16(extension_->name())); 203 base::UTF8ToUTF16(extension_->name()));
204 } 204 }
205 205
206 base::string16 DevicePermissionsPrompt::Prompt::GetDeviceName( 206 base::string16 DevicePermissionsPrompt::Prompt::GetDeviceName(
207 size_t index) const { 207 size_t index) const {
208 DCHECK_LT(index, devices_.size()); 208 DCHECK_LT(index, devices_.size());
209 return devices_[index]->name(); 209 return devices_[index]->name();
(...skipping 26 matching lines...) Expand all
236 content::BrowserContext* context, 236 content::BrowserContext* context,
237 bool multiple, 237 bool multiple,
238 const std::vector<UsbDeviceFilter>& filters, 238 const std::vector<UsbDeviceFilter>& filters,
239 const UsbDevicesCallback& callback) { 239 const UsbDevicesCallback& callback) {
240 prompt_ = new UsbDevicePermissionsPrompt(extension, context, multiple, 240 prompt_ = new UsbDevicePermissionsPrompt(extension, context, multiple,
241 filters, callback); 241 filters, callback);
242 ShowDialog(); 242 ShowDialog();
243 } 243 }
244 244
245 } // namespace extensions 245 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698