summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authortfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-29 01:11:41 +0000
committertfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-29 01:11:41 +0000
commitf519c9482e9f8fc288162bf2775ad4cdb717695a (patch)
tree69d210b7c8224d587992939787311aaac272dfb7 /views
parent769c7aa11e79e08bd367f6d8b97b09314ed55263 (diff)
downloadchromium_src-f519c9482e9f8fc288162bf2775ad4cdb717695a.zip
chromium_src-f519c9482e9f8fc288162bf2775ad4cdb717695a.tar.gz
chromium_src-f519c9482e9f8fc288162bf2775ad4cdb717695a.tar.bz2
views: Change TabbedPane::AddTab() to string16.
BUG=68267 R=sky@chromium.org Review URL: http://codereview.chromium.org/8068009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103218 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/tabbed_pane/native_tabbed_pane_gtk.cc8
-rw-r--r--views/controls/tabbed_pane/native_tabbed_pane_gtk.h6
-rw-r--r--views/controls/tabbed_pane/native_tabbed_pane_win.cc11
-rw-r--r--views/controls/tabbed_pane/native_tabbed_pane_win.h8
-rw-r--r--views/controls/tabbed_pane/native_tabbed_pane_wrapper.h10
-rw-r--r--views/controls/tabbed_pane/tabbed_pane.cc4
-rw-r--r--views/controls/tabbed_pane/tabbed_pane.h5
-rw-r--r--views/controls/tabbed_pane/tabbed_pane_unittest.cc15
-rw-r--r--views/examples/examples_main.cc2
-rw-r--r--views/examples/tabbed_pane_example.cc14
-rw-r--r--views/examples/tabbed_pane_example.h2
-rw-r--r--views/focus/focus_manager_unittest.cc12
12 files changed, 51 insertions, 46 deletions
diff --git a/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc b/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc
index 8ffe306..63d3d5e 100644
--- a/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc
+++ b/views/controls/tabbed_pane/native_tabbed_pane_gtk.cc
@@ -47,12 +47,12 @@ void NativeTabbedPaneGtk::CreateNativeControl() {
////////////////////////////////////////////////////////////////////////////////
// NativeTabbedPaneGtk, NativeTabbedPaneWrapper implementation:
-void NativeTabbedPaneGtk::AddTab(const std::wstring& title, View* contents) {
+void NativeTabbedPaneGtk::AddTab(const string16& title, View* contents) {
AddTabAtIndex(GetTabCount(), title, contents, true);
}
void NativeTabbedPaneGtk::AddTabAtIndex(int index,
- const std::wstring& title,
+ const string16& title,
View* contents,
bool select_if_first_tab) {
DCHECK(native_view());
@@ -146,7 +146,7 @@ FocusTraversable* NativeTabbedPaneGtk::GetFocusTraversable() {
////////////////////////////////////////////////////////////////////////////////
// NativeTabbedPaneGtk, private:
void NativeTabbedPaneGtk::DoAddTabAtIndex(int index,
- const std::wstring& title,
+ const string16& title,
View* contents,
bool select_if_first_tab) {
int tab_count = GetTabCount();
@@ -175,7 +175,7 @@ void NativeTabbedPaneGtk::DoAddTabAtIndex(int index,
GtkWidget* parent = gtk_widget_get_parent(page);
gtk_container_remove(GTK_CONTAINER(parent), page);
- GtkWidget* label = gtk_label_new(WideToUTF8(title).c_str());
+ GtkWidget* label = gtk_label_new(UTF16ToUTF8(title).c_str());
gtk_widget_show(label);
gtk_notebook_insert_page(GTK_NOTEBOOK(native_view()),
page,
diff --git a/views/controls/tabbed_pane/native_tabbed_pane_gtk.h b/views/controls/tabbed_pane/native_tabbed_pane_gtk.h
index 60d76cc..28b32e6 100644
--- a/views/controls/tabbed_pane/native_tabbed_pane_gtk.h
+++ b/views/controls/tabbed_pane/native_tabbed_pane_gtk.h
@@ -23,9 +23,9 @@ class NativeTabbedPaneGtk : public NativeControlGtk,
virtual void CreateNativeControl() OVERRIDE;
// NativeTabbedPaneWrapper:
- virtual void AddTab(const std::wstring& title, View* contents) OVERRIDE;
+ virtual void AddTab(const string16& title, View* contents) OVERRIDE;
virtual void AddTabAtIndex(int index,
- const std::wstring& title,
+ const string16& title,
View* contents,
bool select_if_first_tab) OVERRIDE;
virtual View* RemoveTabAtIndex(int index) OVERRIDE;
@@ -43,7 +43,7 @@ class NativeTabbedPaneGtk : public NativeControlGtk,
private:
void DoAddTabAtIndex(int index,
- const std::wstring& title,
+ const string16& title,
View* contents,
bool select_if_first_tab);
diff --git a/views/controls/tabbed_pane/native_tabbed_pane_win.cc b/views/controls/tabbed_pane/native_tabbed_pane_win.cc
index 27b61e2..b15b8d3 100644
--- a/views/controls/tabbed_pane/native_tabbed_pane_win.cc
+++ b/views/controls/tabbed_pane/native_tabbed_pane_win.cc
@@ -8,6 +8,7 @@
#include "base/logging.h"
#include "base/stl_util.h"
+#include "base/utf_string_conversions.h"
#include "ui/base/l10n/l10n_util_win.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/win/hwnd_util.h"
@@ -130,11 +131,12 @@ NativeTabbedPaneWin::~NativeTabbedPaneWin() {
////////////////////////////////////////////////////////////////////////////////
// NativeTabbedPaneWin, NativeTabbedPaneWrapper implementation:
-void NativeTabbedPaneWin::AddTab(const std::wstring& title, View* contents) {
+void NativeTabbedPaneWin::AddTab(const string16& title, View* contents) {
AddTabAtIndex(static_cast<int>(tab_views_.size()), title, contents, true);
}
-void NativeTabbedPaneWin::AddTabAtIndex(int index, const std::wstring& title,
+void NativeTabbedPaneWin::AddTabAtIndex(int index,
+ const string16& title,
View* contents,
bool select_if_first_tab) {
DCHECK(index <= static_cast<int>(tab_views_.size()));
@@ -163,8 +165,7 @@ void NativeTabbedPaneWin::AddTabAtIndex(int index, const std::wstring& title,
}
}
-void NativeTabbedPaneWin::AddNativeTab(int index,
- const std::wstring &title) {
+void NativeTabbedPaneWin::AddNativeTab(int index, const string16& title) {
TCITEM tcitem;
tcitem.mask = TCIF_TEXT;
@@ -174,7 +175,7 @@ void NativeTabbedPaneWin::AddNativeTab(int index,
tcitem.mask |= TCIF_RTLREADING;
}
- tcitem.pszText = const_cast<wchar_t*>(title.c_str());
+ tcitem.pszText = const_cast<wchar_t*>(UTF16ToWide(title).c_str());
int result = TabCtrl_InsertItem(native_view(), index, &tcitem);
DCHECK(result != -1);
}
diff --git a/views/controls/tabbed_pane/native_tabbed_pane_win.h b/views/controls/tabbed_pane/native_tabbed_pane_win.h
index f3e84ea..f8bd4ed 100644
--- a/views/controls/tabbed_pane/native_tabbed_pane_win.h
+++ b/views/controls/tabbed_pane/native_tabbed_pane_win.h
@@ -23,9 +23,9 @@ class NativeTabbedPaneWin : public NativeControlWin,
virtual ~NativeTabbedPaneWin();
// NativeTabbedPaneWrapper implementation:
- virtual void AddTab(const std::wstring& title, View* contents);
+ virtual void AddTab(const string16& title, View* contents);
virtual void AddTabAtIndex(int index,
- const std::wstring& title,
+ const string16& title,
View* contents,
bool select_if_first_tab);
virtual View* RemoveTabAtIndex(int index);
@@ -56,7 +56,7 @@ class NativeTabbedPaneWin : public NativeControlWin,
void InitializeTabs();
// Adds a tab with the given content to native control at the given index.
- void AddNativeTab(int index, const std::wstring& title);
+ void AddNativeTab(int index, const string16& title);
// Changes the contents view to the view associated with the tab at |index|.
// |invoke_listener| controls if this methold should invoke the
@@ -76,7 +76,7 @@ class NativeTabbedPaneWin : public NativeControlWin,
std::vector<View*> tab_views_;
// The tab's title strings.
- std::vector<const std::wstring> tab_titles_;
+ std::vector<const string16> tab_titles_;
// The index of the selected tab.
int selected_index_;
diff --git a/views/controls/tabbed_pane/native_tabbed_pane_wrapper.h b/views/controls/tabbed_pane/native_tabbed_pane_wrapper.h
index 6b08d84..0a35992 100644
--- a/views/controls/tabbed_pane/native_tabbed_pane_wrapper.h
+++ b/views/controls/tabbed_pane/native_tabbed_pane_wrapper.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -6,6 +6,8 @@
#define VIEWS_CONTROLS_TABBED_PANE_NATIVE_TABBED_PANE_WRAPPER_H_
#pragma once
+#include "base/string16.h"
+
namespace views {
class TabbedPane;
@@ -17,12 +19,12 @@ class NativeTabbedPaneWrapper {
public:
// The TabbedPane calls this when it is destroyed to clean up the wrapper
// object.
- virtual ~NativeTabbedPaneWrapper() { }
+ virtual ~NativeTabbedPaneWrapper() {}
// Adds a new tab at the end of this TabbedPane with the specified |title|.
// |contents| is the view displayed when the tab is selected and is owned by
// the TabbedPane.
- virtual void AddTab(const std::wstring& title, View* contents) = 0;
+ virtual void AddTab(const string16& title, View* contents) = 0;
// Adds a new tab at the specified |index| with the specified |title|.
// |contents| is the view displayed when the tab is selected and is owned by
@@ -31,7 +33,7 @@ class NativeTabbedPaneWrapper {
// |select_if_first_tab| you need to explicitly invoke SelectTabAt, otherwise
// the tabbed pane will not have a valid selection.
virtual void AddTabAtIndex(int index,
- const std::wstring& title,
+ const string16& title,
View* contents,
bool select_if_first_tab) = 0;
diff --git a/views/controls/tabbed_pane/tabbed_pane.cc b/views/controls/tabbed_pane/tabbed_pane.cc
index 3dec215..4ac4bc3 100644
--- a/views/controls/tabbed_pane/tabbed_pane.cc
+++ b/views/controls/tabbed_pane/tabbed_pane.cc
@@ -38,13 +38,13 @@ View* TabbedPane::GetSelectedTab() {
return native_tabbed_pane_->GetSelectedTab();
}
-void TabbedPane::AddTab(const std::wstring& title, View* contents) {
+void TabbedPane::AddTab(const string16& title, View* contents) {
native_tabbed_pane_->AddTab(title, contents);
PreferredSizeChanged();
}
void TabbedPane::AddTabAtIndex(int index,
- const std::wstring& title,
+ const string16& title,
View* contents,
bool select_if_first_tab) {
native_tabbed_pane_->AddTabAtIndex(index, title, contents,
diff --git a/views/controls/tabbed_pane/tabbed_pane.h b/views/controls/tabbed_pane/tabbed_pane.h
index a987e8a6..d9d51df 100644
--- a/views/controls/tabbed_pane/tabbed_pane.h
+++ b/views/controls/tabbed_pane/tabbed_pane.h
@@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/string16.h"
#include "views/view.h"
namespace views {
@@ -41,7 +42,7 @@ class VIEWS_EXPORT TabbedPane : public View {
// Adds a new tab at the end of this TabbedPane with the specified |title|.
// |contents| is the view displayed when the tab is selected and is owned by
// the TabbedPane.
- void AddTab(const std::wstring& title, View* contents);
+ void AddTab(const string16& title, View* contents);
// Adds a new tab at |index| with |title|.
// |contents| is the view displayed when the tab is selected and is owned by
@@ -50,7 +51,7 @@ class VIEWS_EXPORT TabbedPane : public View {
// |select_if_first_tab| you need to explicitly invoke SelectTabAt, otherwise
// the tabbed pane will not have a valid selection.
void AddTabAtIndex(int index,
- const std::wstring& title,
+ const string16& title,
View* contents,
bool select_if_first_tab);
diff --git a/views/controls/tabbed_pane/tabbed_pane_unittest.cc b/views/controls/tabbed_pane/tabbed_pane_unittest.cc
index 6ffc6c6..4dd7f8f 100644
--- a/views/controls/tabbed_pane/tabbed_pane_unittest.cc
+++ b/views/controls/tabbed_pane/tabbed_pane_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/utf_string_conversions.h"
#include "base/message_loop.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "views/controls/tabbed_pane/tabbed_pane.h"
@@ -68,9 +69,9 @@ class TabbedPaneTest : public testing::Test,
// Tests that TabbedPane::GetPreferredSize() and TabbedPane::Layout().
TEST_F(TabbedPaneTest, SizeAndLayout) {
View* child1 = new FixedSizeView(gfx::Size(20, 10));
- tabbed_pane_->AddTab(L"tab1", child1);
+ tabbed_pane_->AddTab(ASCIIToUTF16("tab1"), child1);
View* child2 = new FixedSizeView(gfx::Size(5, 5));
- tabbed_pane_->AddTab(L"tab2", child2);
+ tabbed_pane_->AddTab(ASCIIToUTF16("tab2"), child2);
tabbed_pane_->SelectTabAt(0);
// Check that the preferred size is larger than the largest child.
@@ -94,14 +95,14 @@ TEST_F(TabbedPaneTest, SizeAndLayout) {
TEST_F(TabbedPaneTest, AddRemove) {
View* tab0 = new View;
- tabbed_pane_->AddTab(L"tab0", tab0);
+ tabbed_pane_->AddTab(ASCIIToUTF16("tab0"), tab0);
EXPECT_EQ(tab0, tabbed_pane_->GetSelectedTab());
EXPECT_EQ(0, tabbed_pane_->GetSelectedTabIndex());
// Add more 3 tabs.
- tabbed_pane_->AddTab(L"tab1", new View);
- tabbed_pane_->AddTab(L"tab2", new View);
- tabbed_pane_->AddTab(L"tab3", new View);
+ tabbed_pane_->AddTab(ASCIIToUTF16("tab1"), new View);
+ tabbed_pane_->AddTab(ASCIIToUTF16("tab2"), new View);
+ tabbed_pane_->AddTab(ASCIIToUTF16("tab3"), new View);
EXPECT_EQ(4, tabbed_pane_->GetTabCount());
// Note: AddTab() doesn't select a tab if the tabbed pane isn't empty.
@@ -118,7 +119,7 @@ TEST_F(TabbedPaneTest, AddRemove) {
// tab.
EXPECT_EQ(2, tabbed_pane_->GetSelectedTabIndex());
- tabbed_pane_->AddTabAtIndex(0, L"tab4", new View, true);
+ tabbed_pane_->AddTabAtIndex(0, ASCIIToUTF16("tab4"), new View, true);
// Assert that even adding a new tab, the tabbed pane doesn't change the
// selection, i.e., it doesn't select the new one.
diff --git a/views/examples/examples_main.cc b/views/examples/examples_main.cc
index 2eda948..4ee0b83 100644
--- a/views/examples/examples_main.cc
+++ b/views/examples/examples_main.cc
@@ -114,7 +114,7 @@ void ExamplesMain::SetStatus(const std::string& status) {
}
void ExamplesMain::AddExample(ExampleBase* example) {
- tabbed_pane_->AddTab(UTF8ToWide(example->example_title()),
+ tabbed_pane_->AddTab(UTF8ToUTF16(example->example_title()),
example->GetExampleView());
}
diff --git a/views/examples/tabbed_pane_example.cc b/views/examples/tabbed_pane_example.cc
index c5c0b81..2e7d74a 100644
--- a/views/examples/tabbed_pane_example.cc
+++ b/views/examples/tabbed_pane_example.cc
@@ -35,8 +35,8 @@ void TabbedPaneExample::CreateExampleView(views::View* container) {
layout->AddView(tabbed_pane_);
// Create a few tabs with a button first.
- AddButton(L"Tab 1");
- AddButton(L"Tab 2");
+ AddButton("Tab 1");
+ AddButton("Tab 2");
// Add control buttons horizontally.
const int button_column = 1;
@@ -56,10 +56,10 @@ void TabbedPaneExample::CreateExampleView(views::View* container) {
void TabbedPaneExample::ButtonPressed(views::Button* sender,
const views::Event& event) {
if (sender == add_) {
- AddButton(L"Added");
+ AddButton("Added");
} else if (sender == add_at_) {
const std::wstring label = L"Added at 1";
- tabbed_pane_->AddTabAtIndex(1, label,
+ tabbed_pane_->AddTabAtIndex(1, WideToUTF16Hack(label),
new views::TextButton(NULL, label), true);
} else if (sender == remove_at_) {
if (tabbed_pane_->GetTabCount() > 1)
@@ -82,9 +82,9 @@ void TabbedPaneExample::PrintStatus() {
tabbed_pane_->GetSelectedTabIndex());
}
-void TabbedPaneExample::AddButton(const std::wstring& label) {
- views::TextButton* button = new views::TextButton(NULL, label);
- tabbed_pane_->AddTab(label, button);
+void TabbedPaneExample::AddButton(const std::string& label) {
+ views::TextButton* button = new views::TextButton(NULL, ASCIIToWide(label));
+ tabbed_pane_->AddTab(ASCIIToUTF16(label), button);
}
} // namespace examples
diff --git a/views/examples/tabbed_pane_example.h b/views/examples/tabbed_pane_example.h
index c7345b8..0dd217d 100644
--- a/views/examples/tabbed_pane_example.h
+++ b/views/examples/tabbed_pane_example.h
@@ -40,7 +40,7 @@ class TabbedPaneExample : public ExampleBase,
// Print the status of the tab in the status area.
void PrintStatus();
- void AddButton(const std::wstring& label);
+ void AddButton(const std::string& label);
// The tabbed pane to be tested.
views::TabbedPane* tabbed_pane_;
diff --git a/views/focus/focus_manager_unittest.cc b/views/focus/focus_manager_unittest.cc
index 58d8bbc..4f8ca5c 100644
--- a/views/focus/focus_manager_unittest.cc
+++ b/views/focus/focus_manager_unittest.cc
@@ -695,8 +695,8 @@ void FocusTraversalTest::InitContentView() {
style_tab_->set_id(kStyleContainerID);
content_view_->AddChildView(style_tab_);
style_tab_->SetBounds(10, y, 210, 100);
- style_tab_->AddTab(L"Style", contents);
- style_tab_->AddTab(L"Other", new View());
+ style_tab_->AddTab(ASCIIToUTF16("Style"), contents);
+ style_tab_->AddTab(ASCIIToUTF16("Other"), new View());
// Right bottom box with search.
contents = new View();
@@ -938,7 +938,7 @@ TEST_F(FocusManagerTest, FAILS_FocusNativeControls) {
content_view_->AddChildView(textfield);
content_view_->AddChildView(tabbed_pane);
- tabbed_pane->AddTab(L"Awesome textfield", textfield2);
+ tabbed_pane->AddTab(ASCIIToUTF16("Awesome textfield"), textfield2);
// Simulate the native view getting the native focus (such as by user click).
FocusNativeView(textfield->TestGetNativeControlView());
@@ -1049,8 +1049,8 @@ TEST_F(FocusManagerTest, ContainsView) {
content_view_->AddChildView(tabbed_pane);
// Adding a View inside a TabbedPane to test the case of nested root view.
- tabbed_pane->AddTab(L"Awesome tab", nested_tabbed_pane);
- nested_tabbed_pane->AddTab(L"Awesomer tab", tab_button);
+ tabbed_pane->AddTab(ASCIIToUTF16("Awesome tab"), nested_tabbed_pane);
+ nested_tabbed_pane->AddTab(ASCIIToUTF16("Awesomer tab"), tab_button);
EXPECT_TRUE(GetFocusManager()->ContainsView(view));
EXPECT_TRUE(GetFocusManager()->ContainsView(tabbed_pane));
@@ -1739,7 +1739,7 @@ TEST_F(FocusManagerDtorTest, FocusManagerDestructedLast) {
NativeButtonDtorTracked* button = new NativeButtonDtorTracked(L"button",
&dtor_tracker_);
- tabbed_pane->AddTab(L"Awesome tab", button);
+ tabbed_pane->AddTab(ASCIIToUTF16("Awesome tab"), button);
// Close the window.
window_->Close();