| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/gtk/options/advanced_contents_gtk.h" | 5 #include "chrome/browser/gtk/options/advanced_contents_gtk.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/gtk/options/options_layout_gtk.h" | 10 #include "chrome/browser/gtk/options/options_layout_gtk.h" |
| 11 #include "chrome/browser/options_page_base.h" | 11 #include "chrome/browser/options_page_base.h" |
| 12 #include "chrome/browser/profile.h" | 12 #include "chrome/browser/profile.h" |
| 13 #include "chrome/common/gtk_util.h" | 13 #include "chrome/common/gtk_util.h" |
| 14 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 15 #include "chrome/installer/util/google_update_settings.h" | 15 #include "chrome/installer/util/google_update_settings.h" |
| 16 #include "grit/chromium_strings.h" | 16 #include "grit/chromium_strings.h" |
| 17 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 18 | 18 |
| 19 | 19 |
| 20 /////////////////////////////////////////////////////////////////////////////// | 20 /////////////////////////////////////////////////////////////////////////////// |
| 21 // DownloadSection |
| 22 |
| 23 class DownloadSection : public OptionsPageBase { |
| 24 public: |
| 25 explicit DownloadSection(Profile* profile); |
| 26 virtual ~DownloadSection() {} |
| 27 |
| 28 GtkWidget* get_page_widget() const { |
| 29 return page_; |
| 30 } |
| 31 |
| 32 private: |
| 33 // The widget containing the options for this section. |
| 34 GtkWidget* page_; |
| 35 |
| 36 DISALLOW_COPY_AND_ASSIGN(DownloadSection); |
| 37 }; |
| 38 |
| 39 DownloadSection::DownloadSection(Profile* profile) |
| 40 : OptionsPageBase(profile) { |
| 41 page_ = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); |
| 42 gtk_box_pack_start(GTK_BOX(page_), gtk_label_new("TODO download options"), |
| 43 FALSE, FALSE, 0); |
| 44 } |
| 45 |
| 46 /////////////////////////////////////////////////////////////////////////////// |
| 47 // NetworkSection |
| 48 |
| 49 class NetworkSection : public OptionsPageBase { |
| 50 public: |
| 51 explicit NetworkSection(Profile* profile); |
| 52 virtual ~NetworkSection() {} |
| 53 |
| 54 GtkWidget* get_page_widget() const { |
| 55 return page_; |
| 56 } |
| 57 |
| 58 private: |
| 59 // The widget containing the options for this section. |
| 60 GtkWidget* page_; |
| 61 |
| 62 DISALLOW_COPY_AND_ASSIGN(NetworkSection); |
| 63 }; |
| 64 |
| 65 NetworkSection::NetworkSection(Profile* profile) |
| 66 : OptionsPageBase(profile) { |
| 67 page_ = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); |
| 68 gtk_box_pack_start(GTK_BOX(page_), gtk_label_new("TODO network options"), |
| 69 FALSE, FALSE, 0); |
| 70 } |
| 71 |
| 72 /////////////////////////////////////////////////////////////////////////////// |
| 21 // PrivacySection | 73 // PrivacySection |
| 22 | 74 |
| 23 class PrivacySection : public OptionsPageBase { | 75 class PrivacySection : public OptionsPageBase { |
| 24 public: | 76 public: |
| 25 explicit PrivacySection(Profile* profile); | 77 explicit PrivacySection(Profile* profile); |
| 26 virtual ~PrivacySection() {} | 78 virtual ~PrivacySection() {} |
| 27 | 79 |
| 28 GtkWidget* get_page_widget() const { | 80 GtkWidget* get_page_widget() const { |
| 29 return page_; | 81 return page_; |
| 30 } | 82 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 48 | 100 |
| 49 GtkWidget* metrics = gtk_check_button_new(); | 101 GtkWidget* metrics = gtk_check_button_new(); |
| 50 GtkWidget* metrics_label = gtk_label_new( | 102 GtkWidget* metrics_label = gtk_label_new( |
| 51 l10n_util::GetStringUTF8(IDS_OPTIONS_ENABLE_LOGGING).c_str()); | 103 l10n_util::GetStringUTF8(IDS_OPTIONS_ENABLE_LOGGING).c_str()); |
| 52 gtk_label_set_line_wrap(GTK_LABEL(metrics_label), TRUE); | 104 gtk_label_set_line_wrap(GTK_LABEL(metrics_label), TRUE); |
| 53 // TODO(evanm): make the label wrap at the appropriate width. | 105 // TODO(evanm): make the label wrap at the appropriate width. |
| 54 gtk_widget_set_size_request(metrics_label, 475, -1); | 106 gtk_widget_set_size_request(metrics_label, 475, -1); |
| 55 gtk_container_add(GTK_CONTAINER(metrics), metrics_label); | 107 gtk_container_add(GTK_CONTAINER(metrics), metrics_label); |
| 56 gtk_box_pack_start(GTK_BOX(page_), metrics, FALSE, FALSE, 0); | 108 gtk_box_pack_start(GTK_BOX(page_), metrics, FALSE, FALSE, 0); |
| 57 gtk_box_pack_start(GTK_BOX(page_), | 109 gtk_box_pack_start(GTK_BOX(page_), |
| 58 gtk_label_new("TODO rest of the advanced options"), | 110 gtk_label_new("TODO rest of the privacy options"), |
| 59 FALSE, FALSE, 0); | 111 FALSE, FALSE, 0); |
| 60 bool logging = g_browser_process->local_state()->GetBoolean( | 112 bool logging = g_browser_process->local_state()->GetBoolean( |
| 61 prefs::kMetricsReportingEnabled); | 113 prefs::kMetricsReportingEnabled); |
| 62 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(metrics), logging); | 114 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(metrics), logging); |
| 63 g_signal_connect(metrics, "clicked", G_CALLBACK(OnLoggingChange), this); | 115 g_signal_connect(metrics, "clicked", G_CALLBACK(OnLoggingChange), this); |
| 64 } | 116 } |
| 65 | 117 |
| 66 // static | 118 // static |
| 67 void PrivacySection::OnLoggingChange(GtkWidget* widget, | 119 void PrivacySection::OnLoggingChange(GtkWidget* widget, |
| 68 PrivacySection* privacy_section) { | 120 PrivacySection* privacy_section) { |
| 69 privacy_section->LoggingChanged(widget); | 121 privacy_section->LoggingChanged(widget); |
| 70 } | 122 } |
| 71 | 123 |
| 72 void PrivacySection::LoggingChanged(GtkWidget* metrics) { | 124 void PrivacySection::LoggingChanged(GtkWidget* metrics) { |
| 73 bool logging = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(metrics)) == | 125 bool logging = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(metrics)) == |
| 74 TRUE); | 126 TRUE); |
| 75 g_browser_process->local_state()->SetBoolean(prefs::kMetricsReportingEnabled, | 127 g_browser_process->local_state()->SetBoolean(prefs::kMetricsReportingEnabled, |
| 76 logging); | 128 logging); |
| 77 GoogleUpdateSettings::SetCollectStatsConsent(logging); | 129 GoogleUpdateSettings::SetCollectStatsConsent(logging); |
| 78 } | 130 } |
| 79 | 131 |
| 80 /////////////////////////////////////////////////////////////////////////////// | 132 /////////////////////////////////////////////////////////////////////////////// |
| 133 // SecuritySection |
| 134 |
| 135 class SecuritySection : public OptionsPageBase { |
| 136 public: |
| 137 explicit SecuritySection(Profile* profile); |
| 138 virtual ~SecuritySection() {} |
| 139 |
| 140 GtkWidget* get_page_widget() const { |
| 141 return page_; |
| 142 } |
| 143 |
| 144 private: |
| 145 // The widget containing the options for this section. |
| 146 GtkWidget* page_; |
| 147 |
| 148 DISALLOW_COPY_AND_ASSIGN(SecuritySection); |
| 149 }; |
| 150 |
| 151 SecuritySection::SecuritySection(Profile* profile) |
| 152 : OptionsPageBase(profile) { |
| 153 page_ = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); |
| 154 gtk_box_pack_start(GTK_BOX(page_), gtk_label_new("TODO security options"), |
| 155 FALSE, FALSE, 0); |
| 156 } |
| 157 |
| 158 /////////////////////////////////////////////////////////////////////////////// |
| 159 // WebContentSection |
| 160 |
| 161 class WebContentSection : public OptionsPageBase { |
| 162 public: |
| 163 explicit WebContentSection(Profile* profile); |
| 164 virtual ~WebContentSection() {} |
| 165 |
| 166 GtkWidget* get_page_widget() const { |
| 167 return page_; |
| 168 } |
| 169 |
| 170 private: |
| 171 // The widget containing the options for this section. |
| 172 GtkWidget* page_; |
| 173 |
| 174 DISALLOW_COPY_AND_ASSIGN(WebContentSection); |
| 175 }; |
| 176 |
| 177 WebContentSection::WebContentSection(Profile* profile) |
| 178 : OptionsPageBase(profile) { |
| 179 page_ = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); |
| 180 gtk_box_pack_start(GTK_BOX(page_), gtk_label_new("TODO web content options"), |
| 181 FALSE, FALSE, 0); |
| 182 } |
| 183 |
| 184 /////////////////////////////////////////////////////////////////////////////// |
| 81 // AdvancedContentsGtk | 185 // AdvancedContentsGtk |
| 82 | 186 |
| 83 AdvancedContentsGtk::AdvancedContentsGtk(Profile* profile) | 187 AdvancedContentsGtk::AdvancedContentsGtk(Profile* profile) |
| 84 : profile_(profile) { | 188 : profile_(profile) { |
| 85 Init(); | 189 Init(); |
| 86 } | 190 } |
| 87 | 191 |
| 88 AdvancedContentsGtk::~AdvancedContentsGtk() { | 192 AdvancedContentsGtk::~AdvancedContentsGtk() { |
| 89 } | 193 } |
| 90 | 194 |
| 91 void AdvancedContentsGtk::Init() { | 195 void AdvancedContentsGtk::Init() { |
| 92 OptionsLayoutBuilderGtk options_builder; | 196 OptionsLayoutBuilderGtk options_builder; |
| 93 | 197 |
| 198 network_section_.reset(new NetworkSection(profile_)); |
| 199 options_builder.AddOptionGroup( |
| 200 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_NETWORK), |
| 201 network_section_->get_page_widget(), false); |
| 202 |
| 94 privacy_section_.reset(new PrivacySection(profile_)); | 203 privacy_section_.reset(new PrivacySection(profile_)); |
| 95 options_builder.AddOptionGroup( | 204 options_builder.AddOptionGroup( |
| 96 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY), | 205 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY), |
| 97 privacy_section_->get_page_widget(), false); | 206 privacy_section_->get_page_widget(), false); |
| 98 | 207 |
| 208 download_section_.reset(new DownloadSection(profile_)); |
| 209 options_builder.AddOptionGroup( |
| 210 l10n_util::GetStringUTF8(IDS_OPTIONS_DOWNLOADLOCATION_GROUP_NAME), |
| 211 download_section_->get_page_widget(), false); |
| 212 |
| 213 web_content_section_.reset(new WebContentSection(profile_)); |
| 214 options_builder.AddOptionGroup( |
| 215 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT), |
| 216 web_content_section_->get_page_widget(), false); |
| 217 |
| 218 security_section_.reset(new SecuritySection(profile_)); |
| 219 options_builder.AddOptionGroup( |
| 220 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_SECURITY), |
| 221 security_section_->get_page_widget(), false); |
| 222 |
| 99 page_ = options_builder.get_page_widget(); | 223 page_ = options_builder.get_page_widget(); |
| 100 } | 224 } |
| OLD | NEW |