| 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 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/browser/gtk/gtk_util.h" | 32 #include "chrome/browser/gtk/gtk_util.h" |
| 33 #include "chrome/browser/gtk/options/content_settings_window_gtk.h" | 33 #include "chrome/browser/gtk/options/content_settings_window_gtk.h" |
| 34 #include "chrome/browser/gtk/options/options_layout_gtk.h" | 34 #include "chrome/browser/gtk/options/options_layout_gtk.h" |
| 35 #include "chrome/browser/options_page_base.h" | 35 #include "chrome/browser/options_page_base.h" |
| 36 #include "chrome/browser/options_util.h" | 36 #include "chrome/browser/options_util.h" |
| 37 #include "chrome/browser/prefs/pref_member.h" | 37 #include "chrome/browser/prefs/pref_member.h" |
| 38 #include "chrome/browser/prefs/pref_set_observer.h" | 38 #include "chrome/browser/prefs/pref_set_observer.h" |
| 39 #include "chrome/browser/profile.h" | 39 #include "chrome/browser/profile.h" |
| 40 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 40 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| 41 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 41 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 42 #include "chrome/browser/show_options_url.h" |
| 42 #include "chrome/common/chrome_paths.h" | 43 #include "chrome/common/chrome_paths.h" |
| 43 #include "chrome/common/chrome_switches.h" | 44 #include "chrome/common/chrome_switches.h" |
| 44 #include "chrome/common/pref_names.h" | 45 #include "chrome/common/pref_names.h" |
| 45 #include "chrome/common/process_watcher.h" | 46 #include "chrome/common/process_watcher.h" |
| 46 #include "grit/chromium_strings.h" | 47 #include "grit/chromium_strings.h" |
| 47 #include "grit/generated_resources.h" | 48 #include "grit/generated_resources.h" |
| 48 #include "grit/locale_settings.h" | 49 #include "grit/locale_settings.h" |
| 49 | 50 |
| 50 namespace { | 51 namespace { |
| 51 | 52 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 const char** argv; | 361 const char** argv; |
| 361 }; | 362 }; |
| 362 // The callback functions for invoking the proxy config dialog. | 363 // The callback functions for invoking the proxy config dialog. |
| 363 static void OnChangeProxiesButtonClicked(GtkButton *button, | 364 static void OnChangeProxiesButtonClicked(GtkButton *button, |
| 364 NetworkSection* section); | 365 NetworkSection* section); |
| 365 // Search $PATH to find one of the commands. Store the full path to | 366 // Search $PATH to find one of the commands. Store the full path to |
| 366 // it in the |binary| field and the command array index in in |index|. | 367 // it in the |binary| field and the command array index in in |index|. |
| 367 static bool SearchPATH(ProxyConfigCommand* commands, size_t ncommands, | 368 static bool SearchPATH(ProxyConfigCommand* commands, size_t ncommands, |
| 368 size_t* index); | 369 size_t* index); |
| 369 // Start the given proxy configuration utility. | 370 // Start the given proxy configuration utility. |
| 370 static void StartProxyConfigUtil(const ProxyConfigCommand& command); | 371 static void StartProxyConfigUtil(Profile* profile, |
| 372 const ProxyConfigCommand& command); |
| 371 | 373 |
| 372 // Tracks the state of proxy preferences. | 374 // Tracks the state of proxy preferences. |
| 373 scoped_ptr<PrefSetObserver> proxy_prefs_; | 375 scoped_ptr<PrefSetObserver> proxy_prefs_; |
| 374 | 376 |
| 375 // The widget containing the options for this section. | 377 // The widget containing the options for this section. |
| 376 GtkWidget* page_; | 378 GtkWidget* page_; |
| 377 | 379 |
| 378 // The proxy configuration button. | 380 // The proxy configuration button. |
| 379 GtkWidget* change_proxies_button_; | 381 GtkWidget* change_proxies_button_; |
| 380 | 382 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 command.argv = kKDE4ProxyConfigCommand; | 450 command.argv = kKDE4ProxyConfigCommand; |
| 449 found_command = SearchPATH(&command, 1, NULL); | 451 found_command = SearchPATH(&command, 1, NULL); |
| 450 break; | 452 break; |
| 451 | 453 |
| 452 case base::DESKTOP_ENVIRONMENT_XFCE: | 454 case base::DESKTOP_ENVIRONMENT_XFCE: |
| 453 case base::DESKTOP_ENVIRONMENT_OTHER: | 455 case base::DESKTOP_ENVIRONMENT_OTHER: |
| 454 break; | 456 break; |
| 455 } | 457 } |
| 456 | 458 |
| 457 if (found_command) { | 459 if (found_command) { |
| 458 StartProxyConfigUtil(command); | 460 StartProxyConfigUtil(section->profile(), command); |
| 459 } else { | 461 } else { |
| 460 const char* name = base::GetDesktopEnvironmentName(env.get()); | 462 const char* name = base::GetDesktopEnvironmentName(env.get()); |
| 461 if (name) | 463 if (name) |
| 462 LOG(ERROR) << "Could not find " << name << " network settings in $PATH"; | 464 LOG(ERROR) << "Could not find " << name << " network settings in $PATH"; |
| 463 BrowserList::GetLastActive()-> | 465 browser::ShowOptionsURL(section->profile(), GURL(kLinuxProxyConfigUrl)); |
| 464 OpenURL(GURL(kLinuxProxyConfigUrl), | |
| 465 GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); | |
| 466 } | 466 } |
| 467 } | 467 } |
| 468 | 468 |
| 469 // static | 469 // static |
| 470 bool NetworkSection::SearchPATH(ProxyConfigCommand* commands, size_t ncommands, | 470 bool NetworkSection::SearchPATH(ProxyConfigCommand* commands, size_t ncommands, |
| 471 size_t* index) { | 471 size_t* index) { |
| 472 const char* path = getenv("PATH"); | 472 const char* path = getenv("PATH"); |
| 473 if (!path) | 473 if (!path) |
| 474 return false; | 474 return false; |
| 475 FilePath bin_path; | 475 FilePath bin_path; |
| 476 CStringTokenizer tk(path, path + strlen(path), ":"); | 476 CStringTokenizer tk(path, path + strlen(path), ":"); |
| 477 // Search $PATH looking for the commands in order. | 477 // Search $PATH looking for the commands in order. |
| 478 while (tk.GetNext()) { | 478 while (tk.GetNext()) { |
| 479 for (size_t i = 0; i < ncommands; i++) { | 479 for (size_t i = 0; i < ncommands; i++) { |
| 480 bin_path = FilePath(tk.token()).Append(commands[i].argv[0]); | 480 bin_path = FilePath(tk.token()).Append(commands[i].argv[0]); |
| 481 if (file_util::PathExists(bin_path)) { | 481 if (file_util::PathExists(bin_path)) { |
| 482 commands[i].binary = bin_path.value(); | 482 commands[i].binary = bin_path.value(); |
| 483 if (index) | 483 if (index) |
| 484 *index = i; | 484 *index = i; |
| 485 return true; | 485 return true; |
| 486 } | 486 } |
| 487 } | 487 } |
| 488 } | 488 } |
| 489 // Did not find any of the binaries in $PATH. | 489 // Did not find any of the binaries in $PATH. |
| 490 return false; | 490 return false; |
| 491 } | 491 } |
| 492 | 492 |
| 493 // static | 493 // static |
| 494 void NetworkSection::StartProxyConfigUtil(const ProxyConfigCommand& command) { | 494 void NetworkSection::StartProxyConfigUtil(Profile* profile, |
| 495 const ProxyConfigCommand& command) { |
| 495 std::vector<std::string> argv; | 496 std::vector<std::string> argv; |
| 496 argv.push_back(command.binary); | 497 argv.push_back(command.binary); |
| 497 for (size_t i = 1; command.argv[i]; i++) | 498 for (size_t i = 1; command.argv[i]; i++) |
| 498 argv.push_back(command.argv[i]); | 499 argv.push_back(command.argv[i]); |
| 499 base::file_handle_mapping_vector no_files; | 500 base::file_handle_mapping_vector no_files; |
| 500 base::ProcessHandle handle; | 501 base::ProcessHandle handle; |
| 501 if (!base::LaunchApp(argv, no_files, false, &handle)) { | 502 if (!base::LaunchApp(argv, no_files, false, &handle)) { |
| 502 LOG(ERROR) << "StartProxyConfigUtil failed to start " << command.binary; | 503 LOG(ERROR) << "StartProxyConfigUtil failed to start " << command.binary; |
| 503 BrowserList::GetLastActive()-> | 504 browser::ShowOptionsURL(profile, GURL(kLinuxProxyConfigUrl)); |
| 504 OpenURL(GURL(kLinuxProxyConfigUrl), GURL(), NEW_FOREGROUND_TAB, | |
| 505 PageTransition::LINK); | |
| 506 return; | 505 return; |
| 507 } | 506 } |
| 508 ProcessWatcher::EnsureProcessGetsReaped(handle); | 507 ProcessWatcher::EnsureProcessGetsReaped(handle); |
| 509 } | 508 } |
| 510 | 509 |
| 511 /////////////////////////////////////////////////////////////////////////////// | 510 /////////////////////////////////////////////////////////////////////////////// |
| 512 // TranslateSection | 511 // TranslateSection |
| 513 | 512 |
| 514 class TranslateSection : public OptionsPageBase { | 513 class TranslateSection : public OptionsPageBase { |
| 515 public: | 514 public: |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 bool enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | 675 bool enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); |
| 677 UserMetricsRecordAction( | 676 UserMetricsRecordAction( |
| 678 enabled ? | 677 enabled ? |
| 679 UserMetricsAction("Options_BackgroundMode_Enable") : | 678 UserMetricsAction("Options_BackgroundMode_Enable") : |
| 680 UserMetricsAction("Options_BackgroundMode_Disable"), | 679 UserMetricsAction("Options_BackgroundMode_Disable"), |
| 681 profile()->GetPrefs()); | 680 profile()->GetPrefs()); |
| 682 enable_background_mode_.SetValue(enabled); | 681 enable_background_mode_.SetValue(enabled); |
| 683 } | 682 } |
| 684 | 683 |
| 685 void ChromeAppsSection::OnLearnMoreLinkClicked(GtkWidget* widget) { | 684 void ChromeAppsSection::OnLearnMoreLinkClicked(GtkWidget* widget) { |
| 686 BrowserList::GetLastActive()->OpenURL( | 685 browser::ShowOptionsURL( |
| 687 GURL(l10n_util::GetStringUTF8(IDS_LEARN_MORE_BACKGROUND_MODE_URL)), | 686 profile(), |
| 688 GURL(), NEW_WINDOW, PageTransition::LINK); | 687 GURL(l10n_util::GetStringUTF8(IDS_LEARN_MORE_BACKGROUND_MODE_URL))); |
| 689 } | 688 } |
| 690 | 689 |
| 691 | 690 |
| 692 /////////////////////////////////////////////////////////////////////////////// | 691 /////////////////////////////////////////////////////////////////////////////// |
| 693 // PrivacySection | 692 // PrivacySection |
| 694 | 693 |
| 695 class PrivacySection : public OptionsPageBase { | 694 class PrivacySection : public OptionsPageBase { |
| 696 public: | 695 public: |
| 697 explicit PrivacySection(Profile* profile); | 696 explicit PrivacySection(Profile* profile); |
| 698 virtual ~PrivacySection() {} | 697 virtual ~PrivacySection() {} |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 void PrivacySection::OnClearBrowsingDataButtonClicked(GtkButton* widget, | 876 void PrivacySection::OnClearBrowsingDataButtonClicked(GtkButton* widget, |
| 878 PrivacySection* section) { | 877 PrivacySection* section) { |
| 879 ClearBrowsingDataDialogGtk::Show( | 878 ClearBrowsingDataDialogGtk::Show( |
| 880 GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(widget))), | 879 GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(widget))), |
| 881 section->profile()); | 880 section->profile()); |
| 882 } | 881 } |
| 883 | 882 |
| 884 // static | 883 // static |
| 885 void PrivacySection::OnLearnMoreLinkClicked(GtkButton *button, | 884 void PrivacySection::OnLearnMoreLinkClicked(GtkButton *button, |
| 886 PrivacySection* privacy_section) { | 885 PrivacySection* privacy_section) { |
| 887 BrowserList::GetLastActive()-> | 886 browser::ShowOptionsURL( |
| 888 OpenURL(GURL(l10n_util::GetStringUTF8(IDS_LEARN_MORE_PRIVACY_URL)), | 887 privacy_section->profile(), |
| 889 GURL(), NEW_WINDOW, PageTransition::LINK); | 888 GURL(l10n_util::GetStringUTF8(IDS_LEARN_MORE_PRIVACY_URL))); |
| 890 } | 889 } |
| 891 | 890 |
| 892 // static | 891 // static |
| 893 void PrivacySection::OnEnableLinkDoctorChange(GtkWidget* widget, | 892 void PrivacySection::OnEnableLinkDoctorChange(GtkWidget* widget, |
| 894 PrivacySection* privacy_section) { | 893 PrivacySection* privacy_section) { |
| 895 if (privacy_section->pref_changing_) | 894 if (privacy_section->pref_changing_) |
| 896 return; | 895 return; |
| 897 bool enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); | 896 bool enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); |
| 898 privacy_section->UserMetricsRecordAction( | 897 privacy_section->UserMetricsRecordAction( |
| 899 enabled ? | 898 enabled ? |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tls1_enabled_checkbox_), | 1176 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tls1_enabled_checkbox_), |
| 1178 tls1_enabled_.GetValue()); | 1177 tls1_enabled_.GetValue()); |
| 1179 } | 1178 } |
| 1180 pref_changing_ = false; | 1179 pref_changing_ = false; |
| 1181 } | 1180 } |
| 1182 | 1181 |
| 1183 | 1182 |
| 1184 // static | 1183 // static |
| 1185 void SecuritySection::OnManageCertificatesClicked(GtkButton* button, | 1184 void SecuritySection::OnManageCertificatesClicked(GtkButton* button, |
| 1186 SecuritySection* section) { | 1185 SecuritySection* section) { |
| 1187 BrowserList::GetLastActive()-> | 1186 browser::ShowOptionsURL(section->profile(), |
| 1188 OpenURL(GURL(kLinuxCertificatesConfigUrl), GURL(), NEW_WINDOW, | 1187 GURL(kLinuxCertificatesConfigUrl)); |
| 1189 PageTransition::LINK); | |
| 1190 } | 1188 } |
| 1191 | 1189 |
| 1192 // static | 1190 // static |
| 1193 void SecuritySection::OnRevCheckingEnabledToggled(GtkToggleButton* togglebutton, | 1191 void SecuritySection::OnRevCheckingEnabledToggled(GtkToggleButton* togglebutton, |
| 1194 SecuritySection* section) { | 1192 SecuritySection* section) { |
| 1195 if (section->pref_changing_) | 1193 if (section->pref_changing_) |
| 1196 return; | 1194 return; |
| 1197 | 1195 |
| 1198 bool enabled = gtk_toggle_button_get_active(togglebutton); | 1196 bool enabled = gtk_toggle_button_get_active(togglebutton); |
| 1199 if (enabled) { | 1197 if (enabled) { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1365 // Add ChromeApps preferences if background mode is runtime-enabled. | 1363 // Add ChromeApps preferences if background mode is runtime-enabled. |
| 1366 if (CommandLine::ForCurrentProcess()->HasSwitch( | 1364 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 1367 switches::kEnableBackgroundMode)) { | 1365 switches::kEnableBackgroundMode)) { |
| 1368 chrome_apps_section_.reset(new ChromeAppsSection(profile_)); | 1366 chrome_apps_section_.reset(new ChromeAppsSection(profile_)); |
| 1369 options_builder->AddOptionGroup(l10n_util::GetStringUTF8( | 1367 options_builder->AddOptionGroup(l10n_util::GetStringUTF8( |
| 1370 IDS_OPTIONS_ADVANCED_SECTION_TITLE_CHROME_APPS), | 1368 IDS_OPTIONS_ADVANCED_SECTION_TITLE_CHROME_APPS), |
| 1371 chrome_apps_section_->get_page_widget(), false); | 1369 chrome_apps_section_->get_page_widget(), false); |
| 1372 } | 1370 } |
| 1373 page_ = options_builder->get_page_widget(); | 1371 page_ = options_builder->get_page_widget(); |
| 1374 } | 1372 } |
| OLD | NEW |