summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-18 16:17:20 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-18 16:17:20 +0000
commit81415229bc291e102450807f4a1fb868f7c0413a (patch)
treea455aa48309b7b0f2f74b0f7818c62b655b98786 /chrome
parentdf0659bd984865987412a48bd6b1ce49f6876247 (diff)
downloadchromium_src-81415229bc291e102450807f4a1fb868f7c0413a.zip
chromium_src-81415229bc291e102450807f4a1fb868f7c0413a.tar.gz
chromium_src-81415229bc291e102450807f4a1fb868f7c0413a.tar.bz2
Convert strings in bookmarks, part 2.
This eliminates the wstring version of BookmarkModel::GetBookmarksWithTitleMatchingTerm(). It also converts a pile of wide strings in bookmark_model_unittest.cc. BUG=23581 TEST=builds and passes tests Review URL: http://codereview.chromium.org/3141024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56533 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autocomplete/history_contents_provider.cc4
-rw-r--r--chrome/browser/bookmarks/bookmark_index_unittest.cc16
-rw-r--r--chrome/browser/bookmarks/bookmark_model.cc11
-rw-r--r--chrome/browser/bookmarks/bookmark_model.h7
-rw-r--r--chrome/browser/bookmarks/bookmark_model_unittest.cc40
5 files changed, 34 insertions, 44 deletions
diff --git a/chrome/browser/autocomplete/history_contents_provider.cc b/chrome/browser/autocomplete/history_contents_provider.cc
index 947f0be..3e4917a 100644
--- a/chrome/browser/autocomplete/history_contents_provider.cc
+++ b/chrome/browser/autocomplete/history_contents_provider.cc
@@ -267,8 +267,8 @@ void HistoryContentsProvider::QueryBookmarks(const AutocompleteInput& input) {
TimeTicks start_time = TimeTicks::Now();
std::vector<bookmark_utils::TitleMatch> matches;
- bookmark_model->GetBookmarksWithTitlesMatching(input.text(), kMaxMatches,
- &matches);
+ bookmark_model->GetBookmarksWithTitlesMatching(WideToUTF16Hack(input.text()),
+ kMaxMatches, &matches);
for (size_t i = 0; i < matches.size(); ++i)
AddBookmarkTitleMatchToResults(matches[i]);
UMA_HISTOGRAM_TIMES("Omnibox.QueryBookmarksTime",
diff --git a/chrome/browser/bookmarks/bookmark_index_unittest.cc b/chrome/browser/bookmarks/bookmark_index_unittest.cc
index f631528..946bb42 100644
--- a/chrome/browser/bookmarks/bookmark_index_unittest.cc
+++ b/chrome/browser/bookmarks/bookmark_index_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -47,7 +47,8 @@ class BookmarkIndexTest : public testing::Test {
void ExpectMatches(const std::wstring& query,
const std::vector<std::wstring> expected_titles) {
std::vector<bookmark_utils::TitleMatch> matches;
- model_->GetBookmarksWithTitlesMatching(query, 1000, &matches);
+ model_->GetBookmarksWithTitlesMatching(WideToUTF16Hack(query), 1000,
+ &matches);
ASSERT_EQ(expected_titles.size(), matches.size());
for (size_t i = 0; i < expected_titles.size(); ++i) {
bool found = false;
@@ -82,7 +83,8 @@ class BookmarkIndexTest : public testing::Test {
void ExpectMatchPositions(const std::wstring& query,
const Snippet::MatchPositions& expected_positions) {
std::vector<bookmark_utils::TitleMatch> matches;
- model_->GetBookmarksWithTitlesMatching(query, 1000, &matches);
+ model_->GetBookmarksWithTitlesMatching(WideToUTF16Hack(query), 1000,
+ &matches);
ASSERT_EQ(1U, matches.size());
const bookmark_utils::TitleMatch& match = matches[0];
ASSERT_EQ(expected_positions.size(), match.match_positions.size());
@@ -197,7 +199,7 @@ TEST_F(BookmarkIndexTest, HonorMax) {
AddBookmarksWithTitles(input, ARRAYSIZE_UNSAFE(input));
std::vector<bookmark_utils::TitleMatch> matches;
- model_->GetBookmarksWithTitlesMatching(L"ABc", 1, &matches);
+ model_->GetBookmarksWithTitlesMatching(ASCIIToUTF16("ABc"), 1, &matches);
EXPECT_EQ(1U, matches.size());
}
@@ -208,7 +210,7 @@ TEST_F(BookmarkIndexTest, EmptyMatchOnMultiwideLowercaseString) {
GURL("http://www.google.com"));
std::vector<bookmark_utils::TitleMatch> matches;
- model_->GetBookmarksWithTitlesMatching(L"i", 100, &matches);
+ model_->GetBookmarksWithTitlesMatching(ASCIIToUTF16("i"), 100, &matches);
ASSERT_EQ(1U, matches.size());
EXPECT_TRUE(matches[0].node == n1);
EXPECT_TRUE(matches[0].match_positions.empty());
@@ -275,7 +277,7 @@ TEST_F(BookmarkIndexTest, GetResultsSortedByTypedCount) {
// Populate match nodes.
std::vector<bookmark_utils::TitleMatch> matches;
- model->GetBookmarksWithTitlesMatching(L"google", 4, &matches);
+ model->GetBookmarksWithTitlesMatching(ASCIIToUTF16("google"), 4, &matches);
// The resulting order should be:
// 1. Google (google.com) 100
@@ -290,7 +292,7 @@ TEST_F(BookmarkIndexTest, GetResultsSortedByTypedCount) {
matches.clear();
// Select top two matches.
- model->GetBookmarksWithTitlesMatching(L"google", 2, &matches);
+ model->GetBookmarksWithTitlesMatching(ASCIIToUTF16("google"), 2, &matches);
EXPECT_EQ(2, static_cast<int>(matches.size()));
EXPECT_EQ(data[0].url, matches[0].node->GetURL());
diff --git a/chrome/browser/bookmarks/bookmark_model.cc b/chrome/browser/bookmarks/bookmark_model.cc
index 4e35c21..0929ba6 100644
--- a/chrome/browser/bookmarks/bookmark_model.cc
+++ b/chrome/browser/bookmarks/bookmark_model.cc
@@ -488,14 +488,6 @@ void BookmarkModel::ResetDateGroupModified(const BookmarkNode* node) {
SetDateGroupModified(node, Time());
}
-#if !defined(WCHAR_T_IS_UTF16)
-void BookmarkModel::GetBookmarksWithTitlesMatching(
- const std::wstring& text,
- size_t max_count,
- std::vector<bookmark_utils::TitleMatch>* matches) {
- GetBookmarksWithTitlesMatching(WideToUTF16(text), max_count, matches);
-}
-#endif
void BookmarkModel::GetBookmarksWithTitlesMatching(
const string16& text,
size_t max_count,
@@ -503,7 +495,8 @@ void BookmarkModel::GetBookmarksWithTitlesMatching(
if (!loaded_)
return;
- index_->GetBookmarksWithTitlesMatching(UTF16ToWide(text), max_count, matches);
+ index_->GetBookmarksWithTitlesMatching(UTF16ToWideHack(text), max_count,
+ matches);
}
void BookmarkModel::ClearStore() {
diff --git a/chrome/browser/bookmarks/bookmark_model.h b/chrome/browser/bookmarks/bookmark_model.h
index 7103615..c5436db 100644
--- a/chrome/browser/bookmarks/bookmark_model.h
+++ b/chrome/browser/bookmarks/bookmark_model.h
@@ -315,13 +315,6 @@ class BookmarkModel : public NotificationObserver, public BookmarkService {
// combobox of most recently modified groups.
void ResetDateGroupModified(const BookmarkNode* node);
- // TODO(munjal): Remove wstring overload once all code is moved to string16.
-#if !defined(WCHAR_T_IS_UTF16)
- void GetBookmarksWithTitlesMatching(
- const std::wstring& text,
- size_t max_count,
- std::vector<bookmark_utils::TitleMatch>* matches);
-#endif
void GetBookmarksWithTitlesMatching(
const string16& text,
size_t max_count,
diff --git a/chrome/browser/bookmarks/bookmark_model_unittest.cc b/chrome/browser/bookmarks/bookmark_model_unittest.cc
index b1d5883..f588068 100644
--- a/chrome/browser/bookmarks/bookmark_model_unittest.cc
+++ b/chrome/browser/bookmarks/bookmark_model_unittest.cc
@@ -13,6 +13,7 @@
#include "base/string16.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_codec.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
@@ -218,7 +219,7 @@ TEST_F(BookmarkModelTest, AddGroup) {
TEST_F(BookmarkModelTest, RemoveURL) {
const BookmarkNode* root = model.GetBookmarkBarNode();
- const std::wstring title(L"foo");
+ const string16 title(ASCIIToUTF16("foo"));
const GURL url("http://foo.com");
model.AddURL(root, 0, title, url);
ClearCounts();
@@ -234,12 +235,12 @@ TEST_F(BookmarkModelTest, RemoveURL) {
TEST_F(BookmarkModelTest, RemoveGroup) {
const BookmarkNode* root = model.GetBookmarkBarNode();
- const BookmarkNode* group = model.AddGroup(root, 0, L"foo");
+ const BookmarkNode* group = model.AddGroup(root, 0, ASCIIToUTF16("foo"));
ClearCounts();
// Add a URL as a child.
- const std::wstring title(L"foo");
+ const string16 title(ASCIIToUTF16("foo"));
const GURL url("http://foo.com");
model.AddURL(group, 0, title, url);
@@ -272,7 +273,7 @@ TEST_F(BookmarkModelTest, SetTitle) {
TEST_F(BookmarkModelTest, SetURL) {
const BookmarkNode* root = model.GetBookmarkBarNode();
- const std::wstring title(L"foo");
+ const string16 title(ASCIIToUTF16("foo"));
GURL url("http://foo.com");
const BookmarkNode* node = model.AddURL(root, 0, title, url);
@@ -287,10 +288,10 @@ TEST_F(BookmarkModelTest, SetURL) {
TEST_F(BookmarkModelTest, Move) {
const BookmarkNode* root = model.GetBookmarkBarNode();
- std::wstring title(L"foo");
+ const string16 title(ASCIIToUTF16("foo"));
const GURL url("http://foo.com");
const BookmarkNode* node = model.AddURL(root, 0, title, url);
- const BookmarkNode* group1 = model.AddGroup(root, 0, L"foo");
+ const BookmarkNode* group1 = model.AddGroup(root, 0, ASCIIToUTF16("foo"));
ClearCounts();
model.Move(node, group1, 0);
@@ -370,7 +371,7 @@ TEST_F(BookmarkModelTest, Copy) {
TEST_F(BookmarkModelTest, ParentForNewNodes) {
ASSERT_EQ(model.GetBookmarkBarNode(), model.GetParentForNewNodes());
- const std::wstring title(L"foo");
+ const string16 title(ASCIIToUTF16("foo"));
const GURL url("http://foo.com");
model.AddURL(model.other_node(), 0, title, url);
@@ -380,9 +381,10 @@ TEST_F(BookmarkModelTest, ParentForNewNodes) {
// Make sure recently modified stays in sync when adding a URL.
TEST_F(BookmarkModelTest, MostRecentlyModifiedGroups) {
// Add a group.
- const BookmarkNode* group = model.AddGroup(model.other_node(), 0, L"foo");
+ const BookmarkNode* group = model.AddGroup(model.other_node(), 0,
+ ASCIIToUTF16("foo"));
// Add a URL to it.
- model.AddURL(group, 0, L"blah", GURL("http://foo.com"));
+ model.AddURL(group, 0, ASCIIToUTF16("blah"), GURL("http://foo.com"));
// Make sure group is in the most recently modified.
std::vector<const BookmarkNode*> most_recent_groups =
@@ -406,19 +408,19 @@ TEST_F(BookmarkModelTest, MostRecentlyAddedEntries) {
Time base_time = Time::Now();
BookmarkNode* n1 = AsMutable(model.AddURL(model.GetBookmarkBarNode(),
0,
- L"blah",
+ ASCIIToUTF16("blah"),
GURL("http://foo.com/0")));
BookmarkNode* n2 = AsMutable(model.AddURL(model.GetBookmarkBarNode(),
1,
- L"blah",
+ ASCIIToUTF16("blah"),
GURL("http://foo.com/1")));
BookmarkNode* n3 = AsMutable(model.AddURL(model.GetBookmarkBarNode(),
2,
- L"blah",
+ ASCIIToUTF16("blah"),
GURL("http://foo.com/2")));
BookmarkNode* n4 = AsMutable(model.AddURL(model.GetBookmarkBarNode(),
3,
- L"blah",
+ ASCIIToUTF16("blah"),
GURL("http://foo.com/3")));
n1->set_date_added(base_time + TimeDelta::FromDays(4));
n2->set_date_added(base_time + TimeDelta::FromDays(3));
@@ -450,9 +452,9 @@ TEST_F(BookmarkModelTest, GetMostRecentlyAddedNodeForURL) {
Time base_time = Time::Now();
const GURL url("http://foo.com/0");
BookmarkNode* n1 = AsMutable(model.AddURL(
- model.GetBookmarkBarNode(), 0, L"blah", url));
+ model.GetBookmarkBarNode(), 0, ASCIIToUTF16("blah"), url));
BookmarkNode* n2 = AsMutable(model.AddURL(
- model.GetBookmarkBarNode(), 1, L"blah", url));
+ model.GetBookmarkBarNode(), 1, ASCIIToUTF16("blah"), url));
n1->set_date_added(base_time + TimeDelta::FromDays(4));
n2->set_date_added(base_time + TimeDelta::FromDays(3));
@@ -467,8 +469,8 @@ TEST_F(BookmarkModelTest, GetMostRecentlyAddedNodeForURL) {
// Makes sure GetBookmarks removes duplicates.
TEST_F(BookmarkModelTest, GetBookmarksWithDups) {
const GURL url("http://foo.com/0");
- model.AddURL(model.GetBookmarkBarNode(), 0, L"blah", url);
- model.AddURL(model.GetBookmarkBarNode(), 1, L"blah", url);
+ model.AddURL(model.GetBookmarkBarNode(), 0, ASCIIToUTF16("blah"), url);
+ model.AddURL(model.GetBookmarkBarNode(), 1, ASCIIToUTF16("blah"), url);
std::vector<GURL> urls;
model.GetBookmarks(&urls);
@@ -514,7 +516,7 @@ TEST_F(BookmarkModelTest, NotifyURLsStarred) {
StarredListener listener;
const GURL url("http://foo.com/0");
const BookmarkNode* n1 = model.AddURL(
- model.GetBookmarkBarNode(), 0, L"blah", url);
+ model.GetBookmarkBarNode(), 0, ASCIIToUTF16("blah"), url);
// Starred notification should be sent.
EXPECT_EQ(1, listener.notification_count_);
@@ -527,7 +529,7 @@ TEST_F(BookmarkModelTest, NotifyURLsStarred) {
// Add another bookmark for the same URL. This should not send any
// notification.
const BookmarkNode* n2 = model.AddURL(
- model.GetBookmarkBarNode(), 1, L"blah", url);
+ model.GetBookmarkBarNode(), 1, ASCIIToUTF16("blah"), url);
EXPECT_EQ(0, listener.notification_count_);