| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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> | 7 #include <sys/types.h> |
| 8 #include <sys/wait.h> | 8 #include <sys/wait.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "chrome/browser/gtk/accessible_widget_helper_gtk.h" | 27 #include "chrome/browser/gtk/accessible_widget_helper_gtk.h" |
| 28 #include "chrome/browser/gtk/clear_browsing_data_dialog_gtk.h" | 28 #include "chrome/browser/gtk/clear_browsing_data_dialog_gtk.h" |
| 29 #include "chrome/browser/gtk/gtk_chrome_link_button.h" | 29 #include "chrome/browser/gtk/gtk_chrome_link_button.h" |
| 30 #include "chrome/browser/gtk/gtk_util.h" | 30 #include "chrome/browser/gtk/gtk_util.h" |
| 31 #include "chrome/browser/gtk/options/content_settings_window_gtk.h" | 31 #include "chrome/browser/gtk/options/content_settings_window_gtk.h" |
| 32 #include "chrome/browser/gtk/options/options_layout_gtk.h" | 32 #include "chrome/browser/gtk/options/options_layout_gtk.h" |
| 33 #include "chrome/browser/net/predictor_api.h" | 33 #include "chrome/browser/net/predictor_api.h" |
| 34 #include "chrome/browser/options_page_base.h" | 34 #include "chrome/browser/options_page_base.h" |
| 35 #include "chrome/browser/options_util.h" | 35 #include "chrome/browser/options_util.h" |
| 36 #include "chrome/browser/pref_member.h" | 36 #include "chrome/browser/pref_member.h" |
| 37 #include "chrome/browser/pref_set_observer.h" |
| 37 #include "chrome/browser/profile.h" | 38 #include "chrome/browser/profile.h" |
| 38 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 39 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| 39 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 40 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 40 #include "chrome/common/chrome_paths.h" | 41 #include "chrome/common/chrome_paths.h" |
| 41 #include "chrome/common/pref_names.h" | 42 #include "chrome/common/pref_names.h" |
| 42 #include "chrome/common/process_watcher.h" | 43 #include "chrome/common/process_watcher.h" |
| 43 #include "grit/chromium_strings.h" | 44 #include "grit/chromium_strings.h" |
| 44 #include "grit/generated_resources.h" | 45 #include "grit/generated_resources.h" |
| 45 #include "grit/locale_settings.h" | 46 #include "grit/locale_settings.h" |
| 46 | 47 |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 class NetworkSection : public OptionsPageBase { | 343 class NetworkSection : public OptionsPageBase { |
| 343 public: | 344 public: |
| 344 explicit NetworkSection(Profile* profile); | 345 explicit NetworkSection(Profile* profile); |
| 345 virtual ~NetworkSection() {} | 346 virtual ~NetworkSection() {} |
| 346 | 347 |
| 347 GtkWidget* get_page_widget() const { | 348 GtkWidget* get_page_widget() const { |
| 348 return page_; | 349 return page_; |
| 349 } | 350 } |
| 350 | 351 |
| 351 private: | 352 private: |
| 353 // Overridden from OptionsPageBase. |
| 354 virtual void NotifyPrefChanged(const std::wstring* pref_name); |
| 355 |
| 352 struct ProxyConfigCommand { | 356 struct ProxyConfigCommand { |
| 353 std::string binary; | 357 std::string binary; |
| 354 const char** argv; | 358 const char** argv; |
| 355 }; | 359 }; |
| 356 // The callback functions for invoking the proxy config dialog. | 360 // The callback functions for invoking the proxy config dialog. |
| 357 static void OnChangeProxiesButtonClicked(GtkButton *button, | 361 static void OnChangeProxiesButtonClicked(GtkButton *button, |
| 358 NetworkSection* section); | 362 NetworkSection* section); |
| 359 // Search $PATH to find one of the commands. Store the full path to | 363 // Search $PATH to find one of the commands. Store the full path to |
| 360 // it in the |binary| field and the command array index in in |index|. | 364 // it in the |binary| field and the command array index in in |index|. |
| 361 static bool SearchPATH(ProxyConfigCommand* commands, size_t ncommands, | 365 static bool SearchPATH(ProxyConfigCommand* commands, size_t ncommands, |
| 362 size_t* index); | 366 size_t* index); |
| 363 // Start the given proxy configuration utility. | 367 // Start the given proxy configuration utility. |
| 364 static void StartProxyConfigUtil(const ProxyConfigCommand& command); | 368 static void StartProxyConfigUtil(const ProxyConfigCommand& command); |
| 365 | 369 |
| 370 // Tracks the state of proxy preferences. |
| 371 scoped_ptr<PrefSetObserver> proxy_prefs_; |
| 372 |
| 366 // The widget containing the options for this section. | 373 // The widget containing the options for this section. |
| 367 GtkWidget* page_; | 374 GtkWidget* page_; |
| 368 | 375 |
| 376 // The proxy configuration button. |
| 377 GtkWidget* change_proxies_button_; |
| 378 |
| 369 DISALLOW_COPY_AND_ASSIGN(NetworkSection); | 379 DISALLOW_COPY_AND_ASSIGN(NetworkSection); |
| 370 }; | 380 }; |
| 371 | 381 |
| 372 NetworkSection::NetworkSection(Profile* profile) | 382 NetworkSection::NetworkSection(Profile* profile) |
| 373 : OptionsPageBase(profile) { | 383 : OptionsPageBase(profile) { |
| 374 page_ = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); | 384 page_ = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); |
| 375 | 385 |
| 376 GtkWidget* proxy_description_label = CreateWrappedLabel( | 386 GtkWidget* proxy_description_label = CreateWrappedLabel( |
| 377 IDS_OPTIONS_PROXIES_LABEL); | 387 IDS_OPTIONS_PROXIES_LABEL); |
| 378 gtk_misc_set_alignment(GTK_MISC(proxy_description_label), 0, 0); | 388 gtk_misc_set_alignment(GTK_MISC(proxy_description_label), 0, 0); |
| 379 gtk_box_pack_start(GTK_BOX(page_), proxy_description_label, | 389 gtk_box_pack_start(GTK_BOX(page_), proxy_description_label, |
| 380 FALSE, FALSE, 0); | 390 FALSE, FALSE, 0); |
| 381 | 391 |
| 382 GtkWidget* change_proxies_button = gtk_button_new_with_label( | 392 change_proxies_button_ = gtk_button_new_with_label( |
| 383 l10n_util::GetStringUTF8( | 393 l10n_util::GetStringUTF8( |
| 384 IDS_OPTIONS_PROXIES_CONFIGURE_BUTTON).c_str()); | 394 IDS_OPTIONS_PROXIES_CONFIGURE_BUTTON).c_str()); |
| 385 g_signal_connect(change_proxies_button, "clicked", | 395 g_signal_connect(change_proxies_button_, "clicked", |
| 386 G_CALLBACK(OnChangeProxiesButtonClicked), this); | 396 G_CALLBACK(OnChangeProxiesButtonClicked), this); |
| 387 | 397 |
| 388 // Stick it in an hbox so it doesn't expand to the whole width. | 398 // Stick it in an hbox so it doesn't expand to the whole width. |
| 389 GtkWidget* button_hbox = gtk_hbox_new(FALSE, 0); | 399 GtkWidget* button_hbox = gtk_hbox_new(FALSE, 0); |
| 390 gtk_box_pack_start(GTK_BOX(button_hbox), | 400 gtk_box_pack_start(GTK_BOX(button_hbox), |
| 391 change_proxies_button, | 401 change_proxies_button_, |
| 392 FALSE, FALSE, 0); | 402 FALSE, FALSE, 0); |
| 393 gtk_box_pack_start(GTK_BOX(page_), | 403 gtk_box_pack_start(GTK_BOX(page_), |
| 394 gtk_util::IndentWidget(button_hbox), | 404 gtk_util::IndentWidget(button_hbox), |
| 395 FALSE, FALSE, 0); | 405 FALSE, FALSE, 0); |
| 406 |
| 407 proxy_prefs_.reset(PrefSetObserver::CreateProxyPrefSetObserver( |
| 408 profile->GetPrefs(), this)); |
| 409 NotifyPrefChanged(NULL); |
| 410 } |
| 411 |
| 412 void NetworkSection::NotifyPrefChanged(const std::wstring* pref_name) { |
| 413 if (!pref_name || proxy_prefs_->IsObserved(*pref_name)) |
| 414 gtk_widget_set_sensitive(change_proxies_button_, |
| 415 !proxy_prefs_->IsManaged()); |
| 396 } | 416 } |
| 397 | 417 |
| 398 // static | 418 // static |
| 399 void NetworkSection::OnChangeProxiesButtonClicked(GtkButton *button, | 419 void NetworkSection::OnChangeProxiesButtonClicked(GtkButton *button, |
| 400 NetworkSection* section) { | 420 NetworkSection* section) { |
| 401 section->UserMetricsRecordAction(UserMetricsAction("Options_ChangeProxies"), | 421 section->UserMetricsRecordAction(UserMetricsAction("Options_ChangeProxies"), |
| 402 NULL); | 422 NULL); |
| 403 | 423 |
| 404 scoped_ptr<base::EnvVarGetter> env_getter(base::EnvVarGetter::Create()); | 424 scoped_ptr<base::EnvVarGetter> env_getter(base::EnvVarGetter::Create()); |
| 405 | 425 |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT), | 1254 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT), |
| 1235 web_content_section_->get_page_widget(), false); | 1255 web_content_section_->get_page_widget(), false); |
| 1236 | 1256 |
| 1237 security_section_.reset(new SecuritySection(profile_)); | 1257 security_section_.reset(new SecuritySection(profile_)); |
| 1238 options_builder->AddOptionGroup( | 1258 options_builder->AddOptionGroup( |
| 1239 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_SECURITY), | 1259 l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_SECTION_TITLE_SECURITY), |
| 1240 security_section_->get_page_widget(), false); | 1260 security_section_->get_page_widget(), false); |
| 1241 | 1261 |
| 1242 page_ = options_builder->get_page_widget(); | 1262 page_ = options_builder->get_page_widget(); |
| 1243 } | 1263 } |
| OLD | NEW |