summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-18 05:12:29 +0000
committerjshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-18 05:12:29 +0000
commitb5b2385af64eb08b1feb53fb0ad65c835f472912 (patch)
tree6af57cd4a4965cebe2107e07ca8e563444c3afe9 /chrome
parent80d6524d33061e0e4f7b06dd87ee94de3e05c7a8 (diff)
downloadchromium_src-b5b2385af64eb08b1feb53fb0ad65c835f472912.zip
chromium_src-b5b2385af64eb08b1feb53fb0ad65c835f472912.tar.gz
chromium_src-b5b2385af64eb08b1feb53fb0ad65c835f472912.tar.bz2
Use 'icu::' namespace explicitly throughout Chrome tree instead of relying on 'using namespace icu'.
This is Chrome's counterpart to the ICU header change that disables 'using namespace icu' (http://codereview.chromium.org/171010/show), which is required to avoid the name colission between Chrome's StringPiece (in base) and ICU's StringPiece. The webkit change (which is minor) will be dealt with in the webkit bugzilla. This can go in before the ICU change/upgrade without affecting anything. BUG=8198 TEST=All the targets are built without an error on all platforms. Review URL: http://codereview.chromium.org/171012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23613 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/bookmarks/bookmark_model.cc10
-rw-r--r--chrome/browser/history/snippet.cc10
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_util.cc2
-rw-r--r--chrome/browser/spellcheck_worditerator.cc16
-rw-r--r--chrome/browser/task_manager.cc4
-rw-r--r--chrome/common/time_format.cc52
6 files changed, 46 insertions, 48 deletions
diff --git a/chrome/browser/bookmarks/bookmark_model.cc b/chrome/browser/bookmarks/bookmark_model.cc
index 9bcc8c3..2eeeff1 100644
--- a/chrome/browser/bookmarks/bookmark_model.cc
+++ b/chrome/browser/bookmarks/bookmark_model.cc
@@ -83,7 +83,7 @@ class SortComparator : public std::binary_function<const BookmarkNode*,
const BookmarkNode*,
bool> {
public:
- explicit SortComparator(Collator* collator) : collator_(collator) { }
+ explicit SortComparator(icu::Collator* collator) : collator_(collator) { }
// Returns true if lhs preceeds rhs.
bool operator() (const BookmarkNode* n1, const BookmarkNode* n2) {
@@ -99,7 +99,7 @@ class SortComparator : public std::binary_function<const BookmarkNode*,
}
private:
- Collator* collator_;
+ icu::Collator* collator_;
};
} // namespace
@@ -343,9 +343,9 @@ void BookmarkModel::SortChildren(const BookmarkNode* parent) {
}
UErrorCode error = U_ZERO_ERROR;
- scoped_ptr<Collator> collator(
- Collator::createInstance(
- Locale(g_browser_process->GetApplicationLocale().c_str()),
+ scoped_ptr<icu::Collator> collator(
+ icu::Collator::createInstance(
+ icu::Locale(g_browser_process->GetApplicationLocale().c_str()),
error));
if (U_FAILURE(error))
collator.reset(NULL);
diff --git a/chrome/browser/history/snippet.cc b/chrome/browser/history/snippet.cc
index b13a901..b44bb00 100644
--- a/chrome/browser/history/snippet.cc
+++ b/chrome/browser/history/snippet.cc
@@ -118,7 +118,7 @@ size_t AdvanceAndReturnWidePos(const char* utf8_string,
// Given a character break iterator over a UTF-8 string, set the iterator
// position to |*utf8_pos| and move by |count| characters. |count| can
// be either positive or negative.
-void MoveByNGraphemes(BreakIterator* bi, int count, size_t* utf8_pos) {
+void MoveByNGraphemes(icu::BreakIterator* bi, int count, size_t* utf8_pos) {
// Ignore the return value. A side effect of the current position
// being set at or following |*utf8_pos| is exploited here.
// It's simpler than calling following(n) and then previous().
@@ -136,7 +136,7 @@ const int kSnippetContext = 50;
// Returns true if next match falls within a snippet window
// from the previous match. The window size is counted in terms
// of graphemes rather than bytes in UTF-8.
-bool IsNextMatchWithinSnippetWindow(BreakIterator* bi,
+bool IsNextMatchWithinSnippetWindow(icu::BreakIterator* bi,
size_t previous_match_end,
size_t next_match_start) {
// If it's within a window in terms of bytes, it's certain
@@ -152,7 +152,7 @@ bool IsNextMatchWithinSnippetWindow(BreakIterator* bi,
bi->next(kSnippetContext);
int64 current = bi->current();
return (next_match_start < static_cast<uint64>(current) ||
- current == BreakIterator::DONE);
+ current == icu::BreakIterator::DONE);
}
} // namespace
@@ -211,8 +211,8 @@ void Snippet::ComputeSnippet(const MatchPositions& match_positions,
document.size(), &status);
// Locale does not matter because there's no per-locale customization
// for character iterator.
- scoped_ptr<BreakIterator> bi(
- BreakIterator::createCharacterInstance(Locale::getDefault(), status));
+ scoped_ptr<icu::BreakIterator> bi(icu::BreakIterator::createCharacterInstance(
+ icu::Locale::getDefault(), status));
bi->setText(document_utext, status);
DCHECK(U_SUCCESS(status));
diff --git a/chrome/browser/safe_browsing/safe_browsing_util.cc b/chrome/browser/safe_browsing/safe_browsing_util.cc
index 4f9d776..f0267c1 100644
--- a/chrome/browser/safe_browsing/safe_browsing_util.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_util.cc
@@ -193,7 +193,7 @@ void FreeChunks(std::deque<SBChunk>* chunks) {
GURL GeneratePhishingReportUrl(const std::string& report_page,
const std::string& url_to_report) {
- Locale locale = Locale::getDefault();
+ icu::Locale locale = icu::Locale::getDefault();
const char* lang = locale.getLanguage();
if (!lang)
lang = "en"; // fallback
diff --git a/chrome/browser/spellcheck_worditerator.cc b/chrome/browser/spellcheck_worditerator.cc
index ab85fb0..dde4752 100644
--- a/chrome/browser/spellcheck_worditerator.cc
+++ b/chrome/browser/spellcheck_worditerator.cc
@@ -84,16 +84,16 @@ void SpellcheckCharAttribute::SetDefaultLanguage(const std::string& language) {
// combining characters for such languages.
// To treat such combining characters as word characters, we decompose
// this exemplar set and treat the decomposed characters as word characters.
- UnicodeString composed;
+ icu::UnicodeString composed;
for (int i = 0; i < length; ++i)
composed.append(uset_charAt(exemplar_set, i));
- UnicodeString decomposed;
- Normalizer::decompose(composed, FALSE, 0, decomposed, status);
+ icu::UnicodeString decomposed;
+ icu::Normalizer::decompose(composed, FALSE, 0, decomposed, status);
if (U_SUCCESS(status)) {
- StringCharacterIterator iterator(decomposed);
+ icu::StringCharacterIterator iterator(decomposed);
UChar32 character = iterator.first32();
- while (character != CharacterIterator::DONE) {
+ while (character != icu::CharacterIterator::DONE) {
SetWordScript(GetScriptCode(character), true);
character = iterator.next32();
}
@@ -264,10 +264,10 @@ bool SpellcheckWordIterator::Normalize(int input_start,
// does not only write NFKD and NFKC can compose ligatures into their ASCII
// alternatives, but also write NFKC keeps accents of characters.
// Therefore, NFKC seems to be the best option for hunspell.
- UnicodeString input(FALSE, &word_[input_start], input_length);
+ icu::UnicodeString input(FALSE, &word_[input_start], input_length);
UErrorCode status = U_ZERO_ERROR;
- UnicodeString output;
- Normalizer::normalize(input, UNORM_NFKC, 0, output, status);
+ icu::UnicodeString output;
+ icu::Normalizer::normalize(input, UNORM_NFKC, 0, output, status);
if (U_SUCCESS(status))
output_string->assign(output.getTerminatedBuffer());
return status == U_ZERO_ERROR || status == U_STRING_NOT_TERMINATED_WARNING;
diff --git a/chrome/browser/task_manager.cc b/chrome/browser/task_manager.cc
index b7de95e..62c00dc 100644
--- a/chrome/browser/task_manager.cc
+++ b/chrome/browser/task_manager.cc
@@ -202,10 +202,10 @@ int TaskManagerModel::CompareValues(int row1, int row2, int col_id) const {
switch (col_id) {
case IDS_TASK_MANAGER_PAGE_COLUMN: {
// Let's do the default, string compare on the resource title.
- static Collator* collator = NULL;
+ static icu::Collator* collator = NULL;
if (!collator) {
UErrorCode create_status = U_ZERO_ERROR;
- collator = Collator::createInstance(create_status);
+ collator = icu::Collator::createInstance(create_status);
if (!U_SUCCESS(create_status)) {
collator = NULL;
NOTREACHED();
diff --git a/chrome/common/time_format.cc b/chrome/common/time_format.cc
index 80fe242b..a692218 100644
--- a/chrome/common/time_format.cc
+++ b/chrome/common/time_format.cc
@@ -113,7 +113,7 @@ enum FormatType {
class TimeFormatter {
public:
- const std::vector<PluralFormat*>& formatter(FormatType format_type) {
+ const std::vector<icu::PluralFormat*>& formatter(FormatType format_type) {
switch (format_type) {
case FORMAT_SHORT:
return short_formatter_;
@@ -171,39 +171,38 @@ class TimeFormatter {
friend class Singleton<TimeFormatter>;
friend struct DefaultSingletonTraits<TimeFormatter>;
- std::vector<PluralFormat*> short_formatter_;
- std::vector<PluralFormat*> time_left_formatter_;
- std::vector<PluralFormat*> time_elapsed_formatter_;
+ std::vector<icu::PluralFormat*> short_formatter_;
+ std::vector<icu::PluralFormat*> time_left_formatter_;
+ std::vector<icu::PluralFormat*> time_elapsed_formatter_;
static void BuildFormats(FormatType format_type,
- std::vector<PluralFormat*>* time_formats);
- static PluralFormat* createFallbackFormat(const PluralRules& rules,
- int index,
- FormatType format_type);
+ std::vector<icu::PluralFormat*>* time_formats);
+ static icu::PluralFormat* createFallbackFormat(
+ const icu::PluralRules& rules, int index, FormatType format_type);
DISALLOW_EVIL_CONSTRUCTORS(TimeFormatter);
};
-void TimeFormatter::BuildFormats(FormatType format_type,
- std::vector<PluralFormat*>* time_formats) {
- const static UnicodeString kKeywords[] = {
+void TimeFormatter::BuildFormats(
+ FormatType format_type, std::vector<icu::PluralFormat*>* time_formats) {
+ static const icu::UnicodeString kKeywords[] = {
UNICODE_STRING_SIMPLE("other"), UNICODE_STRING_SIMPLE("one"),
UNICODE_STRING_SIMPLE("zero"), UNICODE_STRING_SIMPLE("two"),
UNICODE_STRING_SIMPLE("few"), UNICODE_STRING_SIMPLE("many")
};
UErrorCode err = U_ZERO_ERROR;
- scoped_ptr<PluralRules> rules(
- PluralRules::forLocale(Locale::getDefault(), err));
+ scoped_ptr<icu::PluralRules> rules(
+ icu::PluralRules::forLocale(icu::Locale::getDefault(), err));
if (U_FAILURE(err)) {
err = U_ZERO_ERROR;
- UnicodeString fallback_rules("one: n is 1", -1, US_INV);
- rules.reset(PluralRules::createRules(fallback_rules, err));
+ icu::UnicodeString fallback_rules("one: n is 1", -1, US_INV);
+ rules.reset(icu::PluralRules::createRules(fallback_rules, err));
DCHECK(U_SUCCESS(err));
}
const MessageIDs& message_ids = GetMessageIDs(format_type);
for (int i = 0; i < 4; ++i) {
- UnicodeString pattern;
+ icu::UnicodeString pattern;
for (size_t j = 0; j < arraysize(kKeywords); ++j) {
int msg_id = message_ids.ids[i][j];
std::string sub_pattern = WideToUTF8(l10n_util::GetString(msg_id));
@@ -216,11 +215,11 @@ void TimeFormatter::BuildFormats(FormatType format_type,
(j == 0 || rules->isKeyword(kKeywords[j]))) {
pattern += kKeywords[j];
pattern += UNICODE_STRING_SIMPLE("{");
- pattern += UnicodeString(sub_pattern.c_str(), "UTF-8");
+ pattern += icu::UnicodeString(sub_pattern.c_str(), "UTF-8");
pattern += UNICODE_STRING_SIMPLE("}");
}
}
- PluralFormat* format = new PluralFormat(*rules, pattern, err);
+ icu::PluralFormat* format = new icu::PluralFormat(*rules, pattern, err);
if (U_SUCCESS(err)) {
time_formats->push_back(format);
} else {
@@ -234,23 +233,22 @@ void TimeFormatter::BuildFormats(FormatType format_type,
// Create a hard-coded fallback plural format. This will never be called
// unless translators make a mistake.
-PluralFormat* TimeFormatter::createFallbackFormat(const PluralRules& rules,
- int index,
- FormatType format_type) {
- const static UnicodeString kUnits[4][2] = {
+icu::PluralFormat* TimeFormatter::createFallbackFormat(
+ const icu::PluralRules& rules, int index, FormatType format_type) {
+ static const icu::UnicodeString kUnits[4][2] = {
{ UNICODE_STRING_SIMPLE("sec"), UNICODE_STRING_SIMPLE("secs") },
{ UNICODE_STRING_SIMPLE("min"), UNICODE_STRING_SIMPLE("mins") },
{ UNICODE_STRING_SIMPLE("hour"), UNICODE_STRING_SIMPLE("hours") },
{ UNICODE_STRING_SIMPLE("day"), UNICODE_STRING_SIMPLE("days") }
};
- UnicodeString suffix(GetFallbackFormatSuffix(format_type), -1, US_INV);
- UnicodeString pattern;
+ icu::UnicodeString suffix(GetFallbackFormatSuffix(format_type), -1, US_INV);
+ icu::UnicodeString pattern;
if (rules.isKeyword(UNICODE_STRING_SIMPLE("one"))) {
pattern += UNICODE_STRING_SIMPLE("one{# ") + kUnits[index][0] + suffix;
}
pattern += UNICODE_STRING_SIMPLE(" other{# ") + kUnits[index][1] + suffix;
UErrorCode err = U_ZERO_ERROR;
- PluralFormat* format = new PluralFormat(rules, pattern, err);
+ icu::PluralFormat* format = new icu::PluralFormat(rules, pattern, err);
DCHECK(U_SUCCESS(err));
return format;
}
@@ -266,11 +264,11 @@ static std::wstring FormatTimeImpl(const TimeDelta& delta,
int number;
- const std::vector<PluralFormat*>& formatters =
+ const std::vector<icu::PluralFormat*>& formatters =
time_formatter->formatter(format_type);
UErrorCode error = U_ZERO_ERROR;
- UnicodeString time_string;
+ icu::UnicodeString time_string;
// Less than a minute gets "X seconds left"
if (delta.ToInternalValue() < Time::kMicrosecondsPerMinute) {
number = static_cast<int>(delta.ToInternalValue() /