summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-24 15:51:30 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-24 15:51:30 +0000
commit7d1208ce239e0298f016e6839f25551975de2269 (patch)
tree9359fa6b88e7e9d198d8b0b4a35e6793c52ab860
parent4906e580b4a46aaa70b9e857cfa62a415415f6b9 (diff)
downloadchromium_src-7d1208ce239e0298f016e6839f25551975de2269.zip
chromium_src-7d1208ce239e0298f016e6839f25551975de2269.tar.gz
chromium_src-7d1208ce239e0298f016e6839f25551975de2269.tar.bz2
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
-rw-r--r--chrome/browser/ui/views/about_chrome_view.cc10
-rw-r--r--views/drag_utils.cc4
-rw-r--r--views/view_text_utils.cc12
-rw-r--r--views/view_text_utils.h11
-rw-r--r--views/view_unittest.cc12
5 files changed, 25 insertions, 24 deletions
diff --git a/chrome/browser/ui/views/about_chrome_view.cc b/chrome/browser/ui/views/about_chrome_view.cc
index 702b696..24b7afc 100644
--- a/chrome/browser/ui/views/about_chrome_view.cc
+++ b/chrome/browser/ui/views/about_chrome_view.cc
@@ -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.
diff --git a/views/drag_utils.cc b/views/drag_utils.cc
index 7d417c2..fa6c9a0 100644
--- a/views/drag_utils.cc
+++ b/views/drag_utils.cc
@@ -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
diff --git a/views/view_text_utils.cc b/views/view_text_utils.cc
index 645f402..430fdbf 100644
--- a/views/view_text_utils.cc
+++ b/views/view_text_utils.cc
@@ -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())
diff --git a/views/view_text_utils.h b/views/view_text_utils.h
index 27ab5d3..68ed201 100644
--- a/views/view_text_utils.h
+++ b/views/view_text_utils.h
@@ -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,
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index 0cf7e77..7551859 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.cc
@@ -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