diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-06 22:38:08 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-06 22:38:08 +0000 |
commit | 3693262b7dee1403e3adb8ad240fad8e2fa80e85 (patch) | |
tree | 4c6d4c7f948d123cdf99592cd58be7e2bf19d6ab /chrome/browser | |
parent | 2590b5c54896952e37a3f24e3cc3e59e6b415573 (diff) | |
download | chromium_src-3693262b7dee1403e3adb8ad240fad8e2fa80e85.zip chromium_src-3693262b7dee1403e3adb8ad240fad8e2fa80e85.tar.gz chromium_src-3693262b7dee1403e3adb8ad240fad8e2fa80e85.tar.bz2 |
Lands http://codereview.chromium.org/1543007 for Thiago:
views: Disable the "Import" button on Import Bookmarks dialog if there
is no checkbox checked.
BUG=30401
TEST=open Import Bookmarks dialog, uncheck all checkboxes, see if the
"Import" button is disabled.
Review URL: http://codereview.chromium.org/1566022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43774 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/views/importer_view.cc | 22 | ||||
-rw-r--r-- | chrome/browser/views/importer_view.h | 28 |
2 files changed, 38 insertions, 12 deletions
diff --git a/chrome/browser/views/importer_view.cc b/chrome/browser/views/importer_view.cc index d99fd42..151badf 100644 --- a/chrome/browser/views/importer_view.cc +++ b/chrome/browser/views/importer_view.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -126,6 +126,18 @@ std::wstring ImporterView::GetDialogButtonLabel( } } +bool ImporterView::IsDialogButtonEnabled( + MessageBoxFlags::DialogButton button) const { + if (button == MessageBoxFlags::DIALOGBUTTON_OK) { + return history_checkbox_->checked() || + favorites_checkbox_->checked() || + passwords_checkbox_->checked() || + search_engines_checkbox_->checked(); + } + + return true; +} + bool ImporterView::IsModal() const { return true; } @@ -156,6 +168,13 @@ views::View* ImporterView::GetContentsView() { return this; } +void ImporterView::ButtonPressed( + views::Button* sender, const views::Event& event) { + // When no checkbox is checked we should disable the "Import" button. + // This forces the button to evaluate what state they should be in. + GetDialogClientView()->UpdateDialogButtons(); +} + int ImporterView::GetItemCount() { DCHECK(importer_host_.get()); int item_count = importer_host_->GetAvailableProfileCount(); @@ -205,6 +224,7 @@ views::Checkbox* ImporterView::InitCheckbox(const std::wstring& text, bool checked) { views::Checkbox* checkbox = new views::Checkbox(text); checkbox->SetChecked(checked); + checkbox->set_listener(this); return checkbox; } diff --git a/chrome/browser/views/importer_view.h b/chrome/browser/views/importer_view.h index ac1bc20..ae62820 100644 --- a/chrome/browser/views/importer_view.h +++ b/chrome/browser/views/importer_view.h @@ -1,9 +1,9 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_VIEWS_IMPORTER_VIEW_H__ -#define CHROME_BROWSER_VIEWS_IMPORTER_VIEW_H__ +#ifndef CHROME_BROWSER_VIEWS_IMPORTER_VIEW_H_ +#define CHROME_BROWSER_VIEWS_IMPORTER_VIEW_H_ #include "app/combobox_model.h" #include "chrome/browser/importer/importer.h" @@ -26,6 +26,7 @@ class Profile; // So now use dialog as a placeholder. class ImporterView : public views::View, public views::DialogDelegate, + public views::ButtonListener, public ComboboxModel, public views::Combobox::Listener, public ImportObserver { @@ -35,23 +36,28 @@ class ImporterView : public views::View, ImporterView(Profile* profile, int initial_state); virtual ~ImporterView(); - // Overridden from views::View. + // Overridden from views::View: virtual gfx::Size GetPreferredSize(); virtual void Layout(); // Overridden from views::DialogDelegate: virtual std::wstring GetDialogButtonLabel( MessageBoxFlags::DialogButton button) const; + virtual bool IsDialogButtonEnabled( + MessageBoxFlags::DialogButton button) const; virtual bool IsModal() const; virtual std::wstring GetWindowTitle() const; virtual bool Accept(); virtual views::View* GetContentsView(); - // Overridden from ComboboxModel. + // Overridden from views::ButtonListener: + virtual void ButtonPressed(views::Button* sender, const views::Event& event); + + // Overridden from ComboboxModel: virtual int GetItemCount(); virtual std::wstring GetItemAt(int index); - // Overridden from ChromeViews::Combobox::Listener + // Overridden from ChromeViews::Combobox::Listener: virtual void ItemChanged(views::Combobox* combobox, int prev_index, int new_index); @@ -70,10 +76,10 @@ class ImporterView : public views::View, // Create a bitmap from the checkboxes of the view. uint16 GetCheckedItems(); - // Enables/Disables all the checked items for the given state + // Enables/Disables all the checked items for the given state. void SetCheckedItemsState(uint16 items); - // Sets all checked items in the given state + // Sets all checked items in the given state. void SetCheckedItems(uint16 items); views::Label* import_from_label_; @@ -90,12 +96,12 @@ class ImporterView : public views::View, // selected item in the combo-box. std::vector<uint16> checkbox_items_; - // Initial state of the checkbox_items_. + // Initial state of the |checkbox_items_|. uint16 initial_state_; Profile* profile_; - DISALLOW_EVIL_CONSTRUCTORS(ImporterView); + DISALLOW_COPY_AND_ASSIGN(ImporterView); }; -#endif // CHROME_BROWSER_VIEWS_IMPORTER_VIEW_H__ +#endif // CHROME_BROWSER_VIEWS_IMPORTER_VIEW_H_ |