OLD | NEW |
1 // Copyright (c) 2011 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/ui/toolbar/encoding_menu_controller.h" | 5 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" |
6 | 6 |
7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/character_encoding.h" | 11 #include "chrome/browser/character_encoding.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 | 79 |
80 bool EncodingMenuController::IsItemChecked( | 80 bool EncodingMenuController::IsItemChecked( |
81 Profile* browser_profile, | 81 Profile* browser_profile, |
82 const std::string& current_tab_encoding, | 82 const std::string& current_tab_encoding, |
83 int item_id) { | 83 int item_id) { |
84 if (!DoesCommandBelongToEncodingMenu(item_id)) | 84 if (!DoesCommandBelongToEncodingMenu(item_id)) |
85 return false; | 85 return false; |
86 | 86 |
87 std::string encoding = current_tab_encoding; | 87 std::string encoding = current_tab_encoding; |
88 if (encoding.empty()) { | 88 if (encoding.empty()) |
89 encoding = | 89 encoding = browser_profile->GetPrefs()->GetString(prefs::kDefaultCharset); |
90 browser_profile->GetPrefs()->GetString(prefs::kGlobalDefaultCharset); | |
91 } | |
92 | 90 |
93 if (item_id == IDC_ENCODING_AUTO_DETECT) { | 91 if (item_id == IDC_ENCODING_AUTO_DETECT) { |
94 return browser_profile->GetPrefs()->GetBoolean( | 92 return browser_profile->GetPrefs()->GetBoolean( |
95 prefs::kWebKitUsesUniversalDetector); | 93 prefs::kWebKitUsesUniversalDetector); |
96 } | 94 } |
97 | 95 |
98 if (!encoding.empty()) { | 96 if (!encoding.empty()) { |
99 return encoding == | 97 return encoding == |
100 CharacterEncoding::GetCanonicalEncodingNameByCommandId(item_id); | 98 CharacterEncoding::GetCanonicalEncodingNameByCommandId(item_id); |
101 } | 99 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 for (it = encodings->begin(); it != encodings->end(); ++it) { | 131 for (it = encodings->begin(); it != encodings->end(); ++it) { |
134 if (it->encoding_id) { | 132 if (it->encoding_id) { |
135 string16 encoding = it->encoding_display_name; | 133 string16 encoding = it->encoding_display_name; |
136 base::i18n::AdjustStringForLocaleDirection(&encoding); | 134 base::i18n::AdjustStringForLocaleDirection(&encoding); |
137 menu_items->push_back(EncodingMenuItem(it->encoding_id, encoding)); | 135 menu_items->push_back(EncodingMenuItem(it->encoding_id, encoding)); |
138 } else { | 136 } else { |
139 menu_items->push_back(separator); | 137 menu_items->push_back(separator); |
140 } | 138 } |
141 } | 139 } |
142 } | 140 } |
OLD | NEW |