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

Side by Side Diff: components/translate/content/renderer/translate_helper.cc

Issue 461633002: Refactor language detection logic to allow non-static CLD data sources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make some of the harness factory methods private Created 6 years, 1 month 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 | « components/translate/content/renderer/translate_helper.h ('k') | third_party/cld_2/BUILD.gn » ('j') | 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 "components/translate/content/renderer/translate_helper.h" 5 #include "components/translate/content/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/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "components/translate/content/common/translate_messages.h" 15 #include "components/translate/content/common/translate_messages.h"
16 #include "components/translate/content/renderer/renderer_cld_data_provider.h"
17 #include "components/translate/content/renderer/renderer_cld_utils.h"
16 #include "components/translate/core/common/translate_constants.h" 18 #include "components/translate/core/common/translate_constants.h"
17 #include "components/translate/core/common/translate_metrics.h" 19 #include "components/translate/core/common/translate_metrics.h"
18 #include "components/translate/core/common/translate_util.h" 20 #include "components/translate/core/common/translate_util.h"
19 #include "components/translate/core/language_detection/language_detection_util.h " 21 #include "components/translate/core/language_detection/language_detection_util.h "
20 #include "content/public/common/content_constants.h" 22 #include "content/public/common/content_constants.h"
21 #include "content/public/common/url_constants.h" 23 #include "content/public/common/url_constants.h"
22 #include "content/public/renderer/render_thread.h" 24 #include "content/public/renderer/render_thread.h"
23 #include "content/public/renderer/render_view.h" 25 #include "content/public/renderer/render_view.h"
24 #include "ipc/ipc_platform_file.h" 26 #include "ipc/ipc_platform_file.h"
25 #include "third_party/WebKit/public/web/WebDocument.h" 27 #include "third_party/WebKit/public/web/WebDocument.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 //////////////////////////////////////////////////////////////////////////////// 77 ////////////////////////////////////////////////////////////////////////////////
76 // TranslateHelper, public: 78 // TranslateHelper, public:
77 // 79 //
78 TranslateHelper::TranslateHelper(content::RenderView* render_view, 80 TranslateHelper::TranslateHelper(content::RenderView* render_view,
79 int world_id, 81 int world_id,
80 int extension_group, 82 int extension_group,
81 const std::string& extension_scheme) 83 const std::string& extension_scheme)
82 : content::RenderViewObserver(render_view), 84 : content::RenderViewObserver(render_view),
83 page_seq_no_(0), 85 page_seq_no_(0),
84 translation_pending_(false), 86 translation_pending_(false),
85 cld_data_provider_(translate::CreateRendererCldDataProviderFor(this)), 87 cld_data_provider_(
88 static_cast<translate::RendererCldDataProvider*>(NULL)),
86 cld_data_polling_started_(false), 89 cld_data_polling_started_(false),
87 cld_data_polling_canceled_(false), 90 cld_data_polling_canceled_(false),
88 deferred_page_capture_(false), 91 deferred_page_capture_(false),
89 deferred_page_seq_no_(-1), 92 deferred_page_seq_no_(-1),
90 world_id_(world_id), 93 world_id_(world_id),
91 extension_group_(extension_group), 94 extension_group_(extension_group),
92 extension_scheme_(extension_scheme), 95 extension_scheme_(extension_scheme),
93 weak_method_factory_(this) { 96 weak_method_factory_(this) {
97 translate::RendererCldUtils::ConfigureDefaultDataProvider();
98 cld_data_provider_ = translate::RendererCldDataProvider::Get();
94 } 99 }
95 100
96 TranslateHelper::~TranslateHelper() { 101 TranslateHelper::~TranslateHelper() {
97 CancelPendingTranslation(); 102 CancelPendingTranslation();
98 CancelCldDataPolling(); 103 CancelCldDataPolling();
99 } 104 }
100 105
101 void TranslateHelper::PrepareForUrl(const GURL& url) { 106 void TranslateHelper::PrepareForUrl(const GURL& url) {
102 ++page_seq_no_; 107 ++page_seq_no_;
103 Send(new ChromeViewHostMsg_TranslateAssignedSequenceNumber( 108 Send(new ChromeViewHostMsg_TranslateAssignedSequenceNumber(
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 // this, everything should start being ON_TIME. This should never run more 634 // this, everything should start being ON_TIME. This should never run more
630 // than twice in a page load, under any conditions. 635 // than twice in a page load, under any conditions.
631 // Also note that language detection is triggered off of a delay AFTER the 636 // Also note that language detection is triggered off of a delay AFTER the
632 // page load completed event has fired, making this very much off the critical 637 // page load completed event has fired, making this very much off the critical
633 // path. 638 // path.
634 content::RenderThread::Get()->UpdateHistograms( 639 content::RenderThread::Get()->UpdateHistograms(
635 content::kHistogramSynchronizerReservedSequenceNumber); 640 content::kHistogramSynchronizerReservedSequenceNumber);
636 } 641 }
637 642
638 } // namespace translate 643 } // namespace translate
OLDNEW
« no previous file with comments | « components/translate/content/renderer/translate_helper.h ('k') | third_party/cld_2/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698