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

Side by Side Diff: components/translate/content/browser/content_translate_driver.cc

Issue 2034413003: Delete the non-static CLD data source logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase to latest master Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser/content_translate_driver.h" 5 #include "components/translate/content/browser/content_translate_driver.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
11 #include "base/threading/thread_task_runner_handle.h" 11 #include "base/threading/thread_task_runner_handle.h"
12 #include "components/translate/content/browser/browser_cld_data_provider.h"
13 #include "components/translate/content/browser/browser_cld_data_provider_factory .h"
14 #include "components/translate/content/common/translate_messages.h" 12 #include "components/translate/content/common/translate_messages.h"
15 #include "components/translate/core/browser/translate_download_manager.h" 13 #include "components/translate/core/browser/translate_download_manager.h"
16 #include "components/translate/core/browser/translate_manager.h" 14 #include "components/translate/core/browser/translate_manager.h"
17 #include "content/public/browser/browser_context.h" 15 #include "content/public/browser/browser_context.h"
18 #include "content/public/browser/navigation_controller.h" 16 #include "content/public/browser/navigation_controller.h"
19 #include "content/public/browser/navigation_details.h" 17 #include "content/public/browser/navigation_details.h"
20 #include "content/public/browser/navigation_entry.h" 18 #include "content/public/browser/navigation_entry.h"
21 #include "content/public/browser/page_navigator.h" 19 #include "content/public/browser/page_navigator.h"
22 #include "content/public/browser/render_frame_host.h" 20 #include "content/public/browser/render_frame_host.h"
23 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
(...skipping 10 matching lines...) Expand all
34 } // namespace 32 } // namespace
35 33
36 namespace translate { 34 namespace translate {
37 35
38 ContentTranslateDriver::ContentTranslateDriver( 36 ContentTranslateDriver::ContentTranslateDriver(
39 content::NavigationController* nav_controller) 37 content::NavigationController* nav_controller)
40 : content::WebContentsObserver(nav_controller->GetWebContents()), 38 : content::WebContentsObserver(nav_controller->GetWebContents()),
41 navigation_controller_(nav_controller), 39 navigation_controller_(nav_controller),
42 translate_manager_(NULL), 40 translate_manager_(NULL),
43 max_reload_check_attempts_(kMaxTranslateLoadCheckAttempts), 41 max_reload_check_attempts_(kMaxTranslateLoadCheckAttempts),
44 cld_data_provider_(
45 translate::BrowserCldDataProviderFactory::Get()->
46 CreateBrowserCldDataProvider(nav_controller->GetWebContents())),
47 weak_pointer_factory_(this) { 42 weak_pointer_factory_(this) {
48 DCHECK(navigation_controller_); 43 DCHECK(navigation_controller_);
49 } 44 }
50 45
51 ContentTranslateDriver::~ContentTranslateDriver() {} 46 ContentTranslateDriver::~ContentTranslateDriver() {}
52 47
53 void ContentTranslateDriver::AddObserver(Observer* observer) { 48 void ContentTranslateDriver::AddObserver(Observer* observer) {
54 observer_list_.AddObserver(observer); 49 observer_list_.AddObserver(observer);
55 } 50 }
56 51
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 content::RenderFrameHost* render_frame_host) { 215 content::RenderFrameHost* render_frame_host) {
221 bool handled = true; 216 bool handled = true;
222 IPC_BEGIN_MESSAGE_MAP(ContentTranslateDriver, message) 217 IPC_BEGIN_MESSAGE_MAP(ContentTranslateDriver, message)
223 IPC_MESSAGE_HANDLER(ChromeFrameHostMsg_TranslateAssignedSequenceNumber, 218 IPC_MESSAGE_HANDLER(ChromeFrameHostMsg_TranslateAssignedSequenceNumber,
224 OnTranslateAssignedSequenceNumber) 219 OnTranslateAssignedSequenceNumber)
225 IPC_MESSAGE_HANDLER(ChromeFrameHostMsg_TranslateLanguageDetermined, 220 IPC_MESSAGE_HANDLER(ChromeFrameHostMsg_TranslateLanguageDetermined,
226 OnLanguageDetermined) 221 OnLanguageDetermined)
227 IPC_MESSAGE_HANDLER(ChromeFrameHostMsg_PageTranslated, OnPageTranslated) 222 IPC_MESSAGE_HANDLER(ChromeFrameHostMsg_PageTranslated, OnPageTranslated)
228 IPC_MESSAGE_UNHANDLED(handled = false) 223 IPC_MESSAGE_UNHANDLED(handled = false)
229 IPC_END_MESSAGE_MAP() 224 IPC_END_MESSAGE_MAP()
230 if (!handled) {
231 // The CLD Data Provider may have its own embedder-specific communication,
232 // such as transferring the file handle for a CLD data file to the render
233 // process.
234 handled = cld_data_provider_->OnMessageReceived(message);
235 }
236 return handled; 225 return handled;
237 } 226 }
238 227
239 void ContentTranslateDriver::OnTranslateAssignedSequenceNumber( 228 void ContentTranslateDriver::OnTranslateAssignedSequenceNumber(
240 int page_seq_no) { 229 int page_seq_no) {
241 translate_manager_->set_current_seq_no(page_seq_no); 230 translate_manager_->set_current_seq_no(page_seq_no);
242 } 231 }
243 232
244 void ContentTranslateDriver::OnLanguageDetermined( 233 void ContentTranslateDriver::OnLanguageDetermined(
245 const LanguageDetectionDetails& details, 234 const LanguageDetectionDetails& details,
(...skipping 13 matching lines...) Expand all
259 TranslateErrors::Type error_type) { 248 TranslateErrors::Type error_type) {
260 translate_manager_->PageTranslated( 249 translate_manager_->PageTranslated(
261 original_lang, translated_lang, error_type); 250 original_lang, translated_lang, error_type);
262 FOR_EACH_OBSERVER( 251 FOR_EACH_OBSERVER(
263 Observer, 252 Observer,
264 observer_list_, 253 observer_list_,
265 OnPageTranslated(original_lang, translated_lang, error_type)); 254 OnPageTranslated(original_lang, translated_lang, error_type));
266 } 255 }
267 256
268 } // namespace translate 257 } // namespace translate
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698