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/views/options/advanced_contents_view.h" | 5 #include "chrome/browser/views/options/advanced_contents_view.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include <cryptuiapi.h> | 9 #include <cryptuiapi.h> |
10 #pragma comment(lib, "cryptui.lib") | 10 #pragma comment(lib, "cryptui.lib") |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 HDC dc = canvas->beginPlatformPaint(); | 66 HDC dc = canvas->beginPlatformPaint(); |
67 RECT native_lb = view->GetLocalBounds(true).ToRECT(); | 67 RECT native_lb = view->GetLocalBounds(true).ToRECT(); |
68 gfx::NativeTheme::instance()->PaintListBackground(dc, true, &native_lb); | 68 gfx::NativeTheme::instance()->PaintListBackground(dc, true, &native_lb); |
69 canvas->endPlatformPaint(); | 69 canvas->endPlatformPaint(); |
70 } | 70 } |
71 | 71 |
72 private: | 72 private: |
73 DISALLOW_COPY_AND_ASSIGN(ListBackground); | 73 DISALLOW_COPY_AND_ASSIGN(ListBackground); |
74 }; | 74 }; |
75 | 75 |
76 } // namespace | |
77 //////////////////////////////////////////////////////////////////////////////// | 76 //////////////////////////////////////////////////////////////////////////////// |
78 // AdvancedSection | 77 // AdvancedSection |
79 // A convenience view for grouping advanced options together into related | 78 // A convenience view for grouping advanced options together into related |
80 // sections. | 79 // sections. |
81 // | 80 // |
82 class AdvancedSection : public OptionsPageView { | 81 class AdvancedSection : public OptionsPageView { |
83 public: | 82 public: |
84 AdvancedSection(Profile* profile, const std::wstring& title); | 83 AdvancedSection(Profile* profile, const std::wstring& title); |
85 virtual ~AdvancedSection() {} | 84 virtual ~AdvancedSection() {} |
86 | 85 |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 } else { | 934 } else { |
936 enable_ssl2_checkbox_->SetEnabled(false); | 935 enable_ssl2_checkbox_->SetEnabled(false); |
937 check_for_cert_revocation_checkbox_->SetEnabled(false); | 936 check_for_cert_revocation_checkbox_->SetEnabled(false); |
938 } | 937 } |
939 } | 938 } |
940 } | 939 } |
941 | 940 |
942 //////////////////////////////////////////////////////////////////////////////// | 941 //////////////////////////////////////////////////////////////////////////////// |
943 // NetworkSection | 942 // NetworkSection |
944 | 943 |
945 namespace { | |
946 | |
947 // A helper method that opens the Internet Options control panel dialog with | 944 // A helper method that opens the Internet Options control panel dialog with |
948 // the Connections tab selected. | 945 // the Connections tab selected. |
949 class OpenConnectionDialogTask : public Task { | 946 class OpenConnectionDialogTask : public Task { |
950 public: | 947 public: |
951 OpenConnectionDialogTask() {} | 948 OpenConnectionDialogTask() {} |
952 | 949 |
953 virtual void Run() { | 950 virtual void Run() { |
954 // Using rundll32 seems better than LaunchConnectionDialog which causes a | 951 // Using rundll32 seems better than LaunchConnectionDialog which causes a |
955 // new dialog to be made for each call. rundll32 uses the same global | 952 // new dialog to be made for each call. rundll32 uses the same global |
956 // dialog and it seems to share with the shortcut in control panel. | 953 // dialog and it seems to share with the shortcut in control panel. |
(...skipping 14 matching lines...) Expand all Loading... |
971 args.append(inetcpl); | 968 args.append(inetcpl); |
972 | 969 |
973 ShellExecute(NULL, L"open", rundll32.c_str(), args.c_str(), NULL, | 970 ShellExecute(NULL, L"open", rundll32.c_str(), args.c_str(), NULL, |
974 SW_SHOWNORMAL); | 971 SW_SHOWNORMAL); |
975 } | 972 } |
976 | 973 |
977 private: | 974 private: |
978 DISALLOW_COPY_AND_ASSIGN(OpenConnectionDialogTask); | 975 DISALLOW_COPY_AND_ASSIGN(OpenConnectionDialogTask); |
979 }; | 976 }; |
980 | 977 |
981 } // namespace | |
982 | |
983 class NetworkSection : public AdvancedSection, | 978 class NetworkSection : public AdvancedSection, |
984 public views::ButtonListener { | 979 public views::ButtonListener { |
985 public: | 980 public: |
986 explicit NetworkSection(Profile* profile); | 981 explicit NetworkSection(Profile* profile); |
987 virtual ~NetworkSection() {} | 982 virtual ~NetworkSection() {} |
988 | 983 |
989 // Overridden from views::ButtonListener: | 984 // Overridden from views::ButtonListener: |
990 virtual void ButtonPressed(views::Button* sender); | 985 virtual void ButtonPressed(views::Button* sender); |
991 | 986 |
992 protected: | 987 protected: |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 AddWrappingLabelRow(layout, change_proxies_label_, single_column_view_set_id, | 1037 AddWrappingLabelRow(layout, change_proxies_label_, single_column_view_set_id, |
1043 true); | 1038 true); |
1044 AddLeadingControl(layout, change_proxies_button_, indented_view_set_id, | 1039 AddLeadingControl(layout, change_proxies_button_, indented_view_set_id, |
1045 false); | 1040 false); |
1046 } | 1041 } |
1047 | 1042 |
1048 void NetworkSection::NotifyPrefChanged(const std::wstring* pref_name) { | 1043 void NetworkSection::NotifyPrefChanged(const std::wstring* pref_name) { |
1049 } | 1044 } |
1050 | 1045 |
1051 //////////////////////////////////////////////////////////////////////////////// | 1046 //////////////////////////////////////////////////////////////////////////////// |
| 1047 // DevToolsSection |
| 1048 |
| 1049 class DevToolsSection : public AdvancedSection, |
| 1050 public views::ButtonListener { |
| 1051 public: |
| 1052 explicit DevToolsSection(Profile* profile); |
| 1053 virtual ~DevToolsSection() {} |
| 1054 |
| 1055 // Overridden from views::ButtonListener: |
| 1056 virtual void ButtonPressed(views::Button* sender); |
| 1057 |
| 1058 protected: |
| 1059 // OptionsPageView overrides: |
| 1060 virtual void InitControlLayout(); |
| 1061 virtual void NotifyPrefChanged(const std::wstring* pref_name); |
| 1062 |
| 1063 private: |
| 1064 // Controls for this section: |
| 1065 views::Checkbox* enable_devtools_checkbox_; |
| 1066 |
| 1067 // Preferences for this section: |
| 1068 BooleanPrefMember enable_devtools_; |
| 1069 |
| 1070 DISALLOW_COPY_AND_ASSIGN(DevToolsSection); |
| 1071 }; |
| 1072 |
| 1073 DevToolsSection::DevToolsSection(Profile* profile) |
| 1074 : enable_devtools_checkbox_(NULL), |
| 1075 AdvancedSection(profile, |
| 1076 l10n_util::GetString(IDS_OPTIONS_ADVANCED_SECTION_TITLE_DEVTOOLS)) { |
| 1077 } |
| 1078 |
| 1079 void DevToolsSection::ButtonPressed(views::Button* sender) { |
| 1080 if (sender == enable_devtools_checkbox_) { |
| 1081 bool enabled = enable_devtools_checkbox_->checked(); |
| 1082 UserMetricsRecordAction(enabled ? |
| 1083 L"Options_DevToolsCheckbox_Enable" : |
| 1084 L"Options_DevToolsCheckbox_Disable", |
| 1085 profile()->GetPrefs()); |
| 1086 enable_devtools_.SetValue(enabled); |
| 1087 } |
| 1088 } |
| 1089 |
| 1090 void DevToolsSection::InitControlLayout() { |
| 1091 AdvancedSection::InitControlLayout(); |
| 1092 |
| 1093 enable_devtools_checkbox_ = new views::Checkbox( |
| 1094 l10n_util::GetString(IDS_OPTIONS_ENABLE_DEVTOOLS)); |
| 1095 enable_devtools_checkbox_->set_listener(this); |
| 1096 |
| 1097 GridLayout* layout = new GridLayout(contents_); |
| 1098 contents_->SetLayoutManager(layout); |
| 1099 |
| 1100 const int single_column_view_set_id = 0; |
| 1101 AddWrappingColumnSet(layout, single_column_view_set_id); |
| 1102 |
| 1103 AddWrappingCheckboxRow(layout, enable_devtools_checkbox_, |
| 1104 single_column_view_set_id, false); |
| 1105 |
| 1106 // Init member prefs so we can update the controls if prefs change. |
| 1107 enable_devtools_.Init(prefs::kWebKitDeveloperExtrasEnabled, |
| 1108 profile()->GetPrefs(), this); |
| 1109 } |
| 1110 |
| 1111 void DevToolsSection::NotifyPrefChanged(const std::wstring* pref_name) { |
| 1112 if (!pref_name || *pref_name == prefs::kWebKitDeveloperExtrasEnabled) { |
| 1113 enable_devtools_checkbox_->SetChecked( |
| 1114 enable_devtools_.GetValue()); |
| 1115 } |
| 1116 } |
| 1117 |
| 1118 } // namespace |
| 1119 |
| 1120 //////////////////////////////////////////////////////////////////////////////// |
1052 // AdvancedContentsView | 1121 // AdvancedContentsView |
1053 | 1122 |
1054 class AdvancedContentsView : public OptionsPageView { | 1123 class AdvancedContentsView : public OptionsPageView { |
1055 public: | 1124 public: |
1056 explicit AdvancedContentsView(Profile* profile); | 1125 explicit AdvancedContentsView(Profile* profile); |
1057 virtual ~AdvancedContentsView(); | 1126 virtual ~AdvancedContentsView(); |
1058 | 1127 |
1059 // views::View overrides: | 1128 // views::View overrides: |
1060 virtual int GetLineScrollIncrement(views::ScrollView* scroll_view, | 1129 virtual int GetLineScrollIncrement(views::ScrollView* scroll_view, |
1061 bool is_horizontal, bool is_positive); | 1130 bool is_horizontal, bool is_positive); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 GridLayout::USE_PREF, 0, 0); | 1203 GridLayout::USE_PREF, 0, 0); |
1135 | 1204 |
1136 layout->StartRow(0, single_column_view_set_id); | 1205 layout->StartRow(0, single_column_view_set_id); |
1137 layout->AddView(new PrivacySection(profile())); | 1206 layout->AddView(new PrivacySection(profile())); |
1138 layout->StartRow(0, single_column_view_set_id); | 1207 layout->StartRow(0, single_column_view_set_id); |
1139 layout->AddView(new NetworkSection(profile())); | 1208 layout->AddView(new NetworkSection(profile())); |
1140 layout->StartRow(0, single_column_view_set_id); | 1209 layout->StartRow(0, single_column_view_set_id); |
1141 layout->AddView(new WebContentSection(profile())); | 1210 layout->AddView(new WebContentSection(profile())); |
1142 layout->StartRow(0, single_column_view_set_id); | 1211 layout->StartRow(0, single_column_view_set_id); |
1143 layout->AddView(new SecuritySection(profile())); | 1212 layout->AddView(new SecuritySection(profile())); |
| 1213 layout->StartRow(0, single_column_view_set_id); |
| 1214 layout->AddView(new DevToolsSection(profile())); |
1144 } | 1215 } |
1145 | 1216 |
1146 //////////////////////////////////////////////////////////////////////////////// | 1217 //////////////////////////////////////////////////////////////////////////////// |
1147 // AdvancedContentsView, private: | 1218 // AdvancedContentsView, private: |
1148 | 1219 |
1149 void AdvancedContentsView::InitClass() { | 1220 void AdvancedContentsView::InitClass() { |
1150 static bool initialized = false; | 1221 static bool initialized = false; |
1151 if (!initialized) { | 1222 if (!initialized) { |
1152 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 1223 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
1153 line_height_ = rb.GetFont(ResourceBundle::BaseFont).height(); | 1224 line_height_ = rb.GetFont(ResourceBundle::BaseFont).height(); |
(...skipping 20 matching lines...) Expand all Loading... |
1174 | 1245 |
1175 void AdvancedScrollViewContainer::Layout() { | 1246 void AdvancedScrollViewContainer::Layout() { |
1176 gfx::Rect lb = GetLocalBounds(false); | 1247 gfx::Rect lb = GetLocalBounds(false); |
1177 | 1248 |
1178 gfx::Size border = gfx::NativeTheme::instance()->GetThemeBorderSize( | 1249 gfx::Size border = gfx::NativeTheme::instance()->GetThemeBorderSize( |
1179 gfx::NativeTheme::LIST); | 1250 gfx::NativeTheme::LIST); |
1180 lb.Inset(border.width(), border.height()); | 1251 lb.Inset(border.width(), border.height()); |
1181 scroll_view_->SetBounds(lb); | 1252 scroll_view_->SetBounds(lb); |
1182 scroll_view_->Layout(); | 1253 scroll_view_->Layout(); |
1183 } | 1254 } |
OLD | NEW |