| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/options_menu_model.h" | 5 #include "chrome/browser/translate/options_menu_model.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/google/google_util.h" | 9 #include "chrome/browser/google/google_util.h" |
| 10 #include "chrome/browser/infobars/infobar_tab_helper.h" | 10 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/translate/translate_infobar_delegate.h" | 12 #include "chrome/browser/translate/translate_infobar_delegate.h" |
| 13 #include "content/public/browser/navigation_entry.h" | 13 #include "content/public/browser/navigation_entry.h" |
| 14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 #include "grit/generated_resources.h" | 15 #include "grit/generated_resources.h" |
| 16 #include "grit/locale_settings.h" | 16 #include "grit/locale_settings.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 18 | 18 |
| 19 using content::NavigationEntry; |
| 19 using content::OpenURLParams; | 20 using content::OpenURLParams; |
| 20 using content::Referrer; | 21 using content::Referrer; |
| 21 using content::WebContents; | 22 using content::WebContents; |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 const char kAboutGoogleTranslateUrl[] = | 26 const char kAboutGoogleTranslateUrl[] = |
| 26 #if defined(OS_CHROMEOS) | 27 #if defined(OS_CHROMEOS) |
| 27 "https://www.google.com/support/chromeos/bin/answer.py?answer=173424"; | 28 "https://www.google.com/support/chromeos/bin/answer.py?answer=173424"; |
| 28 #else | 29 #else |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 case IDC_TRANSLATE_OPTIONS_ALWAYS : | 94 case IDC_TRANSLATE_OPTIONS_ALWAYS : |
| 94 return (!translate_infobar_delegate_->IsLanguageBlacklisted() && | 95 return (!translate_infobar_delegate_->IsLanguageBlacklisted() && |
| 95 !translate_infobar_delegate_->IsSiteBlacklisted()); | 96 !translate_infobar_delegate_->IsSiteBlacklisted()); |
| 96 | 97 |
| 97 case IDC_TRANSLATE_REPORT_BAD_LANGUAGE_DETECTION : { | 98 case IDC_TRANSLATE_REPORT_BAD_LANGUAGE_DETECTION : { |
| 98 // Until we have a secure URL for reporting language detection errors, | 99 // Until we have a secure URL for reporting language detection errors, |
| 99 // we don't report errors that happened on secure URLs. | 100 // we don't report errors that happened on secure URLs. |
| 100 DCHECK(translate_infobar_delegate_ != NULL); | 101 DCHECK(translate_infobar_delegate_ != NULL); |
| 101 DCHECK(translate_infobar_delegate_->owner() != NULL); | 102 DCHECK(translate_infobar_delegate_->owner() != NULL); |
| 102 DCHECK(translate_infobar_delegate_->owner()->web_contents() != NULL); | 103 DCHECK(translate_infobar_delegate_->owner()->web_contents() != NULL); |
| 103 content::NavigationEntry* entry = translate_infobar_delegate_->owner()-> | 104 NavigationEntry* entry = translate_infobar_delegate_->owner()-> |
| 104 web_contents()->GetController().GetActiveEntry(); | 105 web_contents()->GetController().GetActiveEntry(); |
| 105 // Delegate and tab contents should never be NULL, but active entry | 106 // Delegate and tab contents should never be NULL, but active entry |
| 106 // can be NULL when running tests. We want to return false if NULL. | 107 // can be NULL when running tests. We want to return false if NULL. |
| 107 return (entry != NULL) && !entry->GetURL().SchemeIsSecure(); | 108 return (entry != NULL) && !entry->GetURL().SchemeIsSecure(); |
| 108 } | 109 } |
| 109 default: | 110 default: |
| 110 break; | 111 break; |
| 111 } | 112 } |
| 112 return true; | 113 return true; |
| 113 } | 114 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 web_contents->OpenURL(params); | 151 web_contents->OpenURL(params); |
| 151 } | 152 } |
| 152 break; | 153 break; |
| 153 } | 154 } |
| 154 | 155 |
| 155 default: | 156 default: |
| 156 NOTREACHED() << "Invalid command id from menu."; | 157 NOTREACHED() << "Invalid command id from menu."; |
| 157 break; | 158 break; |
| 158 } | 159 } |
| 159 } | 160 } |
| OLD | NEW |