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

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

Issue 1184001: Don't autotranslate in incognito mode (so we don't send information... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 | « no previous file | chrome/browser/translate/translate_manager_unittest.cc » ('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) 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 "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/pref_service.h" 10 #include "chrome/browser/pref_service.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // - any Chrome specific page (New Tab Page, Download, History... pages). 163 // - any Chrome specific page (New Tab Page, Download, History... pages).
164 // - similar languages (ex: en-US to en). 164 // - similar languages (ex: en-US to en).
165 // - any user black-listed URLs or user selected language combination. 165 // - any user black-listed URLs or user selected language combination.
166 // - any language the user configured as accepted languages. 166 // - any language the user configured as accepted languages.
167 if (entry->url().SchemeIs("chrome") || page_lang == ui_lang || 167 if (entry->url().SchemeIs("chrome") || page_lang == ui_lang ||
168 !TranslatePrefs::CanTranslate(prefs, page_lang, entry->url()) || 168 !TranslatePrefs::CanTranslate(prefs, page_lang, entry->url()) ||
169 IsAcceptLanguage(tab, page_lang)) { 169 IsAcceptLanguage(tab, page_lang)) {
170 return; 170 return;
171 } 171 }
172 172
173 if (TranslatePrefs::ShouldAutoTranslate(prefs, page_lang, ui_lang)) { 173 // If the user has previously selected "always translate" for this language we
174 // The user has previously select "always translate" for this language. 174 // automatically translate. Note that in incognito mode we disable that
175 // feature; the user will get an infobar, so they can control whether the
176 // page's text is sent to the translate server.
177 if (TranslatePrefs::ShouldAutoTranslate(prefs, page_lang, ui_lang) &&
178 !tab->profile()->IsOffTheRecord()) {
175 tab->TranslatePage(page_lang, ui_lang); 179 tab->TranslatePage(page_lang, ui_lang);
176 return; 180 return;
177 } 181 }
178 182
179 std::string auto_translate_to = tab->language_state().AutoTranslateTo(); 183 std::string auto_translate_to = tab->language_state().AutoTranslateTo();
180 if (!auto_translate_to.empty()) { 184 if (!auto_translate_to.empty()) {
181 // This page was navigated through a click from a translated page. 185 // This page was navigated through a click from a translated page.
182 tab->TranslatePage(page_lang, auto_translate_to); 186 tab->TranslatePage(page_lang, auto_translate_to);
183 return; 187 return;
184 } 188 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 TranslateInfoBarDelegate* infobar = 262 TranslateInfoBarDelegate* infobar =
259 TranslateInfoBarDelegate::Create(tab, prefs, state, url, 263 TranslateInfoBarDelegate::Create(tab, prefs, state, url,
260 original_language, target_language); 264 original_language, target_language);
261 if (!infobar) { 265 if (!infobar) {
262 NOTREACHED() << "Failed to create infobar for language " << 266 NOTREACHED() << "Failed to create infobar for language " <<
263 original_language << " and " << target_language; 267 original_language << " and " << target_language;
264 return; 268 return;
265 } 269 }
266 tab->AddInfoBar(infobar); 270 tab->AddInfoBar(infobar);
267 } 271 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/translate/translate_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698