| 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 <sys/types.h> |
| 8 #include <sys/wait.h> |
| 9 |
| 7 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| 8 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/linux_util.h" |
| 9 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/process_util.h" |
| 10 #include "chrome/browser/browser_list.h" | 15 #include "chrome/browser/browser_list.h" |
| 11 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/download/download_manager.h" | 17 #include "chrome/browser/download/download_manager.h" |
| 13 #include "chrome/browser/fonts_languages_window.h" | 18 #include "chrome/browser/fonts_languages_window.h" |
| 14 #include "chrome/browser/gtk/gtk_chrome_link_button.h" | 19 #include "chrome/browser/gtk/gtk_chrome_link_button.h" |
| 15 #include "chrome/browser/gtk/options/options_layout_gtk.h" | 20 #include "chrome/browser/gtk/options/options_layout_gtk.h" |
| 16 #include "chrome/browser/net/dns_global.h" | 21 #include "chrome/browser/net/dns_global.h" |
| 17 #include "chrome/browser/options_page_base.h" | 22 #include "chrome/browser/options_page_base.h" |
| 18 #include "chrome/browser/options_util.h" | 23 #include "chrome/browser/options_util.h" |
| 19 #include "chrome/browser/profile.h" | 24 #include "chrome/browser/profile.h" |
| 20 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 25 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 21 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
| 22 #include "chrome/common/gtk_util.h" | 27 #include "chrome/common/gtk_util.h" |
| 23 #include "chrome/common/pref_member.h" | 28 #include "chrome/common/pref_member.h" |
| 24 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 25 #include "grit/chromium_strings.h" | 30 #include "grit/chromium_strings.h" |
| 26 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
| 27 #include "grit/locale_settings.h" | 32 #include "grit/locale_settings.h" |
| 28 #include "net/base/cookie_policy.h" | 33 #include "net/base/cookie_policy.h" |
| 29 | 34 |
| 30 namespace { | 35 namespace { |
| 31 | 36 |
| 37 // Command used to configure the gconf proxy settings. |
| 38 const char kProxyConfigBinary[] = "gnome-network-preferences"; |
| 39 |
| 32 // The pixel width we wrap labels at. | 40 // The pixel width we wrap labels at. |
| 33 // TODO(evanm): make the labels wrap at the appropriate width. | 41 // TODO(evanm): make the labels wrap at the appropriate width. |
| 34 const int kWrapWidth = 475; | 42 const int kWrapWidth = 475; |
| 35 | 43 |
| 36 GtkWidget* CreateWrappedLabel(int string_id) { | 44 GtkWidget* CreateWrappedLabel(int string_id) { |
| 37 GtkWidget* label = gtk_label_new( | 45 GtkWidget* label = gtk_label_new( |
| 38 l10n_util::GetStringUTF8(string_id).c_str()); | 46 l10n_util::GetStringUTF8(string_id).c_str()); |
| 39 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | 47 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
| 40 gtk_widget_set_size_request(label, kWrapWidth, -1); | 48 gtk_widget_set_size_request(label, kWrapWidth, -1); |
| 41 return label; | 49 return label; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 class NetworkSection : public OptionsPageBase { | 251 class NetworkSection : public OptionsPageBase { |
| 244 public: | 252 public: |
| 245 explicit NetworkSection(Profile* profile); | 253 explicit NetworkSection(Profile* profile); |
| 246 virtual ~NetworkSection() {} | 254 virtual ~NetworkSection() {} |
| 247 | 255 |
| 248 GtkWidget* get_page_widget() const { | 256 GtkWidget* get_page_widget() const { |
| 249 return page_; | 257 return page_; |
| 250 } | 258 } |
| 251 | 259 |
| 252 private: | 260 private: |
| 261 // The callback functions for invoking the proxy config dialog. |
| 262 static void OnChangeProxiesButtonClicked(GtkButton *button, |
| 263 NetworkSection* section); |
| 264 |
| 253 // The widget containing the options for this section. | 265 // The widget containing the options for this section. |
| 254 GtkWidget* page_; | 266 GtkWidget* page_; |
| 255 | 267 |
| 256 DISALLOW_COPY_AND_ASSIGN(NetworkSection); | 268 DISALLOW_COPY_AND_ASSIGN(NetworkSection); |
| 257 }; | 269 }; |
| 258 | 270 |
| 259 NetworkSection::NetworkSection(Profile* profile) | 271 NetworkSection::NetworkSection(Profile* profile) |
| 260 : OptionsPageBase(profile) { | 272 : OptionsPageBase(profile) { |
| 261 page_ = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); | 273 page_ = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); |
| 262 gtk_box_pack_start(GTK_BOX(page_), gtk_label_new("TODO network options"), | 274 |
| 275 GtkWidget* proxy_description_label = CreateWrappedLabel( |
| 276 IDS_OPTIONS_PROXIES_LABEL); |
| 277 gtk_misc_set_alignment(GTK_MISC(proxy_description_label), 0, 0); |
| 278 gtk_box_pack_start(GTK_BOX(page_), proxy_description_label, |
| 279 FALSE, FALSE, 0); |
| 280 |
| 281 GtkWidget* change_proxies_button = gtk_button_new_with_label( |
| 282 l10n_util::GetStringUTF8( |
| 283 IDS_OPTIONS_PROXIES_CONFIGURE_BUTTON).c_str()); |
| 284 g_signal_connect(change_proxies_button, "clicked", |
| 285 G_CALLBACK(OnChangeProxiesButtonClicked), this); |
| 286 // Stick it in an hbox so it doesn't expand to the whole width. |
| 287 GtkWidget* button_hbox = gtk_hbox_new(FALSE, 0); |
| 288 gtk_box_pack_start(GTK_BOX(button_hbox), |
| 289 change_proxies_button, |
| 290 FALSE, FALSE, 0); |
| 291 gtk_box_pack_start(GTK_BOX(page_), |
| 292 OptionsLayoutBuilderGtk::IndentWidget(button_hbox), |
| 263 FALSE, FALSE, 0); | 293 FALSE, FALSE, 0); |
| 264 } | 294 } |
| 265 | 295 |
| 296 // static |
| 297 void NetworkSection::OnChangeProxiesButtonClicked(GtkButton *button, |
| 298 NetworkSection* section) { |
| 299 section->UserMetricsRecordAction(L"Options_ChangeProxies", NULL); |
| 300 |
| 301 if (base::UseGnomeForSettings()) { |
| 302 std::vector<std::string> argv; |
| 303 argv.push_back(kProxyConfigBinary); |
| 304 if (!base::LaunchApp(CommandLine(argv), false, false, NULL)) { |
| 305 LOG(ERROR) << "OpenProxyConfigDialogTask failed"; |
| 306 return; |
| 307 } |
| 308 } else { |
| 309 BrowserList::GetLastActive()-> |
| 310 OpenURL(GURL(l10n_util::GetStringUTF8(IDS_LINUX_PROXY_CONFIG_URL)), |
| 311 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); |
| 312 } |
| 313 } |
| 314 |
| 315 |
| 266 /////////////////////////////////////////////////////////////////////////////// | 316 /////////////////////////////////////////////////////////////////////////////// |
| 267 // PrivacySection | 317 // PrivacySection |
| 268 | 318 |
| 269 class PrivacySection : public OptionsPageBase { | 319 class PrivacySection : public OptionsPageBase { |
| 270 public: | 320 public: |
| 271 explicit PrivacySection(Profile* profile); | 321 explicit PrivacySection(Profile* profile); |
| 272 virtual ~PrivacySection() {} | 322 virtual ~PrivacySection() {} |
| 273 | 323 |
| 274 GtkWidget* get_page_widget() const { | 324 GtkWidget* get_page_widget() const { |
| 275 return page_; | 325 return page_; |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT), | 778 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT), |
| 729 web_content_section_->get_page_widget(), false); | 779 web_content_section_->get_page_widget(), false); |
| 730 | 780 |
| 731 security_section_.reset(new SecuritySection(profile_)); | 781 security_section_.reset(new SecuritySection(profile_)); |
| 732 options_builder.AddOptionGroup( | 782 options_builder.AddOptionGroup( |
| 733 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_SECURITY), | 783 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_SECURITY), |
| 734 security_section_->get_page_widget(), false); | 784 security_section_->get_page_widget(), false); |
| 735 | 785 |
| 736 page_ = options_builder.get_page_widget(); | 786 page_ = options_builder.get_page_widget(); |
| 737 } | 787 } |
| OLD | NEW |