| 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" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 bool OptionsMenuModel::IsCommandIdEnabled(int command_id) const { | 82 bool OptionsMenuModel::IsCommandIdEnabled(int command_id) const { |
| 83 switch (command_id) { | 83 switch (command_id) { |
| 84 case IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_LANG : | 84 case IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_LANG : |
| 85 case IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_SITE : | 85 case IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_SITE : |
| 86 return !translate_infobar_delegate_->ShouldAlwaysTranslate(); | 86 return !translate_infobar_delegate_->ShouldAlwaysTranslate(); |
| 87 | 87 |
| 88 case IDC_TRANSLATE_OPTIONS_ALWAYS : | 88 case IDC_TRANSLATE_OPTIONS_ALWAYS : |
| 89 return (!translate_infobar_delegate_->IsLanguageBlacklisted() && | 89 return (!translate_infobar_delegate_->IsLanguageBlacklisted() && |
| 90 !translate_infobar_delegate_->IsSiteBlacklisted()); | 90 !translate_infobar_delegate_->IsSiteBlacklisted()); |
| 91 | 91 |
| 92 case IDC_TRANSLATE_REPORT_BAD_LANGUAGE_DETECTION : { |
| 93 // Until we have a secure URL for reporting language detection errors, |
| 94 // we don't report errors that happened on secure URLs. |
| 95 DCHECK(translate_infobar_delegate_ != NULL); |
| 96 DCHECK(translate_infobar_delegate_->owner() != NULL); |
| 97 DCHECK(translate_infobar_delegate_->owner()->tab_contents() != NULL); |
| 98 NavigationEntry* entry = translate_infobar_delegate_->owner()-> |
| 99 tab_contents()->controller().GetActiveEntry(); |
| 100 // Delegate and tab contents should never be NULL, but active entry |
| 101 // can be NULL when running tests. We want to return false if NULL. |
| 102 return (entry != NULL) && !entry->url().SchemeIsSecure(); |
| 103 } |
| 92 default: | 104 default: |
| 93 break; | 105 break; |
| 94 } | 106 } |
| 95 return true; | 107 return true; |
| 96 } | 108 } |
| 97 | 109 |
| 98 bool OptionsMenuModel::GetAcceleratorForCommandId( | 110 bool OptionsMenuModel::GetAcceleratorForCommandId( |
| 99 int command_id, ui::Accelerator* accelerator) { | 111 int command_id, ui::Accelerator* accelerator) { |
| 100 return false; | 112 return false; |
| 101 } | 113 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 131 about_url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); | 143 about_url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); |
| 132 } | 144 } |
| 133 break; | 145 break; |
| 134 } | 146 } |
| 135 | 147 |
| 136 default: | 148 default: |
| 137 NOTREACHED() << "Invalid command id from menu."; | 149 NOTREACHED() << "Invalid command id from menu."; |
| 138 break; | 150 break; |
| 139 } | 151 } |
| 140 } | 152 } |
| OLD | NEW |