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

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

Issue 5915004: Introduce incognito preference settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits Created 9 years, 11 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_manager.h" 5 #include "chrome/browser/translate/translate_manager.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 notification_registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, 345 notification_registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
346 NotificationService::AllSources()); 346 NotificationService::AllSources());
347 notification_registrar_.Add(this, NotificationType::TAB_LANGUAGE_DETERMINED, 347 notification_registrar_.Add(this, NotificationType::TAB_LANGUAGE_DETERMINED,
348 NotificationService::AllSources()); 348 NotificationService::AllSources());
349 notification_registrar_.Add(this, NotificationType::PAGE_TRANSLATED, 349 notification_registrar_.Add(this, NotificationType::PAGE_TRANSLATED,
350 NotificationService::AllSources()); 350 NotificationService::AllSources());
351 } 351 }
352 352
353 void TranslateManager::InitiateTranslation(TabContents* tab, 353 void TranslateManager::InitiateTranslation(TabContents* tab,
354 const std::string& page_lang) { 354 const std::string& page_lang) {
355 PrefService* prefs = tab->profile()->GetPrefs(); 355 PrefService* prefs = tab->profile()->GetOriginalProfile()->GetPrefs();
356 if (!prefs->GetBoolean(prefs::kEnableTranslate)) 356 if (!prefs->GetBoolean(prefs::kEnableTranslate))
357 return; 357 return;
358 358
359 pref_change_registrar_.Init(prefs); 359 pref_change_registrar_.Init(prefs);
360 360
361 // Allow disabling of translate from the command line to assist with 361 // Allow disabling of translate from the command line to assist with
362 // automated browser testing. 362 // automated browser testing.
363 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableTranslate)) 363 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableTranslate))
364 return; 364 return;
365 365
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 } else { 531 } else {
532 infobar = TranslateInfoBarDelegate::CreateDelegate( 532 infobar = TranslateInfoBarDelegate::CreateDelegate(
533 TranslateInfoBarDelegate::AFTER_TRANSLATE, tab, 533 TranslateInfoBarDelegate::AFTER_TRANSLATE, tab,
534 details->source_language, details->target_language); 534 details->source_language, details->target_language);
535 } 535 }
536 ShowInfoBar(tab, infobar); 536 ShowInfoBar(tab, infobar);
537 } 537 }
538 538
539 bool TranslateManager::IsAcceptLanguage(TabContents* tab, 539 bool TranslateManager::IsAcceptLanguage(TabContents* tab,
540 const std::string& language) { 540 const std::string& language) {
541 PrefService* pref_service = tab->profile()->GetPrefs(); 541 PrefService* pref_service = tab->profile()->GetOriginalProfile()->GetPrefs();
542 PrefServiceLanguagesMap::const_iterator iter = 542 PrefServiceLanguagesMap::const_iterator iter =
543 accept_languages_.find(pref_service); 543 accept_languages_.find(pref_service);
544 if (iter == accept_languages_.end()) { 544 if (iter == accept_languages_.end()) {
545 InitAcceptLanguages(pref_service); 545 InitAcceptLanguages(pref_service);
546 // Listen for this profile going away, in which case we would need to clear 546 // Listen for this profile going away, in which case we would need to clear
547 // the accepted languages for the profile. 547 // the accepted languages for the profile.
548 notification_registrar_.Add(this, NotificationType::PROFILE_DESTROYED, 548 notification_registrar_.Add(this, NotificationType::PROFILE_DESTROYED,
549 Source<Profile>(tab->profile())); 549 Source<Profile>(tab->profile()));
550 // Also start listening for changes in the accept languages. 550 // Also start listening for changes in the accept languages.
551 pref_change_registrar_.Add(prefs::kAcceptLanguages, this); 551 pref_change_registrar_.Add(prefs::kAcceptLanguages, this);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 TranslateInfoBarDelegate* TranslateManager::GetTranslateInfoBarDelegate( 624 TranslateInfoBarDelegate* TranslateManager::GetTranslateInfoBarDelegate(
625 TabContents* tab) { 625 TabContents* tab) {
626 for (int i = 0; i < tab->infobar_delegate_count(); ++i) { 626 for (int i = 0; i < tab->infobar_delegate_count(); ++i) {
627 TranslateInfoBarDelegate* delegate = 627 TranslateInfoBarDelegate* delegate =
628 tab->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); 628 tab->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate();
629 if (delegate) 629 if (delegate)
630 return delegate; 630 return delegate;
631 } 631 }
632 return NULL; 632 return NULL;
633 } 633 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698