Skip to content

Commit 105f668

Browse files
Merge branch '26.eap' into santo/26.eap11/user-agent-os1
2 parents 16795de + 56b39bb commit 105f668

32 files changed

+818
-79
lines changed

cobalt/app/cobalt.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ void SbEventHandle(const SbEvent* event) {
198198
}
199199
break;
200200
}
201-
case kSbEventTypeVerticalSync:
202201
case kSbEventTypeScheduled:
203202
case kSbEventTypeWindowSizeChanged:
204203
CHECK(g_platform_event_source);

cobalt/browser/h5vcc_metrics/public/mojom/h5vcc_metrics.mojom

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ interface H5vccMetrics {
2929

3030
[Sync] Enable(bool enable) => ();
3131
SetMetricEventInterval(uint64 interval_seconds) => ();
32-
RequestHistograms() => (string histograms_json);
32+
RequestHistograms() => (string histograms_base64);
3333
};

cobalt/common/libc/locale/lconv_support.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,16 @@ std::string GetGroupingString(const icu::DecimalFormat* formatter) {
310310
}
311311
} // namespace
312312

313-
// Helper function to set an LconvImpl to the default C lconv.
314-
void LconvImpl::ResetToC() {
313+
// Resets the LconvImpl's LC_NUMERIC values to the C/POSIX locale values.
314+
void LconvImpl::ResetNumericToC() {
315315
stored_decimal = ".";
316316
stored_thousands = "";
317317
stored_grouping = "";
318+
current_numeric_locale = "C";
319+
}
318320

321+
// Resets the LconvImpl's LC_MONETARY values to the C/POSIX locale values.
322+
void LconvImpl::ResetMonetaryToC() {
319323
stored_mon_decimal = "";
320324
stored_mon_thousands_sep = "";
321325
stored_mon_grouping = "";
@@ -351,7 +355,6 @@ void LconvImpl::ResetToC() {
351355
result.negative_sign = const_cast<char*>(stored_neg_sign.c_str());
352356
result.currency_symbol = const_cast<char*>(stored_currency_sym.c_str());
353357
result.int_curr_symbol = const_cast<char*>(stored_int_curr_sym.c_str());
354-
current_numeric_locale = "C";
355358
current_monetary_locale = "C";
356359
}
357360

cobalt/common/libc/locale/lconv_support.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@ struct LconvImpl {
3434
std::string current_numeric_locale;
3535
std::string current_monetary_locale;
3636

37-
LconvImpl() { ResetToC(); }
37+
LconvImpl() {
38+
ResetNumericToC();
39+
ResetMonetaryToC();
40+
}
3841

39-
void ResetToC();
42+
void ResetNumericToC();
43+
void ResetMonetaryToC();
4044
};
4145

4246
// Updates all lconv values tied to the LC_NUMERIC locale for a given LconvImpl

cobalt/common/libc/locale/lconv_support_test.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ namespace {
2626
// specification of these values.
2727
class LconvSupportTest : public ::testing::Test {
2828
protected:
29-
void SetUp() override { lconv_.ResetToC(); }
29+
void SetUp() override {
30+
lconv_.ResetNumericToC();
31+
lconv_.ResetMonetaryToC();
32+
}
3033

3134
LconvImpl lconv_;
3235
};

cobalt/common/libc/locale/locale.cc

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -223,19 +223,25 @@ struct lconv* localeconv(void) {
223223
std::string numeric_locale = current_loc->categories[LC_NUMERIC];
224224
std::string monetary_locale = current_loc->categories[LC_MONETARY];
225225

226-
if ((numeric_locale == cobalt::kCLocale ||
227-
numeric_locale == cobalt::kPosixLocale) &&
228-
(monetary_locale == cobalt::kCLocale ||
229-
monetary_locale == cobalt::kPosixLocale)) {
230-
current_lconv->ResetToC();
231-
return &(current_lconv->result);
226+
bool is_c_or_posix_numeric_locale = (numeric_locale == cobalt::kCLocale ||
227+
numeric_locale == cobalt::kPosixLocale);
228+
if (is_c_or_posix_numeric_locale) {
229+
current_lconv->ResetNumericToC();
230+
} else if (!cobalt::UpdateNumericLconv(numeric_locale, current_lconv)) {
231+
SB_LOG(WARNING)
232+
<< "Failed to retrieve lconv numeric values. Returning C values.";
233+
current_lconv->ResetNumericToC();
232234
}
233235

234-
if (!cobalt::UpdateNumericLconv(numeric_locale, current_lconv) ||
235-
!cobalt::UpdateMonetaryLconv(monetary_locale, current_lconv)) {
236-
SB_LOG(WARNING) << "Failed to properly retrieve the updated lconv struct. "
237-
"Returning the C lconv.";
238-
current_lconv->ResetToC();
236+
bool is_c_or_posix_monetary_locale =
237+
(monetary_locale == cobalt::kCLocale ||
238+
monetary_locale == cobalt::kPosixLocale);
239+
if (is_c_or_posix_monetary_locale) {
240+
current_lconv->ResetMonetaryToC();
241+
} else if (!cobalt::UpdateMonetaryLconv(monetary_locale, current_lconv)) {
242+
SB_LOG(WARNING)
243+
<< "Failed to retrieve lconv monetary values. Returning C values.";
244+
current_lconv->ResetMonetaryToC();
239245
}
240246

241247
return &(current_lconv->result);
@@ -268,8 +274,7 @@ char* nl_langinfo_l(nl_item item, locale_t locale) {
268274
case AM_STR:
269275
case PM_STR:
270276
langinfo_buffer = cobalt::GetLocalizedDateSymbol(
271-
cur_locale->categories[LC_TIME], cobalt::TimeNameType::kAmPm,
272-
item - AM_STR);
277+
cur_locale->categories[LC_TIME], cobalt::TimeNameType::kAmPm, item);
273278
break;
274279

275280
// Days
@@ -281,8 +286,7 @@ char* nl_langinfo_l(nl_item item, locale_t locale) {
281286
case DAY_6:
282287
case DAY_7:
283288
langinfo_buffer = cobalt::GetLocalizedDateSymbol(
284-
cur_locale->categories[LC_TIME], cobalt::TimeNameType::kDay,
285-
item - DAY_1);
289+
cur_locale->categories[LC_TIME], cobalt::TimeNameType::kDay, item);
286290
break;
287291

288292
// Abbreviated days
@@ -295,7 +299,7 @@ char* nl_langinfo_l(nl_item item, locale_t locale) {
295299
case ABDAY_7:
296300
langinfo_buffer = cobalt::GetLocalizedDateSymbol(
297301
cur_locale->categories[LC_TIME], cobalt::TimeNameType::kAbbrevDay,
298-
item - ABDAY_1);
302+
item);
299303
break;
300304

301305
// Months
@@ -312,8 +316,7 @@ char* nl_langinfo_l(nl_item item, locale_t locale) {
312316
case MON_11:
313317
case MON_12:
314318
langinfo_buffer = cobalt::GetLocalizedDateSymbol(
315-
cur_locale->categories[LC_TIME], cobalt::TimeNameType::kMonth,
316-
item - MON_1);
319+
cur_locale->categories[LC_TIME], cobalt::TimeNameType::kMonth, item);
317320
break;
318321

319322
// Abbreviated months
@@ -331,7 +334,7 @@ char* nl_langinfo_l(nl_item item, locale_t locale) {
331334
case ABMON_12:
332335
langinfo_buffer = cobalt::GetLocalizedDateSymbol(
333336
cur_locale->categories[LC_TIME], cobalt::TimeNameType::kAbbrevMonth,
334-
item - ABMON_1);
337+
item);
335338
break;
336339
case RADIXCHAR:
337340
case THOUSEP:

cobalt/common/libc/locale/nl_langinfo_support.cc

Lines changed: 134 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,123 @@ std::string CollapseSpaces(const std::string& input) {
8989
return result;
9090
}
9191

92+
// Returns the relevant LC_TIME nl_langinfo string from the C/POSIX locale.
93+
std::string GetCTimeLanginfo(nl_item item) {
94+
switch (item) {
95+
// Date and Time Formats
96+
case D_T_FMT:
97+
return "%a %b %e %H:%M:%S %Y";
98+
case D_FMT:
99+
return "%m/%d/%y";
100+
case T_FMT:
101+
return "%H:%M:%S";
102+
case T_FMT_AMPM:
103+
return "%I:%M:%S %p";
104+
case AM_STR:
105+
return "AM";
106+
case PM_STR:
107+
return "PM";
108+
109+
// Days of the Week (Full)
110+
case DAY_1:
111+
return "Sunday";
112+
case DAY_2:
113+
return "Monday";
114+
case DAY_3:
115+
return "Tuesday";
116+
case DAY_4:
117+
return "Wednesday";
118+
case DAY_5:
119+
return "Thursday";
120+
case DAY_6:
121+
return "Friday";
122+
case DAY_7:
123+
return "Saturday";
124+
125+
// Days of the Week (Abbreviated)
126+
case ABDAY_1:
127+
return "Sun";
128+
case ABDAY_2:
129+
return "Mon";
130+
case ABDAY_3:
131+
return "Tue";
132+
case ABDAY_4:
133+
return "Wed";
134+
case ABDAY_5:
135+
return "Thu";
136+
case ABDAY_6:
137+
return "Fri";
138+
case ABDAY_7:
139+
return "Sat";
140+
141+
// Months (Full)
142+
case MON_1:
143+
return "January";
144+
case MON_2:
145+
return "February";
146+
case MON_3:
147+
return "March";
148+
case MON_4:
149+
return "April";
150+
case MON_5:
151+
return "May";
152+
case MON_6:
153+
return "June";
154+
case MON_7:
155+
return "July";
156+
case MON_8:
157+
return "August";
158+
case MON_9:
159+
return "September";
160+
case MON_10:
161+
return "October";
162+
case MON_11:
163+
return "November";
164+
case MON_12:
165+
return "December";
166+
167+
// Months (Abbreviated)
168+
case ABMON_1:
169+
return "Jan";
170+
case ABMON_2:
171+
return "Feb";
172+
case ABMON_3:
173+
return "Mar";
174+
case ABMON_4:
175+
return "Apr";
176+
case ABMON_5:
177+
return "May";
178+
case ABMON_6:
179+
return "Jun";
180+
case ABMON_7:
181+
return "Jul";
182+
case ABMON_8:
183+
return "Aug";
184+
case ABMON_9:
185+
return "Sep";
186+
case ABMON_10:
187+
return "Oct";
188+
case ABMON_11:
189+
return "Nov";
190+
case ABMON_12:
191+
return "Dec";
192+
193+
default:
194+
return "";
195+
}
196+
}
197+
198+
// Returns the relevant LC_NUMERIC nl_langinfo string from the C/POSIX locale.
199+
std::string GetCNumericLanginfo(nl_item item) {
200+
switch (item) {
201+
case RADIXCHAR:
202+
return ".";
203+
case THOUSEP:
204+
default:
205+
return "";
206+
}
207+
}
208+
92209
// Convenience method to convert a POSIX locale string to the ICU string format.
93210
// Some POSIX strings like sr_RS@latin require special handling to be fully
94211
// translated from POSIX to ICU.
@@ -342,7 +459,10 @@ icu::UnicodeString GetPatternFromSkeleton(const std::string& locale_id,
342459

343460
std::string GetLocalizedDateSymbol(const std::string& locale,
344461
TimeNameType type,
345-
int index) {
462+
nl_item item) {
463+
if (locale == cobalt::kCLocale || locale == cobalt::kPosixLocale) {
464+
return GetCTimeLanginfo(item);
465+
}
346466
std::string result;
347467

348468
UErrorCode status = U_ZERO_ERROR;
@@ -354,35 +474,44 @@ std::string GetLocalizedDateSymbol(const std::string& locale,
354474
}
355475

356476
int count = 0;
477+
int index;
357478

358479
switch (type) {
359480
case TimeNameType::kDay:
481+
index = item - DAY_1;
360482
result =
361483
ToUtf8(syms.getWeekdays(count, icu::DateFormatSymbols::STANDALONE,
362484
icu::DateFormatSymbols::WIDE)[index + 1]);
363485
break;
364486
case TimeNameType::kAbbrevDay:
487+
index = item - ABDAY_1;
365488
result = ToUtf8(
366489
syms.getWeekdays(count, icu::DateFormatSymbols::STANDALONE,
367490
icu::DateFormatSymbols::ABBREVIATED)[index + 1]);
368491
break;
369492
case TimeNameType::kMonth:
493+
index = item - MON_1;
370494
result = ToUtf8(syms.getMonths(count, icu::DateFormatSymbols::STANDALONE,
371495
icu::DateFormatSymbols::WIDE)[index]);
372496
break;
373497
case TimeNameType::kAbbrevMonth:
498+
index = item - ABMON_1;
374499
result =
375500
ToUtf8(syms.getMonths(count, icu::DateFormatSymbols::STANDALONE,
376501
icu::DateFormatSymbols::ABBREVIATED)[index]);
377502
break;
378503
case TimeNameType::kAmPm:
504+
index = item - AM_STR;
379505
result = ToUtf8(syms.getAmPmStrings(count)[index]);
380506
}
381507

382508
return result;
383509
}
384510

385511
std::string NlGetNumericData(const std::string& locale, nl_item type) {
512+
if (locale == cobalt::kCLocale || locale == cobalt::kPosixLocale) {
513+
return GetCNumericLanginfo(type);
514+
}
386515
std::string result;
387516

388517
UErrorCode status = U_ZERO_ERROR;
@@ -412,6 +541,10 @@ std::string NlGetNumericData(const std::string& locale, nl_item type) {
412541
}
413542

414543
std::string GetPosixPattern(const std::string& locale, nl_item item) {
544+
if (locale == cobalt::kCLocale || locale == cobalt::kPosixLocale) {
545+
return GetCTimeLanginfo(item);
546+
}
547+
415548
icu::UnicodeString icu_pattern;
416549

417550
// For |D_FMT| and |T_FMT|, ICU has stored data for each locale that closely

cobalt/common/libc/locale/nl_langinfo_support.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ enum class TimeNameType { kDay, kAbbrevDay, kMonth, kAbbrevMonth, kAmPm };
3030
// TimeNameType. This includes |DAY*|, |ABDAY*|, |AM/PM_STR|, |MON*|, |ABMON*|.
3131
std::string GetLocalizedDateSymbol(const std::string& locale,
3232
TimeNameType type,
33-
int index);
33+
nl_item item);
3434

3535
// Will retrieve the corresponding Numeric data for a given locale. This mainly
3636
// supports the |RADIXCHAR| and |THOUSEP| nl_items.

cobalt/updater/configurator.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ std::string Configurator::GetAppGuidHelper(const std::string& updater_channel,
303303
auto it = kChannelAndSbVersionToOmahaIdMap.find(channel +
304304
std::to_string(sb_version));
305305
if (it != kChannelAndSbVersionToOmahaIdMap.end()) {
306-
return it->second;
306+
return std::string(it->second);
307307
}
308308
// All undefined channel requests go to the default EAP config.
309309
LOG(INFO) << "Configurator::GetAppGuidHelper updater channel and starboard "

cobalt/updater/one_app_only_sandbox.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ void SbEventHandle(const SbEvent* event) {
226226
}
227227
break;
228228
}
229-
case kSbEventTypeVerticalSync:
230229
case kSbEventTypeScheduled:
231230
case kSbEventTypeWindowSizeChanged:
232231
if (g_platform_event_source) {

0 commit comments

Comments
 (0)