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

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

Issue 143003020: Move TranslateLanguageList to the Translate component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@removeDelegate
Patch Set: rebase Created 6 years, 10 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 (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_infobar_delegate.h" 5 #include "chrome/browser/translate/translate_infobar_delegate.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/string_compare.h" 9 #include "base/i18n/string_compare.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/infobars/infobar.h" 13 #include "chrome/browser/infobars/infobar.h"
14 #include "chrome/browser/infobars/infobar_service.h" 14 #include "chrome/browser/infobars/infobar_service.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/translate/translate_accept_languages.h" 16 #include "chrome/browser/translate/translate_accept_languages.h"
17 #include "chrome/browser/translate/translate_manager.h" 17 #include "chrome/browser/translate/translate_manager.h"
18 #include "chrome/browser/translate/translate_tab_helper.h" 18 #include "chrome/browser/translate/translate_tab_helper.h"
19 #include "components/translate/core/browser/translate_download_manager.h"
19 #include "components/translate/core/common/translate_constants.h" 20 #include "components/translate/core/common/translate_constants.h"
20 #include "content/public/browser/navigation_details.h" 21 #include "content/public/browser/navigation_details.h"
21 #include "content/public/browser/navigation_entry.h" 22 #include "content/public/browser/navigation_entry.h"
22 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
23 #include "grit/generated_resources.h" 24 #include "grit/generated_resources.h"
24 #include "grit/theme_resources.h" 25 #include "grit/theme_resources.h"
25 #include "third_party/icu/source/i18n/unicode/coll.h" 26 #include "third_party/icu/source/i18n/unicode/coll.h"
26 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
27 28
28 29
29 const size_t TranslateInfoBarDelegate::kNoIndex = TranslateUIDelegate::NO_INDEX; 30 const size_t TranslateInfoBarDelegate::kNoIndex = TranslateUIDelegate::NO_INDEX;
30 31
31 TranslateInfoBarDelegate::~TranslateInfoBarDelegate() { 32 TranslateInfoBarDelegate::~TranslateInfoBarDelegate() {
32 } 33 }
33 34
34 // static 35 // static
35 void TranslateInfoBarDelegate::Create( 36 void TranslateInfoBarDelegate::Create(
36 bool replace_existing_infobar, 37 bool replace_existing_infobar,
37 content::WebContents* web_contents, 38 content::WebContents* web_contents,
38 Type infobar_type, 39 Type infobar_type,
39 const std::string& original_language, 40 const std::string& original_language,
40 const std::string& target_language, 41 const std::string& target_language,
41 TranslateErrors::Type error_type, 42 TranslateErrors::Type error_type,
42 PrefService* prefs, 43 PrefService* prefs,
43 const ShortcutConfiguration& shortcut_config) { 44 const ShortcutConfiguration& shortcut_config) {
44 // Check preconditions. 45 // Check preconditions.
45 if (infobar_type != TRANSLATION_ERROR) { 46 if (infobar_type != TRANSLATION_ERROR) {
46 DCHECK(TranslateManager::IsSupportedLanguage(target_language)); 47 DCHECK(TranslateDownloadManager::IsSupportedLanguage(target_language));
47 if (!TranslateManager::IsSupportedLanguage(original_language)) { 48 if (!TranslateDownloadManager::IsSupportedLanguage(original_language)) {
48 // The original language can only be "unknown" for the "translating" 49 // The original language can only be "unknown" for the "translating"
49 // infobar, which is the case when the user started a translation from the 50 // infobar, which is the case when the user started a translation from the
50 // context menu. 51 // context menu.
51 DCHECK(infobar_type == TRANSLATING || infobar_type == AFTER_TRANSLATE); 52 DCHECK(infobar_type == TRANSLATING || infobar_type == AFTER_TRANSLATE);
52 DCHECK_EQ(translate::kUnknownLanguageCode, original_language); 53 DCHECK_EQ(translate::kUnknownLanguageCode, original_language);
53 } 54 }
54 } 55 }
55 56
56 // Do not create the after translate infobar if we are auto translating. 57 // Do not create the after translate infobar if we are auto translating.
57 if ((infobar_type == TranslateInfoBarDelegate::AFTER_TRANSLATE) || 58 if ((infobar_type == TranslateInfoBarDelegate::AFTER_TRANSLATE) ||
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 if (!details.is_navigation_to_different_page() && !details.is_main_frame) 340 if (!details.is_navigation_to_different_page() && !details.is_main_frame)
340 return false; 341 return false;
341 342
342 return InfoBarDelegate::ShouldExpireInternal(details); 343 return InfoBarDelegate::ShouldExpireInternal(details);
343 } 344 }
344 345
345 TranslateInfoBarDelegate* 346 TranslateInfoBarDelegate*
346 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { 347 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() {
347 return this; 348 return this;
348 } 349 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/render_view_context_menu.cc ('k') | chrome/browser/translate/translate_language_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698