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

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

Issue 14798008: Translate: add UMA to measure duration time of infobar user action (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (rebase) Created 7 years, 7 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
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/translate_helper.h" 5 #include "chrome/renderer/translate/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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // being the language of the document and the latter being the 119 // being the language of the document and the latter being the
120 // language of the intended audience (a distinction really only 120 // language of the intended audience (a distinction really only
121 // relevant for things like langauge textbooks). This distinction 121 // relevant for things like langauge textbooks). This distinction
122 // shouldn't affect translation. 122 // shouldn't affect translation.
123 WebDocument document = GetMainFrame()->document(); 123 WebDocument document = GetMainFrame()->document();
124 std::string content_language = document.contentLanguage().utf8(); 124 std::string content_language = document.contentLanguage().utf8();
125 std::string language = DeterminePageLanguage(content_language, contents); 125 std::string language = DeterminePageLanguage(content_language, contents);
126 if (language.empty()) 126 if (language.empty())
127 return; 127 return;
128 128
129 language_determined_time_ = base::TimeTicks::Now();
130
129 Send(new ChromeViewHostMsg_TranslateLanguageDetermined( 131 Send(new ChromeViewHostMsg_TranslateLanguageDetermined(
130 routing_id(), language, IsPageTranslatable(&document))); 132 routing_id(), language, IsPageTranslatable(&document)));
131 } 133 }
132 134
133 void TranslateHelper::CancelPendingTranslation() { 135 void TranslateHelper::CancelPendingTranslation() {
134 weak_method_factory_.InvalidateWeakPtrs(); 136 weak_method_factory_.InvalidateWeakPtrs();
135 translation_pending_ = false; 137 translation_pending_ = false;
136 page_id_ = -1; 138 page_id_ = -1;
137 source_lang_.clear(); 139 source_lang_.clear();
138 target_lang_.clear(); 140 target_lang_.clear();
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 433
432 // Set our states. 434 // Set our states.
433 translation_pending_ = true; 435 translation_pending_ = true;
434 page_id_ = page_id; 436 page_id_ = page_id;
435 // If the source language is undetermined, we'll let the translate element 437 // If the source language is undetermined, we'll let the translate element
436 // detect it. 438 // detect it.
437 source_lang_ = (source_lang != chrome::kUnknownLanguageCode) ? 439 source_lang_ = (source_lang != chrome::kUnknownLanguageCode) ?
438 source_lang : kAutoDetectionLanguage; 440 source_lang : kAutoDetectionLanguage;
439 target_lang_ = target_lang; 441 target_lang_ = target_lang;
440 442
443 TranslateHelperMetrics::ReportUserActionDuration(language_determined_time_,
444 base::TimeTicks::Now());
445
441 if (!IsTranslateLibAvailable()) { 446 if (!IsTranslateLibAvailable()) {
442 // Evaluate the script to add the translation related method to the global 447 // Evaluate the script to add the translation related method to the global
443 // context of the page. 448 // context of the page.
444 ExecuteScript(translate_script); 449 ExecuteScript(translate_script);
445 DCHECK(IsTranslateLibAvailable()); 450 DCHECK(IsTranslateLibAvailable());
446 } 451 }
447 452
448 TranslatePageImpl(0); 453 TranslatePageImpl(0);
449 } 454 }
450 455
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 WebView* web_view = render_view()->GetWebView(); 575 WebView* web_view = render_view()->GetWebView();
571 if (!web_view) { 576 if (!web_view) {
572 // When the WebView is going away, the render view should have called 577 // When the WebView is going away, the render view should have called
573 // CancelPendingTranslation() which should have stopped any pending work, so 578 // CancelPendingTranslation() which should have stopped any pending work, so
574 // that case should not happen. 579 // that case should not happen.
575 NOTREACHED(); 580 NOTREACHED();
576 return NULL; 581 return NULL;
577 } 582 }
578 return web_view->mainFrame(); 583 return web_view->mainFrame();
579 } 584 }
OLDNEW
« no previous file with comments | « chrome/renderer/translate/translate_helper.h ('k') | chrome/renderer/translate/translate_helper_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698