Commit 22b28c13 authored by tony@chromium.org's avatar tony@chromium.org

Some wstring -> string16 conversion in src/app.

It looks like l10n_util_dummy.cc isn't needed anymore: The function
in the file doesn't match any functions in l10n_util.h.

Convert BidiLineIterator to use string16.  I don't see any unittests
for this file. :(

BUG=23581
TEST=None

Review URL: http://codereview.chromium.org/6315002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71667 0039d316-1c4b-4281-b951-d872f2087c98
parent b1357f5d
...@@ -441,7 +441,6 @@ ...@@ -441,7 +441,6 @@
], ],
}, },
'sources': [ 'sources': [
'l10n_util_dummy.cc',
'resource_bundle_dummy.cc', 'resource_bundle_dummy.cc',
], ],
'include_dirs': [ 'include_dirs': [
......
...@@ -15,7 +15,7 @@ BiDiLineIterator::~BiDiLineIterator() { ...@@ -15,7 +15,7 @@ BiDiLineIterator::~BiDiLineIterator() {
} }
} }
UBool BiDiLineIterator::Open(const std::wstring& text, UBool BiDiLineIterator::Open(const string16& text,
bool right_to_left, bool right_to_left,
bool url) { bool url) {
DCHECK(bidi_ == NULL); DCHECK(bidi_ == NULL);
...@@ -25,12 +25,7 @@ UBool BiDiLineIterator::Open(const std::wstring& text, ...@@ -25,12 +25,7 @@ UBool BiDiLineIterator::Open(const std::wstring& text,
return false; return false;
if (right_to_left && url) if (right_to_left && url)
ubidi_setReorderingMode(bidi_, UBIDI_REORDER_RUNS_ONLY); ubidi_setReorderingMode(bidi_, UBIDI_REORDER_RUNS_ONLY);
#if defined(WCHAR_T_IS_UTF32) ubidi_setPara(bidi_, text.data(), static_cast<int>(text.length()),
const string16 text_utf16 = WideToUTF16(text);
#else
const std::wstring &text_utf16 = text;
#endif // U_SIZEOF_WCHAR_T != 4
ubidi_setPara(bidi_, text_utf16.data(), static_cast<int>(text_utf16.length()),
right_to_left ? UBIDI_DEFAULT_RTL : UBIDI_DEFAULT_LTR, right_to_left ? UBIDI_DEFAULT_RTL : UBIDI_DEFAULT_LTR,
NULL, &error); NULL, &error);
return U_SUCCESS(error); return U_SUCCESS(error);
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "unicode/ubidi.h" #include "unicode/ubidi.h"
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/string16.h"
// A simple wrapper class for the bidirectional iterator of ICU. // A simple wrapper class for the bidirectional iterator of ICU.
// This class uses the bidirectional iterator of ICU to split a line of // This class uses the bidirectional iterator of ICU to split a line of
...@@ -22,7 +23,7 @@ class BiDiLineIterator { ...@@ -22,7 +23,7 @@ class BiDiLineIterator {
// Initializes the bidirectional iterator with the specified text. Returns // Initializes the bidirectional iterator with the specified text. Returns
// whether initialization succeeded. // whether initialization succeeded.
UBool Open(const std::wstring& text, bool right_to_left, bool url); UBool Open(const string16& text, bool right_to_left, bool url);
// Returns the number of visual runs in the text, or zero on error. // Returns the number of visual runs in the text, or zero on error.
int CountRuns(); int CountRuns();
......
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "app/resource_bundle.h"
#include "base/command_line.h"
#include "base/string16.h"
#include "base/string_piece.h"
#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
#include "build/build_config.h"
#include "unicode/uscript.h"
namespace l10n_util {
std::wstring GetString(int message_id) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
return UTF16ToWide(rb.GetLocalizedString(message_id));
}
} // namespace l10n_util
...@@ -60,5 +60,5 @@ ResourceBundle::~ResourceBundle() { ...@@ -60,5 +60,5 @@ ResourceBundle::~ResourceBundle() {
string16 ResourceBundle::GetLocalizedString(int message_id) { string16 ResourceBundle::GetLocalizedString(int message_id) {
return std::wstring(); return string16();
} }
...@@ -159,7 +159,7 @@ string16 ResourceBundle::GetLocalizedString(int message_id) { ...@@ -159,7 +159,7 @@ string16 ResourceBundle::GetLocalizedString(int message_id) {
// See http://crbug.com/21925. // See http://crbug.com/21925.
base::debug::StackTrace().PrintBacktrace(); base::debug::StackTrace().PrintBacktrace();
NOTREACHED() << "unable to find resource: " << message_id; NOTREACHED() << "unable to find resource: " << message_id;
return std::wstring(); return string16();
} }
} }
// Copy into a string16 and return. // Copy into a string16 and return.
......
...@@ -559,7 +559,7 @@ int AutocompleteResultView::DrawString( ...@@ -559,7 +559,7 @@ int AutocompleteResultView::DrawString(
// unintended ways, e.g. by removing directional markings or by adding an // unintended ways, e.g. by removing directional markings or by adding an
// ellipsis that's not enclosed in appropriate markings. // ellipsis that's not enclosed in appropriate markings.
BiDiLineIterator bidi_line; BiDiLineIterator bidi_line;
if (!bidi_line.Open(text, base::i18n::IsRTL(), is_url)) if (!bidi_line.Open(WideToUTF16Hack(text), base::i18n::IsRTL(), is_url))
return x; return x;
const int num_runs = bidi_line.CountRuns(); const int num_runs = bidi_line.CountRuns();
Runs runs; Runs runs;
......
...@@ -32,7 +32,7 @@ void DrawTextAndPositionUrl(gfx::Canvas* canvas, ...@@ -32,7 +32,7 @@ void DrawTextAndPositionUrl(gfx::Canvas* canvas,
// initialize a bidirectional ICU line iterator and split the text into // initialize a bidirectional ICU line iterator and split the text into
// runs that are either strictly LTR or strictly RTL, with no mix. // runs that are either strictly LTR or strictly RTL, with no mix.
BiDiLineIterator bidi_line; BiDiLineIterator bidi_line;
if (!bidi_line.Open(text.c_str(), true, false)) if (!bidi_line.Open(WideToUTF16Hack(text), true, false))
return; return;
// Iterate over each run and draw it. // Iterate over each run and draw it.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment