OLD | NEW |
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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/browser.h" | 5 #include "chrome/browser/browser.h" |
6 | 6 |
7 #include "app/animation.h" | 7 #include "app/animation.h" |
8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/idle_timer.h" | 10 #include "base/idle_timer.h" |
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 | 1006 |
1007 void Browser::ToggleEncodingAutoDetect() { | 1007 void Browser::ToggleEncodingAutoDetect() { |
1008 UserMetrics::RecordAction(L"AutoDetectChange", profile_); | 1008 UserMetrics::RecordAction(L"AutoDetectChange", profile_); |
1009 encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue()); | 1009 encoding_auto_detect_.SetValue(!encoding_auto_detect_.GetValue()); |
1010 // Reload the page so we can try to auto-detect the charset. | 1010 // Reload the page so we can try to auto-detect the charset. |
1011 Reload(); | 1011 Reload(); |
1012 } | 1012 } |
1013 | 1013 |
1014 void Browser::OverrideEncoding(int encoding_id) { | 1014 void Browser::OverrideEncoding(int encoding_id) { |
1015 UserMetrics::RecordAction(L"OverrideEncoding", profile_); | 1015 UserMetrics::RecordAction(L"OverrideEncoding", profile_); |
1016 const std::wstring selected_encoding = | 1016 const std::string selected_encoding = |
1017 CharacterEncoding::GetCanonicalEncodingNameByCommandId(encoding_id); | 1017 CharacterEncoding::GetCanonicalEncodingNameByCommandId(encoding_id); |
1018 TabContents* contents = GetSelectedTabContents(); | 1018 TabContents* contents = GetSelectedTabContents(); |
1019 if (!selected_encoding.empty() && contents) | 1019 if (!selected_encoding.empty() && contents) |
1020 contents->override_encoding(selected_encoding); | 1020 contents->override_encoding(selected_encoding); |
1021 // Update the list of recently selected encodings. | 1021 // Update the list of recently selected encodings. |
1022 std::wstring new_selected_encoding_list; | 1022 std::string new_selected_encoding_list; |
1023 if (CharacterEncoding::UpdateRecentlySelectdEncoding( | 1023 if (CharacterEncoding::UpdateRecentlySelectdEncoding( |
1024 profile_->GetPrefs()->GetString(prefs::kRecentlySelectedEncoding), | 1024 WideToASCII(profile_->GetPrefs()->GetString( |
1025 encoding_id, | 1025 prefs::kRecentlySelectedEncoding)), |
1026 &new_selected_encoding_list)) { | 1026 encoding_id, |
| 1027 &new_selected_encoding_list)) { |
1027 profile_->GetPrefs()->SetString(prefs::kRecentlySelectedEncoding, | 1028 profile_->GetPrefs()->SetString(prefs::kRecentlySelectedEncoding, |
1028 new_selected_encoding_list); | 1029 ASCIIToWide(new_selected_encoding_list)); |
1029 } | 1030 } |
1030 } | 1031 } |
1031 | 1032 |
1032 #if defined(OS_WIN) | 1033 #if defined(OS_WIN) |
1033 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always | 1034 // TODO(devint): http://b/issue?id=1117225 Cut, Copy, and Paste are always |
1034 // enabled in the page menu regardless of whether the command will do | 1035 // enabled in the page menu regardless of whether the command will do |
1035 // anything. When someone selects the menu item, we just act as if they hit | 1036 // anything. When someone selects the menu item, we just act as if they hit |
1036 // the keyboard shortcut for the command by sending the associated key press | 1037 // the keyboard shortcut for the command by sending the associated key press |
1037 // to windows. The real fix to this bug is to disable the commands when they | 1038 // to windows. The real fix to this bug is to disable the commands when they |
1038 // won't do anything. We'll need something like an overall clipboard command | 1039 // won't do anything. We'll need something like an overall clipboard command |
(...skipping 1843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2882 /////////////////////////////////////////////////////////////////////////////// | 2883 /////////////////////////////////////////////////////////////////////////////// |
2883 // BrowserToolbarModel (private): | 2884 // BrowserToolbarModel (private): |
2884 | 2885 |
2885 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { | 2886 NavigationController* Browser::BrowserToolbarModel::GetNavigationController() { |
2886 // This |current_tab| can be NULL during the initialization of the | 2887 // This |current_tab| can be NULL during the initialization of the |
2887 // toolbar during window creation (i.e. before any tabs have been added | 2888 // toolbar during window creation (i.e. before any tabs have been added |
2888 // to the window). | 2889 // to the window). |
2889 TabContents* current_tab = browser_->GetSelectedTabContents(); | 2890 TabContents* current_tab = browser_->GetSelectedTabContents(); |
2890 return current_tab ? ¤t_tab->controller() : NULL; | 2891 return current_tab ? ¤t_tab->controller() : NULL; |
2891 } | 2892 } |
OLD | NEW |