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

Side by Side Diff: chrome/browser/chromeos/system/timezone_util.cc

Issue 105193002: Replace string16 with base::string16. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/browser/chromeos/system/timezone_util.h" 5 #include "chrome/browser/chromeos/system/timezone_util.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 zone_id.toUTF8String(zone_id_str); 57 zone_id.toUTF8String(zone_id_str);
58 58
59 // Resource keys for timezones use ':' in place of '/'. 59 // Resource keys for timezones use ':' in place of '/'.
60 ReplaceSubstringsAfterOffset(&zone_id_str, 0, "/", ":"); 60 ReplaceSubstringsAfterOffset(&zone_id_str, 0, "/", ":");
61 scoped_ptr_malloc<UResourceBundle, UResClose> zone_item( 61 scoped_ptr_malloc<UResourceBundle, UResClose> zone_item(
62 ures_getByKey(zone_strings, zone_id_str.c_str(), NULL, &status)); 62 ures_getByKey(zone_strings, zone_id_str.c_str(), NULL, &status));
63 icu::UnicodeString city; 63 icu::UnicodeString city;
64 if (!U_FAILURE(status)) { 64 if (!U_FAILURE(status)) {
65 city = icu::ures_getUnicodeStringByKey(zone_item.get(), "ec", &status); 65 city = icu::ures_getUnicodeStringByKey(zone_item.get(), "ec", &status);
66 if (U_SUCCESS(status)) 66 if (U_SUCCESS(status))
67 return string16(city.getBuffer(), city.length()); 67 return base::string16(city.getBuffer(), city.length());
68 } 68 }
69 69
70 // Fallback case in case of failure. 70 // Fallback case in case of failure.
71 ReplaceSubstringsAfterOffset(&zone_id_str, 0, ":", "/"); 71 ReplaceSubstringsAfterOffset(&zone_id_str, 0, ":", "/");
72 // Take the last component of a timezone id (e.g. 'Baz' in 'Foo/Bar/Baz'). 72 // Take the last component of a timezone id (e.g. 'Baz' in 'Foo/Bar/Baz').
73 // Depending on timezones, keeping all but the 1st component 73 // Depending on timezones, keeping all but the 1st component
74 // (e.g. Bar/Baz) may be better, but our current list does not have 74 // (e.g. Bar/Baz) may be better, but our current list does not have
75 // any timezone for which that's the case. 75 // any timezone for which that's the case.
76 std::string::size_type slash_pos = zone_id_str.rfind('/'); 76 std::string::size_type slash_pos = zone_id_str.rfind('/');
77 if (slash_pos != std::string::npos && slash_pos < zone_id_str.size()) 77 if (slash_pos != std::string::npos && slash_pos < zone_id_str.size())
(...skipping 27 matching lines...) Expand all
105 // have to come up with better 'display' names. One possibility is to list 105 // have to come up with better 'display' names. One possibility is to list
106 // multiple cities (e.g. "Los Angeles, Vancouver .." in the order of 106 // multiple cities (e.g. "Los Angeles, Vancouver .." in the order of
107 // the population of a country the city belongs to.). 107 // the population of a country the city belongs to.).
108 // We can also think of using LONG_GENERIC or LOCATION once we upgrade 108 // We can also think of using LONG_GENERIC or LOCATION once we upgrade
109 // to ICU 4.6. 109 // to ICU 4.6.
110 // In the meantime, we use "LONG" name with "Exemplar City" to distinguish 110 // In the meantime, we use "LONG" name with "Exemplar City" to distinguish
111 // multiple timezones with the same "LONG" name but with different 111 // multiple timezones with the same "LONG" name but with different
112 // rules (e.g. US Mountain Time in Denver vs Phoenix). 112 // rules (e.g. US Mountain Time in Denver vs Phoenix).
113 icu::UnicodeString name; 113 icu::UnicodeString name;
114 timezone.getDisplayName(dst_offset != 0, icu::TimeZone::LONG, name); 114 timezone.getDisplayName(dst_offset != 0, icu::TimeZone::LONG, name);
115 string16 result(l10n_util::GetStringFUTF16( 115 base::string16 result(l10n_util::GetStringFUTF16(
116 IDS_OPTIONS_SETTINGS_TIMEZONE_DISPLAY_TEMPLATE, ASCIIToUTF16(offset_str), 116 IDS_OPTIONS_SETTINGS_TIMEZONE_DISPLAY_TEMPLATE, ASCIIToUTF16(offset_str),
117 string16(name.getBuffer(), name.length()), GetExemplarCity(timezone))); 117 base::string16(name.getBuffer(), name.length()), GetExemplarCity(timezone) ));
118 base::i18n::AdjustStringForLocaleDirection(&result); 118 base::i18n::AdjustStringForLocaleDirection(&result);
119 return result; 119 return result;
120 } 120 }
121 121
122 } // namespace 122 } // namespace
123 123
124 namespace chromeos { 124 namespace chromeos {
125 namespace system { 125 namespace system {
126 126
127 // Creates a list of pairs of each timezone's ID and name. 127 // Creates a list of pairs of each timezone's ID and name.
128 scoped_ptr<base::ListValue> GetTimezoneList() { 128 scoped_ptr<base::ListValue> GetTimezoneList() {
129 const std::vector<icu::TimeZone*> &timezones = 129 const std::vector<icu::TimeZone*> &timezones =
130 chromeos::system::TimezoneSettings::GetInstance()->GetTimezoneList(); 130 chromeos::system::TimezoneSettings::GetInstance()->GetTimezoneList();
131 scoped_ptr<base::ListValue> timezoneList(new base::ListValue()); 131 scoped_ptr<base::ListValue> timezoneList(new base::ListValue());
132 for (std::vector<icu::TimeZone*>::const_iterator iter = timezones.begin(); 132 for (std::vector<icu::TimeZone*>::const_iterator iter = timezones.begin();
133 iter != timezones.end(); ++iter) { 133 iter != timezones.end(); ++iter) {
134 const icu::TimeZone* timezone = *iter; 134 const icu::TimeZone* timezone = *iter;
135 base::ListValue* option = new base::ListValue(); 135 base::ListValue* option = new base::ListValue();
136 option->Append(new base::StringValue( 136 option->Append(new base::StringValue(
137 chromeos::system::TimezoneSettings::GetTimezoneID(*timezone))); 137 chromeos::system::TimezoneSettings::GetTimezoneID(*timezone)));
138 option->Append(new base::StringValue(GetTimezoneName(*timezone))); 138 option->Append(new base::StringValue(GetTimezoneName(*timezone)));
139 timezoneList->Append(option); 139 timezoneList->Append(option);
140 } 140 }
141 return timezoneList.Pass(); 141 return timezoneList.Pass();
142 } 142 }
143 143
144 } // namespace system 144 } // namespace system
145 } // namespace chromeos 145 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/system/ash_system_tray_delegate.cc ('k') | chrome/browser/chromeos/ui/echo_dialog_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698