diff options
author | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-02 14:55:09 +0000 |
---|---|---|
committer | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-02 14:55:09 +0000 |
commit | d2f7d56bd62cd8d6a8e50b25dac8f2bc4871eafe (patch) | |
tree | e66610ffde53c34e58f671b92092b69e714268f2 /chrome/browser/views/options | |
parent | fbde2f7efff4198e4138e1f202395dacc1847da6 (diff) | |
download | chromium_src-d2f7d56bd62cd8d6a8e50b25dac8f2bc4871eafe.zip chromium_src-d2f7d56bd62cd8d6a8e50b25dac8f2bc4871eafe.tar.gz chromium_src-d2f7d56bd62cd8d6a8e50b25dac8f2bc4871eafe.tar.bz2 |
Revert r51526 (Auto-size the views version of the options dialog.)
Unexpected unit_tests crash on chromeos.
TBR: mnissler
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51529 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/options')
5 files changed, 72 insertions, 36 deletions
diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc index bbe232f..9ee6485e 100644 --- a/chrome/browser/views/options/advanced_contents_view.cc +++ b/chrome/browser/views/options/advanced_contents_view.cc @@ -287,6 +287,7 @@ AdvancedSection::AdvancedSection(Profile* profile, void AdvancedSection::DidChangeBounds(const gfx::Rect& previous, const gfx::Rect& current) { Layout(); + contents_->Layout(); } //////////////////////////////////////////////////////////////////////////////// @@ -433,6 +434,9 @@ class PrivacySection : public AdvancedSection, // Overridden from views::LinkController: virtual void LinkActivated(views::Link* source, int event_flags); + // Overridden from views::View: + virtual void Layout(); + protected: // OptionsPageView overrides: virtual void InitControlLayout(); @@ -545,6 +549,22 @@ void PrivacySection::LinkActivated(views::Link* source, int event_flags) { } } +void PrivacySection::Layout() { + if (reporting_enabled_checkbox_) { + // We override this to try and set the width of the enable logging checkbox + // to the width of the parent less some fudging since the checkbox's + // preferred size calculation code is dependent on its width, and if we + // don't do this then it will return 0 as a preferred width when GridLayout + // (called from View::Layout) tries to access it. + views::View* parent = GetParent(); + if (parent && parent->width()) { + const int parent_width = parent->width(); + reporting_enabled_checkbox_->SetBounds(0, 0, parent_width - 20, 0); + } + } + View::Layout(); +} + void PrivacySection::InitControlLayout() { AdvancedSection::InitControlLayout(); @@ -616,8 +636,8 @@ void PrivacySection::InitControlLayout() { reporting_enabled_checkbox_ != NULL); // The "Help make Google Chrome better" checkbox. if (reporting_enabled_checkbox_) { - AddWrappingCheckboxRow(layout, reporting_enabled_checkbox_, - indented_view_set_id, false); + AddLeadingControl(layout, reporting_enabled_checkbox_, indented_view_set_id, + false); } // Init member prefs so we can update the controls if prefs change. @@ -1401,4 +1421,5 @@ void AdvancedScrollViewContainer::Layout() { gfx::NativeTheme::LIST); lb.Inset(border.width(), border.height()); scroll_view_->SetBounds(lb); + scroll_view_->Layout(); } diff --git a/chrome/browser/views/options/content_page_view.cc b/chrome/browser/views/options/content_page_view.cc index 04ccf65..add146e 100644 --- a/chrome/browser/views/options/content_page_view.cc +++ b/chrome/browser/views/options/content_page_view.cc @@ -41,10 +41,8 @@ namespace { -// All the options pages are in the same view hierarchy. This means we need to -// make sure group identifiers don't collide across different pages. -const int kPasswordSavingRadioGroup = 201; -const int kFormAutofillRadioGroup = 202; +const int kPasswordSavingRadioGroup = 1; +const int kFormAutofillRadioGroup = 2; // Background color for the status label when it's showing an error. static const SkColor kSyncLabelErrorBgColor = SkColorSetRGB(0xff, 0x9a, 0x9a); @@ -254,6 +252,17 @@ void ContentPageView::NotifyPrefChanged(const std::wstring* pref_name) { void ContentPageView::Layout() { if (is_initialized()) UpdateSyncControls(); + // We need to Layout twice - once to get the width of the contents box... + View::Layout(); + passwords_asktosave_radio_->SetBounds( + 0, 0, passwords_group_->GetContentsWidth(), 0); + passwords_neversave_radio_->SetBounds( + 0, 0, passwords_group_->GetContentsWidth(), 0); + if (is_initialized()) { + sync_status_label_->SetBounds( + 0, 0, sync_group_->GetContentsWidth(), 0); + } + // ... and twice to get the height of multi-line items correct. View::Layout(); } @@ -299,12 +308,10 @@ void ContentPageView::InitPasswordSavingGroup() { GridLayout::USE_PREF, 0, 0); layout->StartRow(0, single_column_view_set_id); - layout->AddView(passwords_asktosave_radio_, 1, 1, - GridLayout::FILL, GridLayout::LEADING); + layout->AddView(passwords_asktosave_radio_); layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); layout->StartRow(0, single_column_view_set_id); - layout->AddView(passwords_neversave_radio_, 1, 1, - GridLayout::FILL, GridLayout::LEADING); + layout->AddView(passwords_neversave_radio_); layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); layout->StartRow(0, single_column_view_set_id); layout->AddView(show_passwords_button_); @@ -349,12 +356,10 @@ void ContentPageView::InitFormAutofillGroup() { GridLayout::USE_PREF, 0, 0); layout->StartRow(0, fill_column_view_set_id); - layout->AddView(form_autofill_enable_radio_, 1, 1, - GridLayout::FILL, GridLayout::LEADING); + layout->AddView(form_autofill_enable_radio_); layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); layout->StartRow(0, fill_column_view_set_id); - layout->AddView(form_autofill_disable_radio_, 1, 1, - GridLayout::FILL, GridLayout::LEADING); + layout->AddView(form_autofill_disable_radio_); layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); layout->StartRow(0, leading_column_view_set_id); layout->AddView(change_autofill_settings_button_); @@ -452,8 +457,7 @@ void ContentPageView::InitSyncGroup() { GridLayout::USE_PREF, 0, 0); layout->StartRow(0, single_column_view_set_id); - layout->AddView(sync_status_label_, 3, 1, - GridLayout::FILL, GridLayout::LEADING); + layout->AddView(sync_status_label_, 3, 1); layout->StartRow(0, single_column_view_set_id); layout->AddView(sync_action_link_, 3, 1); layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); diff --git a/chrome/browser/views/options/general_page_view.cc b/chrome/browser/views/options/general_page_view.cc index f836ea4..20504c9 100644 --- a/chrome/browser/views/options/general_page_view.cc +++ b/chrome/browser/views/options/general_page_view.cc @@ -35,13 +35,10 @@ namespace { -// All the options pages are in the same view hierarchy. This means we need to -// make sure group identifiers don't collide across different pages. -const int kStartupRadioGroup = 101; -const int kHomePageRadioGroup = 102; +const int kStartupRadioGroup = 1; +const int kHomePageRadioGroup = 2; const SkColor kDefaultBrowserLabelColor = SkColorSetRGB(0, 135, 0); const SkColor kNotDefaultBrowserLabelColor = SkColorSetRGB(135, 0, 0); -const int kHomePageTextfieldWidthChars = 40; } // namespace @@ -405,6 +402,24 @@ void GeneralPageView::HighlightGroup(OptionsGroup highlight_group) { } /////////////////////////////////////////////////////////////////////////////// +// GeneralPageView, views::View overrides: + +void GeneralPageView::Layout() { + // We need to Layout twice - once to get the width of the contents box... + View::Layout(); + startup_last_session_radio_->SetBounds( + 0, 0, startup_group_->GetContentsWidth(), 0); + homepage_use_newtab_radio_->SetBounds( + 0, 0, homepage_group_->GetContentsWidth(), 0); + homepage_show_home_button_checkbox_->SetBounds( + 0, 0, homepage_group_->GetContentsWidth(), 0); + default_browser_status_label_->SetBounds( + 0, 0, default_browser_group_->GetContentsWidth(), 0); + // ... and twice to get the height of multi-line items correct. + View::Layout(); +} + +/////////////////////////////////////////////////////////////////////////////// // GeneralPageView, private: void GeneralPageView::SetDefaultBrowserUIState( @@ -497,16 +512,14 @@ void GeneralPageView::InitStartupGroup() { layout->AddView(startup_homepage_radio_); layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); layout->StartRow(0, single_column_view_set_id); - layout->AddView(startup_last_session_radio_, 1, 1, - GridLayout::FILL, GridLayout::LEADING); + layout->AddView(startup_last_session_radio_); layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); layout->StartRow(0, single_column_view_set_id); layout->AddView(startup_custom_radio_); layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); layout->StartRow(0, double_column_view_set_id); - layout->AddView(startup_custom_pages_table_, 1, 1, - GridLayout::FILL, GridLayout::FILL); + layout->AddView(startup_custom_pages_table_); views::View* button_stack = new views::View; GridLayout* button_stack_layout = new GridLayout(button_stack); @@ -545,8 +558,6 @@ void GeneralPageView::InitHomepageGroup() { homepage_use_url_radio_->set_listener(this); homepage_use_url_textfield_ = new views::Textfield; homepage_use_url_textfield_->SetController(this); - homepage_use_url_textfield_->set_default_width_in_chars( - kHomePageTextfieldWidthChars); homepage_show_home_button_checkbox_ = new views::Checkbox( l10n_util::GetString(IDS_OPTIONS_HOMEPAGE_SHOW_BUTTON)); homepage_show_home_button_checkbox_->set_listener(this); @@ -573,16 +584,14 @@ void GeneralPageView::InitHomepageGroup() { GridLayout::USE_PREF, 0, 0); layout->StartRow(0, single_column_view_set_id); - layout->AddView(homepage_use_newtab_radio_, 1, 1, - GridLayout::FILL, GridLayout::LEADING); + layout->AddView(homepage_use_newtab_radio_); layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); layout->StartRow(0, double_column_view_set_id); layout->AddView(homepage_use_url_radio_); layout->AddView(homepage_use_url_textfield_); layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); layout->StartRow(0, single_column_view_set_id); - layout->AddView(homepage_show_home_button_checkbox_, 1, 1, - GridLayout::FILL, GridLayout::LEADING); + layout->AddView(homepage_show_home_button_checkbox_); homepage_group_ = new OptionsGroupView( contents, l10n_util::GetString(IDS_OPTIONS_HOMEPAGE_GROUP_NAME), @@ -648,8 +657,7 @@ void GeneralPageView::InitDefaultBrowserGroup() { GridLayout::USE_PREF, 0, 0); layout->StartRow(0, single_column_view_set_id); - layout->AddView(default_browser_status_label_, 1, 1, - GridLayout::FILL, GridLayout::LEADING); + layout->AddView(default_browser_status_label_); layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); layout->StartRow(0, single_column_view_set_id); layout->AddView(default_browser_use_as_default_button_); diff --git a/chrome/browser/views/options/general_page_view.h b/chrome/browser/views/options/general_page_view.h index 6cc4911..7838fbe 100644 --- a/chrome/browser/views/options/general_page_view.h +++ b/chrome/browser/views/options/general_page_view.h @@ -62,6 +62,9 @@ class GeneralPageView : public OptionsPageView, virtual void NotifyPrefChanged(const std::wstring* pref_name); virtual void HighlightGroup(OptionsGroup highlight_group); + // views::View overrides: + virtual void Layout(); + private: // ShellIntegration::DefaultBrowserObserver implementation: // Updates the UI state to reflect the current default browser state. diff --git a/chrome/browser/views/options/options_window_view.cc b/chrome/browser/views/options/options_window_view.cc index 70a043d..76c219b 100644 --- a/chrome/browser/views/options/options_window_view.cc +++ b/chrome/browser/views/options/options_window_view.cc @@ -183,9 +183,9 @@ void OptionsWindowView::Layout() { } gfx::Size OptionsWindowView::GetPreferredSize() { - gfx::Size size(tabs_->GetPreferredSize()); - size.Enlarge(2 * kDialogPadding, 2 * kDialogPadding); - return size; + return gfx::Size(views::Window::GetLocalizedContentsSize( + IDS_OPTIONS_DIALOG_WIDTH_CHARS, + IDS_OPTIONS_DIALOG_HEIGHT_LINES)); } void OptionsWindowView::ViewHierarchyChanged(bool is_add, |