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

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

Powered by Google App Engine
This is Rietveld 408576698