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

Side by Side Diff: chrome/browser/translate/translate_tab_helper.cc

Issue 227043005: Eliminate TranslateManager listening to //chrome-level notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + respond to review Created 6 years, 8 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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/browser/translate/translate_tab_helper.h" 5 #include "chrome/browser/translate/translate_tab_helper.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } 345 }
346 } 346 }
347 #endif // defined(CLD2_DYNAMIC_MODE) 347 #endif // defined(CLD2_DYNAMIC_MODE)
348 348
349 void TranslateTabHelper::OnLanguageDetermined( 349 void TranslateTabHelper::OnLanguageDetermined(
350 const LanguageDetectionDetails& details, 350 const LanguageDetectionDetails& details,
351 bool page_needs_translation) { 351 bool page_needs_translation) {
352 translate_driver_.GetLanguageState().LanguageDetermined( 352 translate_driver_.GetLanguageState().LanguageDetermined(
353 details.adopted_language, page_needs_translation); 353 details.adopted_language, page_needs_translation);
354 354
355 if (web_contents())
356 translate_manager_->InitiateTranslation(details.adopted_language);
357
355 content::NotificationService::current()->Notify( 358 content::NotificationService::current()->Notify(
356 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, 359 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
357 content::Source<content::WebContents>(web_contents()), 360 content::Source<content::WebContents>(web_contents()),
358 content::Details<const LanguageDetectionDetails>(&details)); 361 content::Details<const LanguageDetectionDetails>(&details));
359 } 362 }
360 363
361 void TranslateTabHelper::OnPageTranslated(int32 page_id, 364 void TranslateTabHelper::OnPageTranslated(int32 page_id,
362 const std::string& original_lang, 365 const std::string& original_lang,
363 const std::string& translated_lang, 366 const std::string& translated_lang,
364 TranslateErrors::Type error_type) { 367 TranslateErrors::Type error_type) {
365 DCHECK(web_contents()); 368 DCHECK(web_contents());
366 translate_driver_.GetLanguageState().SetCurrentLanguage(translated_lang); 369 translate_manager_->PageTranslated(
367 translate_driver_.GetLanguageState().set_translation_pending(false); 370 original_lang, translated_lang, error_type);
371
368 PageTranslatedDetails details; 372 PageTranslatedDetails details;
369 details.source_language = original_lang; 373 details.source_language = original_lang;
370 details.target_language = translated_lang; 374 details.target_language = translated_lang;
371 details.error_type = error_type; 375 details.error_type = error_type;
372 content::NotificationService::current()->Notify( 376 content::NotificationService::current()->Notify(
373 chrome::NOTIFICATION_PAGE_TRANSLATED, 377 chrome::NOTIFICATION_PAGE_TRANSLATED,
374 content::Source<content::WebContents>(web_contents()), 378 content::Source<content::WebContents>(web_contents()),
375 content::Details<PageTranslatedDetails>(&details)); 379 content::Details<PageTranslatedDetails>(&details));
376 } 380 }
377 381
(...skipping 29 matching lines...) Expand all
407 if (GetLanguageState().InTranslateNavigation()) 411 if (GetLanguageState().InTranslateNavigation())
408 return; 412 return;
409 } 413 }
410 414
411 TranslateBubbleFactory::Show( 415 TranslateBubbleFactory::Show(
412 browser->window(), web_contents(), step, error_type); 416 browser->window(), web_contents(), step, error_type);
413 #else 417 #else
414 NOTREACHED(); 418 NOTREACHED();
415 #endif 419 #endif
416 } 420 }
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