Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4204)

Unified Diff: chrome/renderer/render_view.cc

Issue 2802010: Revert 49594 - Convert page contents grabbing from wide to UTF16. The current... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/437/src/
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/render_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/render_view.cc
===================================================================
--- chrome/renderer/render_view.cc (revision 50158)
+++ chrome/renderer/render_view.cc (working copy)
@@ -355,7 +355,7 @@
//
// Note this only works on Windows at this time. It always returns 'unknown'
// on other platforms.
-static std::string DetermineTextLanguage(const string16& text) {
+static std::string DetermineTextLanguage(const std::wstring& text) {
// Text with less than 100 bytes will probably not provide good results.
// Report it as unknown language.
if (text.length() < 100)
@@ -364,8 +364,9 @@
std::string language = RenderView::kUnknownLanguageCode;
int num_languages = 0;
bool is_reliable = false;
+ string16 input = WideToUTF16(text);
Language cld_language =
- DetectLanguageOfUnicodeText(NULL, text.c_str(), true, &is_reliable,
+ DetectLanguageOfUnicodeText(NULL, input.c_str(), true, &is_reliable,
&num_languages, NULL);
if (is_reliable && cld_language != NUM_LANGUAGES &&
cld_language != UNKNOWN_LANGUAGE && cld_language != TG_UNKNOWN_LANGUAGE) {
@@ -827,7 +828,7 @@
return;
// Retrieve the frame's full text.
- string16 contents;
+ std::wstring contents;
CaptureText(main_frame, &contents);
if (contents.size()) {
base::TimeTicks begin_time = base::TimeTicks::Now();
@@ -844,7 +845,7 @@
OnCaptureThumbnail();
}
-void RenderView::CaptureText(WebFrame* frame, string16* contents) {
+void RenderView::CaptureText(WebFrame* frame, std::wstring* contents) {
contents->clear();
if (!frame)
return;
@@ -854,7 +855,7 @@
#endif
// get the contents of the frame
- *contents = frame->contentAsText(kMaxIndexChars);
+ *contents = UTF16ToWideHack(frame->contentAsText(kMaxIndexChars));
#ifdef TIME_TEXT_RETRIEVAL
double end = time_util::GetHighResolutionTimeNow();
@@ -868,7 +869,7 @@
// 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(kWhitespaceUTF16);
+ size_t last_space_index = contents->find_last_of(kWhitespaceWide);
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);
« no previous file with comments | « chrome/renderer/render_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698