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

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

Issue 1923143003: Implement the 2016Q2 Translate UI designe spec out in (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change based on msw comments. Created 4 years, 7 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 "chrome/browser/translate/chrome_translate_client.h" 5 #include "chrome/browser/translate/chrome_translate_client.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 if (error_type != translate::TranslateErrors::NONE) 183 if (error_type != translate::TranslateErrors::NONE)
184 step = translate::TRANSLATE_STEP_TRANSLATE_ERROR; 184 step = translate::TRANSLATE_STEP_TRANSLATE_ERROR;
185 185
186 #if !defined(USE_AURA) 186 #if !defined(USE_AURA)
187 if (!TranslateService::IsTranslateBubbleEnabled()) { 187 if (!TranslateService::IsTranslateBubbleEnabled()) {
188 // Infobar UI. 188 // Infobar UI.
189 translate::TranslateInfoBarDelegate::Create( 189 translate::TranslateInfoBarDelegate::Create(
190 step != translate::TRANSLATE_STEP_BEFORE_TRANSLATE, 190 step != translate::TRANSLATE_STEP_BEFORE_TRANSLATE,
191 translate_manager_->GetWeakPtr(), 191 translate_manager_->GetWeakPtr(),
192 InfoBarService::FromWebContents(web_contents()), 192 InfoBarService::FromWebContents(web_contents()),
193 web_contents()->GetBrowserContext()->IsOffTheRecord(), 193 web_contents()->GetBrowserContext()->IsOffTheRecord(), step,
194 step, 194 source_language, target_language, error_type, triggered_from_menu);
195 source_language,
196 target_language,
197 error_type,
198 triggered_from_menu);
199 return; 195 return;
200 } 196 }
201 #endif 197 #endif
202 198
203 // Bubble UI. 199 // Bubble UI.
204 if (step == translate::TRANSLATE_STEP_BEFORE_TRANSLATE) { 200 if (step == translate::TRANSLATE_STEP_BEFORE_TRANSLATE) {
205 // TODO(droger): Move this logic out of UI code. 201 // TODO(droger): Move this logic out of UI code.
206 GetLanguageState().SetTranslateEnabled(true); 202 GetLanguageState().SetTranslateEnabled(true);
207 if (!GetLanguageState().HasLanguageChanged()) 203 // In the new UI, keep offer the translation after user navigate to
msw 2016/05/04 00:19:20 grammar nit: "continue offering translation after
ftang 2016/05/04 00:34:01 Done. from my point of view, the old UI does not m
204 // another page.
205 if (!base::FeatureList::IsEnabled(translate::kTranslateUI2016Q2) &&
206 !GetLanguageState().HasLanguageChanged()) {
208 return; 207 return;
208 }
209 209
210 if (!triggered_from_menu) { 210 if (!triggered_from_menu) {
211 if (web_contents()->GetBrowserContext()->IsOffTheRecord()) 211 if (web_contents()->GetBrowserContext()->IsOffTheRecord())
212 return; 212 return;
213 if (GetTranslatePrefs()->IsTooOftenDenied(source_language)) 213 if (GetTranslatePrefs()->IsTooOftenDenied(source_language))
214 return; 214 return;
215 } 215 }
216 } 216 }
217 ShowBubble(step, error_type); 217 ShowBubble(step, error_type);
218 } 218 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 // Android does not support reporting language detection errors. 261 // Android does not support reporting language detection errors.
262 NOTREACHED(); 262 NOTREACHED();
263 #else 263 #else
264 // We'll open the URL in a new tab so that the user can tell us more. 264 // We'll open the URL in a new tab so that the user can tell us more.
265 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); 265 Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
266 if (!browser) { 266 if (!browser) {
267 NOTREACHED(); 267 NOTREACHED();
268 return; 268 return;
269 } 269 }
270 270
271 chrome::AddSelectedTabWithURL( 271 chrome::AddSelectedTabWithURL(browser, report_url,
272 browser, report_url, ui::PAGE_TRANSITION_AUTO_BOOKMARK); 272 ui::PAGE_TRANSITION_AUTO_BOOKMARK);
273 #endif // defined(OS_ANDROID) 273 #endif // defined(OS_ANDROID)
274 } 274 }
275 275
276 void ChromeTranslateClient::WebContentsDestroyed() { 276 void ChromeTranslateClient::WebContentsDestroyed() {
277 // Translation process can be interrupted. 277 // Translation process can be interrupted.
278 // Destroying the TranslateManager now guarantees that it never has to deal 278 // Destroying the TranslateManager now guarantees that it never has to deal
279 // with NULL WebContents. 279 // with NULL WebContents.
280 translate_manager_.reset(); 280 translate_manager_.reset();
281 } 281 }
282 282
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 if (browser != chrome::FindLastActive()) 334 if (browser != chrome::FindLastActive())
335 return; 335 return;
336 336
337 // During auto-translating, the bubble should not be shown. 337 // During auto-translating, the bubble should not be shown.
338 if (step == translate::TRANSLATE_STEP_TRANSLATING || 338 if (step == translate::TRANSLATE_STEP_TRANSLATING ||
339 step == translate::TRANSLATE_STEP_AFTER_TRANSLATE) { 339 step == translate::TRANSLATE_STEP_AFTER_TRANSLATE) {
340 if (GetLanguageState().InTranslateNavigation()) 340 if (GetLanguageState().InTranslateNavigation())
341 return; 341 return;
342 } 342 }
343 343
344 TranslateBubbleFactory::Show( 344 TranslateBubbleFactory::Show(browser->window(), web_contents(), step,
345 browser->window(), web_contents(), step, error_type); 345 error_type);
346 #else 346 #else
347 NOTREACHED(); 347 NOTREACHED();
348 #endif 348 #endif
349 } 349 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698