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

Unified Diff: chrome/renderer/render_view.cc

Issue 2714012: Convert page contents grabbing from wide to UTF16. The current code is a bit... (Closed) Base URL: svn://chrome-svn/chrome/trunk/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
« chrome/renderer/render_view.h ('K') | « 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 49439)
+++ 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 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 @@
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 @@
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 @@
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 @@
#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 @@
// 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);
« chrome/renderer/render_view.h ('K') | « chrome/renderer/render_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698