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

Side by Side Diff: chrome/browser/encoding_menu_controller_delegate.cc

Issue 7647: Character encoding override (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_commands.cc ('k') | chrome/browser/render_view_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/encoding_menu_controller_delegate.h" 5 #include "chrome/browser/encoding_menu_controller_delegate.h"
6 6
7 #include "chrome/app/chrome_dll_resource.h" 7 #include "chrome/app/chrome_dll_resource.h"
8 #include "chrome/browser/browser.h" 8 #include "chrome/browser/browser.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/character_encoding.h" 10 #include "chrome/browser/character_encoding.h"
11 #include "chrome/browser/profile.h" 11 #include "chrome/browser/profile.h"
12 #include "chrome/browser/tab_contents.h" 12 #include "chrome/browser/web_contents.h"
13 #include "chrome/common/l10n_util.h" 13 #include "chrome/common/l10n_util.h"
14 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
15 #include "chrome/common/pref_service.h" 15 #include "chrome/common/pref_service.h"
16 16
17 #include "generated_resources.h" 17 #include "generated_resources.h"
18 18
19 EncodingMenuControllerDelegate::EncodingMenuControllerDelegate( 19 EncodingMenuControllerDelegate::EncodingMenuControllerDelegate(
20 Browser* browser, Controller* wrapped) 20 Browser* browser, Controller* wrapped)
21 : BaseControllerDelegate(wrapped), 21 : BaseControllerDelegate(wrapped),
22 browser_(browser) { 22 browser_(browser) {
23 } 23 }
24 24
25 bool EncodingMenuControllerDelegate::IsItemChecked(int id) const { 25 bool EncodingMenuControllerDelegate::IsItemChecked(int id) const {
26 Profile* profile = browser_->profile(); 26 Profile* profile = browser_->profile();
27 if (!profile) 27 if (!profile)
28 return false; 28 return false;
29 TabContents* current_tab = browser_->GetSelectedTabContents(); 29 TabContents* current_tab = browser_->GetSelectedTabContents();
30 if (!current_tab) 30 if (!current_tab)
31 return false; 31 return false;
32 std::wstring encoding_name = current_tab->encoding(); 32 std::wstring encoding;
33 if (encoding_name.empty()) 33 if (current_tab->AsWebContents())
34 encoding_name = profile->GetPrefs()->GetString(prefs::kDefaultCharset); 34 encoding = current_tab->AsWebContents()->encoding();
35 if (encoding.empty())
36 encoding = profile->GetPrefs()->GetString(prefs::kDefaultCharset);
35 switch (id) { 37 switch (id) {
36 case IDC_ENCODING_AUTO_DETECT: 38 case IDC_ENCODING_AUTO_DETECT:
37 return profile->GetPrefs()->GetBoolean( 39 return profile->GetPrefs()->GetBoolean(
38 prefs::kWebKitUsesUniversalDetector); 40 prefs::kWebKitUsesUniversalDetector);
39 case IDC_ENCODING_UTF8: 41 case IDC_ENCODING_UTF8:
40 case IDC_ENCODING_UTF16LE: 42 case IDC_ENCODING_UTF16LE:
41 case IDC_ENCODING_ISO88591: 43 case IDC_ENCODING_ISO88591:
42 case IDC_ENCODING_WINDOWS1252: 44 case IDC_ENCODING_WINDOWS1252:
43 case IDC_ENCODING_GB2312: 45 case IDC_ENCODING_GB2312:
44 case IDC_ENCODING_GB18030: 46 case IDC_ENCODING_GB18030:
(...skipping 21 matching lines...) Expand all
66 case IDC_ENCODING_ISO885910: 68 case IDC_ENCODING_ISO885910:
67 case IDC_ENCODING_ISO885914: 69 case IDC_ENCODING_ISO885914:
68 case IDC_ENCODING_ISO885916: 70 case IDC_ENCODING_ISO885916:
69 case IDC_ENCODING_ISO88599: 71 case IDC_ENCODING_ISO88599:
70 case IDC_ENCODING_WINDOWS1254: 72 case IDC_ENCODING_WINDOWS1254:
71 case IDC_ENCODING_ISO88596: 73 case IDC_ENCODING_ISO88596:
72 case IDC_ENCODING_WINDOWS1256: 74 case IDC_ENCODING_WINDOWS1256:
73 case IDC_ENCODING_ISO88598: 75 case IDC_ENCODING_ISO88598:
74 case IDC_ENCODING_WINDOWS1255: 76 case IDC_ENCODING_WINDOWS1255:
75 case IDC_ENCODING_WINDOWS1258: 77 case IDC_ENCODING_WINDOWS1258:
76 return (!encoding_name.empty() && encoding_name == 78 return (!encoding.empty() && encoding ==
77 CharacterEncoding::GetCanonicalEncodingNameByCommandId(id)); 79 CharacterEncoding::GetCanonicalEncodingNameByCommandId(id));
78 default: 80 default:
79 return false; 81 return false;
80 } 82 }
81 } 83 }
82 84
83 void EncodingMenuControllerDelegate::BuildEncodingMenu( 85 void EncodingMenuControllerDelegate::BuildEncodingMenu(
84 Profile* profile, Menu* encoding_menu) { 86 Profile* profile, Menu* encoding_menu) {
85 // Append auto-detection item. 87 // Append auto-detection item.
86 encoding_menu->AppendMenuItem(IDC_ENCODING_AUTO_DETECT, 88 encoding_menu->AppendMenuItem(IDC_ENCODING_AUTO_DETECT,
(...skipping 24 matching lines...) Expand all
111 if (l10n_util::AdjustStringForLocaleDirection(encoding, 113 if (l10n_util::AdjustStringForLocaleDirection(encoding,
112 &bidi_safe_encoding)) 114 &bidi_safe_encoding))
113 encoding.swap(bidi_safe_encoding); 115 encoding.swap(bidi_safe_encoding);
114 encoding_menu->AppendMenuItem(*it, encoding, Menu::RADIO); 116 encoding_menu->AppendMenuItem(*it, encoding, Menu::RADIO);
115 } 117 }
116 else 118 else
117 encoding_menu->AppendSeparator(); 119 encoding_menu->AppendSeparator();
118 } 120 }
119 } 121 }
120 122
OLDNEW
« no previous file with comments | « chrome/browser/browser_commands.cc ('k') | chrome/browser/render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698