diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-10 23:05:22 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-10 23:05:22 +0000 |
commit | 603aa0fbe73299c2204d24d1f9a09cf611c464ac (patch) | |
tree | 46bf94e807dc0afbe2303d7ff98c9209a91c3c3a /views | |
parent | 361e25c6d29fdae737b5ddf846606093b5502187 (diff) | |
download | chromium_src-603aa0fbe73299c2204d24d1f9a09cf611c464ac.zip chromium_src-603aa0fbe73299c2204d24d1f9a09cf611c464ac.tar.gz chromium_src-603aa0fbe73299c2204d24d1f9a09cf611c464ac.tar.bz2 |
Restricts the creation of RadioButton to specify an group-id.
The API is dangerous without one, has it will probably collide with other non radio-button views.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/120002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18110 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/button/radio_button.cc | 12 | ||||
-rw-r--r-- | views/controls/button/radio_button.h | 2 |
2 files changed, 6 insertions, 8 deletions
diff --git a/views/controls/button/radio_button.cc b/views/controls/button/radio_button.cc index 3f4820d..744dbe1 100644 --- a/views/controls/button/radio_button.cc +++ b/views/controls/button/radio_button.cc @@ -4,6 +4,7 @@ #include "views/controls/button/radio_button.h" +#include "base/logging.h" #include "views/widget/root_view.h" namespace views { @@ -14,12 +15,6 @@ const char RadioButton::kViewClassName[] = "views/RadioButton"; //////////////////////////////////////////////////////////////////////////////// // RadioButton, public: -RadioButton::RadioButton() : Checkbox() { -} - -RadioButton::RadioButton(const std::wstring& label) : Checkbox(label) { -} - RadioButton::RadioButton(const std::wstring& label, int group_id) : Checkbox(label) { SetGroup(group_id); @@ -47,6 +42,11 @@ void RadioButton::SetChecked(bool checked) { std::vector<View*>::iterator i; for (i = other.begin(); i != other.end(); ++i) { if (*i != this) { + if ((*i)->GetClassName() != kViewClassName) { + NOTREACHED() << "radio-button has same group as other non " + "radio-button views."; + continue; + } RadioButton* peer = static_cast<RadioButton*>(*i); peer->SetChecked(false); } diff --git a/views/controls/button/radio_button.h b/views/controls/button/radio_button.h index ab7fbe2..9a7d82e 100644 --- a/views/controls/button/radio_button.h +++ b/views/controls/button/radio_button.h @@ -15,8 +15,6 @@ class RadioButton : public Checkbox { // The button's class name. static const char kViewClassName[]; - RadioButton(); - RadioButton(const std::wstring& label); RadioButton(const std::wstring& label, int group_id); virtual ~RadioButton(); |