| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "chrome/browser/translate/translate_event_details.h" | 25 #include "chrome/browser/translate/translate_event_details.h" |
| 26 #include "chrome/browser/translate/translate_infobar_delegate.h" | 26 #include "chrome/browser/translate/translate_infobar_delegate.h" |
| 27 #include "chrome/browser/translate/translate_language_list.h" | 27 #include "chrome/browser/translate/translate_language_list.h" |
| 28 #include "chrome/browser/translate/translate_prefs.h" | 28 #include "chrome/browser/translate/translate_prefs.h" |
| 29 #include "chrome/browser/translate/translate_script.h" | 29 #include "chrome/browser/translate/translate_script.h" |
| 30 #include "chrome/browser/translate/translate_tab_helper.h" | 30 #include "chrome/browser/translate/translate_tab_helper.h" |
| 31 #include "chrome/browser/translate/translate_url_util.h" | 31 #include "chrome/browser/translate/translate_url_util.h" |
| 32 #include "chrome/browser/ui/browser.h" | 32 #include "chrome/browser/ui/browser.h" |
| 33 #include "chrome/browser/ui/browser_finder.h" | 33 #include "chrome/browser/ui/browser_finder.h" |
| 34 #include "chrome/browser/ui/browser_tabstrip.h" | 34 #include "chrome/browser/ui/browser_tabstrip.h" |
| 35 #include "chrome/browser/ui/browser_window.h" |
| 35 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 36 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 37 #include "chrome/browser/ui/translate/translate_bubble_factory.h" |
| 36 #include "chrome/common/chrome_switches.h" | 38 #include "chrome/common/chrome_switches.h" |
| 37 #include "chrome/common/pref_names.h" | 39 #include "chrome/common/pref_names.h" |
| 38 #include "chrome/common/render_messages.h" | 40 #include "chrome/common/render_messages.h" |
| 39 #include "chrome/common/translate/language_detection_details.h" | 41 #include "chrome/common/translate/language_detection_details.h" |
| 40 #include "chrome/common/url_constants.h" | 42 #include "chrome/common/url_constants.h" |
| 41 #include "components/translate/common/translate_constants.h" | 43 #include "components/translate/common/translate_constants.h" |
| 42 #include "content/public/browser/navigation_controller.h" | 44 #include "content/public/browser/navigation_controller.h" |
| 43 #include "content/public/browser/navigation_details.h" | 45 #include "content/public/browser/navigation_details.h" |
| 44 #include "content/public/browser/navigation_entry.h" | 46 #include "content/public/browser/navigation_entry.h" |
| 45 #include "content/public/browser/notification_details.h" | 47 #include "content/public/browser/notification_details.h" |
| 46 #include "content/public/browser/notification_service.h" | 48 #include "content/public/browser/notification_service.h" |
| 47 #include "content/public/browser/notification_source.h" | 49 #include "content/public/browser/notification_source.h" |
| 48 #include "content/public/browser/notification_types.h" | 50 #include "content/public/browser/notification_types.h" |
| 49 #include "content/public/browser/render_process_host.h" | 51 #include "content/public/browser/render_process_host.h" |
| 50 #include "content/public/browser/render_view_host.h" | 52 #include "content/public/browser/render_view_host.h" |
| 51 #include "content/public/browser/web_contents.h" | 53 #include "content/public/browser/web_contents.h" |
| 52 #include "net/base/url_util.h" | 54 #include "net/base/url_util.h" |
| 53 #include "net/http/http_status_code.h" | 55 #include "net/http/http_status_code.h" |
| 54 | 56 |
| 55 #ifdef FILE_MANAGER_EXTENSION | 57 #ifdef FILE_MANAGER_EXTENSION |
| 56 #include "chrome/browser/chromeos/file_manager/app_id.h" | 58 #include "chrome/browser/chromeos/file_manager/app_id.h" |
| 57 #include "extensions/common/constants.h" | 59 #include "extensions/common/constants.h" |
| 58 #endif | 60 #endif |
| 59 | 61 |
| 60 using content::NavigationController; | 62 using content::NavigationController; |
| 61 using content::NavigationEntry; | 63 using content::NavigationEntry; |
| 62 using content::WebContents; | 64 using content::WebContents; |
| 63 | 65 |
| 66 namespace { |
| 67 |
| 64 const char kReportLanguageDetectionErrorURL[] = | 68 const char kReportLanguageDetectionErrorURL[] = |
| 65 "https://translate.google.com/translate_error?client=cr&action=langidc"; | 69 "https://translate.google.com/translate_error?client=cr&action=langidc"; |
| 66 | 70 |
| 67 // Used in kReportLanguageDetectionErrorURL to specify the original page | 71 // Used in kReportLanguageDetectionErrorURL to specify the original page |
| 68 // language. | 72 // language. |
| 69 const char kSourceLanguageQueryName[] = "sl"; | 73 const char kSourceLanguageQueryName[] = "sl"; |
| 70 | 74 |
| 71 // Used in kReportLanguageDetectionErrorURL to specify the page URL. | 75 // Used in kReportLanguageDetectionErrorURL to specify the page URL. |
| 72 const char kUrlQueryName[] = "u"; | 76 const char kUrlQueryName[] = "u"; |
| 73 | 77 |
| 74 // The maximum number of attempts we'll do to see if the page has finshed | 78 // The maximum number of attempts we'll do to see if the page has finshed |
| 75 // loading before giving up the translation | 79 // loading before giving up the translation |
| 76 const int kMaxTranslateLoadCheckAttempts = 20; | 80 const int kMaxTranslateLoadCheckAttempts = 20; |
| 77 | 81 |
| 82 bool IsEnabledTranslateNewUX() { |
| 83 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 84 switches::kEnableTranslateNewUX); |
| 85 } |
| 86 |
| 87 } // namespace |
| 88 |
| 78 TranslateManager::~TranslateManager() { | 89 TranslateManager::~TranslateManager() { |
| 79 } | 90 } |
| 80 | 91 |
| 81 // static | 92 // static |
| 82 TranslateManager* TranslateManager::GetInstance() { | 93 TranslateManager* TranslateManager::GetInstance() { |
| 83 return Singleton<TranslateManager>::get(); | 94 return Singleton<TranslateManager>::get(); |
| 84 } | 95 } |
| 85 | 96 |
| 86 // static | 97 // static |
| 87 bool TranslateManager::IsTranslatableURL(const GURL& url) { | 98 bool TranslateManager::IsTranslatableURL(const GURL& url) { |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 content::NotificationService::AllSources()); | 306 content::NotificationService::AllSources()); |
| 296 notification_registrar_.Add(this, chrome::NOTIFICATION_PAGE_TRANSLATED, | 307 notification_registrar_.Add(this, chrome::NOTIFICATION_PAGE_TRANSLATED, |
| 297 content::NotificationService::AllSources()); | 308 content::NotificationService::AllSources()); |
| 298 language_list_.reset(new TranslateLanguageList); | 309 language_list_.reset(new TranslateLanguageList); |
| 299 accept_languages_.reset(new TranslateAcceptLanguages); | 310 accept_languages_.reset(new TranslateAcceptLanguages); |
| 300 script_.reset(new TranslateScript); | 311 script_.reset(new TranslateScript); |
| 301 } | 312 } |
| 302 | 313 |
| 303 void TranslateManager::InitiateTranslation(WebContents* web_contents, | 314 void TranslateManager::InitiateTranslation(WebContents* web_contents, |
| 304 const std::string& page_lang) { | 315 const std::string& page_lang) { |
| 316 TranslateTabHelper* translate_tab_helper = |
| 317 TranslateTabHelper::FromWebContents(web_contents); |
| 318 if (!translate_tab_helper) |
| 319 return; |
| 320 |
| 305 Profile* profile = | 321 Profile* profile = |
| 306 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 322 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 307 Profile* original_profile = profile->GetOriginalProfile(); | 323 Profile* original_profile = profile->GetOriginalProfile(); |
| 308 PrefService* prefs = original_profile->GetPrefs(); | 324 PrefService* prefs = original_profile->GetPrefs(); |
| 309 if (!prefs->GetBoolean(prefs::kEnableTranslate)) { | 325 if (!prefs->GetBoolean(prefs::kEnableTranslate)) { |
| 310 TranslateBrowserMetrics::ReportInitiationStatus( | 326 TranslateBrowserMetrics::ReportInitiationStatus( |
| 311 TranslateBrowserMetrics::INITIATION_STATUS_DISABLED_BY_PREFS); | 327 TranslateBrowserMetrics::INITIATION_STATUS_DISABLED_BY_PREFS); |
| 312 const std::string& locale = g_browser_process->GetApplicationLocale(); | 328 const std::string& locale = g_browser_process->GetApplicationLocale(); |
| 313 TranslateBrowserMetrics::ReportLocalesOnDisabledByPrefs(locale); | 329 TranslateBrowserMetrics::ReportLocalesOnDisabledByPrefs(locale); |
| 314 return; | 330 return; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 // Also, GetLanguageCode will take care of removing country code if any. | 404 // Also, GetLanguageCode will take care of removing country code if any. |
| 389 auto_target_lang = GetLanguageCode(auto_target_lang); | 405 auto_target_lang = GetLanguageCode(auto_target_lang); |
| 390 if (IsSupportedLanguage(auto_target_lang)) { | 406 if (IsSupportedLanguage(auto_target_lang)) { |
| 391 TranslateBrowserMetrics::ReportInitiationStatus( | 407 TranslateBrowserMetrics::ReportInitiationStatus( |
| 392 TranslateBrowserMetrics::INITIATION_STATUS_AUTO_BY_CONFIG); | 408 TranslateBrowserMetrics::INITIATION_STATUS_AUTO_BY_CONFIG); |
| 393 TranslatePage(web_contents, language_code, auto_target_lang); | 409 TranslatePage(web_contents, language_code, auto_target_lang); |
| 394 return; | 410 return; |
| 395 } | 411 } |
| 396 } | 412 } |
| 397 | 413 |
| 398 TranslateTabHelper* translate_tab_helper = | 414 LanguageState& language_state = translate_tab_helper->language_state(); |
| 399 TranslateTabHelper::FromWebContents(web_contents); | 415 std::string auto_translate_to = language_state.AutoTranslateTo(); |
| 400 if (!translate_tab_helper) | |
| 401 return; | |
| 402 std::string auto_translate_to = | |
| 403 translate_tab_helper->language_state().AutoTranslateTo(); | |
| 404 if (!auto_translate_to.empty()) { | 416 if (!auto_translate_to.empty()) { |
| 405 // This page was navigated through a click from a translated page. | 417 // This page was navigated through a click from a translated page. |
| 406 TranslateBrowserMetrics::ReportInitiationStatus( | 418 TranslateBrowserMetrics::ReportInitiationStatus( |
| 407 TranslateBrowserMetrics::INITIATION_STATUS_AUTO_BY_LINK); | 419 TranslateBrowserMetrics::INITIATION_STATUS_AUTO_BY_LINK); |
| 408 TranslatePage(web_contents, language_code, auto_translate_to); | 420 TranslatePage(web_contents, language_code, auto_translate_to); |
| 409 return; | 421 return; |
| 410 } | 422 } |
| 411 | 423 |
| 412 // Prompts the user if he/she wants the page translated. | |
| 413 TranslateBrowserMetrics::ReportInitiationStatus( | 424 TranslateBrowserMetrics::ReportInitiationStatus( |
| 414 TranslateBrowserMetrics::INITIATION_STATUS_SHOW_INFOBAR); | 425 TranslateBrowserMetrics::INITIATION_STATUS_SHOW_INFOBAR); |
| 415 TranslateInfoBarDelegate::Create( | 426 |
| 416 false, InfoBarService::FromWebContents(web_contents), | 427 if (IsEnabledTranslateNewUX()) { |
| 417 TranslateInfoBarDelegate::BEFORE_TRANSLATE, language_code, target_lang, | 428 language_state.SetTranslateEnabled(true); |
| 418 TranslateErrors::NONE, profile->GetPrefs(), ShortcutConfig()); | 429 if (language_state.HasLanguageChanged()) |
| 430 ShowBubble(web_contents, |
| 431 TranslateBubbleModel::VIEW_STATE_BEFORE_TRANSLATE); |
| 432 } else { |
| 433 // Prompts the user if he/she wants the page translated. |
| 434 TranslateInfoBarDelegate::Create( |
| 435 false, InfoBarService::FromWebContents(web_contents), |
| 436 TranslateInfoBarDelegate::BEFORE_TRANSLATE, language_code, target_lang, |
| 437 TranslateErrors::NONE, profile->GetPrefs(), ShortcutConfig()); |
| 438 } |
| 419 } | 439 } |
| 420 | 440 |
| 421 void TranslateManager::InitiateTranslationPosted(int process_id, | 441 void TranslateManager::InitiateTranslationPosted(int process_id, |
| 422 int render_id, | 442 int render_id, |
| 423 const std::string& page_lang, | 443 const std::string& page_lang, |
| 424 int attempt) { | 444 int attempt) { |
| 425 // The tab might have been closed. | 445 // The tab might have been closed. |
| 426 WebContents* web_contents = | 446 WebContents* web_contents = |
| 427 tab_util::GetWebContentsByID(process_id, render_id); | 447 tab_util::GetWebContentsByID(process_id, render_id); |
| 428 if (!web_contents) | 448 if (!web_contents) |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 } | 480 } |
| 461 | 481 |
| 462 // Translation can be kicked by context menu against unsupported languages. | 482 // Translation can be kicked by context menu against unsupported languages. |
| 463 // Unsupported language strings should be replaced with | 483 // Unsupported language strings should be replaced with |
| 464 // kUnknownLanguageCode in order to send a translation request with enabling | 484 // kUnknownLanguageCode in order to send a translation request with enabling |
| 465 // server side auto language detection. | 485 // server side auto language detection. |
| 466 std::string source_lang(original_source_lang); | 486 std::string source_lang(original_source_lang); |
| 467 if (!IsSupportedLanguage(source_lang)) | 487 if (!IsSupportedLanguage(source_lang)) |
| 468 source_lang = std::string(translate::kUnknownLanguageCode); | 488 source_lang = std::string(translate::kUnknownLanguageCode); |
| 469 | 489 |
| 470 Profile* profile = | 490 if (IsEnabledTranslateNewUX()) { |
| 471 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 491 ShowBubble(web_contents, TranslateBubbleModel::VIEW_STATE_TRANSLATING); |
| 472 TranslateInfoBarDelegate::Create( | 492 } else { |
| 473 true, InfoBarService::FromWebContents(web_contents), | 493 Profile* profile = |
| 474 TranslateInfoBarDelegate::TRANSLATING, source_lang, target_lang, | 494 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 475 TranslateErrors::NONE, profile->GetPrefs(), ShortcutConfig()); | 495 TranslateInfoBarDelegate::Create( |
| 496 true, InfoBarService::FromWebContents(web_contents), |
| 497 TranslateInfoBarDelegate::TRANSLATING, source_lang, target_lang, |
| 498 TranslateErrors::NONE, profile->GetPrefs(), ShortcutConfig()); |
| 499 } |
| 476 | 500 |
| 477 DCHECK(script_.get() != NULL); | 501 DCHECK(script_.get() != NULL); |
| 478 | 502 |
| 479 const std::string& translate_script = script_->data(); | 503 const std::string& translate_script = script_->data(); |
| 480 if (!translate_script.empty()) { | 504 if (!translate_script.empty()) { |
| 481 DoTranslatePage(web_contents, translate_script, source_lang, target_lang); | 505 DoTranslatePage(web_contents, translate_script, source_lang, target_lang); |
| 482 return; | 506 return; |
| 483 } | 507 } |
| 484 | 508 |
| 485 // The script is not available yet. Queue that request and query for the | 509 // The script is not available yet. Queue that request and query for the |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 } | 601 } |
| 578 | 602 |
| 579 void TranslateManager::PageTranslated(WebContents* web_contents, | 603 void TranslateManager::PageTranslated(WebContents* web_contents, |
| 580 PageTranslatedDetails* details) { | 604 PageTranslatedDetails* details) { |
| 581 if ((details->error_type == TranslateErrors::NONE) && | 605 if ((details->error_type == TranslateErrors::NONE) && |
| 582 details->source_language != translate::kUnknownLanguageCode && | 606 details->source_language != translate::kUnknownLanguageCode && |
| 583 !IsSupportedLanguage(details->source_language)) { | 607 !IsSupportedLanguage(details->source_language)) { |
| 584 details->error_type = TranslateErrors::UNSUPPORTED_LANGUAGE; | 608 details->error_type = TranslateErrors::UNSUPPORTED_LANGUAGE; |
| 585 } | 609 } |
| 586 | 610 |
| 587 PrefService* prefs = Profile::FromBrowserContext( | 611 if (IsEnabledTranslateNewUX()) { |
| 588 web_contents->GetBrowserContext())->GetPrefs(); | 612 TranslateBubbleModel::ViewState view_state = |
| 589 TranslateInfoBarDelegate::Create( | 613 (details->error_type == TranslateErrors::NONE) ? |
| 590 true, InfoBarService::FromWebContents(web_contents), | 614 TranslateBubbleModel::VIEW_STATE_AFTER_TRANSLATE : |
| 591 (details->error_type == TranslateErrors::NONE) ? | 615 TranslateBubbleModel::VIEW_STATE_ERROR; |
| 592 TranslateInfoBarDelegate::AFTER_TRANSLATE : | 616 ShowBubble(web_contents, view_state); |
| 593 TranslateInfoBarDelegate::TRANSLATION_ERROR, | 617 } else { |
| 594 details->source_language, details->target_language, details->error_type, | 618 PrefService* prefs = Profile::FromBrowserContext( |
| 595 prefs, ShortcutConfig()); | 619 web_contents->GetBrowserContext())->GetPrefs(); |
| 620 TranslateInfoBarDelegate::Create( |
| 621 true, InfoBarService::FromWebContents(web_contents), |
| 622 (details->error_type == TranslateErrors::NONE) ? |
| 623 TranslateInfoBarDelegate::AFTER_TRANSLATE : |
| 624 TranslateInfoBarDelegate::TRANSLATION_ERROR, |
| 625 details->source_language, details->target_language, details->error_type, |
| 626 prefs, ShortcutConfig()); |
| 627 } |
| 596 | 628 |
| 597 if (details->error_type != TranslateErrors::NONE && | 629 if (details->error_type != TranslateErrors::NONE && |
| 598 !web_contents->GetBrowserContext()->IsOffTheRecord()) { | 630 !web_contents->GetBrowserContext()->IsOffTheRecord()) { |
| 599 TranslateErrorDetails error_details; | 631 TranslateErrorDetails error_details; |
| 600 error_details.time = base::Time::Now(); | 632 error_details.time = base::Time::Now(); |
| 601 error_details.url = web_contents->GetLastCommittedURL(); | 633 error_details.url = web_contents->GetLastCommittedURL(); |
| 602 error_details.error = details->error_type; | 634 error_details.error = details->error_type; |
| 603 NotifyTranslateError(error_details); | 635 NotifyTranslateError(error_details); |
| 604 } | 636 } |
| 605 } | 637 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 // We navigated away from the page the translation was triggered on. | 675 // We navigated away from the page the translation was triggered on. |
| 644 continue; | 676 continue; |
| 645 } | 677 } |
| 646 | 678 |
| 647 if (success) { | 679 if (success) { |
| 648 // Translate the page. | 680 // Translate the page. |
| 649 const std::string& translate_script = script_->data(); | 681 const std::string& translate_script = script_->data(); |
| 650 DoTranslatePage(web_contents, translate_script, | 682 DoTranslatePage(web_contents, translate_script, |
| 651 request.source_lang, request.target_lang); | 683 request.source_lang, request.target_lang); |
| 652 } else { | 684 } else { |
| 653 Profile* profile = | 685 if (IsEnabledTranslateNewUX()) { |
| 654 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 686 ShowBubble(web_contents, TranslateBubbleModel::VIEW_STATE_ERROR); |
| 655 TranslateInfoBarDelegate::Create( | 687 } else { |
| 656 true, InfoBarService::FromWebContents(web_contents), | 688 Profile* profile = |
| 657 TranslateInfoBarDelegate::TRANSLATION_ERROR, request.source_lang, | 689 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 658 request.target_lang, TranslateErrors::NETWORK, profile->GetPrefs(), | 690 TranslateInfoBarDelegate::Create( |
| 659 ShortcutConfig()); | 691 true, InfoBarService::FromWebContents(web_contents), |
| 692 TranslateInfoBarDelegate::TRANSLATION_ERROR, request.source_lang, |
| 693 request.target_lang, TranslateErrors::NETWORK, profile->GetPrefs(), |
| 694 ShortcutConfig()); |
| 695 } |
| 660 | 696 |
| 661 if (!web_contents->GetBrowserContext()->IsOffTheRecord()) { | 697 if (!web_contents->GetBrowserContext()->IsOffTheRecord()) { |
| 662 TranslateErrorDetails error_details; | 698 TranslateErrorDetails error_details; |
| 663 error_details.time = base::Time::Now(); | 699 error_details.time = base::Time::Now(); |
| 664 error_details.url = entry->GetURL(); | 700 error_details.url = entry->GetURL(); |
| 665 error_details.error = TranslateErrors::NETWORK; | 701 error_details.error = TranslateErrors::NETWORK; |
| 666 NotifyTranslateError(error_details); | 702 NotifyTranslateError(error_details); |
| 667 } | 703 } |
| 668 } | 704 } |
| 669 } | 705 } |
| 670 pending_requests_.clear(); | 706 pending_requests_.clear(); |
| 671 } | 707 } |
| 672 | 708 |
| 709 void TranslateManager::ShowBubble(WebContents* web_contents, |
| 710 TranslateBubbleModel::ViewState view_state) { |
| 711 // The bubble is implemented only on the desktop platforms. |
| 712 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
| 713 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
| 714 BrowserWindow* window = browser ? browser->window() : NULL; |
| 715 TranslateBubbleFactory::Show(window, web_contents, view_state); |
| 716 #else |
| 717 NOTREACHED(); |
| 718 #endif |
| 719 } |
| 720 |
| 673 // static | 721 // static |
| 674 std::string TranslateManager::GetTargetLanguage(PrefService* prefs) { | 722 std::string TranslateManager::GetTargetLanguage(PrefService* prefs) { |
| 675 std::string ui_lang = | 723 std::string ui_lang = |
| 676 GetLanguageCode(g_browser_process->GetApplicationLocale()); | 724 GetLanguageCode(g_browser_process->GetApplicationLocale()); |
| 677 if (IsSupportedLanguage(ui_lang)) | 725 if (IsSupportedLanguage(ui_lang)) |
| 678 return ui_lang; | 726 return ui_lang; |
| 679 | 727 |
| 680 // Getting the accepted languages list | 728 // Getting the accepted languages list |
| 681 std::string accept_langs_str = prefs->GetString(prefs::kAcceptLanguages); | 729 std::string accept_langs_str = prefs->GetString(prefs::kAcceptLanguages); |
| 682 | 730 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 703 // so we are more aggressive about showing the shortcut to never translate. | 751 // so we are more aggressive about showing the shortcut to never translate. |
| 704 #if defined(OS_ANDROID) | 752 #if defined(OS_ANDROID) |
| 705 config.never_translate_min_count = 1; | 753 config.never_translate_min_count = 1; |
| 706 #else | 754 #else |
| 707 config.never_translate_min_count = 3; | 755 config.never_translate_min_count = 3; |
| 708 #endif // defined(OS_ANDROID) | 756 #endif // defined(OS_ANDROID) |
| 709 | 757 |
| 710 config.always_translate_min_count = 3; | 758 config.always_translate_min_count = 3; |
| 711 return config; | 759 return config; |
| 712 } | 760 } |
| OLD | NEW |