summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-11 21:12:36 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-11 21:12:36 +0000
commite510620c6b1bd4eff20b101c0cdb63166e0b117e (patch)
tree97d58f7932df064b94fd928ed9978731054d6253 /chrome
parent3acba10eb98cd7c4e877f78537353d866b59e62f (diff)
downloadchromium_src-e510620c6b1bd4eff20b101c0cdb63166e0b117e.zip
chromium_src-e510620c6b1bd4eff20b101c0cdb63166e0b117e.tar.gz
chromium_src-e510620c6b1bd4eff20b101c0cdb63166e0b117e.tar.bz2
Convert page contents grabbing from wide to UTF16. The current code is a bit
silly because it would capture it in UTF16, then convert to wide, send it to the browser, then convert it to UTF-8 for FTS. TEST=none BUG=none Review URL: http://codereview.chromium.org/2714012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49594 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc5
-rw-r--r--chrome/browser/autocomplete/history_contents_provider_unittest.cc10
-rw-r--r--chrome/browser/history/expire_history_backend_unittest.cc10
-rw-r--r--chrome/browser/history/history.cc2
-rw-r--r--chrome/browser/history/history.h2
-rw-r--r--chrome/browser/history/history_backend.cc4
-rw-r--r--chrome/browser/history/history_backend.h2
-rw-r--r--chrome/browser/history/history_backend_unittest.cc5
-rw-r--r--chrome/browser/history/history_publisher.cc6
-rw-r--r--chrome/browser/history/history_publisher.h5
-rw-r--r--chrome/browser/history/history_querying_unittest.cc15
-rw-r--r--chrome/browser/history/text_database_manager.cc20
-rw-r--r--chrome/browser/history/text_database_manager.h10
-rw-r--r--chrome/browser/history/text_database_manager_unittest.cc33
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc2
-rw-r--r--chrome/browser/renderer_host/render_view_host.h2
-rw-r--r--chrome/browser/renderer_host/render_view_host_delegate.h2
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc2
-rw-r--r--chrome/browser/tab_contents/tab_contents.h2
-rw-r--r--chrome/browser/translate/translate_manager_unittest.cc92
-rwxr-xr-xchrome/common/render_messages_internal.h2
-rwxr-xr-xchrome/renderer/render_view.cc13
-rw-r--r--chrome/renderer/render_view.h6
23 files changed, 134 insertions, 118 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc
index 23a7967..951a9b0 100644
--- a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc
+++ b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.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.
@@ -12,6 +12,7 @@
#include "base/ref_counted.h"
#include "base/string_util.h"
#include "base/time.h"
+#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/autocomplete/autocomplete.h"
#include "chrome/browser/autocomplete/autocomplete_edit.h"
@@ -232,7 +233,7 @@ class AutocompleteEditViewTest : public InProcessBrowserTest,
Time t = Time::Now() - TimeDelta::FromHours(i + 1);
history_service->AddPageWithDetails(url, cur.title, cur.visit_count,
cur.typed_count, t, false);
- history_service->SetPageContents(url, cur.body);
+ history_service->SetPageContents(url, WideToUTF16(cur.body));
if (cur.starred) {
bookmark_model->SetURLStarred(url, std::wstring(), true);
}
diff --git a/chrome/browser/autocomplete/history_contents_provider_unittest.cc b/chrome/browser/autocomplete/history_contents_provider_unittest.cc
index f956228..ff8fa09 100644
--- a/chrome/browser/autocomplete/history_contents_provider_unittest.cc
+++ b/chrome/browser/autocomplete/history_contents_provider_unittest.cc
@@ -20,11 +20,11 @@ namespace {
struct TestEntry {
const char* url;
const wchar_t* title;
- const wchar_t* body;
+ const char* body;
} test_entries[] = {
- {"http://www.google.com/1", L"PAGEONE 1", L"FOO some body text"},
- {"http://www.google.com/2", L"PAGEONE 2", L"FOO some more blah blah"},
- {"http://www.google.com/3", L"PAGETHREE 3", L"BAR some hello world for you"},
+ {"http://www.google.com/1", L"PAGEONE 1", "FOO some body text"},
+ {"http://www.google.com/2", L"PAGEONE 2", "FOO some more blah blah"},
+ {"http://www.google.com/3", L"PAGETHREE 3", "BAR some hello world for you"},
};
class HistoryContentsProviderTest : public testing::Test,
@@ -73,7 +73,7 @@ class HistoryContentsProviderTest : public testing::Test,
history_service->AddPage(url, t, id_scope, i, GURL(),
PageTransition::LINK, history::RedirectList(), false);
history_service->SetPageTitle(url, test_entries[i].title);
- history_service->SetPageContents(url, test_entries[i].body);
+ history_service->SetPageContents(url, UTF8ToUTF16(test_entries[i].body));
}
provider_ = new HistoryContentsProvider(this, profile_.get());
diff --git a/chrome/browser/history/expire_history_backend_unittest.cc b/chrome/browser/history/expire_history_backend_unittest.cc
index 10563ea..927ba5c 100644
--- a/chrome/browser/history/expire_history_backend_unittest.cc
+++ b/chrome/browser/history/expire_history_backend_unittest.cc
@@ -8,6 +8,7 @@
#include "base/file_util.h"
#include "base/path_service.h"
#include "base/scoped_ptr.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/history/archived_database.h"
#include "chrome/browser/history/expire_history_backend.h"
@@ -242,17 +243,18 @@ void ExpireHistoryTest::AddExampleData(URLID url_ids[3], Time visit_times[4]) {
// Full text index for each visit.
text_db_->AddPageData(url_row1.url(), visit_row1.url_id, visit_row1.visit_id,
- visit_row1.visit_time, L"title", L"body");
+ visit_row1.visit_time, L"title", UTF8ToUTF16("body"));
text_db_->AddPageData(url_row2.url(), visit_row2.url_id, visit_row2.visit_id,
- visit_row2.visit_time, L"title", L"body");
+ visit_row2.visit_time, L"title", UTF8ToUTF16("body"));
text_db_->AddPageData(url_row2.url(), visit_row3.url_id, visit_row3.visit_id,
- visit_row3.visit_time, L"title", L"body");
+ visit_row3.visit_time, L"title", UTF8ToUTF16("body"));
// Note the special text in this URL. We'll search the file for this string
// to make sure it doesn't hang around after the delete.
text_db_->AddPageData(url_row3.url(), visit_row4.url_id, visit_row4.visit_id,
- visit_row4.visit_time, L"title", L"goats body");
+ visit_row4.visit_time, L"title",
+ UTF8ToUTF16("goats body"));
}
bool ExpireHistoryTest::HasFavIcon(FavIconID favicon_id) {
diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc
index 630c490..d115795 100644
--- a/chrome/browser/history/history.cc
+++ b/chrome/browser/history/history.cc
@@ -385,7 +385,7 @@ void HistoryService::AddPagesWithDetails(
}
void HistoryService::SetPageContents(const GURL& url,
- const std::wstring& contents) {
+ const string16& contents) {
if (!CanAddURL(url))
return;
diff --git a/chrome/browser/history/history.h b/chrome/browser/history/history.h
index d4e821a..8e68a86 100644
--- a/chrome/browser/history/history.h
+++ b/chrome/browser/history/history.h
@@ -211,7 +211,7 @@ class HistoryService : public CancelableRequestProvider,
// Notifies history of the body text of the given recently-visited URL.
// If the URL was not visited "recently enough," the history system may
// discard it.
- void SetPageContents(const GURL& url, const std::wstring& contents);
+ void SetPageContents(const GURL& url, const string16& contents);
// Querying ------------------------------------------------------------------
diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc
index 448e2eb..a001233 100644
--- a/chrome/browser/history/history_backend.cc
+++ b/chrome/browser/history/history_backend.cc
@@ -763,7 +763,7 @@ void HistoryBackend::AddPagesWithDetails(const std::vector<URLRow>& urls) {
// create the visit entry with the indexed flag set.
has_indexed = text_database_->AddPageData(i->url(), url_id, 0,
i->last_visit(),
- i->title(), std::wstring());
+ i->title(), string16());
}
// Make up a visit to correspond to that page.
@@ -1426,7 +1426,7 @@ void HistoryBackend::ScheduleAutocomplete(HistoryURLProvider* provider,
}
void HistoryBackend::SetPageContents(const GURL& url,
- const std::wstring& contents) {
+ const string16& contents) {
// This is histogrammed in the text database manager.
if (!text_database_.get())
return;
diff --git a/chrome/browser/history/history_backend.h b/chrome/browser/history/history_backend.h
index 3330ae5..386f393 100644
--- a/chrome/browser/history/history_backend.h
+++ b/chrome/browser/history/history_backend.h
@@ -116,7 +116,7 @@ class HistoryBackend : public base::RefCountedThreadSafe<HistoryBackend>,
// Indexing ------------------------------------------------------------------
- void SetPageContents(const GURL& url, const std::wstring& contents);
+ void SetPageContents(const GURL& url, const string16& contents);
// Querying ------------------------------------------------------------------
diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc
index aa775ae..1628d76 100644
--- a/chrome/browser/history/history_backend_unittest.cc
+++ b/chrome/browser/history/history_backend_unittest.cc
@@ -7,6 +7,7 @@
#include "base/path_service.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/history/history_backend.h"
#include "chrome/browser/history/history_notifications.h"
@@ -249,10 +250,10 @@ TEST_F(HistoryBackendTest, DeleteAll) {
// Set full text index for each one.
backend_->text_database_->AddPageData(row1.url(), row1_id, visit1_id,
row1.last_visit(),
- L"Title 1", L"Body 1");
+ L"Title 1", UTF8ToUTF16("Body 1"));
backend_->text_database_->AddPageData(row2.url(), row2_id, visit2_id,
row2.last_visit(),
- L"Title 2", L"Body 2");
+ L"Title 2", UTF8ToUTF16("Body 2"));
// Now finally clear all history.
backend_->DeleteAllHistory();
diff --git a/chrome/browser/history/history_publisher.cc b/chrome/browser/history/history_publisher.cc
index 364bb821..769a186 100644
--- a/chrome/browser/history/history_publisher.cc
+++ b/chrome/browser/history/history_publisher.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/history/history_publisher.h"
+#include "base/utf_string_conversions.h"
+
namespace history {
const char* const HistoryPublisher::kThumbnailImageFormat = "image/jpeg";
@@ -26,11 +28,11 @@ void HistoryPublisher::PublishPageThumbnail(
void HistoryPublisher::PublishPageContent(const base::Time& time,
const GURL& url,
const std::wstring& title,
- const std::wstring& contents) const {
+ const string16& contents) const {
PageData page_data = {
time,
url,
- contents.c_str(),
+ UTF16ToWide(contents).c_str(),
title.c_str(),
NULL,
NULL,
diff --git a/chrome/browser/history/history_publisher.h b/chrome/browser/history/history_publisher.h
index 95b1893..c7a3530 100644
--- a/chrome/browser/history/history_publisher.h
+++ b/chrome/browser/history/history_publisher.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2008 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.
@@ -9,6 +9,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/string16.h"
#if defined(OS_WIN)
#include "base/scoped_comptr_win.h"
@@ -37,7 +38,7 @@ class HistoryPublisher {
const GURL& url, const base::Time& time) const;
void PublishPageContent(const base::Time& time, const GURL& url,
const std::wstring& title,
- const std::wstring& contents) const;
+ const string16& contents) const;
void DeleteUserHistoryBetween(const base::Time& begin_time,
const base::Time& end_time) const;
diff --git a/chrome/browser/history/history_querying_unittest.cc b/chrome/browser/history/history_querying_unittest.cc
index d934a78..1265eef 100644
--- a/chrome/browser/history/history_querying_unittest.cc
+++ b/chrome/browser/history/history_querying_unittest.cc
@@ -7,6 +7,7 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/path_service.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/history/history.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -23,25 +24,25 @@ struct TestEntry {
const char* url;
const wchar_t* title;
const int days_ago;
- const wchar_t* body;
+ const char* body;
Time time; // Filled by SetUp.
} test_entries[] = {
// This one is visited super long ago so it will be in a different database
// from the next appearance of it at the end.
- {"http://example.com/", L"Other", 180, L"Other"},
+ {"http://example.com/", L"Other", 180, "Other"},
// These are deliberately added out of chronological order. The history
// service should sort them by visit time when returning query results.
// The correct index sort order is 4 2 3 1 0.
{"http://www.google.com/1", L"Title 1", 10,
- L"PAGEONE FOO some body text"},
+ "PAGEONE FOO some body text"},
{"http://www.google.com/3", L"Title 3", 8,
- L"PAGETHREE BAR some hello world for you"},
+ "PAGETHREE BAR some hello world for you"},
{"http://www.google.com/2", L"Title 2", 9,
- L"PAGETWO FOO some more blah blah blah"},
+ "PAGETWO FOO some more blah blah blah"},
// A more recent visit of the first one.
- {"http://example.com/", L"Other", 6, L"Other"},
+ {"http://example.com/", L"Other", 6, "Other"},
};
// Returns true if the nth result in the given results set matches. It will
@@ -112,7 +113,7 @@ class HistoryQueryTest : public testing::Test {
PageTransition::LINK, history::RedirectList(),
false);
history_->SetPageTitle(url, test_entries[i].title);
- history_->SetPageContents(url, test_entries[i].body);
+ history_->SetPageContents(url, UTF8ToUTF16(test_entries[i].body));
}
}
diff --git a/chrome/browser/history/text_database_manager.cc b/chrome/browser/history/text_database_manager.cc
index 451c033..13d681e 100644
--- a/chrome/browser/history/text_database_manager.cc
+++ b/chrome/browser/history/text_database_manager.cc
@@ -28,12 +28,18 @@ namespace {
// The number of database files we will be attached to at once.
const int kCacheDBSize = 5;
-std::string ConvertStringForIndexer(
- const std::wstring& input) {
+std::string ConvertStringForIndexer(const std::wstring& input) {
// TODO(evanm): other transformations here?
return WideToUTF8(CollapseWhitespace(input, false));
}
+#if !defined(OS_WIN) // string16 == wstring on Windows.
+std::string ConvertStringForIndexer(const string16& input) {
+ // TODO(evanm): other transformations here?
+ return UTF16ToUTF8(CollapseWhitespace(input, false));
+}
+#endif
+
// Data older than this will be committed to the full text index even if we
// haven't gotten a title and/or body.
const int kExpirationSec = 20;
@@ -58,9 +64,9 @@ void TextDatabaseManager::PageInfo::set_title(const std::wstring& ttl) {
title_ = ttl;
}
-void TextDatabaseManager::PageInfo::set_body(const std::wstring& bdy) {
+void TextDatabaseManager::PageInfo::set_body(const string16& bdy) {
if (bdy.empty()) // Make the body nonempty when we set it for EverybodySet.
- body_ = L" ";
+ body_ = ASCIIToUTF16(" ");
else
body_ = bdy;
}
@@ -209,7 +215,7 @@ void TextDatabaseManager::AddPageTitle(const GURL& url,
}
AddPageData(url, url_row.id(), visit.visit_id, visit.visit_time,
- title, std::wstring());
+ title, string16());
return; // We don't know about this page, give up.
}
@@ -226,7 +232,7 @@ void TextDatabaseManager::AddPageTitle(const GURL& url,
}
void TextDatabaseManager::AddPageContents(const GURL& url,
- const std::wstring& body) {
+ const string16& body) {
RecentChangeList::iterator found = recent_changes_.Peek(url);
if (found == recent_changes_.end()) {
// This page is not in our cache of recent pages. This means that the page
@@ -266,7 +272,7 @@ bool TextDatabaseManager::AddPageData(const GURL& url,
VisitID visit_id,
Time visit_time,
const std::wstring& title,
- const std::wstring& body) {
+ const string16& body) {
TextDatabase* db = GetDBForTime(visit_time, true);
if (!db)
return false;
diff --git a/chrome/browser/history/text_database_manager.h b/chrome/browser/history/text_database_manager.h
index 47a2b16..b4179a5 100644
--- a/chrome/browser/history/text_database_manager.h
+++ b/chrome/browser/history/text_database_manager.h
@@ -101,7 +101,7 @@ class TextDatabaseManager {
void AddPageURL(const GURL& url, URLID url_id, VisitID visit_id,
base::Time visit_time);
void AddPageTitle(const GURL& url, const std::wstring& title);
- void AddPageContents(const GURL& url, const std::wstring& body);
+ void AddPageContents(const GURL& url, const string16& body);
// Adds the given data to the appropriate database file, returning true on
// success. The visit database row identified by |visit_id| will be updated
@@ -112,7 +112,7 @@ class TextDatabaseManager {
VisitID visit_id,
base::Time visit_time,
const std::wstring& title,
- const std::wstring& body);
+ const string16& body);
// Deletes the instance of indexed data identified by the given time and URL.
// Any changes will be tracked in the optional change set for use when calling
@@ -174,11 +174,11 @@ class TextDatabaseManager {
VisitID visit_id() const { return visit_id_; }
base::Time visit_time() const { return visit_time_; }
const std::wstring& title() const { return title_; }
- const std::wstring& body() const { return body_; }
+ const string16& body() const { return body_; }
// Setters, we can only update the title and body.
void set_title(const std::wstring& ttl);
- void set_body(const std::wstring& bdy);
+ void set_body(const string16& bdy);
// Returns true if both the title or body of the entry has been set. Since
// both the title and body setters will "fix" empty strings to be a space,
@@ -205,7 +205,7 @@ class TextDatabaseManager {
// Will be the string " " when they are set to distinguish set and unset.
std::wstring title_;
- std::wstring body_;
+ string16 body_;
};
// Converts the given time to a database identifier or vice-versa.
diff --git a/chrome/browser/history/text_database_manager_unittest.cc b/chrome/browser/history/text_database_manager_unittest.cc
index ea23e96..aa33af3 100644
--- a/chrome/browser/history/text_database_manager_unittest.cc
+++ b/chrome/browser/history/text_database_manager_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.
@@ -6,6 +6,7 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/message_loop.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/history/text_database_manager.h"
#include "chrome/browser/history/visit_database.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -20,23 +21,23 @@ namespace {
const char* kURL1 = "http://www.google.com/asdf";
const wchar_t* kTitle1 = L"Google A";
-const wchar_t* kBody1 = L"FOO page one.";
+const char* kBody1 = "FOO page one.";
const char* kURL2 = "http://www.google.com/qwer";
const wchar_t* kTitle2 = L"Google B";
-const wchar_t* kBody2 = L"FOO two.";
+const char* kBody2 = "FOO two.";
const char* kURL3 = "http://www.google.com/zxcv";
const wchar_t* kTitle3 = L"Google C";
-const wchar_t* kBody3 = L"FOO drei";
+const char* kBody3 = "FOO drei";
const char* kURL4 = "http://www.google.com/hjkl";
const wchar_t* kTitle4 = L"Google D";
-const wchar_t* kBody4 = L"FOO lalala four.";
+const char* kBody4 = "FOO lalala four.";
const char* kURL5 = "http://www.google.com/uiop";
const wchar_t* kTitle5 = L"Google cinq";
-const wchar_t* kBody5 = L"FOO page one.";
+const char* kBody5 = "FOO page one.";
// This provides a simple implementation of a URL+VisitDatabase using an
// in-memory sqlite connection. The text database manager expects to be able to
@@ -82,7 +83,7 @@ void AddAllPages(TextDatabaseManager& manager, VisitDatabase* visit_db,
times->push_back(visit_row.visit_time);
manager.AddPageData(GURL(kURL1), visit_row.url_id, visit_row.visit_id,
- visit_row.visit_time, kTitle1, kBody1);
+ visit_row.visit_time, kTitle1, UTF8ToUTF16(kBody1));
exploded.day_of_month++;
visit_row.url_id = 2;
@@ -90,7 +91,7 @@ void AddAllPages(TextDatabaseManager& manager, VisitDatabase* visit_db,
visit_id = visit_db->AddVisit(&visit_row);
times->push_back(visit_row.visit_time);
manager.AddPageData(GURL(kURL2), visit_row.url_id, visit_row.visit_id,
- visit_row.visit_time, kTitle2, kBody2);
+ visit_row.visit_time, kTitle2, UTF8ToUTF16(kBody2));
exploded.day_of_month++;
visit_row.url_id = 2;
@@ -98,7 +99,7 @@ void AddAllPages(TextDatabaseManager& manager, VisitDatabase* visit_db,
visit_id = visit_db->AddVisit(&visit_row);
times->push_back(visit_row.visit_time);
manager.AddPageData(GURL(kURL3), visit_row.url_id, visit_row.visit_id,
- visit_row.visit_time, kTitle3, kBody3);
+ visit_row.visit_time, kTitle3, UTF8ToUTF16(kBody3));
// Put the next ones in the next month.
exploded.month++;
@@ -107,7 +108,7 @@ void AddAllPages(TextDatabaseManager& manager, VisitDatabase* visit_db,
visit_id = visit_db->AddVisit(&visit_row);
times->push_back(visit_row.visit_time);
manager.AddPageData(GURL(kURL4), visit_row.url_id, visit_row.visit_id,
- visit_row.visit_time, kTitle4, kBody4);
+ visit_row.visit_time, kTitle4, UTF8ToUTF16(kBody4));
exploded.day_of_month++;
visit_row.url_id = 2;
@@ -115,7 +116,7 @@ void AddAllPages(TextDatabaseManager& manager, VisitDatabase* visit_db,
visit_id = visit_db->AddVisit(&visit_row);
times->push_back(visit_row.visit_time);
manager.AddPageData(GURL(kURL5), visit_row.url_id, visit_row.visit_id,
- visit_row.visit_time, kTitle5, kBody5);
+ visit_row.visit_time, kTitle5, UTF8ToUTF16(kBody5));
// Put the first one in again in the second month.
exploded.day_of_month++;
@@ -124,7 +125,7 @@ void AddAllPages(TextDatabaseManager& manager, VisitDatabase* visit_db,
visit_id = visit_db->AddVisit(&visit_row);
times->push_back(visit_row.visit_time);
manager.AddPageData(GURL(kURL1), visit_row.url_id, visit_row.visit_id,
- visit_row.visit_time, kTitle1, kBody1);
+ visit_row.visit_time, kTitle1, UTF8ToUTF16(kBody1));
}
bool ResultsHaveURL(const std::vector<TextDatabase::Match>& results,
@@ -204,7 +205,7 @@ TEST_F(TextDatabaseManagerTest, InsertCompleteNoVisit) {
const GURL url(kURL1);
manager.AddPageURL(url, 0, 0, Time::Now());
manager.AddPageTitle(url, kTitle1);
- manager.AddPageContents(url, kBody1);
+ manager.AddPageContents(url, UTF8ToUTF16(kBody1));
// Check that the page got added.
QueryOptions options;
@@ -238,7 +239,7 @@ TEST_F(TextDatabaseManagerTest, InsertCompleteVisit) {
// Add a full text indexed entry for that visit.
const GURL url(kURL2);
manager.AddPageURL(url, visit.url_id, visit.visit_id, visit.visit_time);
- manager.AddPageContents(url, kBody2);
+ manager.AddPageContents(url, UTF8ToUTF16(kBody2));
manager.AddPageTitle(url, kTitle2);
// Check that the page got added.
@@ -275,7 +276,7 @@ TEST_F(TextDatabaseManagerTest, InsertPartial) {
// The third one has a URL and body.
GURL url3(kURL3);
manager.AddPageURL(url3, 0, 0, Time::Now());
- manager.AddPageContents(url3, kBody3);
+ manager.AddPageContents(url3, UTF8ToUTF16(kBody3));
// Expire stuff very fast. This assumes that the time between the first
// AddPageURL and this line is less than the expiration time (20 seconds).
@@ -342,7 +343,7 @@ TEST_F(TextDatabaseManagerTest, PartialComplete) {
EXPECT_EQ(0U, results.size());
// Now add the body, which should be queryable.
- manager.AddPageContents(url, L"Very awesome body");
+ manager.AddPageContents(url, UTF8ToUTF16("Very awesome body"));
manager.GetTextMatches(L"awesome", options, &results, &first_time_searched);
EXPECT_EQ(1U, results.size());
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 9f8debc..b14d9d5 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -1873,7 +1873,7 @@ void RenderViewHost::OnCSSInserted() {
void RenderViewHost::OnPageContents(const GURL& url,
int32 page_id,
- const std::wstring& contents,
+ const string16& contents,
const std::string& language) {
RenderViewHostDelegate::BrowserIntegration* integration_delegate =
delegate_->GetBrowserIntegrationDelegate();
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index a429175..53793e0 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -630,7 +630,7 @@ class RenderViewHost : public RenderWidgetHost {
void OnCSSInserted();
void OnPageContents(const GURL& url,
int32 page_id,
- const std::wstring& contents,
+ const string16& contents,
const std::string& language);
void OnPageTranslated(int32 page_id,
const std::string& original_lang,
diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h
index 771562b..80ae7be 100644
--- a/chrome/browser/renderer_host/render_view_host_delegate.h
+++ b/chrome/browser/renderer_host/render_view_host_delegate.h
@@ -238,7 +238,7 @@ class RenderViewHostDelegate {
virtual void OnPageContents(const GURL& url,
int renderer_process_id,
int32 page_id,
- const std::wstring& contents,
+ const string16& contents,
const std::string& language) = 0;
// Notification that the page has been translated.
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index e2bbfe8..0c8a6c8 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -1983,7 +1983,7 @@ void TabContents::OnDidGetApplicationInfo(
void TabContents::OnPageContents(const GURL& url,
int renderer_process_id,
int32 page_id,
- const std::wstring& contents,
+ const string16& contents,
const std::string& language) {
// Don't index any https pages. People generally don't want their bank
// accounts, etc. indexed on their computer, especially since some of these
diff --git a/chrome/browser/tab_contents/tab_contents.h b/chrome/browser/tab_contents/tab_contents.h
index 62dd896..be0a4a2 100644
--- a/chrome/browser/tab_contents/tab_contents.h
+++ b/chrome/browser/tab_contents/tab_contents.h
@@ -852,7 +852,7 @@ class TabContents : public PageNavigator,
virtual void OnPageContents(const GURL& url,
int renderer_process_id,
int32 page_id,
- const std::wstring& contents,
+ const string16& contents,
const std::string& language);
virtual void OnPageTranslated(int32 page_id,
const std::string& original_lang,
diff --git a/chrome/browser/translate/translate_manager_unittest.cc b/chrome/browser/translate/translate_manager_unittest.cc
index acd3e4a..cc0db15 100644
--- a/chrome/browser/translate/translate_manager_unittest.cc
+++ b/chrome/browser/translate/translate_manager_unittest.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/renderer_host/test/test_render_view_host.h"
+#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/renderer_host/mock_render_process_host.h"
#include "chrome/browser/tab_contents/render_view_context_menu.h"
@@ -41,17 +42,18 @@ class TranslateManagerTest : public RenderViewHostTestHarness,
// Simluates navigating to a page and getting the page contents and language
// for that navigation.
void SimulateNavigation(const GURL& url, int page_id,
- const std::wstring& contents,
+ const std::string& contents,
const std::string& lang) {
NavigateAndCommit(url);
SimulateOnPageContents(url, page_id, contents, lang);
}
void SimulateOnPageContents(const GURL& url, int page_id,
- const std::wstring& contents,
+ const std::string& contents,
const std::string& lang) {
rvh()->TestOnMessageReceived(ViewHostMsg_PageContents(0, url, page_id,
- contents, lang));
+ UTF8ToUTF16(contents),
+ lang));
}
bool GetTranslateMessage(int* page_id,
@@ -259,7 +261,7 @@ class TestRenderViewContextMenu : public RenderViewContextMenu {
TEST_F(TranslateManagerTest, NormalTranslate) {
// Simulate navigating to a page.
- SimulateNavigation(GURL("http://www.google.fr"), 0, L"Le Google", "fr");
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr");
// We should have an info-bar.
TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
@@ -320,7 +322,7 @@ TEST_F(TranslateManagerTest, NormalTranslate) {
TEST_F(TranslateManagerTest, TranslateScriptNotAvailable) {
// Simulate navigating to a page.
- SimulateNavigation(GURL("http://www.google.fr"), 0, L"Le Google", "fr");
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr");
// We should have an info-bar.
TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
@@ -401,7 +403,7 @@ TEST_F(TranslateManagerTest, TestAllLanguages) {
// Simulate navigating to a page.
NavigateAndCommit(url);
- SimulateOnPageContents(url, i, L"", lang);
+ SimulateOnPageContents(url, i, "", lang);
// Verify we have/don't have an info-bar as expected.
infobar = GetTranslateInfoBar();
@@ -416,7 +418,7 @@ TEST_F(TranslateManagerTest, TestAllLanguages) {
// Tests auto-translate on page.
TEST_F(TranslateManagerTest, AutoTranslateOnNavigate) {
// Simulate navigating to a page and getting its language.
- SimulateNavigation(GURL("http://www.google.fr"), 0, L"Le Google", "fr");
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr");
// Simulate the user translating.
TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
@@ -429,7 +431,7 @@ TEST_F(TranslateManagerTest, AutoTranslateOnNavigate) {
// Now navigate to a new page in the same language.
process()->sink().ClearMessages();
- SimulateNavigation(GURL("http://news.google.fr"), 1, L"Les news", "fr");
+ SimulateNavigation(GURL("http://news.google.fr"), 1, "Les news", "fr");
// This should have automatically triggered a translation.
int page_id = 0;
@@ -441,7 +443,7 @@ TEST_F(TranslateManagerTest, AutoTranslateOnNavigate) {
// Now navigate to a page in a different language.
process()->sink().ClearMessages();
- SimulateNavigation(GURL("http://news.google.es"), 1, L"Las news", "es");
+ SimulateNavigation(GURL("http://news.google.es"), 1, "Las news", "es");
// This should not have triggered a translate.
EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
@@ -450,28 +452,28 @@ TEST_F(TranslateManagerTest, AutoTranslateOnNavigate) {
// Tests that multiple OnPageContents do not cause multiple infobars.
TEST_F(TranslateManagerTest, MultipleOnPageContents) {
// Simulate navigating to a page and getting its language.
- SimulateNavigation(GURL("http://www.google.fr"), 0, L"Le Google", "fr");
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr");
// Simulate clicking 'Nope' (don't translate).
EXPECT_TRUE(DenyTranslation());
EXPECT_EQ(0, contents()->infobar_delegate_count());
// Send a new PageContents, we should not show an infobar.
- SimulateOnPageContents(GURL("http://www.google.fr"), 0, L"Le Google", "fr");
+ SimulateOnPageContents(GURL("http://www.google.fr"), 0, "Le Google", "fr");
EXPECT_EQ(0, contents()->infobar_delegate_count());
// Do the same steps but simulate closing the infobar this time.
- SimulateNavigation(GURL("http://www.youtube.fr"), 1, L"Le YouTube", "fr");
+ SimulateNavigation(GURL("http://www.youtube.fr"), 1, "Le YouTube", "fr");
EXPECT_TRUE(CloseTranslateInfoBar());
EXPECT_EQ(0, contents()->infobar_delegate_count());
- SimulateOnPageContents(GURL("http://www.youtube.fr"), 1, L"Le YouTube", "fr");
+ SimulateOnPageContents(GURL("http://www.youtube.fr"), 1, "Le YouTube", "fr");
EXPECT_EQ(0, contents()->infobar_delegate_count());
}
// Test that reloading the page brings back the infobar.
TEST_F(TranslateManagerTest, Reload) {
// Simulate navigating to a page and getting its language.
- SimulateNavigation(GURL("http://www.google.fr"), 0, L"Le Google", "fr");
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr");
// Close the infobar.
EXPECT_TRUE(CloseTranslateInfoBar());
@@ -498,7 +500,7 @@ TEST_F(TranslateManagerTest, ReloadFromLocationBar) {
GURL url("http://www.google.fr");
// Simulate navigating to a page and getting its language.
- SimulateNavigation(url, 0, L"Le Google", "fr");
+ SimulateNavigation(url, 0, "Le Google", "fr");
// Close the infobar.
EXPECT_TRUE(CloseTranslateInfoBar());
@@ -526,34 +528,34 @@ TEST_F(TranslateManagerTest, ReloadFromLocationBar) {
// in-page.
TEST_F(TranslateManagerTest, CloseInfoBarInPageNavigation) {
// Simulate navigating to a page and getting its language.
- SimulateNavigation(GURL("http://www.google.fr"), 0, L"Le Google", "fr");
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr");
// Close the infobar.
EXPECT_TRUE(CloseTranslateInfoBar());
// Navigate in page, no infobar should be shown.
- SimulateNavigation(GURL("http://www.google.fr/#ref1"), 0, L"Le Google", "fr");
+ SimulateNavigation(GURL("http://www.google.fr/#ref1"), 0, "Le Google", "fr");
EXPECT_TRUE(GetTranslateInfoBar() == NULL);
// Navigate out of page, a new infobar should show.
- SimulateNavigation(GURL("http://www.google.fr/foot"), 0, L"Le Google", "fr");
+ SimulateNavigation(GURL("http://www.google.fr/foot"), 0, "Le Google", "fr");
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
}
// Tests that denying translation is sticky when navigating in page.
TEST_F(TranslateManagerTest, DenyTranslateInPageNavigation) {
// Simulate navigating to a page and getting its language.
- SimulateNavigation(GURL("http://www.google.fr"), 0, L"Le Google", "fr");
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr");
// Simulate clicking 'Nope' (don't translate).
EXPECT_TRUE(DenyTranslation());
// Navigate in page, no infobar should be shown.
- SimulateNavigation(GURL("http://www.google.fr/#ref1"), 0, L"Le Google", "fr");
+ SimulateNavigation(GURL("http://www.google.fr/#ref1"), 0, "Le Google", "fr");
EXPECT_TRUE(GetTranslateInfoBar() == NULL);
// Navigate out of page, a new infobar should show.
- SimulateNavigation(GURL("http://www.google.fr/foot"), 0, L"Le Google", "fr");
+ SimulateNavigation(GURL("http://www.google.fr/foot"), 0, "Le Google", "fr");
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
}
@@ -561,7 +563,7 @@ TEST_F(TranslateManagerTest, DenyTranslateInPageNavigation) {
// return when navigating in page.
TEST_F(TranslateManagerTest, TranslateCloseInfoBarInPageNavigation) {
// Simulate navigating to a page and getting its language.
- SimulateNavigation(GURL("http://www.google.fr"), 0, L"Le Google", "fr");
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr");
// Simulate the user translating.
TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
@@ -575,14 +577,14 @@ TEST_F(TranslateManagerTest, TranslateCloseInfoBarInPageNavigation) {
EXPECT_TRUE(CloseTranslateInfoBar());
// Navigate in page, no infobar should be shown.
- SimulateNavigation(GURL("http://www.google.fr/#ref1"), 0, L"Le Google", "fr");
+ SimulateNavigation(GURL("http://www.google.fr/#ref1"), 0, "Le Google", "fr");
EXPECT_TRUE(GetTranslateInfoBar() == NULL);
// Navigate out of page, a new infobar should show.
// Note that we navigate to a page in a different language so we don't trigger
// the auto-translate feature (it would translate the page automatically and
// the before translate inforbar would not be shown).
- SimulateNavigation(GURL("http://www.google.de"), 0, L"Das Google", "de");
+ SimulateNavigation(GURL("http://www.google.de"), 0, "Das Google", "de");
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
}
@@ -590,7 +592,7 @@ TEST_F(TranslateManagerTest, TranslateCloseInfoBarInPageNavigation) {
// in-page.
TEST_F(TranslateManagerTest, TranslateInPageNavigation) {
// Simulate navigating to a page and getting its language.
- SimulateNavigation(GURL("http://www.google.fr"), 0, L"Le Google", "fr");
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr");
// Simulate the user translating.
TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
@@ -601,14 +603,14 @@ TEST_F(TranslateManagerTest, TranslateInPageNavigation) {
TranslateErrors::NONE));
// Navigate in page, the same infobar should still be shown.
- SimulateNavigation(GURL("http://www.google.fr/#ref1"), 0, L"Le Google", "fr");
+ SimulateNavigation(GURL("http://www.google.fr/#ref1"), 0, "Le Google", "fr");
EXPECT_FALSE(InfoBarRemoved());
EXPECT_EQ(infobar, GetTranslateInfoBar());
// Navigate out of page, a new infobar should show.
// See note in TranslateCloseInfoBarInPageNavigation test on why it is
// important to navigate to a page in a different language for this test.
- SimulateNavigation(GURL("http://www.google.de"), 0, L"Das Google", "de");
+ SimulateNavigation(GURL("http://www.google.de"), 0, "Das Google", "de");
// The old infobar is gone.
EXPECT_TRUE(CheckInfoBarRemovedAndReset(infobar));
// And there is a new one.
@@ -619,7 +621,7 @@ TEST_F(TranslateManagerTest, TranslateInPageNavigation) {
// unsupported language.
TEST_F(TranslateManagerTest, UnsupportedPageLanguage) {
// Simulate navigating to a page and getting an unsupported language.
- SimulateNavigation(GURL("http://www.google.com"), 0, L"Google", "qbz");
+ SimulateNavigation(GURL("http://www.google.com"), 0, "Google", "qbz");
// No info-bar should be shown.
EXPECT_TRUE(GetTranslateInfoBar() == NULL);
@@ -635,7 +637,7 @@ TEST_F(TranslateManagerTest, UnsupportedUILanguage) {
// Simulate navigating to a page in a language supported by the translate
// server.
- SimulateNavigation(GURL("http://www.google.com"), 0, L"Google", "en");
+ SimulateNavigation(GURL("http://www.google.com"), 0, "Google", "en");
// No info-bar should be shown.
EXPECT_TRUE(GetTranslateInfoBar() == NULL);
@@ -650,7 +652,7 @@ TEST_F(TranslateManagerTest, TranslateEnabledPref) {
prefs->SetBoolean(prefs::kEnableTranslate, true);
// Simulate navigating to a page and getting its language.
- SimulateNavigation(GURL("http://www.google.fr"), 0, L"Le Google", "fr");
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr");
// An infobar should be shown.
TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
@@ -667,7 +669,7 @@ TEST_F(TranslateManagerTest, TranslateEnabledPref) {
// Simulate getting the page contents and language, that should not trigger
// a translate infobar.
- SimulateOnPageContents(url, 1, L"Le YouTube", "fr");
+ SimulateOnPageContents(url, 1, "Le YouTube", "fr");
infobar = GetTranslateInfoBar();
EXPECT_TRUE(infobar == NULL);
}
@@ -676,7 +678,7 @@ TEST_F(TranslateManagerTest, TranslateEnabledPref) {
TEST_F(TranslateManagerTest, NeverTranslateLanguagePref) {
// Simulate navigating to a page and getting its language.
GURL url("http://www.google.fr");
- SimulateNavigation(url, 0, L"Le Google", "fr");
+ SimulateNavigation(url, 0, "Le Google", "fr");
// An infobar should be shown.
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
@@ -697,7 +699,7 @@ TEST_F(TranslateManagerTest, NeverTranslateLanguagePref) {
EXPECT_TRUE(CloseTranslateInfoBar());
// Navigate to a new page also in French.
- SimulateNavigation(GURL("http://wwww.youtube.fr"), 1, L"Le YouTube", "fr");
+ SimulateNavigation(GURL("http://wwww.youtube.fr"), 1, "Le YouTube", "fr");
// There should not be a translate infobar.
EXPECT_TRUE(GetTranslateInfoBar() == NULL);
@@ -709,7 +711,7 @@ TEST_F(TranslateManagerTest, NeverTranslateLanguagePref) {
EXPECT_TRUE(translate_prefs.CanTranslate(prefs, "fr", url));
// Navigate to a page in French.
- SimulateNavigation(url, 2, L"Le Google", "fr");
+ SimulateNavigation(url, 2, "Le Google", "fr");
// There should be a translate infobar.
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
@@ -722,7 +724,7 @@ TEST_F(TranslateManagerTest, NeverTranslateSitePref) {
// Simulate navigating to a page and getting its language.
GURL url("http://www.google.fr");
std::string host(url.host());
- SimulateNavigation(url, 0, L"Le Google", "fr");
+ SimulateNavigation(url, 0, "Le Google", "fr");
// An infobar should be shown.
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
@@ -743,7 +745,7 @@ TEST_F(TranslateManagerTest, NeverTranslateSitePref) {
EXPECT_TRUE(CloseTranslateInfoBar());
// Navigate to a new page also on the same site.
- SimulateNavigation(GURL("http://www.google.fr/hello"), 1, L"Bonjour", "fr");
+ SimulateNavigation(GURL("http://www.google.fr/hello"), 1, "Bonjour", "fr");
// There should not be a translate infobar.
EXPECT_TRUE(GetTranslateInfoBar() == NULL);
@@ -755,7 +757,7 @@ TEST_F(TranslateManagerTest, NeverTranslateSitePref) {
EXPECT_TRUE(translate_prefs.CanTranslate(prefs, "fr", url));
// Navigate to a page in French.
- SimulateNavigation(url, 0, L"Le Google", "fr");
+ SimulateNavigation(url, 0, "Le Google", "fr");
// There should be a translate infobar.
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
@@ -774,7 +776,7 @@ TEST_F(TranslateManagerTest, AlwaysTranslateLanguagePref) {
translate_prefs.WhitelistLanguagePair("fr", "en");
// Load a page in French.
- SimulateNavigation(GURL("http://www.google.fr"), 0, L"Le Google", "fr");
+ SimulateNavigation(GURL("http://www.google.fr"), 0, "Le Google", "fr");
// It should have triggered an automatic translation to English.
SimulateURLFetch(true); // Simulate the translate script being retrieved.
@@ -790,7 +792,7 @@ TEST_F(TranslateManagerTest, AlwaysTranslateLanguagePref) {
EXPECT_TRUE(GetTranslateInfoBar() == NULL);
// Try another language, it should not be autotranslated.
- SimulateNavigation(GURL("http://www.google.es"), 1, L"El Google", "es");
+ SimulateNavigation(GURL("http://www.google.es"), 1, "El Google", "es");
EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
EXPECT_TRUE(CloseTranslateInfoBar());
@@ -800,7 +802,7 @@ TEST_F(TranslateManagerTest, AlwaysTranslateLanguagePref) {
TestingProfile* test_profile =
static_cast<TestingProfile*>(contents()->profile());
test_profile->set_off_the_record(true);
- SimulateNavigation(GURL("http://www.youtube.fr"), 2, L"Le YouTube", "fr");
+ SimulateNavigation(GURL("http://www.youtube.fr"), 2, "Le YouTube", "fr");
EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
EXPECT_TRUE(CloseTranslateInfoBar());
@@ -810,7 +812,7 @@ TEST_F(TranslateManagerTest, AlwaysTranslateLanguagePref) {
// behavior, which is show an infobar.
SetPrefObserverExpectation(TranslatePrefs::kPrefTranslateWhitelists);
translate_prefs.RemoveLanguagePairFromWhitelist("fr", "en");
- SimulateNavigation(GURL("http://www.google.fr"), 3, L"Le Google", "fr");
+ SimulateNavigation(GURL("http://www.google.fr"), 3, "Le Google", "fr");
EXPECT_FALSE(GetTranslateMessage(&page_id, &original_lang, &target_lang));
EXPECT_TRUE(GetTranslateInfoBar() != NULL);
prefs->RemovePrefObserver(TranslatePrefs::kPrefTranslateWhitelists,
@@ -828,7 +830,7 @@ TEST_F(TranslateManagerTest, ContextMenu) {
EXPECT_TRUE(translate_prefs.IsSiteBlacklisted(url.host()));
// Simulate navigating to a page in French. The translate menu should show.
- SimulateNavigation(url, 0, L"Le Google", "fr");
+ SimulateNavigation(url, 0, "Le Google", "fr");
scoped_ptr<TestRenderViewContextMenu> menu(
TestRenderViewContextMenu::CreateContextMenu(contents()));
menu->Init();
@@ -865,7 +867,7 @@ TEST_F(TranslateManagerTest, ContextMenu) {
// Test that selecting translate in the context menu WHILE the page is being
// translated does nothing (this could happen if autotranslate kicks-in and
// the user selects the menu while the translation is being performed).
- SimulateNavigation(GURL("http://www.google.es"), 1, L"El Google", "es");
+ SimulateNavigation(GURL("http://www.google.es"), 1, "El Google", "es");
TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
ASSERT_TRUE(infobar != NULL);
infobar->Translate();
@@ -881,7 +883,7 @@ TEST_F(TranslateManagerTest, ContextMenu) {
// Now test that selecting translate in the context menu AFTER the page has
// been translated does nothing.
- SimulateNavigation(GURL("http://www.google.de"), 2, L"Das Google", "de");
+ SimulateNavigation(GURL("http://www.google.de"), 2, "Das Google", "de");
infobar = GetTranslateInfoBar();
ASSERT_TRUE(infobar != NULL);
infobar->Translate();
@@ -899,7 +901,7 @@ TEST_F(TranslateManagerTest, ContextMenu) {
// Test that the translate context menu is disabled when the page is in the
// same language as the UI.
- SimulateNavigation(url, 0, L"Google", "en");
+ SimulateNavigation(url, 0, "Google", "en");
menu.reset(TestRenderViewContextMenu::CreateContextMenu(contents()));
menu->Init();
EXPECT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_TRANSLATE));
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 67db337..75edafa 100755
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1301,7 +1301,7 @@ IPC_BEGIN_MESSAGES(ViewHost)
IPC_MESSAGE_ROUTED4(ViewHostMsg_PageContents,
GURL /* URL of the page */,
int32 /* page id */,
- std::wstring /* page contents */,
+ string16 /* page contents */,
std::string /* page ISO639_1 language code */)
// Used to get the extension message bundle.
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index eaf7651..f4c952c 100755
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -355,7 +355,7 @@ static bool CrossesExtensionExtents(WebFrame* frame, const GURL& new_url) {
//
// Note this only works on Windows at this time. It always returns 'unknown'
// on other platforms.
-static std::string DetermineTextLanguage(const std::wstring& text) {
+static std::string DetermineTextLanguage(const string16& text) {
// Text with less than 100 bytes will probably not provide good results.
// Report it as unknown language.
if (text.length() < 100)
@@ -364,9 +364,8 @@ static std::string DetermineTextLanguage(const std::wstring& text) {
std::string language = RenderView::kUnknownLanguageCode;
int num_languages = 0;
bool is_reliable = false;
- string16 input = WideToUTF16(text);
Language cld_language =
- DetectLanguageOfUnicodeText(NULL, input.c_str(), true, &is_reliable,
+ DetectLanguageOfUnicodeText(NULL, text.c_str(), true, &is_reliable,
&num_languages, NULL);
if (is_reliable && cld_language != NUM_LANGUAGES &&
cld_language != UNKNOWN_LANGUAGE && cld_language != TG_UNKNOWN_LANGUAGE) {
@@ -822,7 +821,7 @@ void RenderView::CapturePageInfo(int load_id, bool preliminary_capture) {
return;
// Retrieve the frame's full text.
- std::wstring contents;
+ string16 contents;
CaptureText(main_frame, &contents);
if (contents.size()) {
base::TimeTicks begin_time = base::TimeTicks::Now();
@@ -839,7 +838,7 @@ void RenderView::CapturePageInfo(int load_id, bool preliminary_capture) {
OnCaptureThumbnail();
}
-void RenderView::CaptureText(WebFrame* frame, std::wstring* contents) {
+void RenderView::CaptureText(WebFrame* frame, string16* contents) {
contents->clear();
if (!frame)
return;
@@ -849,7 +848,7 @@ void RenderView::CaptureText(WebFrame* frame, std::wstring* contents) {
#endif
// get the contents of the frame
- *contents = UTF16ToWideHack(frame->contentAsText(kMaxIndexChars));
+ *contents = frame->contentAsText(kMaxIndexChars);
#ifdef TIME_TEXT_RETRIEVAL
double end = time_util::GetHighResolutionTimeNow();
@@ -863,7 +862,7 @@ void RenderView::CaptureText(WebFrame* frame, std::wstring* contents) {
// partial word indexed at the end that might have been clipped. Therefore,
// terminate the string at the last space to ensure no words are clipped.
if (contents->size() == kMaxIndexChars) {
- size_t last_space_index = contents->find_last_of(kWhitespaceWide);
+ size_t last_space_index = contents->find_last_of(kWhitespaceUTF16);
if (last_space_index == std::wstring::npos)
return; // don't index if we got a huge block of text with no spaces
contents->resize(last_space_index);
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 093d0e5..65122af 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -647,9 +647,9 @@ class RenderView : public RenderWidget,
// meantime.
void CapturePageInfo(int load_id, bool preliminary_capture);
- // Called to retrieve the text from the given frame contents, the page text
- // up to the maximum amount will be placed into the given buffer
- void CaptureText(WebKit::WebFrame* frame, std::wstring* contents);
+ // Retrieves the text from the given frame contents, the page text up to the
+ // maximum amount kMaxIndexChars will be placed into the given buffer.
+ void CaptureText(WebKit::WebFrame* frame, string16* contents);
// Creates a thumbnail of |frame|'s contents resized to (|w|, |h|)
// and puts that in |thumbnail|. Thumbnail metadata goes in |score|.