| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/views/options/advanced_contents_view.h" | 5 #include "chrome/browser/ui/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") |
| 11 #include <shellapi.h> | 11 #include <shellapi.h> |
| 12 #include <vsstyle.h> | 12 #include <vsstyle.h> |
| 13 #include <vssym32.h> | 13 #include <vssym32.h> |
| 14 | 14 |
| 15 #include <string> | 15 #include <string> |
| 16 | 16 |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/file_util.h" | 18 #include "base/file_util.h" |
| 19 #include "base/i18n/rtl.h" | 19 #include "base/i18n/rtl.h" |
| 20 #include "base/message_loop.h" | 20 #include "base/message_loop.h" |
| 21 #include "base/path_service.h" | 21 #include "base/path_service.h" |
| 22 #include "base/scoped_callback_factory.h" | 22 #include "base/scoped_callback_factory.h" |
| 23 #include "base/threading/thread.h" | 23 #include "base/threading/thread.h" |
| 24 #include "base/utf_string_conversions.h" | 24 #include "base/utf_string_conversions.h" |
| 25 #include "chrome/browser/browser_list.h" | 25 #include "chrome/browser/browser_list.h" |
| 26 #include "chrome/browser/browser_process.h" | 26 #include "chrome/browser/browser_process.h" |
| 27 #include "chrome/browser/download/download_manager.h" | 27 #include "chrome/browser/download/download_manager.h" |
| 28 #include "chrome/browser/download/download_prefs.h" | 28 #include "chrome/browser/download/download_prefs.h" |
| 29 #include "chrome/browser/google/google_util.h" | 29 #include "chrome/browser/google/google_util.h" |
| 30 #include "chrome/browser/gears_integration.h" | |
| 31 #include "chrome/browser/prefs/pref_member.h" | 30 #include "chrome/browser/prefs/pref_member.h" |
| 32 #include "chrome/browser/prefs/pref_service.h" | 31 #include "chrome/browser/prefs/pref_service.h" |
| 33 #include "chrome/browser/prefs/pref_set_observer.h" | 32 #include "chrome/browser/prefs/pref_set_observer.h" |
| 34 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" | 33 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
| 35 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 34 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
| 36 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" | 35 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
| 37 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
| 38 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 37 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 39 #include "chrome/browser/ui/options/options_util.h" | 38 #include "chrome/browser/ui/options/options_util.h" |
| 40 #include "chrome/browser/ui/options/show_options_url.h" | 39 #include "chrome/browser/ui/options/show_options_url.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 // Convenience helpers for adding controls to specific layouts in an | 223 // Convenience helpers for adding controls to specific layouts in an |
| 225 // aesthetically pleasing way. | 224 // aesthetically pleasing way. |
| 226 void AddWrappingCheckboxRow(views::GridLayout* layout, | 225 void AddWrappingCheckboxRow(views::GridLayout* layout, |
| 227 views::Checkbox* checkbox, | 226 views::Checkbox* checkbox, |
| 228 int id, | 227 int id, |
| 229 bool related_follows); | 228 bool related_follows); |
| 230 void AddWrappingLabelRow(views::GridLayout* layout, | 229 void AddWrappingLabelRow(views::GridLayout* layout, |
| 231 views::Label* label, | 230 views::Label* label, |
| 232 int id, | 231 int id, |
| 233 bool related_follows); | 232 bool related_follows); |
| 234 void AddLabeledTwoColumnRow(views::GridLayout* layout, | |
| 235 views::Label* label, | |
| 236 views::View* control, | |
| 237 bool control_stretches, | |
| 238 int id, | |
| 239 bool related_follows); | |
| 240 void AddTwoColumnRow(views::GridLayout* layout, | 233 void AddTwoColumnRow(views::GridLayout* layout, |
| 241 views::View* first, | 234 views::View* first, |
| 242 views::View* second, | 235 views::View* second, |
| 243 bool control_stretches, // Whether or not the control | 236 bool control_stretches, // Whether or not the control |
| 244 // expands to fill the width. | 237 // expands to fill the width. |
| 245 int id, | 238 int id, |
| 246 int trailing_space); | 239 int trailing_space); |
| 247 void AddLeadingControl(views::GridLayout* layout, | 240 void AddLeadingControl(views::GridLayout* layout, |
| 248 views::View* control, | 241 views::View* control, |
| 249 int id, | 242 int id, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 views::Label* label, | 330 views::Label* label, |
| 338 int id, | 331 int id, |
| 339 bool related_follows) { | 332 bool related_follows) { |
| 340 label->SetMultiLine(true); | 333 label->SetMultiLine(true); |
| 341 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | 334 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| 342 layout->StartRow(0, id); | 335 layout->StartRow(0, id); |
| 343 layout->AddView(label); | 336 layout->AddView(label); |
| 344 AddSpacing(layout, related_follows); | 337 AddSpacing(layout, related_follows); |
| 345 } | 338 } |
| 346 | 339 |
| 347 void AdvancedSection::AddLabeledTwoColumnRow(views::GridLayout* layout, | |
| 348 views::Label* label, | |
| 349 views::View* control, | |
| 350 bool control_stretches, | |
| 351 int id, | |
| 352 bool related_follows) { | |
| 353 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); | |
| 354 AddTwoColumnRow(layout, label, control, control_stretches, id, | |
| 355 related_follows ? views::kRelatedControlVerticalSpacing | |
| 356 : views::kUnrelatedControlVerticalSpacing); | |
| 357 } | |
| 358 | |
| 359 void AdvancedSection::AddTwoColumnRow(views::GridLayout* layout, | 340 void AdvancedSection::AddTwoColumnRow(views::GridLayout* layout, |
| 360 views::View* first, | 341 views::View* first, |
| 361 views::View* second, | 342 views::View* second, |
| 362 bool control_stretches, | 343 bool control_stretches, |
| 363 int id, | 344 int id, |
| 364 int trailing_space) { | 345 int trailing_space) { |
| 365 layout->StartRow(0, id); | 346 layout->StartRow(0, id); |
| 366 layout->AddView(first); | 347 layout->AddView(first); |
| 367 if (control_stretches) { | 348 if (control_stretches) { |
| 368 layout->AddView(second); | 349 layout->AddView(second); |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | 666 virtual void ButtonPressed(views::Button* sender, const views::Event& event); |
| 686 | 667 |
| 687 protected: | 668 protected: |
| 688 // OptionsPageView overrides: | 669 // OptionsPageView overrides: |
| 689 virtual void InitControlLayout(); | 670 virtual void InitControlLayout(); |
| 690 | 671 |
| 691 private: | 672 private: |
| 692 // Controls for this section: | 673 // Controls for this section: |
| 693 views::Label* fonts_and_languages_label_; | 674 views::Label* fonts_and_languages_label_; |
| 694 views::NativeButton* change_content_fonts_button_; | 675 views::NativeButton* change_content_fonts_button_; |
| 695 views::Label* gears_label_; | |
| 696 views::NativeButton* gears_settings_button_; | |
| 697 | 676 |
| 698 DISALLOW_COPY_AND_ASSIGN(WebContentSection); | 677 DISALLOW_COPY_AND_ASSIGN(WebContentSection); |
| 699 }; | 678 }; |
| 700 | 679 |
| 701 WebContentSection::WebContentSection(Profile* profile) | 680 WebContentSection::WebContentSection(Profile* profile) |
| 702 : fonts_and_languages_label_(NULL), | 681 : fonts_and_languages_label_(NULL), |
| 703 change_content_fonts_button_(NULL), | 682 change_content_fonts_button_(NULL), |
| 704 gears_label_(NULL), | |
| 705 gears_settings_button_(NULL), | |
| 706 AdvancedSection(profile, UTF16ToWide(l10n_util::GetStringUTF16( | 683 AdvancedSection(profile, UTF16ToWide(l10n_util::GetStringUTF16( |
| 707 IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT))) { | 684 IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT))) { |
| 708 } | 685 } |
| 709 | 686 |
| 710 void WebContentSection::ButtonPressed( | 687 void WebContentSection::ButtonPressed( |
| 711 views::Button* sender, const views::Event& event) { | 688 views::Button* sender, const views::Event& event) { |
| 712 if (sender == gears_settings_button_) { | 689 if (sender == change_content_fonts_button_) { |
| 713 UserMetricsRecordAction(UserMetricsAction("Options_GearsSettings"), NULL); | |
| 714 GearsSettingsPressed(GetAncestor(GetWidget()->GetNativeView(), GA_ROOT)); | |
| 715 } else if (sender == change_content_fonts_button_) { | |
| 716 views::Window::CreateChromeWindow( | 690 views::Window::CreateChromeWindow( |
| 717 GetWindow()->GetNativeWindow(), | 691 GetWindow()->GetNativeWindow(), |
| 718 gfx::Rect(), | 692 gfx::Rect(), |
| 719 new FontsLanguagesWindowView(profile()))->Show(); | 693 new FontsLanguagesWindowView(profile()))->Show(); |
| 720 } | 694 } |
| 721 } | 695 } |
| 722 | 696 |
| 723 void WebContentSection::InitControlLayout() { | 697 void WebContentSection::InitControlLayout() { |
| 724 AdvancedSection::InitControlLayout(); | 698 AdvancedSection::InitControlLayout(); |
| 725 | 699 |
| 726 if (!base::i18n::IsRTL()) { | |
| 727 gears_label_ = new views::Label(UTF16ToWide( | |
| 728 l10n_util::GetStringUTF16(IDS_OPTIONS_GEARSSETTINGS_GROUP_NAME))); | |
| 729 } else { | |
| 730 // Add an RTL mark so that | |
| 731 // ":" in "Google Gears:" in Hebrew Chrome is displayed left-most. | |
| 732 std::wstring gearssetting_group_name = UTF16ToWide( | |
| 733 l10n_util::GetStringUTF16(IDS_OPTIONS_GEARSSETTINGS_GROUP_NAME)); | |
| 734 gearssetting_group_name.push_back( | |
| 735 static_cast<wchar_t>(base::i18n::kRightToLeftMark)); | |
| 736 gears_label_ = new views::Label(gearssetting_group_name); | |
| 737 } | |
| 738 gears_settings_button_ = new views::NativeButton( | |
| 739 this, | |
| 740 UTF16ToWide(l10n_util::GetStringUTF16( | |
| 741 IDS_OPTIONS_GEARSSETTINGS_CONFIGUREGEARS_BUTTON))); | |
| 742 fonts_and_languages_label_ = new views::Label( | 700 fonts_and_languages_label_ = new views::Label( |
| 743 UTF16ToWide(l10n_util::GetStringUTF16(IDS_OPTIONS_FONTSETTINGS_INFO))); | 701 UTF16ToWide(l10n_util::GetStringUTF16(IDS_OPTIONS_FONTSETTINGS_INFO))); |
| 744 | 702 |
| 745 change_content_fonts_button_ = new views::NativeButton( | 703 change_content_fonts_button_ = new views::NativeButton( |
| 746 this, | 704 this, |
| 747 UTF16ToWide(l10n_util::GetStringUTF16( | 705 UTF16ToWide(l10n_util::GetStringUTF16( |
| 748 IDS_OPTIONS_FONTSETTINGS_CONFIGUREFONTS_BUTTON))); | 706 IDS_OPTIONS_FONTSETTINGS_CONFIGUREFONTS_BUTTON))); |
| 749 | 707 |
| 750 GridLayout* layout = new GridLayout(contents_); | 708 GridLayout* layout = new GridLayout(contents_); |
| 751 contents_->SetLayoutManager(layout); | 709 contents_->SetLayoutManager(layout); |
| 752 | 710 |
| 753 const int single_column_view_set_id = 0; | 711 const int single_column_view_set_id = 0; |
| 754 AddWrappingColumnSet(layout, single_column_view_set_id); | 712 AddWrappingColumnSet(layout, single_column_view_set_id); |
| 755 const int indented_column_set_id = 1; | 713 const int indented_column_set_id = 1; |
| 756 AddIndentedColumnSet(layout, indented_column_set_id); | 714 AddIndentedColumnSet(layout, indented_column_set_id); |
| 757 const int single_double_column_set = 2; | 715 const int single_double_column_set = 2; |
| 758 AddTwoColumnSet(layout, single_double_column_set); | 716 AddTwoColumnSet(layout, single_double_column_set); |
| 759 | 717 |
| 760 // Fonts and Languages. | 718 // Fonts and Languages. |
| 761 AddWrappingLabelRow(layout, fonts_and_languages_label_, | 719 AddWrappingLabelRow(layout, fonts_and_languages_label_, |
| 762 single_column_view_set_id, | 720 single_column_view_set_id, |
| 763 true); | 721 true); |
| 764 AddLeadingControl(layout, change_content_fonts_button_, | 722 AddLeadingControl(layout, change_content_fonts_button_, |
| 765 indented_column_set_id, | 723 indented_column_set_id, |
| 766 false); | 724 false); |
| 767 | |
| 768 // Gears. | |
| 769 AddLabeledTwoColumnRow(layout, gears_label_, gears_settings_button_, false, | |
| 770 single_double_column_set, false); | |
| 771 } | 725 } |
| 772 | 726 |
| 773 //////////////////////////////////////////////////////////////////////////////// | 727 //////////////////////////////////////////////////////////////////////////////// |
| 774 // SecuritySection | 728 // SecuritySection |
| 775 | 729 |
| 776 class SecuritySection : public AdvancedSection, | 730 class SecuritySection : public AdvancedSection, |
| 777 public views::ButtonListener { | 731 public views::ButtonListener { |
| 778 public: | 732 public: |
| 779 explicit SecuritySection(Profile* profile); | 733 explicit SecuritySection(Profile* profile); |
| 780 virtual ~SecuritySection() {} | 734 virtual ~SecuritySection() {} |
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1642 // AdvancedScrollViewContainer, views::View overrides: | 1596 // AdvancedScrollViewContainer, views::View overrides: |
| 1643 | 1597 |
| 1644 void AdvancedScrollViewContainer::Layout() { | 1598 void AdvancedScrollViewContainer::Layout() { |
| 1645 gfx::Rect lb = GetLocalBounds(); | 1599 gfx::Rect lb = GetLocalBounds(); |
| 1646 | 1600 |
| 1647 gfx::Size border = gfx::NativeTheme::instance()->GetThemeBorderSize( | 1601 gfx::Size border = gfx::NativeTheme::instance()->GetThemeBorderSize( |
| 1648 gfx::NativeTheme::LIST); | 1602 gfx::NativeTheme::LIST); |
| 1649 lb.Inset(border.width(), border.height()); | 1603 lb.Inset(border.width(), border.height()); |
| 1650 scroll_view_->SetBoundsRect(lb); | 1604 scroll_view_->SetBoundsRect(lb); |
| 1651 } | 1605 } |
| OLD | NEW |