Commit 7d1208ce authored by tfarina@chromium.org's avatar tfarina@chromium.org

views: Change the remaining std::wstring entries to string16.

BUG=68267
R=sky@chromium.org

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106920 0039d316-1c4b-4281-b951-d872f2087c98
parent 4906e580
......@@ -407,15 +407,15 @@ void AboutChromeView::OnPaint(gfx::Canvas* canvas) {
gfx::Size position;
// Draw the first text chunk and position the Chromium url.
view_text_utils::DrawTextAndPositionUrl(canvas, main_text_label_,
UTF16ToWideHack(main_label_chunk1_), link1, rect1, &position,
main_label_chunk1_, link1, rect1, &position,
text_direction_is_rtl_, label_bounds, font);
// Draw the second text chunk and position the Open Source url.
view_text_utils::DrawTextAndPositionUrl(canvas, main_text_label_,
UTF16ToWideHack(main_label_chunk2_), link2, rect2, &position,
main_label_chunk2_, link2, rect2, &position,
text_direction_is_rtl_, label_bounds, font);
// Draw the third text chunk (which has no URL associated with it).
view_text_utils::DrawTextAndPositionUrl(canvas, main_text_label_,
UTF16ToWideHack(main_label_chunk3_), NULL, NULL, &position,
main_label_chunk3_, NULL, NULL, &position,
text_direction_is_rtl_, label_bounds, font);
#if defined(GOOGLE_CHROME_BUILD)
......@@ -425,12 +425,12 @@ void AboutChromeView::OnPaint(gfx::Canvas* canvas) {
// And now the Terms of Service and position the TOS url.
view_text_utils::DrawTextAndPositionUrl(canvas, main_text_label_,
UTF16ToWideHack(main_label_chunk4_), terms_of_service_url_,
main_label_chunk4_, terms_of_service_url_,
&terms_of_service_url_rect_, &position, text_direction_is_rtl_,
label_bounds, font);
// The last text chunk doesn't have a URL associated with it.
view_text_utils::DrawTextAndPositionUrl(canvas, main_text_label_,
UTF16ToWideHack(main_label_chunk5_), NULL, NULL, &position,
main_label_chunk5_, NULL, NULL, &position,
text_direction_is_rtl_, label_bounds, font);
// Position the TOS URL within the main label.
......
......@@ -74,7 +74,7 @@ void CreateDragImageForFile(const FilePath& file_name,
// Paint the icon.
canvas.DrawBitmapInt(*icon, (width - icon->width()) / 2, 0);
std::wstring name = UTF16ToWide(file_name.BaseName().LossyDisplayName());
string16 name = file_name.BaseName().LossyDisplayName();
#if defined(OS_WIN)
// Paint the file name. We inset it one pixel to allow room for the halo.
canvas.DrawStringWithHalo(name, font, kFileDragImageTextColor, SK_ColorWHITE,
......@@ -82,7 +82,7 @@ void CreateDragImageForFile(const FilePath& file_name,
width - 2, font.GetHeight(),
gfx::Canvas::TEXT_ALIGN_CENTER);
#else
canvas.DrawStringInt(WideToUTF16Hack(name), font, kFileDragImageTextColor,
canvas.DrawStringInt(name, font, kFileDragImageTextColor,
0, icon->height() + kLinkDragImageVPadding,
width, font.GetHeight(), gfx::Canvas::TEXT_ALIGN_CENTER);
#endif
......
......@@ -9,6 +9,8 @@
#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/font.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
#include "views/controls/label.h"
#include "views/controls/link.h"
......@@ -17,7 +19,7 @@ namespace view_text_utils {
void DrawTextAndPositionUrl(gfx::Canvas* canvas,
views::Label* label,
const std::wstring& text,
const string16& text,
views::Link* link,
gfx::Rect* rect,
gfx::Size* position,
......@@ -31,7 +33,7 @@ void DrawTextAndPositionUrl(gfx::Canvas* canvas,
// initialize a bidirectional ICU line iterator and split the text into
// runs that are either strictly LTR or strictly RTL, with no mix.
base::i18n::BiDiLineIterator bidi_line;
if (!bidi_line.Open(WideToUTF16Hack(text), true, false))
if (!bidi_line.Open(text, true, false))
return;
// Iterate over each run and draw it.
......@@ -42,7 +44,7 @@ void DrawTextAndPositionUrl(gfx::Canvas* canvas,
UBiDiLevel level = 0;
bidi_line.GetLogicalRun(run_start, &run_end, &level);
DCHECK(run_end > run_start);
std::wstring fragment = text.substr(run_start, run_end - run_start);
string16 fragment = text.substr(run_start, run_end - run_start);
// A flag that tells us whether we found LTR text inside RTL text.
bool ltr_inside_rtl_text =
......@@ -81,7 +83,7 @@ void DrawTextAndPositionUrl(gfx::Canvas* canvas,
void DrawTextStartingFrom(gfx::Canvas* canvas,
views::Label* label,
const std::wstring& text,
const string16& text,
gfx::Size* position,
const gfx::Rect& bounds,
const gfx::Font& font,
......@@ -89,7 +91,7 @@ void DrawTextStartingFrom(gfx::Canvas* canvas,
bool ltr_within_rtl) {
// Iterate through line breaking opportunities (which in English would be
// spaces and such). This tells us where to wrap.
string16 text16(WideToUTF16(text));
string16 text16(text);
base::i18n::BreakIterator iter(text16,
base::i18n::BreakIterator::BREAK_SPACE);
if (!iter.Init())
......
......@@ -8,14 +8,13 @@
#define VIEWS_VIEW_TEXT_UTILS_H_
#pragma once
#include <string>
#include "ui/gfx/font.h"
#include "ui/gfx/rect.h"
#include "base/string16.h"
#include "views/views_export.h"
namespace gfx {
class Canvas;
class Font;
class Rect;
class Size;
}
......@@ -42,7 +41,7 @@ namespace view_text_utils {
// character, which we need to position the URLs within the text.
VIEWS_EXPORT void DrawTextAndPositionUrl(gfx::Canvas* canvas,
views::Label* label,
const std::wstring& text,
const string16& text,
views::Link* link,
gfx::Rect* rect,
gfx::Size* position,
......@@ -57,7 +56,7 @@ VIEWS_EXPORT void DrawTextAndPositionUrl(gfx::Canvas* canvas,
// RTL text. For details on the other parameters, see DrawTextAndPositionUrl.
void DrawTextStartingFrom(gfx::Canvas* canvas,
views::Label* label,
const std::wstring& text,
const string16& text,
gfx::Size* position,
const gfx::Rect& bounds,
const gfx::Font& font,
......
......@@ -850,9 +850,9 @@ TEST_F(ViewTest, Textfield) {
// Tests that the Textfield view respond appropiately to cut/copy/paste.
TEST_F(ViewTest, TextfieldCutCopyPaste) {
const std::wstring kNormalText = L"Normal";
const std::wstring kReadOnlyText = L"Read only";
const std::wstring kPasswordText = L"Password! ** Secret stuff **";
const string16 kNormalText = ASCIIToUTF16("Normal");
const string16 kReadOnlyText = ASCIIToUTF16("Read only");
const string16 kPasswordText = ASCIIToUTF16("Password! ** Secret stuff **");
ui::Clipboard clipboard;
......@@ -941,12 +941,12 @@ TEST_F(ViewTest, TextfieldCutCopyPaste) {
::SendMessage(read_only->GetTestingHandle(), WM_KEYDOWN, 0, 0);
wchar_t buffer[1024] = { 0 };
::GetWindowText(read_only->GetTestingHandle(), buffer, 1024);
EXPECT_EQ(kReadOnlyText, std::wstring(buffer));
EXPECT_EQ(kReadOnlyText, string16(buffer));
password->SelectAll();
::SendMessage(password->GetTestingHandle(), WM_PASTE, 0, 0);
::GetWindowText(password->GetTestingHandle(), buffer, 1024);
EXPECT_EQ(kNormalText, std::wstring(buffer));
EXPECT_EQ(kNormalText, string16(buffer));
// Copy from read_only so the string we are pasting is not the same as the
// current one.
......@@ -955,7 +955,7 @@ TEST_F(ViewTest, TextfieldCutCopyPaste) {
normal->SelectAll();
::SendMessage(normal->GetTestingHandle(), WM_PASTE, 0, 0);
::GetWindowText(normal->GetTestingHandle(), buffer, 1024);
EXPECT_EQ(kReadOnlyText, std::wstring(buffer));
EXPECT_EQ(kReadOnlyText, string16(buffer));
widget->CloseNow();
}
#endif
......
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