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

Side by Side Diff: chrome/renderer/translate_helper.cc

Issue 10831264: Changing VLOG from level 1 to 9 for text to be translated. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changing more VLOGs, forgot about the helper initially. Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/translate/translate_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/translate_helper.h" 5 #include "chrome/renderer/translate_helper.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 WebDocument document = render_view()->GetWebView()->mainFrame()->document(); 62 WebDocument document = render_view()->GetWebView()->mainFrame()->document();
63 // If the page explicitly specifies a language, use it, otherwise we'll 63 // If the page explicitly specifies a language, use it, otherwise we'll
64 // determine it based on the text content using the CLD. 64 // determine it based on the text content using the CLD.
65 std::string language = GetPageLanguageFromMetaTag(&document); 65 std::string language = GetPageLanguageFromMetaTag(&document);
66 if (language.empty()) { 66 if (language.empty()) {
67 base::TimeTicks begin_time = base::TimeTicks::Now(); 67 base::TimeTicks begin_time = base::TimeTicks::Now();
68 language = DetermineTextLanguage(contents); 68 language = DetermineTextLanguage(contents);
69 UMA_HISTOGRAM_MEDIUM_TIMES("Renderer4.LanguageDetection", 69 UMA_HISTOGRAM_MEDIUM_TIMES("Renderer4.LanguageDetection",
70 base::TimeTicks::Now() - begin_time); 70 base::TimeTicks::Now() - begin_time);
71 } else { 71 } else {
72 VLOG(1) << "PageLanguageFromMetaTag: " << language; 72 VLOG(9) << "PageLanguageFromMetaTag: " << language;
73 } 73 }
74 74
75 Send(new ChromeViewHostMsg_TranslateLanguageDetermined( 75 Send(new ChromeViewHostMsg_TranslateLanguageDetermined(
76 routing_id(), language, IsPageTranslatable(&document))); 76 routing_id(), language, IsPageTranslatable(&document)));
77 } 77 }
78 78
79 void TranslateHelper::CancelPendingTranslation() { 79 void TranslateHelper::CancelPendingTranslation() {
80 weak_method_factory_.InvalidateWeakPtrs(); 80 weak_method_factory_.InvalidateWeakPtrs();
81 translation_pending_ = false; 81 translation_pending_ = false;
82 page_id_ = -1; 82 page_id_ = -1;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 if (is_reliable && text_bytes >= 100 && cld_language != NUM_LANGUAGES && 153 if (is_reliable && text_bytes >= 100 && cld_language != NUM_LANGUAGES &&
154 cld_language != UNKNOWN_LANGUAGE && cld_language != TG_UNKNOWN_LANGUAGE) { 154 cld_language != UNKNOWN_LANGUAGE && cld_language != TG_UNKNOWN_LANGUAGE) {
155 // We should not use LanguageCode_ISO_639_1 because it does not cover all 155 // We should not use LanguageCode_ISO_639_1 because it does not cover all
156 // the languages CLD can detect. As a result, it'll return the invalid 156 // the languages CLD can detect. As a result, it'll return the invalid
157 // language code for tradtional Chinese among others. 157 // language code for tradtional Chinese among others.
158 // |LanguageCodeWithDialect| will go through ISO 639-1, ISO-639-2 and 158 // |LanguageCodeWithDialect| will go through ISO 639-1, ISO-639-2 and
159 // 'other' tables to do the 'right' thing. In addition, it'll return zh-CN 159 // 'other' tables to do the 'right' thing. In addition, it'll return zh-CN
160 // for Simplified Chinese. 160 // for Simplified Chinese.
161 language = LanguageCodeWithDialects(cld_language); 161 language = LanguageCodeWithDialects(cld_language);
162 } 162 }
163 VLOG(1) << "Detected lang_id: " << language << ", from Text:\n" << text 163 VLOG(9) << "Detected lang_id: " << language << ", from Text:\n" << text
rvargas (doing something else) 2012/08/10 19:11:30 Actually, I would still want to understand why are
164 << "\n*************************************\n"; 164 << "\n*************************************\n";
165 return language; 165 return language;
166 } 166 }
167 167
168 //////////////////////////////////////////////////////////////////////////////// 168 ////////////////////////////////////////////////////////////////////////////////
169 // TranslateHelper, protected: 169 // TranslateHelper, protected:
170 // 170 //
171 bool TranslateHelper::IsTranslateLibAvailable() { 171 bool TranslateHelper::IsTranslateLibAvailable() {
172 bool lib_available = false; 172 bool lib_available = false;
173 if (!ExecuteScriptAndGetBoolResult( 173 if (!ExecuteScriptAndGetBoolResult(
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 WebView* web_view = render_view()->GetWebView(); 443 WebView* web_view = render_view()->GetWebView();
444 if (!web_view) { 444 if (!web_view) {
445 // When the WebView is going away, the render view should have called 445 // When the WebView is going away, the render view should have called
446 // CancelPendingTranslation() which should have stopped any pending work, so 446 // CancelPendingTranslation() which should have stopped any pending work, so
447 // that case should not happen. 447 // that case should not happen.
448 NOTREACHED(); 448 NOTREACHED();
449 return NULL; 449 return NULL;
450 } 450 }
451 return web_view->mainFrame(); 451 return web_view->mainFrame();
452 } 452 }
OLDNEW
« no previous file with comments | « chrome/browser/translate/translate_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698