summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/task_manager.cc15
-rw-r--r--chrome/browser/views/bookmark_bubble_view.cc11
-rw-r--r--chrome/browser/views/bookmark_bubble_view.h8
-rw-r--r--chrome/browser/views/bookmark_editor_view.cc7
-rw-r--r--chrome/browser/views/bookmark_editor_view.h10
-rw-r--r--chrome/browser/views/bug_report_view.cc16
-rw-r--r--chrome/browser/views/bug_report_view.h7
-rw-r--r--chrome/browser/views/clear_browsing_data.cc39
-rw-r--r--chrome/browser/views/clear_browsing_data.h24
-rw-r--r--chrome/browser/views/download_item_view.cc12
-rw-r--r--chrome/browser/views/download_item_view.h10
-rw-r--r--chrome/browser/views/first_run_bubble.cc17
-rw-r--r--chrome/browser/views/first_run_customize_view.cc28
-rw-r--r--chrome/browser/views/first_run_customize_view.h23
-rw-r--r--chrome/browser/views/first_run_view.cc6
-rw-r--r--chrome/browser/views/first_run_view_base.cc2
-rw-r--r--chrome/browser/views/first_run_view_base.h4
-rw-r--r--chrome/browser/views/hung_renderer_view.cc13
-rw-r--r--chrome/browser/views/importer_view.cc58
-rw-r--r--chrome/browser/views/importer_view.h12
-rw-r--r--chrome/browser/views/infobars/infobars.cc12
-rw-r--r--chrome/browser/views/infobars/infobars.h13
-rw-r--r--chrome/browser/views/keyword_editor_view.cc21
-rw-r--r--chrome/browser/views/keyword_editor_view.h8
-rw-r--r--chrome/browser/views/options/advanced_contents_view.cc140
-rw-r--r--chrome/browser/views/options/advanced_page_view.cc7
-rw-r--r--chrome/browser/views/options/advanced_page_view.h11
-rw-r--r--chrome/browser/views/options/content_page_view.cc43
-rw-r--r--chrome/browser/views/options/content_page_view.h15
-rw-r--r--chrome/browser/views/options/cookies_view.cc14
-rw-r--r--chrome/browser/views/options/cookies_view.h9
-rw-r--r--chrome/browser/views/options/fonts_page_view.cc12
-rw-r--r--chrome/browser/views/options/fonts_page_view.h9
-rw-r--r--chrome/browser/views/options/general_page_view.cc50
-rw-r--r--chrome/browser/views/options/general_page_view.h13
-rw-r--r--chrome/browser/views/options/languages_page_view.cc24
-rw-r--r--chrome/browser/views/options/languages_page_view.h13
-rw-r--r--chrome/browser/views/page_info_window.cc5
-rw-r--r--chrome/browser/views/page_info_window.h8
-rw-r--r--chrome/browser/views/password_manager_exceptions_view.cc8
-rw-r--r--chrome/browser/views/password_manager_exceptions_view.h7
-rw-r--r--chrome/browser/views/password_manager_view.cc19
-rw-r--r--chrome/browser/views/password_manager_view.h10
-rw-r--r--chrome/views/controls/button/button.h13
-rw-r--r--chrome/views/controls/button/checkbox.cc243
-rw-r--r--chrome/views/controls/button/checkbox.h98
-rw-r--r--chrome/views/controls/button/checkbox2.cc166
-rw-r--r--chrome/views/controls/button/checkbox2.h75
-rw-r--r--chrome/views/controls/button/native_button.cc245
-rw-r--r--chrome/views/controls/button/native_button.h169
-rw-r--r--chrome/views/controls/button/native_button2.cc150
-rw-r--r--chrome/views/controls/button/native_button2.h93
-rw-r--r--chrome/views/controls/button/native_button_win.cc23
-rw-r--r--chrome/views/controls/button/native_button_win.h10
-rw-r--r--chrome/views/controls/button/native_button_wrapper.h16
-rw-r--r--chrome/views/controls/button/radio_button.cc142
-rw-r--r--chrome/views/controls/button/radio_button.h54
-rw-r--r--chrome/views/controls/button/radio_button2.cc103
-rw-r--r--chrome/views/controls/button/radio_button2.h45
-rw-r--r--chrome/views/controls/message_box_view.cc24
-rw-r--r--chrome/views/controls/message_box_view.h7
-rw-r--r--chrome/views/controls/native_control_win.cc3
-rw-r--r--chrome/views/focus/focus_manager_unittest.cc27
-rw-r--r--chrome/views/view_unittest.cc36
-rw-r--r--chrome/views/views.vcproj24
-rw-r--r--chrome/views/window/dialog_client_view.cc26
-rw-r--r--chrome/views/window/dialog_client_view.h11
-rw-r--r--chrome/views/window/dialog_delegate.cc1
68 files changed, 865 insertions, 1732 deletions
diff --git a/chrome/browser/task_manager.cc b/chrome/browser/task_manager.cc
index 95da5ee..ab7c562 100644
--- a/chrome/browser/task_manager.cc
+++ b/chrome/browser/task_manager.cc
@@ -674,7 +674,7 @@ bool TaskManagerTableModel::GetProcessMetricsForRows(
////////////////////////////////////////////////////////////////////////////////
class TaskManagerContents : public views::View,
- public views::NativeButton::Listener,
+ public views::ButtonListener,
public views::TableViewObserver,
public views::LinkController,
public views::ContextMenuController,
@@ -692,8 +692,8 @@ class TaskManagerContents : public views::View,
void GetSelection(std::vector<int>* selection);
void GetFocused(std::vector<int>* focused);
- // NativeButton::Listener implementation.
- virtual void ButtonPressed(views::NativeButton* sender);
+ // ButtonListener implementation.
+ virtual void ButtonPressed(views::Button* sender);
// views::TableViewObserver implementation.
virtual void OnSelectionChanged();
@@ -778,8 +778,7 @@ void TaskManagerContents::Init(TaskManagerTableModel* table_model) {
tab_table_->SetObserver(this);
SetContextMenuController(this);
kill_button_.reset(new views::NativeButton(
- l10n_util::GetString(IDS_TASK_MANAGER_KILL)));
- kill_button_->SetListener(this);
+ this, l10n_util::GetString(IDS_TASK_MANAGER_KILL)));
about_memory_link_.reset(new views::Link(
l10n_util::GetString(IDS_TASK_MANAGER_ABOUT_MEMORY_LINK)));
about_memory_link_->SetController(this);
@@ -893,9 +892,9 @@ void TaskManagerContents::GetFocused(std::vector<int>* focused) {
}
}
-// NativeButton::Listener implementation.
-void TaskManagerContents::ButtonPressed(views::NativeButton* sender) {
- if (sender == kill_button_)
+// ButtonListener implementation.
+void TaskManagerContents::ButtonPressed(views::Button* sender) {
+ if (sender == kill_button_.get())
task_manager_->KillSelectedProcesses();
}
diff --git a/chrome/browser/views/bookmark_bubble_view.cc b/chrome/browser/views/bookmark_bubble_view.cc
index 3e4db18..632357f 100644
--- a/chrome/browser/views/bookmark_bubble_view.cc
+++ b/chrome/browser/views/bookmark_bubble_view.cc
@@ -16,8 +16,6 @@
#include "chrome/common/l10n_util.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/resource_bundle.h"
-#include "chrome/views/controls/button/button.h"
-#include "chrome/views/controls/button/checkbox.h"
#include "chrome/views/controls/button/native_button.h"
#include "chrome/views/controls/text_field.h"
#include "grit/generated_resources.h"
@@ -207,11 +205,10 @@ void BookmarkBubbleView::Init() {
remove_link_->SetController(this);
edit_button_ = new NativeButton(
- l10n_util::GetString(IDS_BOOMARK_BUBBLE_OPTIONS));
- edit_button_->SetListener(this);
+ this, l10n_util::GetString(IDS_BOOMARK_BUBBLE_OPTIONS));
- close_button_ = new NativeButton(l10n_util::GetString(IDS_CLOSE), true);
- close_button_->SetListener(this);
+ close_button_ = new NativeButton(this, l10n_util::GetString(IDS_CLOSE));
+ close_button_->SetIsDefault(true);
parent_combobox_ = new ComboBox(&parent_model_);
parent_combobox_->SetSelectedItem(parent_model_.node_parent_index());
@@ -291,7 +288,7 @@ std::wstring BookmarkBubbleView::GetTitle() {
return std::wstring();
}
-void BookmarkBubbleView::ButtonPressed(views::NativeButton* sender) {
+void BookmarkBubbleView::ButtonPressed(views::Button* sender) {
if (sender == edit_button_) {
UserMetrics::RecordAction(L"BookmarkBubble_Edit", profile_);
ShowEditor();
diff --git a/chrome/browser/views/bookmark_bubble_view.h b/chrome/browser/views/bookmark_bubble_view.h
index 3109d8e..f94039a 100644
--- a/chrome/browser/views/bookmark_bubble_view.h
+++ b/chrome/browser/views/bookmark_bubble_view.h
@@ -7,7 +7,7 @@
#include "base/gfx/rect.h"
#include "chrome/browser/views/info_bubble.h"
-#include "chrome/views/controls/button/native_button.h"
+#include "chrome/views/controls/button/button.h"
#include "chrome/views/controls/combo_box.h"
#include "chrome/views/controls/link.h"
#include "chrome/views/view.h"
@@ -19,7 +19,7 @@ class BookmarkModel;
class BookmarkNode;
namespace views {
-class CheckBox;
+class NativeButton;
class TextField;
}
@@ -29,7 +29,7 @@ class TextField;
// instead use the static Show method.
class BookmarkBubbleView : public views::View,
public views::LinkController,
- public views::NativeButton::Listener,
+ public views::ButtonListener,
public views::ComboBox::Listener,
public InfoBubbleDelegate {
public:
@@ -102,7 +102,7 @@ class BookmarkBubbleView : public views::View,
virtual void LinkActivated(views::Link* source, int event_flags);
// ButtonListener method, closes the bubble or opens the edit dialog.
- virtual void ButtonPressed(views::NativeButton* sender);
+ virtual void ButtonPressed(views::Button* sender);
// ComboBox::Listener method. Changes the parent of the bookmark.
virtual void ItemChanged(views::ComboBox* combo_box,
diff --git a/chrome/browser/views/bookmark_editor_view.cc b/chrome/browser/views/bookmark_editor_view.cc
index d88aa9b7..b5a2f6d 100644
--- a/chrome/browser/views/bookmark_editor_view.cc
+++ b/chrome/browser/views/bookmark_editor_view.cc
@@ -15,6 +15,7 @@
#include "chrome/views/background.h"
#include "chrome/views/focus/focus_manager.h"
#include "chrome/views/grid_layout.h"
+#include "chrome/views/controls/button/native_button.h"
#include "chrome/views/controls/label.h"
#include "chrome/views/widget/widget.h"
#include "chrome/views/window/window.h"
@@ -24,6 +25,7 @@
#include "grit/locale_settings.h"
using base::Time;
+using views::Button;
using views::ColumnSet;
using views::GridLayout;
using views::Label;
@@ -168,7 +170,7 @@ void BookmarkEditorView::ContentsChanged(TextField* sender,
UserInputChanged();
}
-void BookmarkEditorView::ButtonPressed(NativeButton* sender) {
+void BookmarkEditorView::ButtonPressed(Button* sender) {
DCHECK(sender);
switch (sender->GetID()) {
case kNewGroupButtonID:
@@ -248,13 +250,12 @@ void BookmarkEditorView::Init() {
if (show_tree_) {
tree_view_ = new views::TreeView();
new_group_button_.reset(new views::NativeButton(
- l10n_util::GetString(IDS_BOOMARK_EDITOR_NEW_FOLDER_BUTTON)));
+ this, l10n_util::GetString(IDS_BOOMARK_EDITOR_NEW_FOLDER_BUTTON)));
new_group_button_->SetParentOwned(false);
tree_view_->SetContextMenuController(this);
tree_view_->SetRootShown(false);
new_group_button_->SetEnabled(false);
- new_group_button_->SetListener(this);
new_group_button_->SetID(kNewGroupButtonID);
}
diff --git a/chrome/browser/views/bookmark_editor_view.h b/chrome/browser/views/bookmark_editor_view.h
index 932d9b7..ed1b001 100644
--- a/chrome/browser/views/bookmark_editor_view.h
+++ b/chrome/browser/views/bookmark_editor_view.h
@@ -8,8 +8,7 @@
#include <set>
#include "chrome/browser/bookmarks/bookmark_model.h"
-#include "chrome/views/controls/button/checkbox.h"
-#include "chrome/views/controls/button/native_button.h"
+#include "chrome/views/controls/button/button.h"
#include "chrome/views/controls/menu/menu.h"
#include "chrome/views/controls/text_field.h"
#include "chrome/views/controls/tree/tree_node_model.h"
@@ -17,6 +16,7 @@
#include "chrome/views/window/dialog_delegate.h"
namespace views {
+class NativeButton;
class Window;
}
@@ -33,7 +33,7 @@ class Profile;
// To use BookmarkEditorView invoke the static show method.
class BookmarkEditorView : public views::View,
- public views::NativeButton::Listener,
+ public views::ButtonListener,
public views::TreeViewController,
public views::DialogDelegate,
public views::TextField::Controller,
@@ -111,8 +111,8 @@ class BookmarkEditorView : public views::View,
UINT message, TCHAR key, UINT repeat_count,
UINT flags) {}
- // NativeButton/CheckBox.
- virtual void ButtonPressed(views::NativeButton* sender);
+ // NativeButton.
+ virtual void ButtonPressed(views::Button* sender);
// Menu::Delegate method.
virtual void ExecuteCommand(int id);
diff --git a/chrome/browser/views/bug_report_view.cc b/chrome/browser/views/bug_report_view.cc
index 0256758..2ae5afa 100644
--- a/chrome/browser/views/bug_report_view.cc
+++ b/chrome/browser/views/bug_report_view.cc
@@ -167,12 +167,12 @@ void BugReportView::SetupControl() {
new views::TextField(views::TextField::STYLE_MULTILINE);
description_text_->SetHeightInLines(kDescriptionLines);
- include_page_source_checkbox_ = new views::CheckBox(
+ include_page_source_checkbox_ = new views::Checkbox(
l10n_util::GetString(IDS_BUGREPORT_INCLUDE_PAGE_SOURCE_CHKBOX));
- include_page_source_checkbox_->SetIsSelected(true);
- include_page_image_checkbox_ = new views::CheckBox(
+ include_page_source_checkbox_->SetChecked(true);
+ include_page_image_checkbox_ = new views::Checkbox(
l10n_util::GetString(IDS_BUGREPORT_INCLUDE_PAGE_IMAGE_CHKBOX));
- include_page_image_checkbox_->SetIsSelected(true);
+ include_page_image_checkbox_->SetChecked(true);
// Arranges controls by using GridLayout.
const int column_set_id = 0;
@@ -249,9 +249,9 @@ void BugReportView::ItemChanged(views::ComboBox* combo_box,
old_report_text_.clear();
}
include_page_source_checkbox_->SetEnabled(!is_phishing_report);
- include_page_source_checkbox_->SetIsSelected(!is_phishing_report);
+ include_page_source_checkbox_->SetChecked(!is_phishing_report);
include_page_image_checkbox_->SetEnabled(!is_phishing_report);
- include_page_image_checkbox_->SetIsSelected(!is_phishing_report);
+ include_page_image_checkbox_->SetChecked(!is_phishing_report);
GetDialogClientView()->UpdateDialogButtons();
}
@@ -448,7 +448,7 @@ void BugReportView::SendReport() {
}
// include the page image if we have one
- if (include_page_image_checkbox_->IsSelected() && png_data_.get()) {
+ if (include_page_image_checkbox_->checked() && png_data_.get()) {
post_body.append("--" + mime_boundary + "\r\n");
post_body.append("Content-Disposition: form-data; name=\"screenshot\"; "
"filename=\"screenshot.png\"\r\n");
@@ -463,7 +463,7 @@ void BugReportView::SendReport() {
}
// TODO(awalker): include the page source if we can get it
- if (include_page_source_checkbox_->IsSelected()) {
+ if (include_page_source_checkbox_->checked()) {
}
// terminate the body
diff --git a/chrome/browser/views/bug_report_view.h b/chrome/browser/views/bug_report_view.h
index 859f7fe..de3e4b4 100644
--- a/chrome/browser/views/bug_report_view.h
+++ b/chrome/browser/views/bug_report_view.h
@@ -6,7 +6,6 @@
#define CHROME_BROWSER_VIEWS_BUGREPORT_VIEW_H_
#include "chrome/browser/net/url_fetcher.h"
-#include "chrome/views/controls/button/native_button.h"
#include "chrome/views/controls/combo_box.h"
#include "chrome/views/controls/text_field.h"
#include "chrome/views/view.h"
@@ -14,7 +13,7 @@
#include "googleurl/src/gurl.h"
namespace views {
-class CheckBox;
+class Checkbox;
class Label;
class Throbber;
class Window;
@@ -99,8 +98,8 @@ class BugReportView : public views::View,
views::TextField* page_url_text_;
views::Label* description_label_;
views::TextField* description_text_;
- views::CheckBox* include_page_source_checkbox_;
- views::CheckBox* include_page_image_checkbox_;
+ views::Checkbox* include_page_source_checkbox_;
+ views::Checkbox* include_page_image_checkbox_;
scoped_ptr<BugReportComboBoxModel> bug_type_model_;
diff --git a/chrome/browser/views/clear_browsing_data.cc b/chrome/browser/views/clear_browsing_data.cc
index f57370d..5a0df99 100644
--- a/chrome/browser/views/clear_browsing_data.cc
+++ b/chrome/browser/views/clear_browsing_data.cc
@@ -10,7 +10,6 @@
#include "chrome/common/l10n_util.h"
#include "chrome/views/background.h"
#include "chrome/views/controls/button/checkbox.h"
-#include "chrome/views/controls/button/native_button.h"
#include "chrome/views/controls/label.h"
#include "chrome/views/controls/throbber.h"
#include "chrome/views/window/window.h"
@@ -252,12 +251,12 @@ bool ClearBrowsingDataView::IsDialogButtonEnabled(DialogButton button) const {
return false;
if (button == DIALOGBUTTON_OK) {
- return del_history_checkbox_->IsSelected() ||
- del_downloads_checkbox_->IsSelected() ||
- del_cache_checkbox_->IsSelected() ||
- del_cookies_checkbox_->IsSelected() ||
- del_passwords_checkbox_->IsSelected() ||
- del_form_data_checkbox_->IsSelected();
+ return del_history_checkbox_->checked() ||
+ del_downloads_checkbox_->checked() ||
+ del_cache_checkbox_->checked() ||
+ del_cookies_checkbox_->checked() ||
+ del_passwords_checkbox_->checked() ||
+ del_form_data_checkbox_->checked();
}
return true;
@@ -333,25 +332,25 @@ void ClearBrowsingDataView::ItemChanged(views::ComboBox* sender,
////////////////////////////////////////////////////////////////////////////////
// ClearBrowsingDataView, views::ButtonListener implementation:
-void ClearBrowsingDataView::ButtonPressed(views::NativeButton* sender) {
+void ClearBrowsingDataView::ButtonPressed(views::Button* sender) {
if (sender == del_history_checkbox_)
profile_->GetPrefs()->SetBoolean(prefs::kDeleteBrowsingHistory,
- del_history_checkbox_->IsSelected() ? true : false);
+ del_history_checkbox_->checked() ? true : false);
else if (sender == del_downloads_checkbox_)
profile_->GetPrefs()->SetBoolean(prefs::kDeleteDownloadHistory,
- del_downloads_checkbox_->IsSelected() ? true : false);
+ del_downloads_checkbox_->checked() ? true : false);
else if (sender == del_cache_checkbox_)
profile_->GetPrefs()->SetBoolean(prefs::kDeleteCache,
- del_cache_checkbox_->IsSelected() ? true : false);
+ del_cache_checkbox_->checked() ? true : false);
else if (sender == del_cookies_checkbox_)
profile_->GetPrefs()->SetBoolean(prefs::kDeleteCookies,
- del_cookies_checkbox_->IsSelected() ? true : false);
+ del_cookies_checkbox_->checked() ? true : false);
else if (sender == del_passwords_checkbox_)
profile_->GetPrefs()->SetBoolean(prefs::kDeletePasswords,
- del_passwords_checkbox_->IsSelected() ? true : false);
+ del_passwords_checkbox_->checked() ? true : false);
else if (sender == del_form_data_checkbox_)
profile_->GetPrefs()->SetBoolean(prefs::kDeleteFormData,
- del_form_data_checkbox_->IsSelected() ? true : false);
+ del_form_data_checkbox_->checked() ? true : false);
// When no checkbox is checked we should not have the action button enabled.
// This forces the button to evaluate what state they should be in.
@@ -361,11 +360,11 @@ void ClearBrowsingDataView::ButtonPressed(views::NativeButton* sender) {
////////////////////////////////////////////////////////////////////////////////
// ClearBrowsingDataView, private:
-views::CheckBox* ClearBrowsingDataView::AddCheckbox(const std::wstring& text,
+views::Checkbox* ClearBrowsingDataView::AddCheckbox(const std::wstring& text,
bool checked) {
- views::CheckBox* checkbox = new views::CheckBox(text);
- checkbox->SetIsSelected(checked);
- checkbox->SetListener(this);
+ views::Checkbox* checkbox = new views::Checkbox(text);
+ checkbox->SetChecked(checked);
+ checkbox->set_listener(this);
AddChildView(checkbox);
return checkbox;
}
@@ -394,8 +393,8 @@ void ClearBrowsingDataView::UpdateControlEnabledState() {
// Convenience method that returns true if the supplied checkbox is selected
// and enabled.
-static bool IsCheckBoxEnabledAndSelected(views::CheckBox* cb) {
- return (cb->IsEnabled() && cb->IsSelected());
+static bool IsCheckBoxEnabledAndSelected(views::Checkbox* cb) {
+ return (cb->IsEnabled() && cb->checked());
}
void ClearBrowsingDataView::OnDelete() {
diff --git a/chrome/browser/views/clear_browsing_data.h b/chrome/browser/views/clear_browsing_data.h
index 3a387fd..18912fc 100644
--- a/chrome/browser/views/clear_browsing_data.h
+++ b/chrome/browser/views/clear_browsing_data.h
@@ -6,14 +6,14 @@
#define CHROME_BROWSER_VIEWS_CLEAR_BROWSING_DATA_H__
#include "chrome/browser/browsing_data_remover.h"
-#include "chrome/views/controls/button/native_button.h"
+#include "chrome/views/controls/button/button.h"
#include "chrome/views/controls/combo_box.h"
#include "chrome/views/controls/label.h"
#include "chrome/views/view.h"
#include "chrome/views/window/dialog_delegate.h"
namespace views {
-class CheckBox;
+class Checkbox;
class Label;
class Throbber;
class Window;
@@ -32,7 +32,7 @@ class MessageLoop;
class ClearBrowsingDataView : public views::View,
public views::DialogDelegate,
public views::ComboBox::Model,
- public views::NativeButton::Listener,
+ public views::ButtonListener,
public views::ComboBox::Listener,
public BrowsingDataRemover::Observer {
public:
@@ -65,8 +65,8 @@ class ClearBrowsingDataView : public views::View,
virtual int GetItemCount(views::ComboBox* source);
virtual std::wstring GetItemAt(views::ComboBox* source, int index);
- // Overridden from views::NativeButton::Listener:
- virtual void ButtonPressed(views::NativeButton* sender);
+ // Overridden from views::ButtonListener:
+ virtual void ButtonPressed(views::Button* sender);
// Overridden from views::ComboBox::Listener:
virtual void ItemChanged(views::ComboBox* sender, int prev_index,
@@ -74,7 +74,7 @@ class ClearBrowsingDataView : public views::View,
private:
// Adds a new check-box as a child to the view.
- views::CheckBox* AddCheckbox(const std::wstring& text, bool checked);
+ views::Checkbox* AddCheckbox(const std::wstring& text, bool checked);
// Sets the controls on the UI to be enabled/disabled depending on whether we
// have a delete operation in progress or not.
@@ -92,12 +92,12 @@ class ClearBrowsingDataView : public views::View,
views::Label status_label_;
// Other UI elements.
views::Label* delete_all_label_;
- views::CheckBox* del_history_checkbox_;
- views::CheckBox* del_downloads_checkbox_;
- views::CheckBox* del_cache_checkbox_;
- views::CheckBox* del_cookies_checkbox_;
- views::CheckBox* del_passwords_checkbox_;
- views::CheckBox* del_form_data_checkbox_;
+ views::Checkbox* del_history_checkbox_;
+ views::Checkbox* del_downloads_checkbox_;
+ views::Checkbox* del_cache_checkbox_;
+ views::Checkbox* del_cookies_checkbox_;
+ views::Checkbox* del_passwords_checkbox_;
+ views::Checkbox* del_form_data_checkbox_;
views::Label* time_period_label_;
views::ComboBox* time_period_combobox_;
diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc
index de402da..9865d5d 100644
--- a/chrome/browser/views/download_item_view.cc
+++ b/chrome/browser/views/download_item_view.cc
@@ -252,13 +252,11 @@ DownloadItemView::DownloadItemView(DownloadItem* download,
warning_icon_ = rb.GetBitmapNamed(IDR_WARNING);
save_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_SAVE_DOWNLOAD));
- save_button_->set_enforce_dlu_min_size(false);
- save_button_->SetListener(this);
+ this, l10n_util::GetString(IDS_SAVE_DOWNLOAD));
+ save_button_->set_ignore_minimum_size(true);
discard_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_DISCARD_DOWNLOAD));
- discard_button_->SetListener(this);
- discard_button_->set_enforce_dlu_min_size(false);
+ this, l10n_util::GetString(IDS_DISCARD_DOWNLOAD));
+ discard_button_->set_ignore_minimum_size(true);
AddChildView(save_button_);
AddChildView(discard_button_);
std::wstring file_name = download->original_name().ToWStringHack();
@@ -387,7 +385,7 @@ void DownloadItemView::Layout() {
}
}
-void DownloadItemView::ButtonPressed(views::NativeButton* sender) {
+void DownloadItemView::ButtonPressed(views::Button* sender) {
if (sender == discard_button_) {
if (download_->state() == DownloadItem::IN_PROGRESS)
download_->Cancel(true);
diff --git a/chrome/browser/views/download_item_view.h b/chrome/browser/views/download_item_view.h
index 8f87c04..d266935 100644
--- a/chrome/browser/views/download_item_view.h
+++ b/chrome/browser/views/download_item_view.h
@@ -21,22 +21,24 @@
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "base/timer.h"
+#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/slide_animation.h"
#include "chrome/browser/cancelable_request.h"
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/icon_manager.h"
#include "chrome/views/event.h"
-#include "chrome/views/controls/button/native_button.h"
+#include "chrome/views/controls/button/button.h"
#include "chrome/views/view.h"
namespace views {
class Label;
+class NativeButton;
}
class BaseDownloadItemModel;
class DownloadShelfView;
class SkBitmap;
-class DownloadItemView : public views::NativeButton::Listener,
+class DownloadItemView : public views::ButtonListener,
public views::View,
public DownloadItem::Observer,
public AnimationDelegate {
@@ -59,8 +61,8 @@ class DownloadItemView : public views::NativeButton::Listener,
virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled);
virtual bool OnMouseDragged(const views::MouseEvent& event);
- // NativeButton::Listener implementation.
- virtual void ButtonPressed(views::NativeButton* sender);
+ // ButtonListener implementation.
+ virtual void ButtonPressed(views::Button* sender);
// AnimationDelegate implementation.
virtual void AnimationProgressed(const Animation* animation);
diff --git a/chrome/browser/views/first_run_bubble.cc b/chrome/browser/views/first_run_bubble.cc
index 4e4f111..6f06973 100644
--- a/chrome/browser/views/first_run_bubble.cc
+++ b/chrome/browser/views/first_run_bubble.cc
@@ -50,7 +50,7 @@ std::wstring GetDefaultSearchEngineName(Profile* profile) {
// Implements the client view inside the first run bubble. It is kind of a
// dialog-ish view, but is not a true dialog.
class FirstRunBubbleView : public views::View,
- public views::NativeButton::Listener,
+ public views::ButtonListener,
public views::FocusChangeListener {
public:
FirstRunBubbleView(FirstRunBubble* bubble_window, Profile* profile)
@@ -90,18 +90,17 @@ class FirstRunBubbleView : public views::View,
std::wstring keep_str =
l10n_util::GetStringF(IDS_FR_BUBBLE_OK,
GetDefaultSearchEngineName(profile));
- keep_button_ = new views::NativeButton(keep_str, true);
- keep_button_->SetListener(this);
+ keep_button_ = new views::NativeButton(this, keep_str);
+ keep_button_->SetIsDefault(true);
AddChildView(keep_button_);
std::wstring change_str = l10n_util::GetString(IDS_FR_BUBBLE_CHANGE);
- change_button_ = new views::NativeButton(change_str);
- change_button_->SetListener(this);
+ change_button_ = new views::NativeButton(this, change_str);
AddChildView(change_button_);
}
- // Overridden from NativeButton::Listener.
- virtual void ButtonPressed(views::NativeButton* sender) {
+ // Overridden from ButtonListener.
+ virtual void ButtonPressed(views::Button* sender) {
bubble_window_->Close();
if (change_button_ == sender) {
Browser* browser = BrowserList::GetLastActive();
@@ -171,13 +170,13 @@ class FirstRunBubbleView : public views::View,
views::NativeButton::kViewClassName) {
views::NativeButton* before =
static_cast<views::NativeButton*>(focused_before);
- before->SetDefaultButton(false);
+ before->SetIsDefault(false);
}
if (focused_now && focused_now->GetClassName() ==
views::NativeButton::kViewClassName) {
views::NativeButton* after =
static_cast<views::NativeButton*>(focused_now);
- after->SetDefaultButton(true);
+ after->SetIsDefault(true);
}
}
diff --git a/chrome/browser/views/first_run_customize_view.cc b/chrome/browser/views/first_run_customize_view.cc
index 1ec7af9..1d0b469 100644
--- a/chrome/browser/views/first_run_customize_view.cc
+++ b/chrome/browser/views/first_run_customize_view.cc
@@ -41,22 +41,22 @@ FirstRunCustomizeView::FirstRunCustomizeView(Profile* profile,
// the customize view, so that the user selection isn't lost when you uncheck
// and then open the Customize dialog. Therefore, we propagate the selection
// status of the default browser here.
- default_browser_->SetIsSelected(default_browser_checked);
+ default_browser_->SetChecked(default_browser_checked);
}
FirstRunCustomizeView::~FirstRunCustomizeView() {
}
-views::CheckBox* FirstRunCustomizeView::MakeCheckBox(int label_id) {
- views::CheckBox* cbox = new views::CheckBox(l10n_util::GetString(label_id));
- cbox->SetListener(this);
+views::Checkbox* FirstRunCustomizeView::MakeCheckBox(int label_id) {
+ views::Checkbox* cbox = new views::Checkbox(l10n_util::GetString(label_id));
+ cbox->set_listener(this);
AddChildView(cbox);
return cbox;
}
void FirstRunCustomizeView::SetupControls() {
using views::Label;
- using views::CheckBox;
+ using views::Checkbox;
main_label_ = new Label(l10n_util::GetString(IDS_FR_CUSTOMIZE_DLG_TEXT));
main_label_->SetMultiLine(true);
@@ -75,10 +75,10 @@ void FirstRunCustomizeView::SetupControls() {
// The two check boxes for the different shortcut creation.
desktop_shortcut_cbox_ = MakeCheckBox(IDS_FR_CUSTOM_SHORTCUT_DESKTOP);
- desktop_shortcut_cbox_->SetIsSelected(true);
+ desktop_shortcut_cbox_->SetChecked(true);
quick_shortcut_cbox_ = MakeCheckBox(IDS_FR_CUSTOM_SHORTCUT_QUICKL);
- quick_shortcut_cbox_->SetIsSelected(true);
+ quick_shortcut_cbox_->SetChecked(true);
}
gfx::Size FirstRunCustomizeView::GetPreferredSize() {
@@ -110,7 +110,7 @@ void FirstRunCustomizeView::Layout() {
import_cbox_->SetBounds(kPanelHorizMargin, next_v_space,
pref_size.width(), pref_size.height());
- import_cbox_->SetIsSelected(true);
+ import_cbox_->SetChecked(true);
int x_offset = import_cbox_->x() +
import_cbox_->width();
@@ -153,10 +153,10 @@ void FirstRunCustomizeView::Layout() {
AdjustDialogWidth(quick_shortcut_cbox_);
}
-void FirstRunCustomizeView::ButtonPressed(views::NativeButton* sender) {
+void FirstRunCustomizeView::ButtonPressed(views::Button* sender) {
if (import_cbox_ == sender) {
// Disable the import combobox if the user unchecks the checkbox.
- import_from_combo_->SetEnabled(import_cbox_->IsSelected());
+ import_from_combo_->SetEnabled(import_cbox_->checked());
}
}
@@ -187,15 +187,15 @@ bool FirstRunCustomizeView::Accept() {
desktop_shortcut_cbox_->SetEnabled(false);
quick_shortcut_cbox_->SetEnabled(false);
- if (desktop_shortcut_cbox_->IsSelected()) {
+ if (desktop_shortcut_cbox_->checked()) {
UserMetrics::RecordAction(L"FirstRunCustom_Do_DesktopShortcut", profile_);
CreateDesktopShortcut();
}
- if (quick_shortcut_cbox_->IsSelected()) {
+ if (quick_shortcut_cbox_->checked()) {
UserMetrics::RecordAction(L"FirstRunCustom_Do_QuickLShortcut", profile_);
CreateQuickLaunchShortcut();
}
- if (!import_cbox_->IsSelected()) {
+ if (!import_cbox_->checked()) {
UserMetrics::RecordAction(L"FirstRunCustom_No_Import", profile_);
} else {
int browser_selected = import_from_combo_->GetSelectedItem();
@@ -203,7 +203,7 @@ bool FirstRunCustomizeView::Accept() {
GetDefaultImportItems(),
window()->GetNativeWindow());
}
- if (default_browser_->IsSelected())
+ if (default_browser_->checked())
SetDefaultBrowser();
if (customize_observer_)
diff --git a/chrome/browser/views/first_run_customize_view.h b/chrome/browser/views/first_run_customize_view.h
index 9727bd8..b394254 100644
--- a/chrome/browser/views/first_run_customize_view.h
+++ b/chrome/browser/views/first_run_customize_view.h
@@ -6,17 +6,18 @@
#define CHROME_BROWSER_VIEWS_FIRST_RUN_CUSTOMIZE_VIEW_H_
#include "chrome/browser/views/first_run_view_base.h"
-#include "chrome/views/controls/button/native_button.h"
+#include "chrome/views/controls/button/button.h"
#include "chrome/views/controls/combo_box.h"
#include "chrome/views/view.h"
#include "chrome/views/window/dialog_delegate.h"
namespace views {
-class Label;
-class Window;
+class Checkbox;
+class ComboBox;
class ImageView;
+class Label;
class Separator;
-class ComboBox;
+class Window;
}
class Profile;
@@ -24,7 +25,7 @@ class Profile;
// FirstRunCustomizeView implements the dialog that allows the user to do
// some simple customizations during the first run.
class FirstRunCustomizeView : public FirstRunViewBase,
- public views::NativeButton::Listener,
+ public views::ButtonListener,
public views::ComboBox::Model {
public:
class CustomizeViewObserver {
@@ -49,8 +50,8 @@ class FirstRunCustomizeView : public FirstRunViewBase,
virtual bool Accept();
virtual bool Cancel();
- // Overridden form views::NativeButton::Listener.
- virtual void ButtonPressed(views::NativeButton* sender);
+ // Overridden form views::ButtonListener.
+ virtual void ButtonPressed(views::Button* sender);
// Overridden form views::ComboBox::Model.
virtual int GetItemCount(views::ComboBox* source);
@@ -68,14 +69,14 @@ class FirstRunCustomizeView : public FirstRunViewBase,
// Initializes the controls on the dialog.
void SetupControls();
- views::CheckBox* MakeCheckBox(int resource_id);
+ views::Checkbox* MakeCheckBox(int resource_id);
views::Label* main_label_;
- views::CheckBox* import_cbox_;
+ views::Checkbox* import_cbox_;
views::ComboBox* import_from_combo_;
views::Label* shortcuts_label_;
- views::CheckBox* desktop_shortcut_cbox_;
- views::CheckBox* quick_shortcut_cbox_;
+ views::Checkbox* desktop_shortcut_cbox_;
+ views::Checkbox* quick_shortcut_cbox_;
CustomizeViewObserver* customize_observer_;
diff --git a/chrome/browser/views/first_run_view.cc b/chrome/browser/views/first_run_view.cc
index d67f8b1..24f5e11 100644
--- a/chrome/browser/views/first_run_view.cc
+++ b/chrome/browser/views/first_run_view.cc
@@ -55,7 +55,7 @@ void FirstRunView::SetupControls() {
using views::Label;
using views::Link;
- default_browser_->SetIsSelected(true);
+ default_browser_->SetChecked(true);
welcome_label_ = new Label(l10n_util::GetString(IDS_FIRSTRUN_DLG_TEXT));
welcome_label_->SetMultiLine(true);
@@ -155,7 +155,7 @@ void FirstRunView::OpenCustomizeDialog() {
new FirstRunCustomizeView(profile_,
importer_host_,
this,
- default_browser_->IsSelected()))->Show();
+ default_browser_->checked()))->Show();
}
void FirstRunView::LinkActivated(views::Link* source, int event_flags) {
@@ -178,7 +178,7 @@ bool FirstRunView::Accept() {
customize_link_->SetEnabled(false);
CreateDesktopShortcut();
CreateQuickLaunchShortcut();
- if (default_browser_->IsSelected())
+ if (default_browser_->checked())
SetDefaultBrowser();
// Index 0 is the default browser.
FirstRun::ImportSettings(profile_, 0, GetDefaultImportItems(),
diff --git a/chrome/browser/views/first_run_view_base.cc b/chrome/browser/views/first_run_view_base.cc
index 90b04d3..c3df0e2 100644
--- a/chrome/browser/views/first_run_view_base.cc
+++ b/chrome/browser/views/first_run_view_base.cc
@@ -85,7 +85,7 @@ void FirstRunViewBase::SetupControls() {
AddChildView(separator_1_);
// The "make us default browser" check box.
- default_browser_ = new views::CheckBox(
+ default_browser_ = new views::Checkbox(
l10n_util::GetString(IDS_FR_CUSTOMIZE_DEFAULT_BROWSER));
default_browser_->SetMultiLine(true);
AddChildView(default_browser_);
diff --git a/chrome/browser/views/first_run_view_base.h b/chrome/browser/views/first_run_view_base.h
index 0790414..d4a08f7 100644
--- a/chrome/browser/views/first_run_view_base.h
+++ b/chrome/browser/views/first_run_view_base.h
@@ -10,7 +10,7 @@
#include "chrome/views/window/dialog_delegate.h"
namespace views {
-class CheckBox;
+class Checkbox;
class Window;
class ImageView;
class Separator;
@@ -77,7 +77,7 @@ class FirstRunViewBase : public views::View,
scoped_refptr<ImporterHost> importer_host_;
Profile* profile_;
- views::CheckBox* default_browser_;
+ views::Checkbox* default_browser_;
private:
// Initializes the controls on the dialog.
diff --git a/chrome/browser/views/hung_renderer_view.cc b/chrome/browser/views/hung_renderer_view.cc
index bf0555a4..9d239e4 100644
--- a/chrome/browser/views/hung_renderer_view.cc
+++ b/chrome/browser/views/hung_renderer_view.cc
@@ -113,7 +113,7 @@ void HungPagesTableModel::GetGroupRangeForItem(int item,
class HungRendererWarningView : public views::View,
public views::DialogDelegate,
- public views::NativeButton::Listener {
+ public views::ButtonListener {
public:
HungRendererWarningView();
~HungRendererWarningView();
@@ -131,8 +131,8 @@ class HungRendererWarningView : public views::View,
virtual bool Accept(bool window_closing);
virtual views::View* GetContentsView();
- // views::NativeButton::Listener overrides:
- virtual void ButtonPressed(views::NativeButton* sender);
+ // views::ButtonListener overrides:
+ virtual void ButtonPressed(views::Button* sender);
protected:
// views::View overrides:
@@ -303,9 +303,9 @@ views::View* HungRendererWarningView::GetContentsView() {
}
///////////////////////////////////////////////////////////////////////////////
-// HungRendererWarningView, views::NativeButton::Listener implementation:
+// HungRendererWarningView, views::ButtonListener implementation:
-void HungRendererWarningView::ButtonPressed(views::NativeButton* sender) {
+void HungRendererWarningView::ButtonPressed(views::Button* sender) {
if (sender == kill_button_) {
// Kill the process.
HANDLE process = contents_->process()->process().handle();
@@ -375,8 +375,7 @@ void HungRendererWarningView::Init() {
void HungRendererWarningView::CreateKillButtonView() {
kill_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_BROWSER_HANGMONITOR_RENDERER_END));
- kill_button_->SetListener(this);
+ this, l10n_util::GetString(IDS_BROWSER_HANGMONITOR_RENDERER_END));
kill_button_container_ = new ButtonContainer;
diff --git a/chrome/browser/views/importer_view.cc b/chrome/browser/views/importer_view.cc
index 9dbd9a4..c3dbbf0 100644
--- a/chrome/browser/views/importer_view.cc
+++ b/chrome/browser/views/importer_view.cc
@@ -186,23 +186,23 @@ void ImporterView::ImportComplete() {
window()->Close();
}
-views::CheckBox* ImporterView::InitCheckbox(const std::wstring& text,
+views::Checkbox* ImporterView::InitCheckbox(const std::wstring& text,
bool checked) {
- views::CheckBox* checkbox = new views::CheckBox(text);
- checkbox->SetIsSelected(checked);
+ views::Checkbox* checkbox = new views::Checkbox(text);
+ checkbox->SetChecked(checked);
return checkbox;
}
uint16 ImporterView::GetCheckedItems() {
uint16 items = NONE;
- if (history_checkbox_->IsEnabled() && history_checkbox_->IsSelected())
+ if (history_checkbox_->IsEnabled() && history_checkbox_->checked())
items |= HISTORY;
- if (favorites_checkbox_->IsEnabled() && favorites_checkbox_->IsSelected())
+ if (favorites_checkbox_->IsEnabled() && favorites_checkbox_->checked())
items |= FAVORITES;
- if (passwords_checkbox_->IsEnabled() && passwords_checkbox_->IsSelected())
+ if (passwords_checkbox_->IsEnabled() && passwords_checkbox_->checked())
items |= PASSWORDS;
if (search_engines_checkbox_->IsEnabled() &&
- search_engines_checkbox_->IsSelected())
+ search_engines_checkbox_->checked())
items |= SEARCH_ENGINES;
return items;
}
@@ -212,58 +212,38 @@ void ImporterView::SetCheckedItemsState(uint16 items) {
history_checkbox_->SetEnabled(true);
} else {
history_checkbox_->SetEnabled(false);
- history_checkbox_->SetIsSelected(false);
+ history_checkbox_->SetChecked(false);
}
if (items & FAVORITES) {
favorites_checkbox_->SetEnabled(true);
} else {
favorites_checkbox_->SetEnabled(false);
- favorites_checkbox_->SetIsSelected(false);
+ favorites_checkbox_->SetChecked(false);
}
if (items & PASSWORDS) {
passwords_checkbox_->SetEnabled(true);
} else {
passwords_checkbox_->SetEnabled(false);
- passwords_checkbox_->SetIsSelected(false);
+ passwords_checkbox_->SetChecked(false);
}
if (items & SEARCH_ENGINES) {
search_engines_checkbox_->SetEnabled(true);
} else {
search_engines_checkbox_->SetEnabled(false);
- search_engines_checkbox_->SetIsSelected(false);
+ search_engines_checkbox_->SetChecked(false);
}
}
void ImporterView::SetCheckedItems(uint16 items) {
- if (history_checkbox_->IsEnabled()) {
- if (items & HISTORY) {
- history_checkbox_->SetIsSelected(true);
- } else {
- history_checkbox_->SetIsSelected(false);
- }
- }
+ if (history_checkbox_->IsEnabled())
+ history_checkbox_->SetChecked(!!(items & HISTORY));
- if (favorites_checkbox_->IsEnabled()) {
- if (items & FAVORITES) {
- favorites_checkbox_->SetIsSelected(true);
- } else {
- favorites_checkbox_->SetIsSelected(false);
- }
- }
+ if (favorites_checkbox_->IsEnabled())
+ favorites_checkbox_->SetChecked(!!(items & FAVORITES));
- if (passwords_checkbox_->IsEnabled()) {
- if (items & PASSWORDS) {
- passwords_checkbox_->SetIsSelected(true);
- } else {
- passwords_checkbox_->SetIsSelected(false);
- }
- }
+ if (passwords_checkbox_->IsEnabled())
+ passwords_checkbox_->SetChecked(!!(items & PASSWORDS));
- if (search_engines_checkbox_->IsEnabled()) {
- if (items & SEARCH_ENGINES) {
- search_engines_checkbox_->SetIsSelected(true);
- } else {
- search_engines_checkbox_->SetIsSelected(false);
- }
- }
+ if (search_engines_checkbox_->IsEnabled())
+ search_engines_checkbox_->SetChecked(!!(items & SEARCH_ENGINES));
}
diff --git a/chrome/browser/views/importer_view.h b/chrome/browser/views/importer_view.h
index ef80f9d..9c6e7a8 100644
--- a/chrome/browser/views/importer_view.h
+++ b/chrome/browser/views/importer_view.h
@@ -12,7 +12,7 @@
#include "chrome/views/window/dialog_delegate.h"
namespace views {
-class CheckBox;
+class Checkbox;
class Label;
class Window;
}
@@ -61,7 +61,7 @@ class ImporterView : public views::View,
void SetupControl();
// Creates and initializes a new check-box.
- views::CheckBox* InitCheckbox(const std::wstring& text, bool checked);
+ views::Checkbox* InitCheckbox(const std::wstring& text, bool checked);
// Create a bitmap from the checkboxes of the view.
uint16 GetCheckedItems();
@@ -75,10 +75,10 @@ class ImporterView : public views::View,
views::Label* import_from_label_;
views::ComboBox* profile_combobox_;
views::Label* import_items_label_;
- views::CheckBox* history_checkbox_;
- views::CheckBox* favorites_checkbox_;
- views::CheckBox* passwords_checkbox_;
- views::CheckBox* search_engines_checkbox_;
+ views::Checkbox* history_checkbox_;
+ views::Checkbox* favorites_checkbox_;
+ views::Checkbox* passwords_checkbox_;
+ views::Checkbox* search_engines_checkbox_;
scoped_refptr<ImporterHost> importer_host_;
diff --git a/chrome/browser/views/infobars/infobars.cc b/chrome/browser/views/infobars/infobars.cc
index 52af060..91111e0 100644
--- a/chrome/browser/views/infobars/infobars.cc
+++ b/chrome/browser/views/infobars/infobars.cc
@@ -13,6 +13,7 @@
#include "chrome/common/slide_animation.h"
#include "chrome/views/background.h"
#include "chrome/views/controls/button/image_button.h"
+#include "chrome/views/controls/button/native_button.h"
#include "chrome/views/controls/image_view.h"
#include "chrome/views/controls/label.h"
#include "chrome/views/focus/external_focus_tracker.h"
@@ -372,11 +373,9 @@ ConfirmInfoBar::ConfirmInfoBar(ConfirmInfoBarDelegate* delegate)
initialized_(false),
AlertInfoBar(delegate) {
ok_button_ = new views::NativeButton(
- delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK));
- ok_button_->SetListener(this);
+ this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK));
cancel_button_ = new views::NativeButton(
- delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL));
- cancel_button_->SetListener(this);
+ this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL));
}
ConfirmInfoBar::~ConfirmInfoBar() {
@@ -422,9 +421,10 @@ void ConfirmInfoBar::ViewHierarchyChanged(bool is_add,
}
}
-// ConfirmInfoBar, views::NativeButton::Listener implementation: ---------------
+// ConfirmInfoBar, views::ButtonListener implementation: ---------------
-void ConfirmInfoBar::ButtonPressed(views::NativeButton* sender) {
+void ConfirmInfoBar::ButtonPressed(views::Button* sender) {
+ InfoBar::ButtonPressed(sender);
if (sender == ok_button_) {
if (GetDelegate()->Accept())
RemoveInfoBar();
diff --git a/chrome/browser/views/infobars/infobars.h b/chrome/browser/views/infobars/infobars.h
index c8b721dc..85388bd 100644
--- a/chrome/browser/views/infobars/infobars.h
+++ b/chrome/browser/views/infobars/infobars.h
@@ -8,16 +8,16 @@
#include "chrome/browser/tab_contents/infobar_delegate.h"
#include "chrome/common/animation.h"
#include "chrome/views/controls/button/button.h"
-#include "chrome/views/controls/button/native_button.h"
#include "chrome/views/controls/link.h"
class InfoBarContainer;
class SlideAnimation;
namespace views {
-class ImageButton;
class ExternalFocusTracker;
+class ImageButton;
class ImageView;
class Label;
+class NativeButton;
}
// This file contains implementations for some general purpose InfoBars. See
@@ -70,10 +70,10 @@ class InfoBar : public views::View,
// (Will lead to this InfoBar being closed).
void RemoveInfoBar() const;
- private:
// Overridden from views::ButtonListener:
virtual void ButtonPressed(views::Button* sender);
+ private:
// Overridden from AnimationDelegate:
virtual void AnimationProgressed(const Animation* animation);
virtual void AnimationEnded(const Animation* animation);
@@ -158,8 +158,7 @@ class LinkInfoBar : public InfoBar,
DISALLOW_COPY_AND_ASSIGN(LinkInfoBar);
};
-class ConfirmInfoBar : public AlertInfoBar,
- public views::NativeButton::Listener {
+class ConfirmInfoBar : public AlertInfoBar {
public:
explicit ConfirmInfoBar(ConfirmInfoBarDelegate* delegate);
virtual ~ConfirmInfoBar();
@@ -173,8 +172,8 @@ class ConfirmInfoBar : public AlertInfoBar,
views::View* parent,
views::View* child);
- // Overridden from views::NativeButton::Listener:
- virtual void ButtonPressed(views::NativeButton* sender);
+ // Overridden from views::ButtonListener:
+ virtual void ButtonPressed(views::Button* sender);
// Overridden from InfoBar:
virtual int GetAvailableWidth() const;
diff --git a/chrome/browser/views/keyword_editor_view.cc b/chrome/browser/views/keyword_editor_view.cc
index b646f10..3018cfa 100644
--- a/chrome/browser/views/keyword_editor_view.cc
+++ b/chrome/browser/views/keyword_editor_view.cc
@@ -21,8 +21,8 @@
#include "chrome/common/resource_bundle.h"
#include "chrome/common/stl_util-inl.h"
#include "chrome/views/background.h"
-#include "chrome/views/controls/button/checkbox.h"
#include "chrome/views/grid_layout.h"
+#include "chrome/views/controls/button/native_button.h"
#include "chrome/views/controls/text_field.h"
#include "chrome/views/widget/widget.h"
#include "chrome/views/window/dialog_delegate.h"
@@ -483,24 +483,21 @@ void KeywordEditorView::Init() {
table_view_->SetObserver(this);
add_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_SEARCH_ENGINES_EDITOR_NEW_BUTTON));
+ this, l10n_util::GetString(IDS_SEARCH_ENGINES_EDITOR_NEW_BUTTON));
add_button_->SetEnabled(url_model_->loaded());
- add_button_->SetListener(this);
-
+
edit_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_SEARCH_ENGINES_EDITOR_EDIT_BUTTON));
+ this, l10n_util::GetString(IDS_SEARCH_ENGINES_EDITOR_EDIT_BUTTON));
edit_button_->SetEnabled(false);
- edit_button_->SetListener(this);
-
+
remove_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_SEARCH_ENGINES_EDITOR_REMOVE_BUTTON));
+ this, l10n_util::GetString(IDS_SEARCH_ENGINES_EDITOR_REMOVE_BUTTON));
remove_button_->SetEnabled(false);
- remove_button_->SetListener(this);
-
+
make_default_button_ = new views::NativeButton(
+ this,
l10n_util::GetString(IDS_SEARCH_ENGINES_EDITOR_MAKE_DEFAULT_BUTTON));
make_default_button_->SetEnabled(false);
- make_default_button_->SetListener(this);
InitLayoutManager();
}
@@ -564,7 +561,7 @@ void KeywordEditorView::OnDoubleClick() {
ButtonPressed(edit_button_);
}
-void KeywordEditorView::ButtonPressed(views::NativeButton* sender) {
+void KeywordEditorView::ButtonPressed(views::Button* sender) {
if (sender == add_button_) {
EditKeywordController* controller =
new EditKeywordController(GetWidget()->GetNativeView(), NULL, this,
diff --git a/chrome/browser/views/keyword_editor_view.h b/chrome/browser/views/keyword_editor_view.h
index a011d61..7d2a95f 100644
--- a/chrome/browser/views/keyword_editor_view.h
+++ b/chrome/browser/views/keyword_editor_view.h
@@ -9,14 +9,14 @@
#include <map>
#include "chrome/browser/search_engines/template_url_model.h"
-#include "chrome/views/controls/button/native_button.h"
+#include "chrome/views/controls/button/button.h"
#include "chrome/views/controls/table/table_view.h"
#include "chrome/views/view.h"
#include "chrome/views/window/dialog_delegate.h"
namespace views {
-class CheckBox;
class Label;
+class NativeButton;
}
namespace {
@@ -116,7 +116,7 @@ class TemplateURLTableModel : public views::TableModel {
class KeywordEditorView : public views::View,
public views::TableViewObserver,
- public views::NativeButton::Listener,
+ public views::ButtonListener,
public TemplateURLModelObserver,
public views::DialogDelegate {
friend class KeywordEditorViewTest;
@@ -168,7 +168,7 @@ class KeywordEditorView : public views::View,
virtual void OnDoubleClick();
// Button::ButtonListener method.
- virtual void ButtonPressed(views::NativeButton* sender);
+ virtual void ButtonPressed(views::Button* sender);
// TemplateURLModelObserver notification.
virtual void OnTemplateURLModelChanged();
diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc
index 45e0cc2..1f73219 100644
--- a/chrome/browser/views/options/advanced_contents_view.cc
+++ b/chrome/browser/views/options/advanced_contents_view.cc
@@ -98,7 +98,7 @@ class AdvancedSection : public OptionsPageView {
// Convenience helpers for adding controls to specific layouts in an
// aesthetically pleasing way.
void AddWrappingCheckboxRow(views::GridLayout* layout,
- views::CheckBox* checkbox,
+ views::Checkbox* checkbox,
int id,
bool related_follows);
void AddWrappingLabelRow(views::GridLayout* layout,
@@ -172,7 +172,7 @@ void AdvancedSection::AddWrappingColumnSet(views::GridLayout* layout, int id) {
void AdvancedSection::AddDependentTwoColumnSet(views::GridLayout* layout,
int id) {
ColumnSet* column_set = layout->AddColumnSet(id);
- column_set->AddPaddingColumn(0, views::CheckBox::GetTextIndent());
+ column_set->AddPaddingColumn(0, views::Checkbox::GetTextIndent());
column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0,
GridLayout::USE_PREF, 0, 0);
column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
@@ -192,13 +192,13 @@ void AdvancedSection::AddTwoColumnSet(views::GridLayout* layout, int id) {
void AdvancedSection::AddIndentedColumnSet(views::GridLayout* layout, int id) {
ColumnSet* column_set = layout->AddColumnSet(id);
- column_set->AddPaddingColumn(0, views::CheckBox::GetTextIndent());
+ column_set->AddPaddingColumn(0, views::Checkbox::GetTextIndent());
column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
GridLayout::USE_PREF, 0, 0);
}
void AdvancedSection::AddWrappingCheckboxRow(views::GridLayout* layout,
- views::CheckBox* checkbox,
+ views::Checkbox* checkbox,
int id,
bool related_follows) {
checkbox->SetMultiLine(true);
@@ -319,15 +319,15 @@ class CookieBehaviorComboModel : public views::ComboBox::Model {
};
class PrivacySection : public AdvancedSection,
- public views::NativeButton::Listener,
+ public views::ButtonListener,
public views::ComboBox::Listener,
public views::LinkController {
public:
explicit PrivacySection(Profile* profile);
virtual ~PrivacySection() {}
- // Overridden from views::NativeButton::Listener:
- virtual void ButtonPressed(views::NativeButton* sender);
+ // Overridden from views::ButtonListener:
+ virtual void ButtonPressed(views::Button* sender);
// Overridden from views::ComboBox::Listener:
virtual void ItemChanged(views::ComboBox* sender,
@@ -348,11 +348,11 @@ class PrivacySection : public AdvancedSection,
private:
// Controls for this section:
views::Label* section_description_label_;
- views::CheckBox* enable_link_doctor_checkbox_;
- views::CheckBox* enable_suggest_checkbox_;
- views::CheckBox* enable_dns_prefetching_checkbox_;
- views::CheckBox* enable_safe_browsing_checkbox_;
- views::CheckBox* reporting_enabled_checkbox_;
+ views::Checkbox* enable_link_doctor_checkbox_;
+ views::Checkbox* enable_suggest_checkbox_;
+ views::Checkbox* enable_dns_prefetching_checkbox_;
+ views::Checkbox* enable_safe_browsing_checkbox_;
+ views::Checkbox* reporting_enabled_checkbox_;
views::Link* learn_more_link_;
views::Label* cookie_behavior_label_;
views::ComboBox* cookie_behavior_combobox_;
@@ -389,23 +389,23 @@ PrivacySection::PrivacySection(Profile* profile)
l10n_util::GetString(IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY)) {
}
-void PrivacySection::ButtonPressed(views::NativeButton* sender) {
+void PrivacySection::ButtonPressed(views::Button* sender) {
if (sender == enable_link_doctor_checkbox_) {
- bool enabled = enable_link_doctor_checkbox_->IsSelected();
+ bool enabled = enable_link_doctor_checkbox_->checked();
UserMetricsRecordAction(enabled ?
L"Options_LinkDoctorCheckbox_Enable" :
L"Options_LinkDoctorCheckbox_Disable",
profile()->GetPrefs());
alternate_error_pages_.SetValue(enabled);
} else if (sender == enable_suggest_checkbox_) {
- bool enabled = enable_suggest_checkbox_->IsSelected();
+ bool enabled = enable_suggest_checkbox_->checked();
UserMetricsRecordAction(enabled ?
L"Options_UseSuggestCheckbox_Enable" :
L"Options_UseSuggestCheckbox_Disable",
profile()->GetPrefs());
use_suggest_.SetValue(enabled);
} else if (sender == enable_dns_prefetching_checkbox_) {
- bool enabled = enable_dns_prefetching_checkbox_->IsSelected();
+ bool enabled = enable_dns_prefetching_checkbox_->checked();
UserMetricsRecordAction(enabled ?
L"Options_DnsPrefetchCheckbox_Enable" :
L"Options_DnsPrefetchCheckbox_Disable",
@@ -413,7 +413,7 @@ void PrivacySection::ButtonPressed(views::NativeButton* sender) {
dns_prefetch_enabled_.SetValue(enabled);
chrome_browser_net::EnableDnsPrefetch(enabled);
} else if (sender == enable_safe_browsing_checkbox_) {
- bool enabled = enable_safe_browsing_checkbox_->IsSelected();
+ bool enabled = enable_safe_browsing_checkbox_->checked();
UserMetricsRecordAction(enabled ?
L"Options_SafeBrowsingCheckbox_Enable" :
L"Options_SafeBrowsingCheckbox_Disable",
@@ -424,13 +424,13 @@ void PrivacySection::ButtonPressed(views::NativeButton* sender) {
MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
safe_browsing_service, &SafeBrowsingService::OnEnable, enabled));
} else if (sender == reporting_enabled_checkbox_) {
- bool enabled = reporting_enabled_checkbox_->IsSelected();
+ bool enabled = reporting_enabled_checkbox_->checked();
UserMetricsRecordAction(enabled ?
L"Options_MetricsReportingCheckbox_Enable" :
L"Options_MetricsReportingCheckbox_Disable",
profile()->GetPrefs());
ResolveMetricsReportingEnabled();
- if (enabled == reporting_enabled_checkbox_->IsSelected())
+ if (enabled == reporting_enabled_checkbox_->checked())
RestartMessageBox::ShowMessageBox(GetRootWindow());
enable_metrics_recording_.SetValue(enabled);
} else if (sender == show_cookies_button_) {
@@ -485,22 +485,22 @@ void PrivacySection::InitControlLayout() {
section_description_label_ = new views::Label(
l10n_util::GetString(IDS_OPTIONS_DISABLE_SERVICES));
- enable_link_doctor_checkbox_ = new views::CheckBox(
+ enable_link_doctor_checkbox_ = new views::Checkbox(
l10n_util::GetString(IDS_OPTIONS_LINKDOCTOR_PREF));
- enable_link_doctor_checkbox_->SetListener(this);
- enable_suggest_checkbox_ = new views::CheckBox(
+ enable_link_doctor_checkbox_->set_listener(this);
+ enable_suggest_checkbox_ = new views::Checkbox(
l10n_util::GetString(IDS_OPTIONS_SUGGEST_PREF));
- enable_suggest_checkbox_->SetListener(this);
- enable_dns_prefetching_checkbox_ = new views::CheckBox(
+ enable_suggest_checkbox_->set_listener(this);
+ enable_dns_prefetching_checkbox_ = new views::Checkbox(
l10n_util::GetString(IDS_NETWORK_DNS_PREFETCH_ENABLED_DESCRIPTION));
- enable_dns_prefetching_checkbox_->SetListener(this);
- enable_safe_browsing_checkbox_ = new views::CheckBox(
+ enable_dns_prefetching_checkbox_->set_listener(this);
+ enable_safe_browsing_checkbox_ = new views::Checkbox(
l10n_util::GetString(IDS_OPTIONS_SAFEBROWSING_ENABLEPROTECTION));
- enable_safe_browsing_checkbox_->SetListener(this);
- reporting_enabled_checkbox_ = new views::CheckBox(
+ enable_safe_browsing_checkbox_->set_listener(this);
+ reporting_enabled_checkbox_ = new views::Checkbox(
l10n_util::GetString(IDS_OPTIONS_ENABLE_LOGGING));
reporting_enabled_checkbox_->SetMultiLine(true);
- reporting_enabled_checkbox_->SetListener(this);
+ reporting_enabled_checkbox_->set_listener(this);
learn_more_link_ = new views::Link(l10n_util::GetString(IDS_LEARN_MORE));
learn_more_link_->SetController(this);
cookie_behavior_label_ = new views::Label(
@@ -510,8 +510,7 @@ void PrivacySection::InitControlLayout() {
allow_cookies_model_.get());
cookie_behavior_combobox_->SetListener(this);
show_cookies_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_OPTIONS_COOKIES_SHOWCOOKIES));
- show_cookies_button_->SetListener(this);
+ this, l10n_util::GetString(IDS_OPTIONS_COOKIES_SHOWCOOKIES));
GridLayout* layout = new GridLayout(contents_);
contents_->SetLayoutManager(layout);
@@ -571,21 +570,21 @@ void PrivacySection::InitControlLayout() {
void PrivacySection::NotifyPrefChanged(const std::wstring* pref_name) {
if (!pref_name || *pref_name == prefs::kAlternateErrorPagesEnabled) {
- enable_link_doctor_checkbox_->SetIsSelected(
+ enable_link_doctor_checkbox_->SetChecked(
alternate_error_pages_.GetValue());
}
if (!pref_name || *pref_name == prefs::kSearchSuggestEnabled) {
- enable_suggest_checkbox_->SetIsSelected(use_suggest_.GetValue());
+ enable_suggest_checkbox_->SetChecked(use_suggest_.GetValue());
}
if (!pref_name || *pref_name == prefs::kDnsPrefetchingEnabled) {
bool enabled = dns_prefetch_enabled_.GetValue();
- enable_dns_prefetching_checkbox_->SetIsSelected(enabled);
+ enable_dns_prefetching_checkbox_->SetChecked(enabled);
chrome_browser_net::EnableDnsPrefetch(enabled);
}
if (!pref_name || *pref_name == prefs::kSafeBrowsingEnabled)
- enable_safe_browsing_checkbox_->SetIsSelected(safe_browsing_.GetValue());
+ enable_safe_browsing_checkbox_->SetChecked(safe_browsing_.GetValue());
if (!pref_name || *pref_name == prefs::kMetricsReportingEnabled) {
- reporting_enabled_checkbox_->SetIsSelected(
+ reporting_enabled_checkbox_->SetChecked(
enable_metrics_recording_.GetValue());
ResolveMetricsReportingEnabled();
}
@@ -597,7 +596,7 @@ void PrivacySection::NotifyPrefChanged(const std::wstring* pref_name) {
}
void PrivacySection::ResolveMetricsReportingEnabled() {
- bool enabled = reporting_enabled_checkbox_->IsSelected();
+ bool enabled = reporting_enabled_checkbox_->checked();
GoogleUpdateSettings::SetCollectStatsConsent(enabled);
bool update_pref = GoogleUpdateSettings::GetCollectStatsConsent();
@@ -622,20 +621,20 @@ void PrivacySection::ResolveMetricsReportingEnabled() {
metrics->Stop();
}
- reporting_enabled_checkbox_->SetIsSelected(enabled);
+ reporting_enabled_checkbox_->SetChecked(enabled);
}
////////////////////////////////////////////////////////////////////////////////
// WebContentSection
class WebContentSection : public AdvancedSection,
- public views::NativeButton::Listener {
+ public views::ButtonListener {
public:
explicit WebContentSection(Profile* profile);
virtual ~WebContentSection() {}
- // Overridden from views::NativeButton::Listener:
- virtual void ButtonPressed(views::NativeButton* sender);
+ // Overridden from views::ButtonListener:
+ virtual void ButtonPressed(views::Button* sender);
protected:
// OptionsPageView overrides:
@@ -644,7 +643,7 @@ class WebContentSection : public AdvancedSection,
private:
// Controls for this section:
- views::CheckBox* popup_blocked_notification_checkbox_;
+ views::Checkbox* popup_blocked_notification_checkbox_;
views::Label* gears_label_;
views::NativeButton* gears_settings_button_;
@@ -661,10 +660,10 @@ WebContentSection::WebContentSection(Profile* profile)
l10n_util::GetString(IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT)) {
}
-void WebContentSection::ButtonPressed(views::NativeButton* sender) {
+void WebContentSection::ButtonPressed(views::Button* sender) {
if (sender == popup_blocked_notification_checkbox_) {
bool notification_disabled =
- popup_blocked_notification_checkbox_->IsSelected();
+ popup_blocked_notification_checkbox_->checked();
if (notification_disabled) {
UserMetricsRecordAction(L"Options_BlockAllPopups_Disable",
profile()->GetPrefs());
@@ -682,9 +681,9 @@ void WebContentSection::ButtonPressed(views::NativeButton* sender) {
void WebContentSection::InitControlLayout() {
AdvancedSection::InitControlLayout();
- popup_blocked_notification_checkbox_ = new views::CheckBox(
+ popup_blocked_notification_checkbox_ = new views::Checkbox(
l10n_util::GetString(IDS_OPTIONS_SHOWPOPUPBLOCKEDNOTIFICATION));
- popup_blocked_notification_checkbox_->SetListener(this);
+ popup_blocked_notification_checkbox_->set_listener(this);
if (l10n_util::GetTextDirection() == l10n_util::LEFT_TO_RIGHT) {
gears_label_ = new views::Label(
@@ -699,8 +698,8 @@ void WebContentSection::InitControlLayout() {
gears_label_ = new views::Label(gearssetting_group_name);
}
gears_settings_button_ = new views::NativeButton(
+ this,
l10n_util::GetString(IDS_OPTIONS_GEARSSETTINGS_CONFIGUREGEARS_BUTTON));
- gears_settings_button_->SetListener(this);
GridLayout* layout = new GridLayout(contents_);
contents_->SetLayoutManager(layout);
@@ -722,7 +721,7 @@ void WebContentSection::InitControlLayout() {
void WebContentSection::NotifyPrefChanged(const std::wstring* pref_name) {
if (!pref_name || *pref_name == prefs::kBlockPopups) {
- popup_blocked_notification_checkbox_->SetIsSelected(
+ popup_blocked_notification_checkbox_->SetChecked(
!disable_popup_blocked_notification_pref_.GetValue());
}
}
@@ -769,14 +768,14 @@ class MixedContentComboModel : public views::ComboBox::Model {
};
class SecuritySection : public AdvancedSection,
- public views::NativeButton::Listener,
+ public views::ButtonListener,
public views::ComboBox::Listener {
public:
explicit SecuritySection(Profile* profile);
virtual ~SecuritySection() {}
- // Overridden from views::NativeButton::Listener:
- virtual void ButtonPressed(views::NativeButton* sender);
+ // Overridden from views::ButtonListener:
+ virtual void ButtonPressed(views::Button* sender);
// Overridden from views::ComboBox::Listener:
virtual void ItemChanged(views::ComboBox* sender,
@@ -793,8 +792,8 @@ class SecuritySection : public AdvancedSection,
views::Label* reset_file_handlers_label_;
views::NativeButton* reset_file_handlers_button_;
views::Label* ssl_info_label_;
- views::CheckBox* enable_ssl2_checkbox_;
- views::CheckBox* check_for_cert_revocation_checkbox_;
+ views::Checkbox* enable_ssl2_checkbox_;
+ views::Checkbox* check_for_cert_revocation_checkbox_;
views::Label* mixed_content_info_label_;
views::ComboBox* mixed_content_combobox_;
views::Label* manage_certificates_label_;
@@ -823,13 +822,13 @@ SecuritySection::SecuritySection(Profile* profile)
l10n_util::GetString(IDS_OPTIONS_ADVANCED_SECTION_TITLE_SECURITY)) {
}
-void SecuritySection::ButtonPressed(views::NativeButton* sender) {
+void SecuritySection::ButtonPressed(views::Button* sender) {
if (sender == reset_file_handlers_button_) {
profile()->GetDownloadManager()->ResetAutoOpenFiles();
UserMetricsRecordAction(L"Options_ResetAutoOpenFiles",
profile()->GetPrefs());
} else if (sender == enable_ssl2_checkbox_) {
- bool enabled = enable_ssl2_checkbox_->IsSelected();
+ bool enabled = enable_ssl2_checkbox_->checked();
if (enabled) {
UserMetricsRecordAction(L"Options_SSL2_Enable", NULL);
} else {
@@ -837,7 +836,7 @@ void SecuritySection::ButtonPressed(views::NativeButton* sender) {
}
net::SSLConfigService::SetSSL2Enabled(enabled);
} else if (sender == check_for_cert_revocation_checkbox_) {
- bool enabled = check_for_cert_revocation_checkbox_->IsSelected();
+ bool enabled = check_for_cert_revocation_checkbox_->checked();
if (enabled) {
UserMetricsRecordAction(L"Options_CheckCertRevocation_Enable", NULL);
} else {
@@ -878,16 +877,15 @@ void SecuritySection::InitControlLayout() {
reset_file_handlers_label_ = new views::Label(
l10n_util::GetString(IDS_OPTIONS_AUTOOPENFILETYPES_INFO));
reset_file_handlers_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_OPTIONS_AUTOOPENFILETYPES_RESETTODEFAULT));
- reset_file_handlers_button_->SetListener(this);
+ this, l10n_util::GetString(IDS_OPTIONS_AUTOOPENFILETYPES_RESETTODEFAULT));
ssl_info_label_ = new views::Label(
l10n_util::GetString(IDS_OPTIONS_SSL_GROUP_DESCRIPTION));
- enable_ssl2_checkbox_ = new views::CheckBox(
+ enable_ssl2_checkbox_ = new views::Checkbox(
l10n_util::GetString(IDS_OPTIONS_SSL_USESSL2));
- enable_ssl2_checkbox_->SetListener(this);
- check_for_cert_revocation_checkbox_ = new views::CheckBox(
+ enable_ssl2_checkbox_->set_listener(this);
+ check_for_cert_revocation_checkbox_ = new views::Checkbox(
l10n_util::GetString(IDS_OPTIONS_SSL_CHECKREVOCATION));
- check_for_cert_revocation_checkbox_->SetListener(this);
+ check_for_cert_revocation_checkbox_->set_listener(this);
mixed_content_info_label_ = new views::Label(
l10n_util::GetString(IDS_OPTIONS_MIXED_CONTENT_LABEL));
mixed_content_model_.reset(new MixedContentComboModel);
@@ -897,8 +895,7 @@ void SecuritySection::InitControlLayout() {
manage_certificates_label_ = new views::Label(
l10n_util::GetString(IDS_OPTIONS_CERTIFICATES_LABEL));
manage_certificates_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_OPTIONS_CERTIFICATES_MANAGE_BUTTON));
- manage_certificates_button_->SetListener(this);
+ this, l10n_util::GetString(IDS_OPTIONS_CERTIFICATES_MANAGE_BUTTON));
GridLayout* layout = new GridLayout(contents_);
contents_->SetLayoutManager(layout);
@@ -962,8 +959,8 @@ void SecuritySection::NotifyPrefChanged(const std::wstring* pref_name) {
if (!pref_name) {
net::SSLConfig config;
if (net::SSLConfigService::GetSSLConfigNow(&config)) {
- enable_ssl2_checkbox_->SetIsSelected(config.ssl2_enabled);
- check_for_cert_revocation_checkbox_->SetIsSelected(
+ enable_ssl2_checkbox_->SetChecked(config.ssl2_enabled);
+ check_for_cert_revocation_checkbox_->SetChecked(
config.rev_checking_enabled);
} else {
enable_ssl2_checkbox_->SetEnabled(false);
@@ -1014,13 +1011,13 @@ class OpenConnectionDialogTask : public Task {
} // namespace
class NetworkSection : public AdvancedSection,
- public views::NativeButton::Listener {
+ public views::ButtonListener {
public:
explicit NetworkSection(Profile* profile);
virtual ~NetworkSection() {}
- // Overridden from views::NativeButton::Listener:
- virtual void ButtonPressed(views::NativeButton* sender);
+ // Overridden from views::ButtonListener:
+ virtual void ButtonPressed(views::Button* sender);
protected:
// OptionsPageView overrides:
@@ -1042,7 +1039,7 @@ NetworkSection::NetworkSection(Profile* profile)
l10n_util::GetString(IDS_OPTIONS_ADVANCED_SECTION_TITLE_NETWORK)) {
}
-void NetworkSection::ButtonPressed(views::NativeButton* sender) {
+void NetworkSection::ButtonPressed(views::Button* sender) {
if (sender == change_proxies_button_) {
UserMetricsRecordAction(L"Options_ChangeProxies", NULL);
base::Thread* thread = g_browser_process->file_thread();
@@ -1057,8 +1054,7 @@ void NetworkSection::InitControlLayout() {
change_proxies_label_ = new views::Label(
l10n_util::GetString(IDS_OPTIONS_PROXIES_LABEL));
change_proxies_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_OPTIONS_PROXIES_CONFIGURE_BUTTON));
- change_proxies_button_->SetListener(this);
+ this, l10n_util::GetString(IDS_OPTIONS_PROXIES_CONFIGURE_BUTTON));
GridLayout* layout = new GridLayout(contents_);
contents_->SetLayoutManager(layout);
diff --git a/chrome/browser/views/options/advanced_page_view.cc b/chrome/browser/views/options/advanced_page_view.cc
index 9e9f1e3..fc258f6 100644
--- a/chrome/browser/views/options/advanced_page_view.cc
+++ b/chrome/browser/views/options/advanced_page_view.cc
@@ -152,9 +152,9 @@ void AdvancedPageView::ResetToDefaults() {
}
///////////////////////////////////////////////////////////////////////////////
-// AdvancedPageView, views::NativeButton::Listener implementation:
+// AdvancedPageView, views::ButtonListener implementation:
-void AdvancedPageView::ButtonPressed(views::NativeButton* sender) {
+void AdvancedPageView::ButtonPressed(views::Button* sender) {
if (sender == reset_to_default_button_) {
UserMetricsRecordAction(L"Options_ResetToDefaults", NULL);
ResetDefaultsConfirmBox::ShowConfirmBox(GetRootWindow(), this);
@@ -166,8 +166,7 @@ void AdvancedPageView::ButtonPressed(views::NativeButton* sender) {
void AdvancedPageView::InitControlLayout() {
reset_to_default_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_OPTIONS_RESET));
- reset_to_default_button_->SetListener(this);
+ this, l10n_util::GetString(IDS_OPTIONS_RESET));
advanced_scroll_view_ = new AdvancedScrollViewContainer(profile());
using views::GridLayout;
diff --git a/chrome/browser/views/options/advanced_page_view.h b/chrome/browser/views/options/advanced_page_view.h
index 54aa8a1..1a9119e 100644
--- a/chrome/browser/views/options/advanced_page_view.h
+++ b/chrome/browser/views/options/advanced_page_view.h
@@ -6,17 +6,20 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_ADVANCED_PAGE_VIEW_H_
#include "chrome/browser/views/options/options_page_view.h"
-#include "chrome/views/controls/button/native_button.h"
+#include "chrome/views/controls/button/button.h"
class AdvancedOptionsListModel;
class AdvancedScrollViewContainer;
class PrefService;
+namespace views {
+class NativeButton;
+}
///////////////////////////////////////////////////////////////////////////////
// AdvancedPageView
class AdvancedPageView : public OptionsPageView,
- public views::NativeButton::Listener {
+ public views::ButtonListener {
public:
explicit AdvancedPageView(Profile* profile);
virtual ~AdvancedPageView();
@@ -24,8 +27,8 @@ class AdvancedPageView : public OptionsPageView,
// Resets all prefs to their default values.
void ResetToDefaults();
- // views::NativeButton::Listener implementation:
- virtual void ButtonPressed(views::NativeButton* sender);
+ // views::ButtonListener implementation:
+ virtual void ButtonPressed(views::Button* sender);
protected:
// OptionsPageView implementation:
diff --git a/chrome/browser/views/options/content_page_view.cc b/chrome/browser/views/options/content_page_view.cc
index 18a7550..e6d6e40 100644
--- a/chrome/browser/views/options/content_page_view.cc
+++ b/chrome/browser/views/options/content_page_view.cc
@@ -23,8 +23,6 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "chrome/common/resource_bundle.h"
-#include "chrome/views/controls/button/checkbox.h"
-#include "chrome/views/controls/button/native_button.h"
#include "chrome/views/controls/button/radio_button.h"
#include "chrome/views/controls/text_field.h"
#include "chrome/views/grid_layout.h"
@@ -207,9 +205,9 @@ void ContentPageView::FileSelected(const std::wstring& path, void* params) {
}
///////////////////////////////////////////////////////////////////////////////
-// ContentPageView, views::NativeButton::Listener implementation:
+// ContentPageView, views::ButtonListener implementation:
-void ContentPageView::ButtonPressed(views::NativeButton* sender) {
+void ContentPageView::ButtonPressed(views::Button* sender) {
if (sender == download_browse_button_) {
const std::wstring dialog_title =
l10n_util::GetString(IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE);
@@ -221,7 +219,7 @@ void ContentPageView::ButtonPressed(views::NativeButton* sender) {
GetRootWindow(),
NULL);
} else if (sender == download_ask_for_save_location_checkbox_) {
- bool enabled = download_ask_for_save_location_checkbox_->IsSelected();
+ bool enabled = download_ask_for_save_location_checkbox_->checked();
if (enabled) {
UserMetricsRecordAction(L"Options_AskForSaveLocation_Enable",
profile()->GetPrefs());
@@ -232,7 +230,7 @@ void ContentPageView::ButtonPressed(views::NativeButton* sender) {
ask_for_save_location_.SetValue(enabled);
} else if (sender == passwords_asktosave_radio_ ||
sender == passwords_neversave_radio_) {
- bool enabled = passwords_asktosave_radio_->IsSelected();
+ bool enabled = passwords_asktosave_radio_->checked();
if (enabled) {
UserMetricsRecordAction(L"Options_PasswordManager_Enable",
profile()->GetPrefs());
@@ -248,7 +246,7 @@ void ContentPageView::ButtonPressed(views::NativeButton* sender) {
UserMetricsRecordAction(L"Options_ShowPasswordManager", NULL);
PasswordManagerView::Show(profile());
} else if (sender == form_autofill_checkbox_) {
- bool enabled = form_autofill_checkbox_->IsSelected();
+ bool enabled = form_autofill_checkbox_->checked();
if (enabled) {
UserMetricsRecordAction(L"Options_FormAutofill_Enable",
profile()->GetPrefs());
@@ -319,18 +317,18 @@ void ContentPageView::NotifyPrefChanged(const std::wstring* pref_name) {
UpdateDownloadDirectoryDisplay();
if (!pref_name || *pref_name == prefs::kPromptForDownload) {
- download_ask_for_save_location_checkbox_->SetIsSelected(
+ download_ask_for_save_location_checkbox_->SetChecked(
ask_for_save_location_.GetValue());
}
if (!pref_name || *pref_name == prefs::kPasswordManagerEnabled) {
if (ask_to_save_passwords_.GetValue()) {
- passwords_asktosave_radio_->SetIsSelected(true);
+ passwords_asktosave_radio_->SetChecked(true);
} else {
- passwords_neversave_radio_->SetIsSelected(true);
+ passwords_neversave_radio_->SetChecked(true);
}
}
if (!pref_name || *pref_name == prefs::kFormAutofillEnabled) {
- form_autofill_checkbox_->SetIsSelected(form_autofill_.GetValue());
+ form_autofill_checkbox_->SetChecked(form_autofill_.GetValue());
}
}
@@ -358,12 +356,11 @@ void ContentPageView::Layout() {
void ContentPageView::InitDownloadLocation() {
download_default_download_location_display_ = new FileDisplayArea;
download_browse_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_BUTTON));
- download_browse_button_->SetListener(this);
+ this, l10n_util::GetString(IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_BUTTON));
- download_ask_for_save_location_checkbox_ = new views::CheckBox(
+ download_ask_for_save_location_checkbox_ = new views::Checkbox(
l10n_util::GetString(IDS_OPTIONS_DOWNLOADLOCATION_ASKFORSAVELOCATION));
- download_ask_for_save_location_checkbox_->SetListener(this);
+ download_ask_for_save_location_checkbox_->set_listener(this);
download_ask_for_save_location_checkbox_->SetMultiLine(true);
using views::GridLayout;
@@ -407,19 +404,17 @@ void ContentPageView::InitPasswordSavingGroup() {
passwords_asktosave_radio_ = new views::RadioButton(
l10n_util::GetString(IDS_OPTIONS_PASSWORDS_ASKTOSAVE),
kPasswordSavingRadioGroup);
- passwords_asktosave_radio_->SetListener(this);
+ passwords_asktosave_radio_->set_listener(this);
passwords_asktosave_radio_->SetMultiLine(true);
passwords_neversave_radio_ = new views::RadioButton(
l10n_util::GetString(IDS_OPTIONS_PASSWORDS_NEVERSAVE),
kPasswordSavingRadioGroup);
- passwords_neversave_radio_->SetListener(this);
+ passwords_neversave_radio_->set_listener(this);
passwords_neversave_radio_->SetMultiLine(true);
passwords_show_passwords_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_OPTIONS_PASSWORDS_SHOWPASSWORDS));
- passwords_show_passwords_button_->SetListener(this);
+ this, l10n_util::GetString(IDS_OPTIONS_PASSWORDS_SHOWPASSWORDS));
passwords_exceptions_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_OPTIONS_PASSWORDS_EXCEPTIONS));
- passwords_exceptions_button_->SetListener(this);
+ this, l10n_util::GetString(IDS_OPTIONS_PASSWORDS_EXCEPTIONS));
using views::GridLayout;
using views::ColumnSet;
@@ -457,9 +452,9 @@ void ContentPageView::InitPasswordSavingGroup() {
}
void ContentPageView::InitFormAutofillGroup() {
- form_autofill_checkbox_ = new views::CheckBox(
+ form_autofill_checkbox_ = new views::Checkbox(
l10n_util::GetString(IDS_AUTOFILL_SAVEFORMS));
- form_autofill_checkbox_->SetListener(this);
+ form_autofill_checkbox_->set_listener(this);
form_autofill_checkbox_->SetMultiLine(true);
using views::GridLayout;
@@ -488,8 +483,8 @@ void ContentPageView::InitFontsLangGroup() {
fonts_and_languages_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
fonts_and_languages_label_->SetMultiLine(true);
change_content_fonts_button_ = new views::NativeButton(
+ this,
l10n_util::GetString(IDS_OPTIONS_FONTSETTINGS_CONFIGUREFONTS_BUTTON));
- change_content_fonts_button_->SetListener(this);
using views::GridLayout;
using views::ColumnSet;
diff --git a/chrome/browser/views/options/content_page_view.h b/chrome/browser/views/options/content_page_view.h
index 3d68bb5..508b568 100644
--- a/chrome/browser/views/options/content_page_view.h
+++ b/chrome/browser/views/options/content_page_view.h
@@ -8,11 +8,12 @@
#include "chrome/browser/views/options/options_page_view.h"
#include "chrome/browser/shell_dialogs.h"
#include "chrome/common/pref_member.h"
-#include "chrome/views/controls/button/native_button.h"
+#include "chrome/views/controls/button/button.h"
#include "chrome/views/view.h"
namespace views {
-class CheckBox;
+class Checkbox;
+class NativeButton;
class RadioButton;
}
class FileDisplayArea;
@@ -23,14 +24,14 @@ class PrefService;
// ContentPageView
class ContentPageView : public OptionsPageView,
- public views::NativeButton::Listener,
+ public views::ButtonListener,
public SelectFileDialog::Listener {
public:
explicit ContentPageView(Profile* profile);
virtual ~ContentPageView();
- // views::NativeButton::Listener implementation:
- virtual void ButtonPressed(views::NativeButton* sender);
+ // views::ButtonListener implementation:
+ virtual void ButtonPressed(views::Button* sender);
// SelectFileDialog::Listener implementation:
virtual void FileSelected(const std::wstring& path, void* params);
@@ -61,7 +62,7 @@ class ContentPageView : public OptionsPageView,
OptionsGroupView* download_location_group_;
FileDisplayArea* download_default_download_location_display_;
views::NativeButton* download_browse_button_;
- views::CheckBox* download_ask_for_save_location_checkbox_;
+ views::Checkbox* download_ask_for_save_location_checkbox_;
scoped_refptr<SelectFileDialog> select_file_dialog_;
// Controls for the Password Saving group
@@ -73,7 +74,7 @@ class ContentPageView : public OptionsPageView,
// Controls for the Form Autofill group
OptionsGroupView* form_autofill_group_;
- views::CheckBox* form_autofill_checkbox_;
+ views::Checkbox* form_autofill_checkbox_;
// Controls for the Popup Blocking group.
OptionsGroupView* popups_group_;
diff --git a/chrome/browser/views/options/cookies_view.cc b/chrome/browser/views/options/cookies_view.cc
index e31fc1e0..2bdc149 100644
--- a/chrome/browser/views/options/cookies_view.cc
+++ b/chrome/browser/views/options/cookies_view.cc
@@ -18,6 +18,7 @@
#include "chrome/views/border.h"
#include "chrome/views/grid_layout.h"
#include "chrome/views/controls/label.h"
+#include "chrome/views/controls/button/native_button.h"
#include "chrome/views/controls/text_field.h"
#include "chrome/views/controls/table/table_view.h"
#include "grit/generated_resources.h"
@@ -571,9 +572,9 @@ void CookiesView::UpdateSearchResults() {
}
///////////////////////////////////////////////////////////////////////////////
-// CookiesView, views::NativeButton::listener implementation:
+// CookiesView, views::Buttonlistener implementation:
-void CookiesView::ButtonPressed(views::NativeButton* sender) {
+void CookiesView::ButtonPressed(views::Button* sender) {
if (sender == remove_button_) {
cookies_table_->RemoveSelectedCookies();
} else if (sender == remove_all_button_) {
@@ -704,8 +705,7 @@ void CookiesView::Init() {
search_field_ = new views::TextField;
search_field_->SetController(this);
clear_search_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_COOKIES_CLEAR_SEARCH_LABEL));
- clear_search_button_->SetListener(this);
+ this, l10n_util::GetString(IDS_COOKIES_CLEAR_SEARCH_LABEL));
description_label_ = new views::Label(
l10n_util::GetString(IDS_COOKIES_INFO_LABEL));
description_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
@@ -728,11 +728,9 @@ void CookiesView::Init() {
true));
cookies_table_->SetSortDescriptors(sort);
remove_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_COOKIES_REMOVE_LABEL));
- remove_button_->SetListener(this);
+ this, l10n_util::GetString(IDS_COOKIES_REMOVE_LABEL));
remove_all_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_COOKIES_REMOVE_ALL_LABEL));
- remove_all_button_->SetListener(this);
+ this, l10n_util::GetString(IDS_COOKIES_REMOVE_ALL_LABEL));
using views::GridLayout;
using views::ColumnSet;
diff --git a/chrome/browser/views/options/cookies_view.h b/chrome/browser/views/options/cookies_view.h
index 1c6aacc..ab8b213 100644
--- a/chrome/browser/views/options/cookies_view.h
+++ b/chrome/browser/views/options/cookies_view.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_VIEWS_OPTIONS_COOKIES_VIEW_H__
#include "base/task.h"
-#include "chrome/views/controls/button/native_button.h"
+#include "chrome/views/controls/button/button.h"
#include "chrome/views/controls/table/table_view.h"
#include "chrome/views/controls/text_field.h"
#include "chrome/views/view.h"
@@ -15,6 +15,7 @@
namespace views {
class Label;
+class NativeButton;
}
class CookieInfoView;
class CookiesTableModel;
@@ -24,7 +25,7 @@ class Timer;
class CookiesView : public views::View,
public views::DialogDelegate,
- public views::NativeButton::Listener,
+ public views::ButtonListener,
public views::TableViewObserver,
public views::TextField::Controller {
public:
@@ -36,8 +37,8 @@ class CookiesView : public views::View,
// Updates the display to show only the search results.
void UpdateSearchResults();
- // views::NativeButton::Listener implementation:
- virtual void ButtonPressed(views::NativeButton* sender);
+ // views::ButtonListener implementation:
+ virtual void ButtonPressed(views::Button* sender);
// views::TableViewObserver implementation:
virtual void OnSelectionChanged();
diff --git a/chrome/browser/views/options/fonts_page_view.cc b/chrome/browser/views/options/fonts_page_view.cc
index d33b23c..7433a65 100644
--- a/chrome/browser/views/options/fonts_page_view.cc
+++ b/chrome/browser/views/options/fonts_page_view.cc
@@ -24,9 +24,7 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "chrome/common/resource_bundle.h"
-#include "chrome/views/controls/button/checkbox.h"
#include "chrome/views/controls/button/native_button.h"
-#include "chrome/views/controls/button/radio_button.h"
#include "chrome/views/controls/text_field.h"
#include "chrome/views/grid_layout.h"
#include "chrome/views/widget/widget.h"
@@ -244,7 +242,7 @@ FontsPageView::FontsPageView(Profile* profile)
FontsPageView::~FontsPageView() {
}
-void FontsPageView::ButtonPressed(views::NativeButton* sender) {
+void FontsPageView::ButtonPressed(views::Button* sender) {
HWND owning_hwnd = GetAncestor(GetWidget()->GetNativeView(), GA_ROOT);
std::wstring font_name;
int font_size = 0;
@@ -375,9 +373,9 @@ void FontsPageView::InitFontLayout() {
// Fixed width.
fixed_width_font_display_view_ = new FontDisplayView;
fixed_width_font_change_page_button_ = new views::NativeButton(
+ this,
l10n_util::GetString(
IDS_FONT_LANGUAGE_SETTING_FONT_SELECTOR_BUTTON_LABEL));
- fixed_width_font_change_page_button_->SetListener(this);
fixed_width_font_label_ = new views::Label(
l10n_util::GetString(
@@ -388,9 +386,9 @@ void FontsPageView::InitFontLayout() {
// Serif font.
serif_font_display_view_ = new FontDisplayView;
serif_font_change_page_button_ = new views::NativeButton(
+ this,
l10n_util::GetString(
IDS_FONT_LANGUAGE_SETTING_FONT_SELECTOR_BUTTON_LABEL));
- serif_font_change_page_button_->SetListener(this);
serif_font_label_ = new views::Label(
l10n_util::GetString(
@@ -401,10 +399,10 @@ void FontsPageView::InitFontLayout() {
// Sans Serif font.
sans_serif_font_display_view_ = new FontDisplayView;
sans_serif_font_change_page_button_ = new views::NativeButton(
+ this,
l10n_util::GetString(
IDS_FONT_LANGUAGE_SETTING_FONT_SELECTOR_BUTTON_LABEL));
- sans_serif_font_change_page_button_->SetListener(this);
-
+
sans_serif_font_label_ = new views::Label(
l10n_util::GetString(
IDS_FONT_LANGUAGE_SETTING_FONT_SELECTOR_SANS_SERIF_LABEL));
diff --git a/chrome/browser/views/options/fonts_page_view.h b/chrome/browser/views/options/fonts_page_view.h
index eb348e6..28f5f91 100644
--- a/chrome/browser/views/options/fonts_page_view.h
+++ b/chrome/browser/views/options/fonts_page_view.h
@@ -9,13 +9,14 @@
#include "chrome/browser/shell_dialogs.h"
#include "chrome/common/pref_member.h"
#include "chrome/views/controls/combo_box.h"
-#include "chrome/views/controls/button/native_button.h"
+#include "chrome/views/controls/button/button.h"
#include "chrome/views/view.h"
namespace views {
class GroupboxView;
class Label;
+class NativeButton;
class TableModel;
class TableView;
}
@@ -29,13 +30,13 @@ class DefaultEncodingComboboxModel;
class FontsPageView : public OptionsPageView,
public views::ComboBox::Listener,
public SelectFontDialog::Listener,
- public views::NativeButton::Listener {
+ public views::ButtonListener {
public:
explicit FontsPageView(Profile* profile);
virtual ~FontsPageView();
- // views::NativeButton::Listener implementation:
- virtual void ButtonPressed(views::NativeButton* sender);
+ // views::ButtonListener implementation:
+ virtual void ButtonPressed(views::Button* sender);
// views::ComboBox::Listener implementation:
virtual void ItemChanged(views::ComboBox* combo_box,
diff --git a/chrome/browser/views/options/general_page_view.cc b/chrome/browser/views/options/general_page_view.cc
index af3e9bd..564aef1 100644
--- a/chrome/browser/views/options/general_page_view.cc
+++ b/chrome/browser/views/options/general_page_view.cc
@@ -29,7 +29,6 @@
#include "chrome/common/pref_service.h"
#include "chrome/common/resource_bundle.h"
#include "chrome/common/url_constants.h"
-#include "chrome/views/controls/button/checkbox.h"
#include "chrome/views/controls/button/radio_button.h"
#include "chrome/views/controls/label.h"
#include "chrome/views/controls/table/table_view.h"
@@ -536,9 +535,9 @@ GeneralPageView::~GeneralPageView() {
}
///////////////////////////////////////////////////////////////////////////////
-// GeneralPageView, views::NativeButton::Listener implementation:
+// GeneralPageView, views::ButtonListener implementation:
-void GeneralPageView::ButtonPressed(views::NativeButton* sender) {
+void GeneralPageView::ButtonPressed(views::Button* sender) {
if (sender == startup_homepage_radio_ ||
sender == startup_last_session_radio_ ||
sender == startup_custom_radio_) {
@@ -570,7 +569,7 @@ void GeneralPageView::ButtonPressed(views::NativeButton* sender) {
SetHomepage(homepage_use_url_textfield_->GetText());
EnableHomepageURLField(true);
} else if (sender == homepage_show_home_button_checkbox_) {
- bool show_button = homepage_show_home_button_checkbox_->IsSelected();
+ bool show_button = homepage_show_home_button_checkbox_->checked();
if (show_button) {
UserMetricsRecordAction(L"Options_Homepage_ShowHomeButton",
profile()->GetPrefs());
@@ -673,17 +672,17 @@ void GeneralPageView::NotifyPrefChanged(const std::wstring* pref_name) {
SessionStartupPref::GetStartupPref(prefs);
switch (startup_pref.type) {
case SessionStartupPref::DEFAULT:
- startup_homepage_radio_->SetIsSelected(true);
+ startup_homepage_radio_->SetChecked(true);
EnableCustomHomepagesControls(false);
break;
case SessionStartupPref::LAST:
- startup_last_session_radio_->SetIsSelected(true);
+ startup_last_session_radio_->SetChecked(true);
EnableCustomHomepagesControls(false);
break;
case SessionStartupPref::URLS:
- startup_custom_radio_->SetIsSelected(true);
+ startup_custom_radio_->SetChecked(true);
EnableCustomHomepagesControls(true);
break;
}
@@ -704,10 +703,10 @@ void GeneralPageView::NotifyPrefChanged(const std::wstring* pref_name) {
if (!pref_name || *pref_name == prefs::kHomePageIsNewTabPage) {
if (new_tab_page_is_home_page_.GetValue()) {
- homepage_use_newtab_radio_->SetIsSelected(true);
+ homepage_use_newtab_radio_->SetChecked(true);
EnableHomepageURLField(false);
} else {
- homepage_use_url_radio_->SetIsSelected(true);
+ homepage_use_url_radio_->SetChecked(true);
EnableHomepageURLField(true);
}
}
@@ -719,7 +718,7 @@ void GeneralPageView::NotifyPrefChanged(const std::wstring* pref_name) {
}
if (!pref_name || *pref_name == prefs::kShowHomeButton) {
- homepage_show_home_button_checkbox_->SetIsSelected(
+ homepage_show_home_button_checkbox_->SetChecked(
show_home_button_.GetValue());
}
}
@@ -772,26 +771,23 @@ void GeneralPageView::InitStartupGroup() {
startup_homepage_radio_ = new views::RadioButton(
l10n_util::GetString(IDS_OPTIONS_STARTUP_SHOW_DEFAULT_AND_NEWTAB),
kStartupRadioGroup);
- startup_homepage_radio_->SetListener(this);
+ startup_homepage_radio_->set_listener(this);
startup_last_session_radio_ = new views::RadioButton(
l10n_util::GetString(IDS_OPTIONS_STARTUP_SHOW_LAST_SESSION),
kStartupRadioGroup);
- startup_last_session_radio_->SetListener(this);
+ startup_last_session_radio_->set_listener(this);
startup_last_session_radio_->SetMultiLine(true);
startup_custom_radio_ = new views::RadioButton(
l10n_util::GetString(IDS_OPTIONS_STARTUP_SHOW_PAGES),
kStartupRadioGroup);
- startup_custom_radio_->SetListener(this);
+ startup_custom_radio_->set_listener(this);
startup_add_custom_page_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_OPTIONS_STARTUP_ADD_BUTTON));
- startup_add_custom_page_button_->SetListener(this);
+ this, l10n_util::GetString(IDS_OPTIONS_STARTUP_ADD_BUTTON));
startup_remove_custom_page_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_OPTIONS_STARTUP_REMOVE_BUTTON));
+ this, l10n_util::GetString(IDS_OPTIONS_STARTUP_REMOVE_BUTTON));
startup_remove_custom_page_button_->SetEnabled(false);
- startup_remove_custom_page_button_->SetListener(this);
startup_use_current_page_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_OPTIONS_STARTUP_USE_CURRENT));
- startup_use_current_page_button_->SetListener(this);
+ this, l10n_util::GetString(IDS_OPTIONS_STARTUP_USE_CURRENT));
startup_custom_pages_table_model_.reset(
new CustomHomePagesTableModel(profile()));
@@ -866,17 +862,17 @@ void GeneralPageView::InitHomepageGroup() {
homepage_use_newtab_radio_ = new views::RadioButton(
l10n_util::GetString(IDS_OPTIONS_HOMEPAGE_USE_NEWTAB),
kHomePageRadioGroup);
- homepage_use_newtab_radio_->SetListener(this);
+ homepage_use_newtab_radio_->set_listener(this);
homepage_use_newtab_radio_->SetMultiLine(true);
homepage_use_url_radio_ = new views::RadioButton(
l10n_util::GetString(IDS_OPTIONS_HOMEPAGE_USE_URL),
kHomePageRadioGroup);
- homepage_use_url_radio_->SetListener(this);
+ homepage_use_url_radio_->set_listener(this);
homepage_use_url_textfield_ = new views::TextField;
homepage_use_url_textfield_->SetController(this);
- homepage_show_home_button_checkbox_ = new views::CheckBox(
+ homepage_show_home_button_checkbox_ = new views::Checkbox(
l10n_util::GetString(IDS_OPTIONS_HOMEPAGE_SHOW_BUTTON));
- homepage_show_home_button_checkbox_->SetListener(this);
+ homepage_show_home_button_checkbox_->set_listener(this);
homepage_show_home_button_checkbox_->SetMultiLine(true);
using views::GridLayout;
@@ -923,8 +919,8 @@ void GeneralPageView::InitDefaultSearchGroup() {
default_search_engine_combobox_->SetListener(this);
default_search_manage_engines_button_ = new views::NativeButton(
+ this,
l10n_util::GetString(IDS_OPTIONS_DEFAULTSEARCH_MANAGE_ENGINES_LINK));
- default_search_manage_engines_button_->SetListener(this);
using views::GridLayout;
using views::ColumnSet;
@@ -956,9 +952,9 @@ void GeneralPageView::InitDefaultBrowserGroup() {
default_browser_status_label_->SetHorizontalAlignment(
views::Label::ALIGN_LEFT);
default_browser_use_as_default_button_ = new views::NativeButton(
+ this,
l10n_util::GetStringF(IDS_OPTIONS_DEFAULTBROWSER_USEASDEFAULT,
l10n_util::GetString(IDS_PRODUCT_NAME)));
- default_browser_use_as_default_button_->SetListener(this);
using views::GridLayout;
using views::ColumnSet;
@@ -988,9 +984,9 @@ void GeneralPageView::InitDefaultBrowserGroup() {
void GeneralPageView::SaveStartupPref() {
SessionStartupPref pref;
- if (startup_last_session_radio_->IsSelected()) {
+ if (startup_last_session_radio_->checked()) {
pref.type = SessionStartupPref::LAST;
- } else if (startup_custom_radio_->IsSelected()) {
+ } else if (startup_custom_radio_->checked()) {
pref.type = SessionStartupPref::URLS;
}
diff --git a/chrome/browser/views/options/general_page_view.h b/chrome/browser/views/options/general_page_view.h
index eea9cf1..2ec7f4e 100644
--- a/chrome/browser/views/options/general_page_view.h
+++ b/chrome/browser/views/options/general_page_view.h
@@ -9,13 +9,14 @@
#include "chrome/browser/views/shelf_item_dialog.h"
#include "chrome/common/pref_member.h"
#include "chrome/views/controls/combo_box.h"
-#include "chrome/views/controls/button/native_button.h"
+#include "chrome/views/controls/button/button.h"
#include "chrome/views/view.h"
namespace views {
-class CheckBox;
+class Checkbox;
class GroupboxView;
class Label;
+class NativeButton;
class RadioButton;
class TableModel;
class TableView;
@@ -30,7 +31,7 @@ class SearchEngineListModel;
class GeneralPageView : public OptionsPageView,
public views::ComboBox::Listener,
- public views::NativeButton::Listener,
+ public views::ButtonListener,
public views::TextField::Controller,
public ShelfItemDialogDelegate,
public views::TableViewObserver {
@@ -39,8 +40,8 @@ class GeneralPageView : public OptionsPageView,
virtual ~GeneralPageView();
protected:
- // views::NativeButton::Listener implementation:
- virtual void ButtonPressed(views::NativeButton* sender);
+ // views::ButtonListener implementation:
+ virtual void ButtonPressed(views::Button* sender);
// views::ComboBox::Listener implementation:
virtual void ItemChanged(views::ComboBox* combo_box,
@@ -133,7 +134,7 @@ class GeneralPageView : public OptionsPageView,
views::RadioButton* homepage_use_newtab_radio_;
views::RadioButton* homepage_use_url_radio_;
views::TextField* homepage_use_url_textfield_;
- views::CheckBox* homepage_show_home_button_checkbox_;
+ views::Checkbox* homepage_show_home_button_checkbox_;
BooleanPrefMember new_tab_page_is_home_page_;
StringPrefMember homepage_;
BooleanPrefMember show_home_button_;
diff --git a/chrome/browser/views/options/languages_page_view.cc b/chrome/browser/views/options/languages_page_view.cc
index b156523..0ed4f94 100644
--- a/chrome/browser/views/options/languages_page_view.cc
+++ b/chrome/browser/views/options/languages_page_view.cc
@@ -25,8 +25,6 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "chrome/common/resource_bundle.h"
-#include "chrome/views/controls/button/checkbox.h"
-#include "chrome/views/controls/button/native_button.h"
#include "chrome/views/controls/button/radio_button.h"
#include "chrome/views/controls/combo_box.h"
#include "chrome/views/controls/tabbed_pane.h"
@@ -495,7 +493,7 @@ LanguagesPageView::~LanguagesPageView() {
language_order_table_->SetModel(NULL);
}
-void LanguagesPageView::ButtonPressed(views::NativeButton* sender) {
+void LanguagesPageView::ButtonPressed(views::Button* sender) {
if (sender == move_up_button_) {
OnMoveUpLanguage();
language_table_edited_ = true;
@@ -512,7 +510,7 @@ void LanguagesPageView::ButtonPressed(views::NativeButton* sender) {
new AddLanguageWindowView(this, profile()))->Show();
language_table_edited_ = true;
} else if (sender == enable_spellchecking_checkbox_) {
- if (enable_spellchecking_checkbox_->IsSelected())
+ if (enable_spellchecking_checkbox_->checked())
enable_spellcheck_.SetValue(true);
else
enable_spellcheck_.SetValue(false);
@@ -527,21 +525,17 @@ void LanguagesPageView::OnAddLanguage(const std::wstring& new_language) {
void LanguagesPageView::InitControlLayout() {
// Define the buttons.
- add_button_ = new views::NativeButton(l10n_util::GetString(
+ add_button_ = new views::NativeButton(this, l10n_util::GetString(
IDS_FONT_LANGUAGE_SETTING_LANGUAGES_SELECTOR_ADD_BUTTON_LABEL));
- add_button_->SetListener(this);
- remove_button_ = new views::NativeButton(l10n_util::GetString(
+ remove_button_ = new views::NativeButton(this, l10n_util::GetString(
IDS_FONT_LANGUAGE_SETTING_LANGUAGES_SELECTOR_REMOVE_BUTTON_LABEL));
remove_button_->SetEnabled(false);
- remove_button_->SetListener(this);
- move_up_button_ = new views::NativeButton(l10n_util::GetString(
+ move_up_button_ = new views::NativeButton(this, l10n_util::GetString(
IDS_FONT_LANGUAGE_SETTING_LANGUAGES_SELECTOR_MOVEUP_BUTTON_LABEL));
move_up_button_->SetEnabled(false);
- move_up_button_->SetListener(this);
- move_down_button_ = new views::NativeButton(l10n_util::GetString(
+ move_down_button_ = new views::NativeButton(this, l10n_util::GetString(
IDS_FONT_LANGUAGE_SETTING_LANGUAGES_SELECTOR_MOVEDOWN_BUTTON_LABEL));
move_down_button_->SetEnabled(false);
- move_down_button_->SetListener(this);
languages_contents_ = new views::View;
using views::GridLayout;
@@ -630,9 +624,9 @@ void LanguagesPageView::InitControlLayout() {
l10n_util::GetString(IDS_OPTIONS_CHROME_DICTIONARY_LANGUAGE));
dictionary_language_label_->SetHorizontalAlignment(
views::Label::ALIGN_LEFT);
- enable_spellchecking_checkbox_ = new views::CheckBox(
+ enable_spellchecking_checkbox_ = new views::Checkbox(
l10n_util::GetString(IDS_OPTIONS_ENABLE_SPELLCHECK));
- enable_spellchecking_checkbox_->SetListener(this);
+ enable_spellchecking_checkbox_->set_listener(this);
enable_spellchecking_checkbox_->SetMultiLine(true);
// Determine Locale Codes.
@@ -731,7 +725,7 @@ void LanguagesPageView::NotifyPrefChanged(const std::wstring* pref_name) {
spellcheck_language_index_selected_ = -1;
}
if (!pref_name || *pref_name == prefs::kEnableSpellCheck) {
- enable_spellchecking_checkbox_->SetIsSelected(
+ enable_spellchecking_checkbox_->SetChecked(
enable_spellcheck_.GetValue());
}
}
diff --git a/chrome/browser/views/options/languages_page_view.h b/chrome/browser/views/options/languages_page_view.h
index a58cb99..f9f6def 100644
--- a/chrome/browser/views/options/languages_page_view.h
+++ b/chrome/browser/views/options/languages_page_view.h
@@ -8,13 +8,14 @@
#include "chrome/browser/views/options/options_page_view.h"
#include "chrome/common/pref_member.h"
#include "chrome/views/controls/combo_box.h"
-#include "chrome/views/controls/button/native_button.h"
+#include "chrome/views/controls/button/button.h"
#include "chrome/views/controls/table/table_view.h"
#include "chrome/views/view.h"
namespace views {
-class CheckBox;
+class Checkbox;
class Label;
+class NativeButton;
class TableModel;
class TableView;
}
@@ -27,15 +28,15 @@ class AddLanguageView;
// LanguagesPageView
class LanguagesPageView : public OptionsPageView,
- public views::NativeButton::Listener,
+ public views::ButtonListener,
public views::TableViewObserver,
public views::ComboBox::Listener {
public:
explicit LanguagesPageView(Profile* profile);
virtual ~LanguagesPageView();
- // views::NativeButton::Listener implementation:
- virtual void ButtonPressed(views::NativeButton* sender);
+ // views::ButtonListener implementation:
+ virtual void ButtonPressed(views::Button* sender);
// Save Changes made to relevant pref members associated with this tab.
// This is public since it is called by FontsLanguageWindowView in its
@@ -77,7 +78,7 @@ class LanguagesPageView : public OptionsPageView,
views::Label* ui_language_label_;
views::ComboBox* change_ui_language_combobox_;
views::ComboBox* change_dictionary_language_combobox_;
- views::CheckBox* enable_spellchecking_checkbox_;
+ views::Checkbox* enable_spellchecking_checkbox_;
views::Label* dictionary_language_label_;
scoped_ptr<LanguageOrderTableModel> language_order_table_model_;
diff --git a/chrome/browser/views/page_info_window.cc b/chrome/browser/views/page_info_window.cc
index 4a4c53d..ecc3ef8 100644
--- a/chrome/browser/views/page_info_window.cc
+++ b/chrome/browser/views/page_info_window.cc
@@ -516,8 +516,7 @@ void PageInfoWindow::Init(Profile* profile,
cert_id_ = ssl.cert_id();
cert_info_button_ = new views::NativeButton(
- l10n_util::GetString(IDS_PAGEINFO_CERT_INFO_BUTTON));
- cert_info_button_->SetListener(this);
+ this, l10n_util::GetString(IDS_PAGEINFO_CERT_INFO_BUTTON));
contents_ = new PageInfoContentView();
DWORD sys_color = ::GetSysColor(COLOR_3DFACE);
@@ -613,7 +612,7 @@ views::View* PageInfoWindow::GetContentsView() {
return contents_;
}
-void PageInfoWindow::ButtonPressed(views::NativeButton* sender) {
+void PageInfoWindow::ButtonPressed(views::Button* sender) {
if (sender == cert_info_button_) {
DCHECK(cert_id_ != 0);
ShowCertDialog(cert_id_);
diff --git a/chrome/browser/views/page_info_window.h b/chrome/browser/views/page_info_window.h
index e82130f..35b2ee0 100644
--- a/chrome/browser/views/page_info_window.h
+++ b/chrome/browser/views/page_info_window.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_VIEWS_PAGE_INFO_WINDOW_H__
#include "chrome/browser/tab_contents/navigation_entry.h"
-#include "chrome/views/controls/button/native_button.h"
+#include "chrome/views/controls/button/button.h"
#include "chrome/views/window/dialog_delegate.h"
#include "chrome/views/window/window.h"
#include "googleurl/src/gurl.h"
@@ -25,7 +25,7 @@ class Profile;
class X509Certificate;
class PageInfoWindow : public views::DialogDelegate,
- public views::NativeButton::Listener {
+ public views::ButtonListener {
public:
enum TabID {
GENERAL = 0,
@@ -62,8 +62,8 @@ class PageInfoWindow : public views::DialogDelegate,
// views::Window overridden method.
void Show();
- // views::NativeButton::Listener method.
- virtual void ButtonPressed(views::NativeButton* sender);
+ // views::ButtonListener method.
+ virtual void ButtonPressed(views::Button* sender);
// views::DialogDelegate methods:
virtual int GetDialogButtons() const;
diff --git a/chrome/browser/views/password_manager_exceptions_view.cc b/chrome/browser/views/password_manager_exceptions_view.cc
index 5af5f7d..ae87998 100644
--- a/chrome/browser/views/password_manager_exceptions_view.cc
+++ b/chrome/browser/views/password_manager_exceptions_view.cc
@@ -99,9 +99,9 @@ void PasswordManagerExceptionsView::Show(Profile* profile) {
}
PasswordManagerExceptionsView::PasswordManagerExceptionsView(Profile* profile)
- : remove_button_(l10n_util::GetString(
+ : remove_button_(this, l10n_util::GetString(
IDS_PASSWORD_MANAGER_EXCEPTIONS_VIEW_REMOVE_BUTTON)),
- remove_all_button_(l10n_util::GetString(
+ remove_all_button_(this, l10n_util::GetString(
IDS_PASSWORD_MANAGER_EXCEPTIONS_VIEW_REMOVE_ALL_BUTTON)),
table_model_(profile) {
Init();
@@ -132,11 +132,9 @@ void PasswordManagerExceptionsView::SetupButtons() {
// Tell View not to delete class stack allocated views.
remove_button_.SetParentOwned(false);
- remove_button_.SetListener(this);
remove_button_.SetEnabled(false);
remove_all_button_.SetParentOwned(false);
- remove_all_button_.SetListener(this);
}
void PasswordManagerExceptionsView::Init() {
@@ -212,7 +210,7 @@ std::wstring PasswordManagerExceptionsView::GetWindowTitle() const {
return l10n_util::GetString(IDS_PASSWORD_MANAGER_EXCEPTIONS_VIEW_TITLE);
}
-void PasswordManagerExceptionsView::ButtonPressed(views::NativeButton* sender) {
+void PasswordManagerExceptionsView::ButtonPressed(views::Button* sender) {
DCHECK(window());
// Close will result in our destruction.
if (sender == &remove_all_button_) {
diff --git a/chrome/browser/views/password_manager_exceptions_view.h b/chrome/browser/views/password_manager_exceptions_view.h
index cfd9297..5dacbb6 100644
--- a/chrome/browser/views/password_manager_exceptions_view.h
+++ b/chrome/browser/views/password_manager_exceptions_view.h
@@ -11,7 +11,6 @@
#include "chrome/browser/webdata/web_data_service.h"
#include "chrome/common/stl_util-inl.h"
#include "chrome/common/gfx/text_elider.h"
-#include "chrome/views/controls/button/native_button.h"
#include "chrome/views/controls/label.h"
#include "chrome/views/controls/table/table_view.h"
#include "chrome/views/window/dialog_delegate.h"
@@ -37,7 +36,7 @@ class PasswordManagerExceptionsTableModel : public PasswordManagerTableModel {
class PasswordManagerExceptionsView : public views::View,
public views::DialogDelegate,
public views::TableViewObserver,
- public views::NativeButton::Listener,
+ public views::ButtonListener,
public PasswordManagerTableModelObserver {
public:
explicit PasswordManagerExceptionsView(Profile* profile);
@@ -55,8 +54,8 @@ class PasswordManagerExceptionsView : public views::View,
// views::TableViewObserver implementation.
virtual void OnSelectionChanged();
- // NativeButton::Listener implementation.
- virtual void ButtonPressed(views::NativeButton* sender);
+ // ButtonListener implementation.
+ virtual void ButtonPressed(views::Button* sender);
// views::DialogDelegate methods:
virtual int GetDialogButtons() const;
diff --git a/chrome/browser/views/password_manager_view.cc b/chrome/browser/views/password_manager_view.cc
index eb7f5eb..a0561a3 100644
--- a/chrome/browser/views/password_manager_view.cc
+++ b/chrome/browser/views/password_manager_view.cc
@@ -26,9 +26,10 @@ static const int kDefaultWindowHeight = 240;
////////////////////////////////////////////////////////////////////////////////
// MultiLabelButtons
//
-MultiLabelButtons::MultiLabelButtons(const std::wstring& label,
+MultiLabelButtons::MultiLabelButtons(views::ButtonListener* listener,
+ const std::wstring& label,
const std::wstring& alt_label)
- : NativeButton(label),
+ : NativeButton(listener, label),
label_(label),
alt_label_(alt_label),
pref_size_(-1, -1) {
@@ -37,7 +38,7 @@ MultiLabelButtons::MultiLabelButtons(const std::wstring& label,
gfx::Size MultiLabelButtons::GetPreferredSize() {
if (pref_size_.width() == -1 && pref_size_.height() == -1) {
// Let's compute our preferred size.
- std::wstring current_label = GetLabel();
+ std::wstring current_label = label();
SetLabel(label_);
pref_size_ = NativeButton::GetPreferredSize();
SetLabel(alt_label_);
@@ -204,11 +205,12 @@ void PasswordManagerView::Show(Profile* profile) {
PasswordManagerView::PasswordManagerView(Profile* profile)
: show_button_(
+ this,
l10n_util::GetString(IDS_PASSWORD_MANAGER_VIEW_SHOW_BUTTON),
l10n_util::GetString(IDS_PASSWORD_MANAGER_VIEW_HIDE_BUTTON)),
- remove_button_(l10n_util::GetString(
+ remove_button_(this, l10n_util::GetString(
IDS_PASSWORD_MANAGER_VIEW_REMOVE_BUTTON)),
- remove_all_button_(l10n_util::GetString(
+ remove_all_button_(this, l10n_util::GetString(
IDS_PASSWORD_MANAGER_VIEW_REMOVE_ALL_BUTTON)),
table_model_(profile) {
Init();
@@ -242,16 +244,13 @@ void PasswordManagerView::SetupButtonsAndLabels() {
// Tell View not to delete class stack allocated views.
show_button_.SetParentOwned(false);
- show_button_.SetListener(this);
show_button_.SetEnabled(false);
remove_button_.SetParentOwned(false);
- remove_button_.SetListener(this);
remove_button_.SetEnabled(false);
remove_all_button_.SetParentOwned(false);
- remove_all_button_.SetListener(this);
-
+
password_label_.SetParentOwned(false);
}
@@ -365,7 +364,7 @@ std::wstring PasswordManagerView::GetWindowTitle() const {
return l10n_util::GetString(IDS_PASSWORD_MANAGER_VIEW_TITLE);
}
-void PasswordManagerView::ButtonPressed(views::NativeButton* sender) {
+void PasswordManagerView::ButtonPressed(views::Button* sender) {
DCHECK(window());
// Close will result in our destruction.
if (sender == &remove_all_button_) {
diff --git a/chrome/browser/views/password_manager_view.h b/chrome/browser/views/password_manager_view.h
index 40bb8ba..ed12d6a 100644
--- a/chrome/browser/views/password_manager_view.h
+++ b/chrome/browser/views/password_manager_view.h
@@ -118,7 +118,9 @@ class PasswordManagerTableModel : public views::TableModel,
// preferred size is the size of the widest string.
class MultiLabelButtons : public views::NativeButton {
public:
- MultiLabelButtons(const std::wstring& label, const std::wstring& alt_label);
+ MultiLabelButtons(views::ButtonListener* listener,
+ const std::wstring& label,
+ const std::wstring& alt_label);
virtual gfx::Size GetPreferredSize();
@@ -133,7 +135,7 @@ class MultiLabelButtons : public views::NativeButton {
class PasswordManagerView : public views::View,
public views::DialogDelegate,
public views::TableViewObserver,
- public views::NativeButton::Listener,
+ public views::ButtonListener,
public PasswordManagerTableModelObserver {
public:
explicit PasswordManagerView(Profile* profile);
@@ -150,8 +152,8 @@ class PasswordManagerView : public views::View,
// views::TableViewObserver implementation.
virtual void OnSelectionChanged();
- // NativeButton::Listener implementation.
- virtual void ButtonPressed(views::NativeButton* sender);
+ // ButtonListener implementation.
+ virtual void ButtonPressed(views::Button* sender);
// views::DialogDelegate methods:
virtual int GetDialogButtons() const;
diff --git a/chrome/views/controls/button/button.h b/chrome/views/controls/button/button.h
index 1f6514b..f00f8a1 100644
--- a/chrome/views/controls/button/button.h
+++ b/chrome/views/controls/button/button.h
@@ -39,15 +39,17 @@ class Button : public View {
virtual void SetAccessibleName(const std::wstring& name);
protected:
- // Construct the Button with a Listener. The listener can be NULL, as long as
- // the specific button implementation makes sure to not call NotifyClick. This
- // can be true of buttons that don't have a listener - e.g. menubuttons where
- // there's no default action.
+ // Construct the Button with a Listener. The listener can be NULL. This can be
+ // true of buttons that don't have a listener - e.g. menubuttons where there's
+ // no default action and checkboxes.
explicit Button(ButtonListener* listener);
// Cause the button to notify the listener that a click occurred.
virtual void NotifyClick(int mouse_event_flags);
+ // The button's listener. Notified when clicked.
+ ButtonListener* listener_;
+
private:
// The text shown in a tooltip.
std::wstring tooltip_text_;
@@ -56,9 +58,6 @@ class Button : public View {
std::wstring accessible_shortcut_;
std::wstring accessible_name_;
- // The button's listener. Notified when clicked.
- ButtonListener* listener_;
-
// The id tag associated with this button. Used to disambiguate buttons in
// the ButtonListener implementation.
int tag_;
diff --git a/chrome/views/controls/button/checkbox.cc b/chrome/views/controls/button/checkbox.cc
index b768037..032a1aa 100644
--- a/chrome/views/controls/button/checkbox.cc
+++ b/chrome/views/controls/button/checkbox.cc
@@ -1,181 +1,164 @@
-// Copyright (c) 2006-2008 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.
+// Copyright (c) 2009 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.
#include "chrome/views/controls/button/checkbox.h"
#include "chrome/common/gfx/chrome_canvas.h"
-#include "chrome/views/controls/button/checkbox.h"
-#include "chrome/views/controls/hwnd_view.h"
#include "chrome/views/controls/label.h"
-// FIXME(ACW) there got be a better way to find out the check box sizes
-static int kCheckBoxWidth = 13;
-static int kCheckBoxHeight = 13;
-static int kCheckBoxToLabel = 4;
-
namespace views {
-// Horizontal focus padding.
-const int CheckBox::kFocusPaddingHorizontal = 2;
-const int CheckBox::kFocusPaddingVertical = 1;
+// static
+const char Checkbox::kViewClassName[] = "chrome/views/Checkbox";
-const char CheckBox::kViewClassName[] = "chrome/views/CheckBox";
+static const int kCheckboxLabelSpacing = 4;
+static const int kLabelFocusPaddingHorizontal = 2;
+static const int kLabelFocusPaddingVertical = 1;
-CheckBox::CheckBox(const std::wstring& label)
- : NativeButton(label),
- is_selected_(false) {
- // Note: we paint the label as a floating view
- SetMinSizeFromDLUs(gfx::Size(0, 0));
- label_ = new Label(label);
- label_->SetHorizontalAlignment(Label::ALIGN_LEFT);
-}
+////////////////////////////////////////////////////////////////////////////////
+// Checkbox, public:
-CheckBox::~CheckBox() {
- delete label_;
+Checkbox::Checkbox() : NativeButton(NULL), checked_(false) {
+ Init(std::wstring());
}
-void CheckBox::SetMultiLine(bool multi_line) {
- label_->SetMultiLine(multi_line);
+Checkbox::Checkbox(const std::wstring& label)
+ : NativeButton(NULL, label),
+ checked_(false) {
+ Init(label);
}
-// static
-int CheckBox::GetTextIndent() {
- return kCheckBoxWidth + kCheckBoxToLabel + kFocusPaddingHorizontal;
+Checkbox::~Checkbox() {
}
-void CheckBox::SetIsSelected(bool f) {
- if (f != is_selected_) {
- is_selected_ = f;
- UpdateNativeButton();
- }
+void Checkbox::SetMultiLine(bool multiline) {
+ label_->SetMultiLine(multiline);
}
-bool CheckBox::IsSelected() const {
- return is_selected_;
+void Checkbox::SetChecked(bool checked) {
+ if (checked_ == checked)
+ return;
+ checked_ = checked;
+ native_wrapper_->UpdateChecked();
}
-std::string CheckBox::GetClassName() const {
- return kViewClassName;
+// static
+int Checkbox::GetTextIndent() {
+ return NativeButtonWrapper::GetFixedWidth() + kCheckboxLabelSpacing;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Checkbox, View overrides:
+
+gfx::Size Checkbox::GetPreferredSize() {
+ gfx::Size prefsize = native_wrapper_->GetView()->GetPreferredSize();
+ prefsize.set_width(
+ prefsize.width() + kCheckboxLabelSpacing +
+ kLabelFocusPaddingHorizontal * 2);
+ gfx::Size label_prefsize = label_->GetPreferredSize();
+ prefsize.set_width(prefsize.width() + label_prefsize.width());
+ prefsize.set_height(
+ std::max(prefsize.height(),
+ label_prefsize.height() + kLabelFocusPaddingVertical * 2));
+ return prefsize;
}
-void CheckBox::Layout() {
- int label_x = GetTextIndent();
- label_->SetBounds(label_x, 0, std::max(0, width() - label_x), height());
- if (hwnd_view_) {
- int first_line_height = label_->GetFont().height();
- hwnd_view_->SetBounds(0, ((first_line_height - kCheckBoxHeight) / 2) + 1,
- kCheckBoxWidth, kCheckBoxHeight);
- hwnd_view_->Layout();
+void Checkbox::Layout() {
+ if (!native_wrapper_)
+ return;
+
+ gfx::Size checkmark_prefsize = native_wrapper_->GetView()->GetPreferredSize();
+ int label_x = checkmark_prefsize.width() + kCheckboxLabelSpacing +
+ kLabelFocusPaddingHorizontal;
+ label_->SetBounds(
+ label_x, 0, std::max(0, width() - label_x - kLabelFocusPaddingHorizontal),
+ height());
+ int first_line_height = label_->GetFont().height();
+ native_wrapper_->GetView()->SetBounds(
+ 0, ((first_line_height - checkmark_prefsize.height()) / 2),
+ checkmark_prefsize.width(), checkmark_prefsize.height());
+ native_wrapper_->GetView()->Layout();
+}
+
+void Checkbox::Paint(ChromeCanvas* canvas) {
+ // Paint the focus border manually since we don't want to send actual focus
+ // in to the inner view.
+ if (HasFocus()) {
+ gfx::Rect label_bounds = label_->bounds();
+ canvas->DrawFocusRect(
+ MirroredLeftPointForRect(label_bounds) - kLabelFocusPaddingHorizontal,
+ 0,
+ label_bounds.width() + kLabelFocusPaddingHorizontal * 2,
+ label_bounds.height() - kLabelFocusPaddingVertical * 2);
}
}
-void CheckBox::ComputeTextRect(gfx::Rect* out) {
- gfx::Size s = label_->GetPreferredSize();
- out->set_x(GetTextIndent());
- out->set_y(kFocusPaddingVertical);
- int new_width = std::min(width() - (kCheckBoxWidth + kCheckBoxToLabel),
- s.width());
- out->set_width(std::max(0, new_width));
- out->set_height(s.height());
+View* Checkbox::GetViewForPoint(const gfx::Point& point) {
+ return GetViewForPoint(point, false);
}
-void CheckBox::Paint(ChromeCanvas* canvas) {
- gfx::Rect r;
- ComputeTextRect(&r);
- // Paint the focus border if any.
- if (HasFocus()) {
- // Mirror left point for rectangle to draw focus for RTL text.
- canvas->DrawFocusRect(MirroredLeftPointForRect(r) - kFocusPaddingHorizontal,
- r.y() - kFocusPaddingVertical,
- r.width() + kFocusPaddingHorizontal * 2,
- r.height() + kFocusPaddingVertical * 2);
- }
- PaintFloatingView(canvas, label_, r.x(), r.y(), r.width(), r.height());
+View* Checkbox::GetViewForPoint(const gfx::Point& point,
+ bool can_create_floating) {
+ return GetLocalBounds(true).Contains(point) ? this : NULL;
}
-void CheckBox::SetEnabled(bool enabled) {
- if (enabled_ == enabled)
- return;
- NativeButton::SetEnabled(enabled);
- label_->SetEnabled(enabled);
-}
-
-HWND CheckBox::CreateNativeControl(HWND parent_container) {
- HWND r = ::CreateWindowEx(WS_EX_TRANSPARENT | GetAdditionalExStyle(),
- L"BUTTON",
- L"",
- WS_CHILD | BS_CHECKBOX | WS_VISIBLE,
- 0, 0, width(), height(),
- parent_container, NULL, NULL, NULL);
- ConfigureNativeButton(r);
- return r;
-}
-
-void CheckBox::ConfigureNativeButton(HWND hwnd) {
- ::SendMessage(hwnd,
- static_cast<UINT>(BM_SETCHECK),
- static_cast<WPARAM>(is_selected_ ? BST_CHECKED : BST_UNCHECKED),
- 0);
- label_->SetText(GetLabel());
-}
-
-gfx::Size CheckBox::GetPreferredSize() {
- gfx::Size prefsize = label_->GetPreferredSize();
- prefsize.set_height(std::max(prefsize.height() + kFocusPaddingVertical * 2,
- kCheckBoxHeight));
- prefsize.Enlarge(GetTextIndent() * 2, 0);
- return prefsize;
+void Checkbox::OnMouseEntered(const MouseEvent& e) {
+ native_wrapper_->SetPushed(HitTestLabel(e));
}
-LRESULT CheckBox::OnCommand(UINT code, int id, HWND source) {
- if (code == BN_CLICKED)
- SetIsSelected(!is_selected_);
-
- return NativeButton::OnCommand(code, id, source);
+void Checkbox::OnMouseMoved(const MouseEvent& e) {
+ native_wrapper_->SetPushed(HitTestLabel(e));
}
-void CheckBox::HighlightButton(bool f) {
- ::SendMessage(GetNativeControlHWND(),
- static_cast<UINT>(BM_SETSTATE),
- static_cast<WPARAM>(f),
- 0);
+void Checkbox::OnMouseExited(const MouseEvent& e) {
+ native_wrapper_->SetPushed(false);
}
-bool CheckBox::LabelHitTest(const MouseEvent& event) {
- CPoint p(event.x(), event.y());
- gfx::Rect r;
- ComputeTextRect(&r);
- return r.Contains(event.x(), event.y());
+bool Checkbox::OnMousePressed(const MouseEvent& e) {
+ native_wrapper_->SetPushed(HitTestLabel(e));
+ return true;
}
-void CheckBox::OnMouseEntered(const MouseEvent& event) {
- HighlightButton(LabelHitTest(event));
+void Checkbox::OnMouseReleased(const MouseEvent& e, bool canceled) {
+ native_wrapper_->SetPushed(false);
+ if (!canceled & HitTestLabel(e)) {
+ SetChecked(!checked());
+ ButtonPressed();
+ }
}
-void CheckBox::OnMouseMoved(const MouseEvent& event) {
- HighlightButton(LabelHitTest(event));
+std::string Checkbox::GetClassName() const {
+ return kViewClassName;
}
-void CheckBox::OnMouseExited(const MouseEvent& event) {
- HighlightButton(false);
+////////////////////////////////////////////////////////////////////////////////
+// Checkbox, NativeButton overrides:
+
+void Checkbox::CreateWrapper() {
+ native_wrapper_ = NativeButtonWrapper::CreateCheckboxWrapper(this);
+ native_wrapper_->UpdateLabel();
+ native_wrapper_->UpdateChecked();
}
-bool CheckBox::OnMousePressed(const MouseEvent& event) {
- HighlightButton(LabelHitTest(event));
- return true;
+void Checkbox::InitBorder() {
+ // No border, so we do nothing.
}
-bool CheckBox::OnMouseDragged(const MouseEvent& event) {
- HighlightButton(LabelHitTest(event));
- return true;
+////////////////////////////////////////////////////////////////////////////////
+// Checkbox, private:
+
+void Checkbox::Init(const std::wstring& label_text) {
+ set_minimum_size(gfx::Size(0, 0));
+ label_ = new Label(label_text);
+ label_->SetHorizontalAlignment(Label::ALIGN_LEFT);
+ AddChildView(label_);
}
-void CheckBox::OnMouseReleased(const MouseEvent& event,
- bool canceled) {
- HighlightButton(false);
- if (!canceled && LabelHitTest(event))
- OnCommand(BN_CLICKED, 0, GetNativeControlHWND());
+bool Checkbox::HitTestLabel(const MouseEvent& e) {
+ gfx::Point tmp(e.location());
+ ConvertPointToView(this, label_, &tmp);
+ return label_->HitTest(tmp);
}
} // namespace views
diff --git a/chrome/views/controls/button/checkbox.h b/chrome/views/controls/button/checkbox.h
index 78c006b..b9def2c 100644
--- a/chrome/views/controls/button/checkbox.h
+++ b/chrome/views/controls/button/checkbox.h
@@ -1,85 +1,81 @@
-// Copyright (c) 2006-2008 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.
+// Copyright (c) 2009 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_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_
#define CHROME_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_
-#include "base/gfx/rect.h"
#include "chrome/views/controls/button/native_button.h"
namespace views {
class Label;
-////////////////////////////////////////////////////////////////////////////////
-//
-// CheckBox implements a check box button. It uses the standard windows control
-// for the check item but not for the label. We have to do this because windows
-// always wants to draw a background under the label. I tried to intercept
-// WM_CTLCOLORSTATIC and return a NULL_BRUSH and setting the BkMode to
-// transparent as well as other things. The background was always drawn as solid
-// black.
-//
-// The label is implemented with a views::Label
-//
-////////////////////////////////////////////////////////////////////////////////
-class CheckBox : public NativeButton {
+// A NativeButton subclass representing a checkbox.
+class Checkbox : public NativeButton {
public:
+ // The button's class name.
static const char kViewClassName[];
- static const int kFocusPaddingHorizontal;
- static const int kFocusPaddingVertical;
- explicit CheckBox(const std::wstring& label);
- virtual ~CheckBox();
+ Checkbox();
+ Checkbox(const std::wstring& label);
+ virtual ~Checkbox();
- // Allows the label to wrap across multiple lines if |multi_line| is true.
- // If false, the text is cropped.
- void SetMultiLine(bool multi_line);
+ // Sets a listener for this checkbox. Checkboxes aren't required to have them
+ // since their state can be read independently of them being toggled.
+ void set_listener(ButtonListener* listener) { listener_ = listener; }
- // Returns the x position of the text. This can also be used to indent
- // subsequent dependent controls.
- static int GetTextIndent();
+ // Sets whether or not the checkbox label should wrap multiple lines of text.
+ // If true, long lines are wrapped, and this is reflected in the preferred
+ // size returned by GetPreferredSize. If false, text that will not fit within
+ // the available bounds for the label will be cropped.
+ void SetMultiLine(bool multiline);
- virtual void SetIsSelected(bool f);
- bool IsSelected() const;
+ // Sets/Gets whether or not the checkbox is checked.
+ virtual void SetChecked(bool checked);
+ bool checked() const { return checked_; }
- virtual std::string GetClassName() const;
+ // Returns the indentation of the text from the left edge of the view.
+ static int GetTextIndent();
+ // Overridden from View:
virtual gfx::Size GetPreferredSize();
virtual void Layout();
-
- virtual bool OnMousePressed(const MouseEvent& event);
- virtual bool OnMouseDragged(const MouseEvent& event);
- virtual void OnMouseReleased(const MouseEvent& event, bool canceled);
- virtual void OnMouseEntered(const MouseEvent& event);
- virtual void OnMouseMoved(const MouseEvent& event);
- virtual void OnMouseExited(const MouseEvent& event);
-
virtual void Paint(ChromeCanvas* canvas);
-
- // Overriden to forward to the label too.
- virtual void SetEnabled(bool enabled);
+ virtual View* GetViewForPoint(const gfx::Point& point);
+ virtual View* GetViewForPoint(const gfx::Point& point,
+ bool can_create_floating);
+ virtual void OnMouseEntered(const MouseEvent& e);
+ virtual void OnMouseMoved(const MouseEvent& e);
+ virtual void OnMouseExited(const MouseEvent& e);
+ virtual bool OnMousePressed(const MouseEvent& e);
+ virtual void OnMouseReleased(const MouseEvent& e, bool canceled);
protected:
+ virtual std::string GetClassName() const;
- virtual HWND CreateNativeControl(HWND parent_container);
- virtual void ConfigureNativeButton(HWND hwnd);
- virtual LRESULT OnCommand(UINT code, int id, HWND source);
+ // Overridden from NativeButton2:
+ virtual void CreateWrapper();
+ virtual void InitBorder();
- Label* label_;
private:
+ // Called from the constructor to create and configure the checkbox label.
+ void Init(const std::wstring& label_text);
- void HighlightButton(bool f);
- bool LabelHitTest(const MouseEvent& event);
- void ComputeTextRect(gfx::Rect* out);
+ // Returns true if the event (in Checkbox coordinates) is within the bounds of
+ // the label.
+ bool HitTestLabel(const MouseEvent& e);
- bool is_selected_;
+ // The checkbox's label. We don't use the OS version because of transparency
+ // and sizing issues.
+ Label* label_;
+ // True if the checkbox is checked.
+ bool checked_;
- DISALLOW_EVIL_CONSTRUCTORS(CheckBox);
+ DISALLOW_COPY_AND_ASSIGN(Checkbox);
};
} // namespace views
-#endif // CHROME_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_
+#endif // #ifndef CHROME_VIEWS_CONTROLS_BUTTON_CHECKBOX_H_
diff --git a/chrome/views/controls/button/checkbox2.cc b/chrome/views/controls/button/checkbox2.cc
deleted file mode 100644
index 426d0d8..0000000
--- a/chrome/views/controls/button/checkbox2.cc
+++ /dev/null
@@ -1,166 +0,0 @@
-// Copyright (c) 2009 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.
-
-#include "chrome/views/controls/button/checkbox2.h"
-
-#include "chrome/common/gfx/chrome_canvas.h"
-#include "chrome/views/controls/label.h"
-
-namespace views {
-
-// static
-const char Checkbox2::kViewClassName[] = "chrome/views/Checkbox";
-
-static const int kCheckboxLabelSpacing = 4;
-static const int kLabelFocusPaddingHorizontal = 2;
-static const int kLabelFocusPaddingVertical = 1;
-
-////////////////////////////////////////////////////////////////////////////////
-// Checkbox2, public:
-
-Checkbox2::Checkbox2() : NativeButton2(NULL), checked_(false) {
- Init(std::wstring());
-}
-
-Checkbox2::Checkbox2(ButtonListener* listener)
- : NativeButton2(listener),
- checked_(false) {
- Init(std::wstring());
-}
-
-Checkbox2::Checkbox2(ButtonListener* listener, const std::wstring& label)
- : NativeButton2(listener, label),
- checked_(false) {
- Init(label);
-}
-
-Checkbox2::~Checkbox2() {
-}
-
-void Checkbox2::SetMultiLine(bool multiline) {
- label_->SetMultiLine(multiline);
-}
-
-void Checkbox2::SetChecked(bool checked) {
- if (checked_ == checked)
- return;
- checked_ = checked;
- native_wrapper_->UpdateChecked();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Checkbox2, View overrides:
-
-gfx::Size Checkbox2::GetPreferredSize() {
- gfx::Size prefsize = native_wrapper_->GetView()->GetPreferredSize();
- prefsize.set_width(
- prefsize.width() + kCheckboxLabelSpacing +
- kLabelFocusPaddingHorizontal * 2);
- gfx::Size label_prefsize = label_->GetPreferredSize();
- prefsize.set_width(prefsize.width() + label_prefsize.width());
- prefsize.set_height(
- std::max(prefsize.height(),
- label_prefsize.height() + kLabelFocusPaddingVertical * 2));
- return prefsize;
-}
-
-void Checkbox2::Layout() {
- if (!native_wrapper_)
- return;
-
- gfx::Size checkmark_prefsize = native_wrapper_->GetView()->GetPreferredSize();
- int label_x = checkmark_prefsize.width() + kCheckboxLabelSpacing +
- kLabelFocusPaddingHorizontal;
- label_->SetBounds(
- label_x, 0, std::max(0, width() - label_x - kLabelFocusPaddingHorizontal),
- height());
- int first_line_height = label_->GetFont().height();
- native_wrapper_->GetView()->SetBounds(
- 0, ((first_line_height - checkmark_prefsize.height()) / 2),
- checkmark_prefsize.width(), checkmark_prefsize.height());
- native_wrapper_->GetView()->Layout();
-}
-
-void Checkbox2::Paint(ChromeCanvas* canvas) {
- // Paint the focus border manually since we don't want to send actual focus
- // in to the inner view.
- if (HasFocus()) {
- gfx::Rect label_bounds = label_->bounds();
- canvas->DrawFocusRect(
- MirroredLeftPointForRect(label_bounds) - kLabelFocusPaddingHorizontal,
- 0,
- label_bounds.width() + kLabelFocusPaddingHorizontal * 2,
- label_bounds.height() - kLabelFocusPaddingVertical * 2);
- }
-}
-
-View* Checkbox2::GetViewForPoint(const gfx::Point& point) {
- return GetViewForPoint(point, false);
-}
-
-View* Checkbox2::GetViewForPoint(const gfx::Point& point,
- bool can_create_floating) {
- return GetLocalBounds(true).Contains(point) ? this : NULL;
-}
-
-void Checkbox2::OnMouseEntered(const MouseEvent& e) {
- native_wrapper_->SetPushed(HitTestLabel(e));
-}
-
-void Checkbox2::OnMouseMoved(const MouseEvent& e) {
- native_wrapper_->SetPushed(HitTestLabel(e));
-}
-
-void Checkbox2::OnMouseExited(const MouseEvent& e) {
- native_wrapper_->SetPushed(false);
-}
-
-bool Checkbox2::OnMousePressed(const MouseEvent& e) {
- native_wrapper_->SetPushed(HitTestLabel(e));
- return true;
-}
-
-void Checkbox2::OnMouseReleased(const MouseEvent& e, bool canceled) {
- native_wrapper_->SetPushed(false);
- if (!canceled & HitTestLabel(e)) {
- SetChecked(!checked());
- ButtonPressed();
- }
-}
-
-std::string Checkbox2::GetClassName() const {
- return kViewClassName;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Checkbox2, NativeButton2 overrides:
-
-void Checkbox2::CreateWrapper() {
- native_wrapper_ = NativeButtonWrapper::CreateCheckboxWrapper(this);
- native_wrapper_->UpdateLabel();
- native_wrapper_->UpdateChecked();
-}
-
-void Checkbox2::InitBorder() {
- // No border, so we do nothing.
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Checkbox2, private:
-
-void Checkbox2::Init(const std::wstring& label_text) {
- SetFocusable(true);
- set_minimum_size(gfx::Size(0, 0));
- label_ = new Label(label_text);
- label_->SetHorizontalAlignment(Label::ALIGN_LEFT);
- AddChildView(label_);
-}
-
-bool Checkbox2::HitTestLabel(const MouseEvent& e) {
- gfx::Point tmp(e.location());
- ConvertPointToView(this, label_, &tmp);
- return label_->HitTest(tmp);
-}
-
-} // namespace views
diff --git a/chrome/views/controls/button/checkbox2.h b/chrome/views/controls/button/checkbox2.h
deleted file mode 100644
index d2c1e0f..0000000
--- a/chrome/views/controls/button/checkbox2.h
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright (c) 2009 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_VIEWS_CONTROLS_BUTTON_CHECKBOX2_H_
-#define CHROME_VIEWS_CONTROLS_BUTTON_CHECKBOX2_H_
-
-#include "chrome/views/controls/button/native_button2.h"
-
-namespace views {
-
-class Label;
-
-// A NativeButton subclass representing a checkbox.
-class Checkbox2 : public NativeButton2 {
- public:
- // The button's class name.
- static const char kViewClassName[];
-
- Checkbox2();
- explicit Checkbox2(ButtonListener* listener);
- Checkbox2(ButtonListener* listener, const std::wstring& label);
- virtual ~Checkbox2();
-
- // Sets whether or not the checkbox label should wrap multiple lines of text.
- // If true, long lines are wrapped, and this is reflected in the preferred
- // size returned by GetPreferredSize. If false, text that will not fit within
- // the available bounds for the label will be cropped.
- void SetMultiLine(bool multiline);
-
- // Sets/Gets whether or not the checkbox is checked.
- virtual void SetChecked(bool checked);
- bool checked() const { return checked_; }
-
- // Overridden from View:
- virtual gfx::Size GetPreferredSize();
- virtual void Layout();
- virtual void Paint(ChromeCanvas* canvas);
- virtual View* GetViewForPoint(const gfx::Point& point);
- virtual View* GetViewForPoint(const gfx::Point& point,
- bool can_create_floating);
- virtual void OnMouseEntered(const MouseEvent& e);
- virtual void OnMouseMoved(const MouseEvent& e);
- virtual void OnMouseExited(const MouseEvent& e);
- virtual bool OnMousePressed(const MouseEvent& e);
- virtual void OnMouseReleased(const MouseEvent& e, bool canceled);
-
- protected:
- virtual std::string GetClassName() const;
-
- // Overridden from NativeButton2:
- virtual void CreateWrapper();
- virtual void InitBorder();
-
- private:
- // Called from the constructor to create and configure the checkbox label.
- void Init(const std::wstring& label_text);
-
- // Returns true if the event (in Checkbox coordinates) is within the bounds of
- // the label.
- bool HitTestLabel(const MouseEvent& e);
-
- // The checkbox's label. We don't use the OS version because of transparency
- // and sizing issues.
- Label* label_;
-
- // True if the checkbox is checked.
- bool checked_;
-
- DISALLOW_COPY_AND_ASSIGN(Checkbox2);
-};
-
-} // namespace views
-
-#endif // #ifndef CHROME_VIEWS_CONTROLS_BUTTON_CHECKBOX2_H_
diff --git a/chrome/views/controls/button/native_button.cc b/chrome/views/controls/button/native_button.cc
index 4da39407..9d681b7 100644
--- a/chrome/views/controls/button/native_button.cc
+++ b/chrome/views/controls/button/native_button.cc
@@ -1,71 +1,53 @@
-// Copyright (c) 2006-2008 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.
+// Copyright (c) 2009 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.
#include "chrome/views/controls/button/native_button.h"
#include "base/logging.h"
-#include "chrome/common/gfx/chrome_canvas.h"
#include "chrome/common/l10n_util.h"
-#include "chrome/common/resource_bundle.h"
-#include "chrome/views/background.h"
namespace views {
-const char NativeButton::kViewClassName[] = "chrome/views/NativeButton";
-
-NativeButton::NativeButton(const std::wstring& label)
- : enforce_dlu_min_size_(true) {
- Init(label, false);
-}
+static int kButtonBorderHWidth = 8;
-NativeButton::NativeButton(const std::wstring& label, bool is_default)
- : enforce_dlu_min_size_(true) {
- Init(label, is_default);
-}
+// static
+const char NativeButton::kViewClassName[] = "chrome/views/NativeButton";
-NativeButton::~NativeButton() {
-}
+////////////////////////////////////////////////////////////////////////////////
+// NativeButton, public:
-std::string NativeButton::GetClassName() const {
- return kViewClassName;
+NativeButton::NativeButton(ButtonListener* listener)
+ : Button(listener),
+ native_wrapper_(NULL),
+ is_default_(false),
+ ignore_minimum_size_(false),
+ minimum_size_(50, 14) {
+ // The min size in DLUs comes from
+ // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch14e.asp
+ InitBorder();
+ SetFocusable(true);
}
-void NativeButton::SetListener(Listener *l) {
- listener_ = l;
+NativeButton::NativeButton(ButtonListener* listener, const std::wstring& label)
+ : Button(listener),
+ native_wrapper_(NULL),
+ label_(label),
+ is_default_(false),
+ ignore_minimum_size_(false),
+ minimum_size_(50, 14) {
+ // The min size in DLUs comes from
+ // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch14e.asp
+ InitBorder();
+ SetFocusable(true);
}
-void NativeButton::SetPadding(CSize size) {
- padding_ = size;
+NativeButton::~NativeButton() {
}
-gfx::Size NativeButton::GetPreferredSize() {
- HWND hwnd = GetNativeControlHWND();
- if (hwnd) {
- SIZE sz = {0, 0};
- ::SendMessage(hwnd,
- BCM_GETIDEALSIZE,
- 0,
- reinterpret_cast<LPARAM>(&sz));
- sz.cx += 2 * padding_.cx;
- sz.cy += 2 * padding_.cy;
-
- if (enforce_dlu_min_size_) {
- if (min_dlu_size_.width()) {
- sz.cx =
- std::max(static_cast<int>(sz.cx),
- font_.horizontal_dlus_to_pixels(min_dlu_size_.width()));
- }
- if (min_dlu_size_.height())
- sz.cy = std::max(static_cast<int>(sz.cy),
- font_.vertical_dlus_to_pixels(min_dlu_size_.height()));
- }
- return gfx::Size(sz.cx, sz.cy);
- }
- return gfx::Size();
-}
+void NativeButton::SetLabel(const std::wstring& label) {
+ label_ = label;
-void NativeButton::SetLabel(const std::wstring& l) {
// Even though we create a flipped HWND for a native button when the locale
// is right-to-left, Windows does not render text for the button using a
// right-to-left context (perhaps because the parent HWND is not flipped).
@@ -77,136 +59,93 @@ void NativeButton::SetLabel(const std::wstring& l) {
// RTL strings explicitly (using the appropriate Unicode formatting) so that
// Windows displays the text correctly regardless of the HWND hierarchy.
std::wstring localized_label;
- if (l10n_util::AdjustStringForLocaleDirection(l, &localized_label))
- label_.assign(localized_label);
- else
- label_.assign(l);
+ if (l10n_util::AdjustStringForLocaleDirection(label_, &localized_label))
+ label_ = localized_label;
- SetAccessibleName(l);
- UpdateNativeButton();
+ if (native_wrapper_)
+ native_wrapper_->UpdateLabel();
}
-const std::wstring NativeButton::GetLabel() const {
- return label_;
+void NativeButton::SetIsDefault(bool is_default) {
+ if (is_default == is_default_)
+ return;
+ is_default_ = is_default;
+ if (native_wrapper_)
+ native_wrapper_->UpdateDefault();
}
-HWND NativeButton::CreateNativeControl(HWND parent_container) {
- DWORD flags = WS_CHILD | BS_PUSHBUTTON;
- if (is_default_)
- flags |= BS_DEFPUSHBUTTON;
- HWND r = ::CreateWindowEx(GetAdditionalExStyle(), L"BUTTON", L"", flags, 0, 0,
- width(), height(), parent_container, NULL,
- NULL, NULL);
- SendMessage(r, WM_SETFONT, reinterpret_cast<WPARAM>(font_.hfont()), FALSE);
- ConfigureNativeButton(r);
- return r;
-}
+void NativeButton::ButtonPressed() {
+ RequestFocus();
-LRESULT NativeButton::OnNotify(int w_param, LPNMHDR l_param) {
- return 0;
+ // TODO(beng): obtain mouse event flags for native buttons someday.
+ NotifyClick(mouse_event_flags());
}
-LRESULT NativeButton::OnCommand(UINT code, int id, HWND source) {
- if (code == BN_CLICKED)
- Clicked();
- return 0;
-}
+////////////////////////////////////////////////////////////////////////////////
+// NativeButton, View overrides:
-void NativeButton::UpdateNativeButton() {
- HWND hwnd = GetNativeControlHWND();
- if (hwnd)
- ConfigureNativeButton(hwnd);
-}
+gfx::Size NativeButton::GetPreferredSize() {
+ gfx::Size sz = native_wrapper_->GetView()->GetPreferredSize();
+
+ // Add in the border size. (Do this before clamping the minimum size in case
+ // that clamping causes an increase in size that would include the borders.
+ gfx::Insets border = GetInsets();
+ sz.set_width(sz.width() + border.left() + border.right());
+ sz.set_height(sz.height() + border.top() + border.bottom());
+
+ // Clamp the size returned to at least the minimum size.
+ if (!ignore_minimum_size_) {
+ if (minimum_size_.width()) {
+ int min_width = font_.horizontal_dlus_to_pixels(minimum_size_.width());
+ sz.set_width(std::max(static_cast<int>(sz.width()), min_width));
+ }
+ if (minimum_size_.height()) {
+ int min_height = font_.vertical_dlus_to_pixels(minimum_size_.height());
+ sz.set_height(std::max(static_cast<int>(sz.height()), min_height));
+ }
+ }
-void NativeButton::ConfigureNativeButton(HWND hwnd) {
- ::SetWindowText(hwnd, label_.c_str());
+ return sz;
}
-void NativeButton::SetDefaultButton(bool is_default_button) {
- if (is_default_button == is_default_)
- return;
- is_default_ = is_default_button;
- if (is_default_button)
- AddAccelerator(Accelerator(VK_RETURN, false, false, false));
- else
- RemoveAccelerator(Accelerator(VK_RETURN, false, false, false));
- SendMessage(GetNativeControlHWND(), BM_SETSTYLE,
- is_default_button ? BS_DEFPUSHBUTTON : BS_PUSHBUTTON, true);
+void NativeButton::Layout() {
+ if (native_wrapper_) {
+ native_wrapper_->GetView()->SetBounds(0, 0, width(), height());
+ native_wrapper_->GetView()->Layout();
+ }
}
-bool NativeButton::AcceleratorPressed(const Accelerator& accelerator) {
- if (enabled_) {
- Clicked();
- return true;
+void NativeButton::ViewHierarchyChanged(bool is_add, View* parent,
+ View* child) {
+ if (is_add && !native_wrapper_ && GetWidget()) {
+ CreateWrapper();
+ AddChildView(native_wrapper_->GetView());
}
- return false;
}
-bool NativeButton::GetAccessibleRole(VARIANT* role) {
- DCHECK(role);
-
- role->vt = VT_I4;
- role->lVal = ROLE_SYSTEM_PUSHBUTTON;
- return true;
+std::string NativeButton::GetClassName() const {
+ return kViewClassName;
}
-bool NativeButton::GetAccessibleName(std::wstring* name) {
- if (!accessible_name_.empty()) {
- *name = accessible_name_;
+bool NativeButton::AcceleratorPressed(const Accelerator& accelerator) {
+ if (IsEnabled()) {
+ NotifyClick(mouse_event_flags());
return true;
}
return false;
}
-void NativeButton::SetAccessibleName(const std::wstring& name) {
- accessible_name_.assign(name);
-}
+////////////////////////////////////////////////////////////////////////////////
+// NativeButton, protected:
-void NativeButton::Init(const std::wstring& label, bool is_default) {
- // Marking the string as an RTL string if the locale is RTL. Refer to
- // the comments in NativeButton::SetLabel for more details.
- std::wstring localized_label;
- if (l10n_util::AdjustStringForLocaleDirection(label, &localized_label))
- label_.assign(localized_label);
- else
- label_.assign(label);
-
- l10n_util::AdjustStringForLocaleDirection(label, &label_);
- listener_ = NULL;
- SetAccessibleName(label);
- // The padding of 8 is a bit arbitrary, there appears to be no way to
- // get a recommended padding, and this value varies greatly among windows
- // dialogs.
- //
- // The min size in DLUs comes from
- // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch14e.asp
- padding_ = CSize(8, 0);
- is_default_ = is_default;
- min_dlu_size_.SetSize(50, 14);
- SetFocusable(true);
- if (is_default)
- AddAccelerator(Accelerator(VK_RETURN, false, false, false));
+void NativeButton::CreateWrapper() {
+ native_wrapper_ = NativeButtonWrapper::CreateNativeButtonWrapper(this);
+ native_wrapper_->UpdateLabel();
}
-void NativeButton::Clicked() {
- DCHECK(enabled_);
- // Give the focus to the button.
- RequestFocus();
-
- if (listener_)
- listener_->ButtonPressed(this);
-}
-
-bool NativeButton::NotifyOnKeyDown() const {
- return true;
-}
-
-bool NativeButton::OnKeyDown(int virtual_key_code) {
- if (virtual_key_code == VK_RETURN) {
- Clicked();
- return true;
- }
- return false;
+void NativeButton::InitBorder() {
+ set_border(Border::CreateEmptyBorder(0, kButtonBorderHWidth, 0,
+ kButtonBorderHWidth));
}
} // namespace views
diff --git a/chrome/views/controls/button/native_button.h b/chrome/views/controls/button/native_button.h
index 07d7340..566038b 100644
--- a/chrome/views/controls/button/native_button.h
+++ b/chrome/views/controls/button/native_button.h
@@ -1,146 +1,93 @@
-// Copyright (c) 2006-2008 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.
+// Copyright (c) 2009 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_VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_H_
#define CHROME_VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_H_
-#include <string>
-
-#include "base/gfx/size.h"
#include "chrome/common/gfx/chrome_font.h"
-#include "chrome/views/controls/native_control.h"
+#include "chrome/views/controls/button/button.h"
+#include "chrome/views/controls/button/native_button_wrapper.h"
+
+class ChromeFont;
namespace views {
-////////////////////////////////////////////////////////////////////////////////
-//
-// NativeButton is a wrapper for a windows native button
-// TODO(beng): (Cleanup) this should derive also from some button-like base to
-// get all the listenery-stuff for free and to work with
-// AddManagedButton.
-//
-////////////////////////////////////////////////////////////////////////////////
-class NativeButton : public NativeControl {
+class NativeButton : public Button {
public:
- explicit NativeButton(const std::wstring& label);
- NativeButton(const std::wstring& label, bool is_default);
- virtual ~NativeButton();
-
- virtual gfx::Size GetPreferredSize();
-
- void SetLabel(const std::wstring& l);
- const std::wstring GetLabel() const;
-
- std::string GetClassName() const;
-
- class Listener {
- public:
- //
- // This is invoked once the button is released.
- virtual void ButtonPressed(NativeButton* sender) = 0;
- };
-
- //
- // The the listener, the object that receives a notification when this
- // button is pressed.
- void SetListener(Listener* listener);
+ // The button's class name.
+ static const char kViewClassName[];
- // Set the font used by this button.
- void SetFont(const ChromeFont& font) { font_ = font; }
+ explicit NativeButton(ButtonListener* listener);
+ NativeButton(ButtonListener* listener, const std::wstring& label);
+ virtual ~NativeButton();
- // Adds some internal padding to the button. The |size| specified is applied
- // on both sides of the button for each directions
- void SetPadding(CSize size);
+ // Sets/Gets the text to be used as the button's label.
+ void SetLabel(const std::wstring& label);
+ std::wstring label() const { return label_; }
- // Sets/unsets this button as the default button. The default button is the
- // one triggered when enter is pressed. It is displayed with a blue border.
- void SetDefaultButton(bool is_default_button);
- bool IsDefaultButton() const { return is_default_; }
+ // Sets the font to be used when displaying the button's label.
+ void set_font(const ChromeFont& font) { font_ = font; }
+ const ChromeFont& font() const { return font_; }
- virtual LRESULT OnNotify(int w_param, LPNMHDR l_param);
- virtual LRESULT OnCommand(UINT code, int id, HWND source);
+ // Sets/Gets whether or not the button appears as the default button in its
+ // current context.
+ void SetIsDefault(bool default_button);
+ bool is_default() const { return is_default_; }
- // Invoked when the accelerator associated with the button is pressed.
- virtual bool AcceleratorPressed(const Accelerator& accelerator);
-
- // Sets the minimum size of the button from the specified size (in dialog
- // units). If the width/height is non-zero, the preferred size of the button
- // is max(preferred size of the content + padding, dlus converted to pixels).
- //
- // The default is 50, 14.
- void SetMinSizeFromDLUs(const gfx::Size& dlu_size) {
- min_dlu_size_ = dlu_size;
+ void set_minimum_size(const gfx::Size& minimum_size) {
+ minimum_size_ = minimum_size;
+ }
+ void set_ignore_minimum_size(bool ignore_minimum_size) {
+ ignore_minimum_size_ = ignore_minimum_size;
}
- // Returns the MSAA role of the current view. The role is what assistive
- // technologies (ATs) use to determine what behavior to expect from a given
- // control.
- bool GetAccessibleRole(VARIANT* role);
-
- // Returns a brief, identifying string, containing a unique, readable name.
- bool GetAccessibleName(std::wstring* name);
-
- // Assigns an accessible string name.
- void SetAccessibleName(const std::wstring& name);
-
- // Sets whether the min size of this button should follow the Windows
- // guidelines. Default is true. Set this to false if you want slim buttons.
- void set_enforce_dlu_min_size(bool value) { enforce_dlu_min_size_ = value; }
+ // Called by the wrapper when the actual wrapped native button was pressed.
+ void ButtonPressed();
- // The view class name.
- static const char kViewClassName[];
+ // Overridden from View:
+ virtual gfx::Size GetPreferredSize();
+ virtual void Layout();
protected:
+ virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
+ virtual std::string GetClassName() const;
+ virtual bool AcceleratorPressed(const Accelerator& accelerator);
- virtual HWND CreateNativeControl(HWND parent_container);
-
- // Sub-classes can call this method to cause the native button to reflect
- // the current state
- virtual void UpdateNativeButton();
+ // Create the button wrapper. Can be overridden by subclass to create a
+ // wrapper of a particular type. See NativeButtonWrapper interface for types.
+ virtual void CreateWrapper();
- // Sub-classes must override this method to properly configure the native
- // button given the current state
- virtual void ConfigureNativeButton(HWND hwnd);
+ // Sets a border to the button. Override to set a different border or to not
+ // set one (the default is 0,8,0,8 for push buttons).
+ virtual void InitBorder();
- // Overridden from NativeControl so we can activate the button when Enter is
- // pressed.
- virtual bool NotifyOnKeyDown() const;
- virtual bool OnKeyDown(int virtual_key_code);
+ // The object that actually implements the native button.
+ NativeButtonWrapper* native_wrapper_;
private:
- NativeButton() {}
-
- // Initializes the button. If |is_default| is true, this appears like the
- // "default" button, and will register Enter as its keyboard accelerator.
- void Init(const std::wstring& label, bool is_default);
-
- void Clicked();
-
- // Whether the button preferred size should follow the Microsoft layout
- // guidelines. Default is true.
- bool enforce_dlu_min_size_;
-
+ // The button label.
std::wstring label_;
- ChromeFont font_;
- Listener* listener_;
- CSize padding_;
-
- // True if the button should be rendered to appear like the "default" button
- // in the containing dialog box. Default buttons register Enter as their
- // accelerator.
+ // True if the button is the default button in its context.
bool is_default_;
- // Minimum size, in dlus (see SetMinSizeFromDLUs).
- gfx::Size min_dlu_size_;
+ // The font used to render the button label.
+ ChromeFont font_;
+
+ // True if the button should ignore the minimum size for the platform. Default
+ // is false. Set to true to create narrower buttons.
+ bool ignore_minimum_size_;
- // Storage of strings needed for accessibility.
- std::wstring accessible_name_;
+ // The minimum size of the button from the specified size in native dialog
+ // units. The definition of this unit may vary from platform to platform. If
+ // the width/height is non-zero, the preferred size of the button will not be
+ // less than this value when the dialog units are converted to pixels.
+ gfx::Size minimum_size_;
DISALLOW_COPY_AND_ASSIGN(NativeButton);
};
} // namespace views
-#endif // CHROME_VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_H_
+#endif // #ifndef CHROME_VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON_H_
diff --git a/chrome/views/controls/button/native_button2.cc b/chrome/views/controls/button/native_button2.cc
deleted file mode 100644
index 0a12e59..0000000
--- a/chrome/views/controls/button/native_button2.cc
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright (c) 2009 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.
-
-#include "chrome/views/controls/button/native_button2.h"
-
-#include "base/logging.h"
-#include "chrome/common/l10n_util.h"
-
-namespace views {
-
-static int kButtonBorderHWidth = 8;
-
-// static
-const char NativeButton2::kViewClassName[] = "chrome/views/NativeButton";
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeButton, public:
-
-NativeButton2::NativeButton2(ButtonListener* listener)
- : Button(listener),
- native_wrapper_(NULL),
- is_default_(false),
- ignore_minimum_size_(false),
- minimum_size_(50, 14) {
- // The min size in DLUs comes from
- // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch14e.asp
- InitBorder();
-}
-
-NativeButton2::NativeButton2(ButtonListener* listener,
- const std::wstring& label)
- : Button(listener),
- native_wrapper_(NULL),
- label_(label),
- is_default_(false),
- ignore_minimum_size_(false),
- minimum_size_(50, 14) {
- // The min size in DLUs comes from
- // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch14e.asp
- InitBorder();
-}
-
-NativeButton2::~NativeButton2() {
-}
-
-void NativeButton2::SetLabel(const std::wstring& label) {
- label_ = label;
-
- // Even though we create a flipped HWND for a native button when the locale
- // is right-to-left, Windows does not render text for the button using a
- // right-to-left context (perhaps because the parent HWND is not flipped).
- // The result is that RTL strings containing punctuation marks are not
- // displayed properly. For example, the string "...ABC" (where A, B and C are
- // Hebrew characters) is displayed as "ABC..." which is incorrect.
- //
- // In order to overcome this problem, we mark the localized Hebrew strings as
- // RTL strings explicitly (using the appropriate Unicode formatting) so that
- // Windows displays the text correctly regardless of the HWND hierarchy.
- std::wstring localized_label;
- if (l10n_util::AdjustStringForLocaleDirection(label_, &localized_label))
- label_ = localized_label;
-
- if (native_wrapper_)
- native_wrapper_->UpdateLabel();
-}
-
-void NativeButton2::SetIsDefault(bool is_default) {
- if (is_default == is_default_)
- return;
- is_default_ = is_default;
- if (native_wrapper_)
- native_wrapper_->UpdateDefault();
-}
-
-void NativeButton2::ButtonPressed() {
- RequestFocus();
-
- // TODO(beng): obtain mouse event flags for native buttons someday.
- NotifyClick(mouse_event_flags());
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeButton, View overrides:
-
-gfx::Size NativeButton2::GetPreferredSize() {
- gfx::Size sz = native_wrapper_->GetView()->GetPreferredSize();
-
- // Add in the border size. (Do this before clamping the minimum size in case
- // that clamping causes an increase in size that would include the borders.
- gfx::Insets border = GetInsets();
- sz.set_width(sz.width() + border.left() + border.right());
- sz.set_height(sz.height() + border.top() + border.bottom());
-
- // Clamp the size returned to at least the minimum size.
- if (!ignore_minimum_size_) {
- if (minimum_size_.width()) {
- int min_width = font_.horizontal_dlus_to_pixels(minimum_size_.width());
- sz.set_width(std::max(static_cast<int>(sz.width()), min_width));
- }
- if (minimum_size_.height()) {
- int min_height = font_.vertical_dlus_to_pixels(minimum_size_.height());
- sz.set_height(std::max(static_cast<int>(sz.height()), min_height));
- }
- }
-
- return sz;
-}
-
-void NativeButton2::Layout() {
- if (native_wrapper_) {
- native_wrapper_->GetView()->SetBounds(0, 0, width(), height());
- native_wrapper_->GetView()->Layout();
- }
-}
-
-void NativeButton2::ViewHierarchyChanged(bool is_add, View* parent,
- View* child) {
- if (is_add && !native_wrapper_ && GetWidget()) {
- CreateWrapper();
- AddChildView(native_wrapper_->GetView());
- }
-}
-
-std::string NativeButton2::GetClassName() const {
- return kViewClassName;
-}
-
-bool NativeButton2::AcceleratorPressed(const Accelerator& accelerator) {
- if (IsEnabled()) {
- NotifyClick(mouse_event_flags());
- return true;
- }
- return false;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeButton, protected:
-
-void NativeButton2::CreateWrapper() {
- native_wrapper_ = NativeButtonWrapper::CreateNativeButtonWrapper(this);
- native_wrapper_->UpdateLabel();
-}
-
-void NativeButton2::InitBorder() {
- set_border(Border::CreateEmptyBorder(0, kButtonBorderHWidth, 0,
- kButtonBorderHWidth));
-}
-
-} // namespace views
diff --git a/chrome/views/controls/button/native_button2.h b/chrome/views/controls/button/native_button2.h
deleted file mode 100644
index 691a76c..0000000
--- a/chrome/views/controls/button/native_button2.h
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright (c) 2009 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_VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON2_H_
-#define CHROME_VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON2_H_
-
-#include "chrome/common/gfx/chrome_font.h"
-#include "chrome/views/controls/button/button.h"
-#include "chrome/views/controls/button/native_button_wrapper.h"
-
-class ChromeFont;
-
-namespace views {
-
-class NativeButton2 : public Button {
- public:
- // The button's class name.
- static const char kViewClassName[];
-
- explicit NativeButton2(ButtonListener* listener);
- NativeButton2(ButtonListener* listener, const std::wstring& label);
- virtual ~NativeButton2();
-
- // Sets/Gets the text to be used as the button's label.
- void SetLabel(const std::wstring& label);
- std::wstring label() const { return label_; }
-
- // Sets the font to be used when displaying the button's label.
- void set_font(const ChromeFont& font) { font_ = font; }
- const ChromeFont& font() const { return font_; }
-
- // Sets/Gets whether or not the button appears as the default button in its
- // current context.
- void SetIsDefault(bool default_button);
- bool is_default() const { return is_default_; }
-
- void set_minimum_size(const gfx::Size& minimum_size) {
- minimum_size_ = minimum_size;
- }
- void set_ignore_minimum_size(bool ignore_minimum_size) {
- ignore_minimum_size_ = ignore_minimum_size;
- }
-
- // Called by the wrapper when the actual wrapped native button was pressed.
- void ButtonPressed();
-
- // Overridden from View:
- virtual gfx::Size GetPreferredSize();
- virtual void Layout();
-
- protected:
- virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
- virtual std::string GetClassName() const;
- virtual bool AcceleratorPressed(const Accelerator& accelerator);
-
- // Create the button wrapper. Can be overridden by subclass to create a
- // wrapper of a particular type. See NativeButtonWrapper interface for types.
- virtual void CreateWrapper();
-
- // Sets a border to the button. Override to set a different border or to not
- // set one (the default is 0,8,0,8 for push buttons).
- virtual void InitBorder();
-
- // The object that actually implements the native button.
- NativeButtonWrapper* native_wrapper_;
-
- private:
- // The button label.
- std::wstring label_;
-
- // True if the button is the default button in its context.
- bool is_default_;
-
- // The font used to render the button label.
- ChromeFont font_;
-
- // True if the button should ignore the minimum size for the platform. Default
- // is false. Set to true to create narrower buttons.
- bool ignore_minimum_size_;
-
- // The minimum size of the button from the specified size in native dialog
- // units. The definition of this unit may vary from platform to platform. If
- // the width/height is non-zero, the preferred size of the button will not be
- // less than this value when the dialog units are converted to pixels.
- gfx::Size minimum_size_;
-
- DISALLOW_COPY_AND_ASSIGN(NativeButton2);
-};
-
-} // namespace views
-
-#endif // #ifndef CHROME_VIEWS_CONTROLS_BUTTON_NATIVE_BUTTON2_H_
diff --git a/chrome/views/controls/button/native_button_win.cc b/chrome/views/controls/button/native_button_win.cc
index 8bffd96..aa664ba 100644
--- a/chrome/views/controls/button/native_button_win.cc
+++ b/chrome/views/controls/button/native_button_win.cc
@@ -5,9 +5,9 @@
#include "chrome/views/controls/button/native_button_win.h"
#include "base/logging.h"
-#include "chrome/views/controls/button/checkbox2.h"
-#include "chrome/views/controls/button/native_button2.h"
-#include "chrome/views/controls/button/radio_button2.h"
+#include "chrome/views/controls/button/checkbox.h"
+#include "chrome/views/controls/button/native_button.h"
+#include "chrome/views/controls/button/radio_button.h"
#include "chrome/views/widget/widget.h"
namespace views {
@@ -15,7 +15,7 @@ namespace views {
////////////////////////////////////////////////////////////////////////////////
// NativeButtonWin, public:
-NativeButtonWin::NativeButtonWin(NativeButton2* native_button)
+NativeButtonWin::NativeButtonWin(NativeButton* native_button)
: NativeControlWin(),
native_button_(native_button) {
}
@@ -108,7 +108,7 @@ static const int kCheckboxSize = 13; // pixels
////////////////////////////////////////////////////////////////////////////////
// NativeCheckboxWin, public:
-NativeCheckboxWin::NativeCheckboxWin(Checkbox2* checkbox)
+NativeCheckboxWin::NativeCheckboxWin(Checkbox* checkbox)
: NativeButtonWin(checkbox),
checkbox_(checkbox) {
}
@@ -170,7 +170,7 @@ void NativeCheckboxWin::NativeControlCreated(HWND control_hwnd) {
////////////////////////////////////////////////////////////////////////////////
// NativeRadioButtonWin, public:
-NativeRadioButtonWin::NativeRadioButtonWin(RadioButton2* radio_button)
+NativeRadioButtonWin::NativeRadioButtonWin(RadioButton* radio_button)
: NativeCheckboxWin(radio_button) {
}
@@ -193,20 +193,25 @@ void NativeRadioButtonWin::CreateNativeControl() {
// NativeButtonWrapper, public:
// static
+int NativeButtonWrapper::GetFixedWidth() {
+ return kCheckboxSize;
+}
+
+// static
NativeButtonWrapper* NativeButtonWrapper::CreateNativeButtonWrapper(
- NativeButton2* native_button) {
+ NativeButton* native_button) {
return new NativeButtonWin(native_button);
}
// static
NativeButtonWrapper* NativeButtonWrapper::CreateCheckboxWrapper(
- Checkbox2* checkbox) {
+ Checkbox* checkbox) {
return new NativeCheckboxWin(checkbox);
}
// static
NativeButtonWrapper* NativeButtonWrapper::CreateRadioButtonWrapper(
- RadioButton2* radio_button) {
+ RadioButton* radio_button) {
return new NativeRadioButtonWin(radio_button);
}
diff --git a/chrome/views/controls/button/native_button_win.h b/chrome/views/controls/button/native_button_win.h
index 4b34a20..501ae0d 100644
--- a/chrome/views/controls/button/native_button_win.h
+++ b/chrome/views/controls/button/native_button_win.h
@@ -14,7 +14,7 @@ namespace views {
class NativeButtonWin : public NativeControlWin,
public NativeButtonWrapper {
public:
- explicit NativeButtonWin(NativeButton2* native_button);
+ explicit NativeButtonWin(NativeButton* native_button);
virtual ~NativeButtonWin();
// Overridden from NativeButtonWrapper:
@@ -42,7 +42,7 @@ class NativeButtonWin : public NativeControlWin,
private:
// The NativeButton we are bound to.
- NativeButton2* native_button_;
+ NativeButton* native_button_;
DISALLOW_COPY_AND_ASSIGN(NativeButtonWin);
};
@@ -50,7 +50,7 @@ class NativeButtonWin : public NativeControlWin,
// A View that hosts a native Windows checkbox.
class NativeCheckboxWin : public NativeButtonWin {
public:
- explicit NativeCheckboxWin(Checkbox2* native_button);
+ explicit NativeCheckboxWin(Checkbox* native_button);
virtual ~NativeCheckboxWin();
// Overridden from View:
@@ -72,7 +72,7 @@ class NativeCheckboxWin : public NativeButtonWin {
private:
// The Checkbox we are bound to.
- Checkbox2* checkbox_;
+ Checkbox* checkbox_;
DISALLOW_COPY_AND_ASSIGN(NativeCheckboxWin);
};
@@ -80,7 +80,7 @@ class NativeCheckboxWin : public NativeButtonWin {
// A View that hosts a native Windows radio button.
class NativeRadioButtonWin : public NativeCheckboxWin {
public:
- explicit NativeRadioButtonWin(RadioButton2* radio_button);
+ explicit NativeRadioButtonWin(RadioButton* radio_button);
virtual ~NativeRadioButtonWin();
protected:
diff --git a/chrome/views/controls/button/native_button_wrapper.h b/chrome/views/controls/button/native_button_wrapper.h
index 3d1c932..79cca23 100644
--- a/chrome/views/controls/button/native_button_wrapper.h
+++ b/chrome/views/controls/button/native_button_wrapper.h
@@ -9,9 +9,9 @@ class ChromeFont;
namespace views {
-class Checkbox2;
-class NativeButton2;
-class RadioButton2;
+class Checkbox;
+class NativeButton;
+class RadioButton;
// A specialization of NativeControlWrapper that hosts a platform-native button.
class NativeButtonWrapper {
@@ -38,11 +38,15 @@ class NativeButtonWrapper {
// Retrieves the views::View that hosts the native control.
virtual View* GetView() = 0;
+ // Return the width of the button. Used for fixed size buttons (checkboxes and
+ // radio buttons) only.
+ static int GetFixedWidth();
+
// Creates an appropriate NativeButtonWrapper for the platform.
- static NativeButtonWrapper* CreateNativeButtonWrapper(NativeButton2* button);
- static NativeButtonWrapper* CreateCheckboxWrapper(Checkbox2* checkbox);
+ static NativeButtonWrapper* CreateNativeButtonWrapper(NativeButton* button);
+ static NativeButtonWrapper* CreateCheckboxWrapper(Checkbox* checkbox);
static NativeButtonWrapper* CreateRadioButtonWrapper(
- RadioButton2* radio_button);
+ RadioButton* radio_button);
};
diff --git a/chrome/views/controls/button/radio_button.cc b/chrome/views/controls/button/radio_button.cc
index 0736189..fb09549 100644
--- a/chrome/views/controls/button/radio_button.cc
+++ b/chrome/views/controls/button/radio_button.cc
@@ -1,110 +1,65 @@
-// Copyright (c) 2006-2008 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.
+// Copyright (c) 2009 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.
#include "chrome/views/controls/button/radio_button.h"
-#include "chrome/views/controls/label.h"
-#include "chrome/views/controls/hwnd_view.h"
#include "chrome/views/widget/root_view.h"
namespace views {
-// FIXME(ACW) there got be a better way to find out the check box sizes
-static int kRadioWidth = 13;
-static int kRadioHeight = 13;
-static int kRadioToLabel = 4;
-
+// static
const char RadioButton::kViewClassName[] = "chrome/views/RadioButton";
-RadioButton::RadioButton(const std::wstring& label, int group_id)
- : CheckBox(label) {
- SetGroup(group_id);
-}
+////////////////////////////////////////////////////////////////////////////////
+// RadioButton, public:
-RadioButton::~RadioButton() {
+RadioButton::RadioButton() : Checkbox() {
}
-HWND RadioButton::CreateNativeControl(HWND parent_container) {
- HWND r = ::CreateWindowEx(GetAdditionalExStyle(),
- L"BUTTON",
- L"",
- WS_CHILD | BS_RADIOBUTTON ,
- 0, 0, width(), height(),
- parent_container, NULL, NULL, NULL);
- ConfigureNativeButton(r);
- return r;
+RadioButton::RadioButton(const std::wstring& label) : Checkbox(label) {
}
-LRESULT RadioButton::OnCommand(UINT code, int id, HWND source) {
- // Radio buttons can't be toggled off once selected except by clicking on
- // another radio button within the same group, so we override this from
- // CheckBox to prevent this from happening.
- if (code == BN_CLICKED) {
- RequestFocus();
- if (!IsSelected()) {
- SetIsSelected(true);
- return NativeButton::OnCommand(code, id, source);
- }
- }
- return 0;
-}
-
-// static
-int RadioButton::GetTextIndent() {
- return kRadioWidth + kRadioToLabel + kFocusPaddingHorizontal;
-}
-
-
-std::string RadioButton::GetClassName() const {
- return kViewClassName;
-}
-
-gfx::Size RadioButton::GetPreferredSize() {
- gfx::Size prefsize = label_->GetPreferredSize();
- prefsize.set_height(std::max(prefsize.height() + kFocusPaddingVertical * 2,
- kRadioHeight));
- prefsize.Enlarge(kRadioToLabel + kRadioWidth + kFocusPaddingHorizontal * 2,
- 0);
- return prefsize;
+RadioButton::RadioButton(const std::wstring& label, int group_id)
+ : Checkbox(label) {
+ SetGroup(group_id);
}
-void RadioButton::Layout() {
- int label_x = GetTextIndent();
- label_->SetBounds(label_x, 0, width() - label_x, height());
- if (hwnd_view_) {
- int first_line_height = label_->GetFont().height();
- hwnd_view_->SetBounds(0, ((first_line_height - kRadioHeight) / 2) + 1,
- kRadioWidth, kRadioHeight);
- hwnd_view_->Layout();
- }
+RadioButton::~RadioButton() {
}
-void RadioButton::SetIsSelected(bool f) {
- if (f != IsSelected()) {
- if (f) {
- // We can't just get the root view here because sometimes the radio
- // button isn't attached to a root view (e.g., if it's part of a tab page
- // that is currently not active).
- View* container = GetParent();
- while (container && container->GetParent())
- container = container->GetParent();
- if (container) {
- std::vector<View*> other;
- container->GetViewsWithGroup(GetGroup(), &other);
- std::vector<View*>::iterator i;
- for (i = other.begin(); i != other.end(); ++i) {
- if (*i != this) {
- RadioButton* peer = static_cast<RadioButton*>(*i);
- peer->SetIsSelected(false);
- }
+////////////////////////////////////////////////////////////////////////////////
+// RadioButton, Checkbox overrides:
+
+void RadioButton::SetChecked(bool checked) {
+ if (checked == RadioButton::checked())
+ return;
+ if (checked) {
+ // We can't just get the root view here because sometimes the radio
+ // button isn't attached to a root view (e.g., if it's part of a tab page
+ // that is currently not active).
+ View* container = GetParent();
+ while (container && container->GetParent())
+ container = container->GetParent();
+ if (container) {
+ std::vector<View*> other;
+ container->GetViewsWithGroup(GetGroup(), &other);
+ std::vector<View*>::iterator i;
+ for (i = other.begin(); i != other.end(); ++i) {
+ if (*i != this) {
+ RadioButton* peer = static_cast<RadioButton*>(*i);
+ peer->SetChecked(false);
}
}
}
- CheckBox::SetIsSelected(f);
}
+ Checkbox::SetChecked(checked);
+
}
+////////////////////////////////////////////////////////////////////////////////
+// RadioButton, View overrides:
+
View* RadioButton::GetSelectedViewForGroup(int group_id) {
std::vector<View*> views;
GetRootView()->GetViewsWithGroup(group_id, &views);
@@ -114,10 +69,29 @@ View* RadioButton::GetSelectedViewForGroup(int group_id) {
for (std::vector<View*>::const_iterator iter = views.begin();
iter != views.end(); ++iter) {
RadioButton* radio_button = static_cast<RadioButton*>(*iter);
- if (radio_button->IsSelected())
+ if (radio_button->checked())
return radio_button;
}
return NULL;
}
+bool RadioButton::IsGroupFocusTraversable() const {
+ // When focusing a radio button with tab/shift+tab, only the selected button
+ // from the group should be focused.
+ return false;
+}
+
+std::string RadioButton::GetClassName() const {
+ return kViewClassName;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// RadioButton, NativeButton overrides:
+
+void RadioButton::CreateWrapper() {
+ native_wrapper_ = NativeButtonWrapper::CreateRadioButtonWrapper(this);
+ native_wrapper_->UpdateLabel();
+ native_wrapper_->UpdateChecked();
+}
+
} // namespace views
diff --git a/chrome/views/controls/button/radio_button.h b/chrome/views/controls/button/radio_button.h
index dbae232..f1db45b 100644
--- a/chrome/views/controls/button/radio_button.h
+++ b/chrome/views/controls/button/radio_button.h
@@ -1,6 +1,6 @@
-// Copyright (c) 2006-2008 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.
+// Copyright (c) 2009 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_VIEWS_CONTROLS_BUTTON_RADIO_BUTTON_H_
#define CHROME_VIEWS_CONTROLS_BUTTON_RADIO_BUTTON_H_
@@ -9,52 +9,34 @@
namespace views {
-////////////////////////////////////////////////////////////////////////////////
-//
-// A wrapper for windows's native radio button. Radio buttons can be mutually
-// exclusive with other radio buttons.
-//
-////////////////////////////////////////////////////////////////////////////////
-class RadioButton : public CheckBox {
+// A Checkbox subclass representing a radio button.
+class RadioButton : public Checkbox {
public:
- // The view class name.
+ // The button's class name.
static const char kViewClassName[];
- // Create a radio button with the provided label and group id.
- // The group id is used to identify all the other radio buttons which are in
- // mutual exclusion with this radio button. Note: RadioButton assumes that
- // all views with that group id are RadioButton. It is an error to give
- // that group id to another view subclass which is not a radio button or
- // a radio button subclass.
+ RadioButton();
+ RadioButton(const std::wstring& label);
RadioButton(const std::wstring& label, int group_id);
virtual ~RadioButton();
- virtual gfx::Size GetPreferredSize();
- virtual void Layout();
-
- virtual std::string GetClassName() const;
-
- // Overridden to properly perform mutual exclusion.
- virtual void SetIsSelected(bool f);
+ // Overridden from Checkbox:
+ virtual void SetChecked(bool checked);
+ // Overridden from View:
virtual View* GetSelectedViewForGroup(int group_id);
-
- // When focusing a RadioButton with Tab/Shift-Tab, only the selected button
- // from the group should be accessible.
- virtual bool IsGroupFocusTraversable() const { return false; }
+ virtual bool IsGroupFocusTraversable() const;
protected:
- virtual HWND CreateNativeControl(HWND parent_container);
- virtual LRESULT OnCommand(UINT code, int id, HWND source);
+ virtual std::string GetClassName() const;
- private:
- // Get the horizontal distance of the start of the text from the left of the
- // control.
- static int GetTextIndent();
+ // Overridden from NativeButton:
+ virtual void CreateWrapper();
- DISALLOW_EVIL_CONSTRUCTORS(RadioButton);
+ private:
+ DISALLOW_COPY_AND_ASSIGN(RadioButton);
};
} // namespace views
-#endif // CHROME_VIEWS_CONTROLS_BUTTON_RADIO_BUTTON_H_
+#endif // #ifndef CHROME_VIEWS_CONTROLS_BUTTON_RADIO_BUTTON_H_
diff --git a/chrome/views/controls/button/radio_button2.cc b/chrome/views/controls/button/radio_button2.cc
deleted file mode 100644
index 72bd927..0000000
--- a/chrome/views/controls/button/radio_button2.cc
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright (c) 2009 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.
-
-#include "chrome/views/controls/button/radio_button2.h"
-
-#include "chrome/views/widget/root_view.h"
-
-namespace views {
-
-// static
-const char RadioButton2::kViewClassName[] = "chrome/views/RadioButton";
-
-////////////////////////////////////////////////////////////////////////////////
-// RadioButton, public:
-
-RadioButton2::RadioButton2() {
-}
-
-RadioButton2::RadioButton2(ButtonListener* listener) : Checkbox2(listener) {
-}
-
-RadioButton2::RadioButton2(ButtonListener* listener, const std::wstring& label)
- : Checkbox2(listener, label) {
-}
-
-RadioButton2::RadioButton2(ButtonListener* listener,
- const std::wstring& label,
- int group_id)
- : Checkbox2(listener, label) {
- SetGroup(group_id);
-}
-
-RadioButton2::~RadioButton2() {
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// RadioButton, Checkbox overrides:
-
-void RadioButton2::SetChecked(bool checked) {
- if (checked == RadioButton2::checked())
- return;
- if (checked) {
- // We can't just get the root view here because sometimes the radio
- // button isn't attached to a root view (e.g., if it's part of a tab page
- // that is currently not active).
- View* container = GetParent();
- while (container && container->GetParent())
- container = container->GetParent();
- if (container) {
- std::vector<View*> other;
- container->GetViewsWithGroup(GetGroup(), &other);
- std::vector<View*>::iterator i;
- for (i = other.begin(); i != other.end(); ++i) {
- if (*i != this) {
- RadioButton2* peer = static_cast<RadioButton2*>(*i);
- peer->SetChecked(false);
- }
- }
- }
- }
- Checkbox2::SetChecked(checked);
-
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// RadioButton, View overrides:
-
-View* RadioButton2::GetSelectedViewForGroup(int group_id) {
- std::vector<View*> views;
- GetRootView()->GetViewsWithGroup(group_id, &views);
- if (views.empty())
- return NULL;
-
- for (std::vector<View*>::const_iterator iter = views.begin();
- iter != views.end(); ++iter) {
- RadioButton2* radio_button = static_cast<RadioButton2*>(*iter);
- if (radio_button->checked())
- return radio_button;
- }
- return NULL;
-}
-
-bool RadioButton2::IsGroupFocusTraversable() const {
- // When focusing a radio button with tab/shift+tab, only the selected button
- // from the group should be focused.
- return false;
-}
-
-std::string RadioButton2::GetClassName() const {
- return kViewClassName;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// RadioButton, NativeButton overrides:
-
-void RadioButton2::CreateWrapper() {
- native_wrapper_ = NativeButtonWrapper::CreateRadioButtonWrapper(this);
- native_wrapper_->UpdateLabel();
- native_wrapper_->UpdateChecked();
-}
-
-} // namespace views
diff --git a/chrome/views/controls/button/radio_button2.h b/chrome/views/controls/button/radio_button2.h
deleted file mode 100644
index ce198d1..0000000
--- a/chrome/views/controls/button/radio_button2.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) 2009 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_VIEWS_CONTROLS_BUTTON_RADIO_BUTTON2_H_
-#define CHROME_VIEWS_CONTROLS_BUTTON_RADIO_BUTTON2_H_
-
-#include "chrome/views/controls/button/checkbox2.h"
-
-namespace views {
-
-// A Checkbox subclass representing a radio button.
-class RadioButton2 : public Checkbox2 {
- public:
- // The button's class name.
- static const char kViewClassName[];
-
- RadioButton2();
- explicit RadioButton2(ButtonListener* listener);
- RadioButton2(ButtonListener* listener, const std::wstring& label);
- RadioButton2(ButtonListener* listener,
- const std::wstring& label,
- int group_id);
- virtual ~RadioButton2();
-
- // Overridden from Checkbox:
- virtual void SetChecked(bool checked);
-
- // Overridden from View:
- virtual View* GetSelectedViewForGroup(int group_id);
- virtual bool IsGroupFocusTraversable() const;
-
- protected:
- virtual std::string GetClassName() const;
-
- // Overridden from NativeButton2:
- virtual void CreateWrapper();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(RadioButton2);
-};
-
-} // namespace views
-
-#endif // #ifndef CHROME_VIEWS_CONTROLS_BUTTON_CHECKBOX2_H_
diff --git a/chrome/views/controls/message_box_view.cc b/chrome/views/controls/message_box_view.cc
index b1219f6..6a57480 100644
--- a/chrome/views/controls/message_box_view.cc
+++ b/chrome/views/controls/message_box_view.cc
@@ -24,7 +24,7 @@ MessageBoxView::MessageBoxView(int dialog_flags,
: message_label_(new views::Label(message)),
prompt_field_(NULL),
icon_(NULL),
- check_box_(NULL),
+ checkbox_(NULL),
message_width_(message_width),
focus_grabber_factory_(this) {
Init(dialog_flags, default_prompt);
@@ -36,7 +36,7 @@ MessageBoxView::MessageBoxView(int dialog_flags,
: message_label_(new views::Label(message)),
prompt_field_(NULL),
icon_(NULL),
- check_box_(NULL),
+ checkbox_(NULL),
message_width_(kDefaultMessageWidth),
focus_grabber_factory_(this) {
Init(dialog_flags, default_prompt);
@@ -49,9 +49,7 @@ std::wstring MessageBoxView::GetInputText() {
}
bool MessageBoxView::IsCheckBoxSelected() {
- if (check_box_ == NULL)
- return false;
- return check_box_->IsSelected();
+ return checkbox_ ? checkbox_->checked() : false;
}
void MessageBoxView::SetIcon(const SkBitmap& icon) {
@@ -63,17 +61,17 @@ void MessageBoxView::SetIcon(const SkBitmap& icon) {
}
void MessageBoxView::SetCheckBoxLabel(const std::wstring& label) {
- if (!check_box_)
- check_box_ = new views::CheckBox(label);
+ if (!checkbox_)
+ checkbox_ = new views::Checkbox(label);
else
- check_box_->SetLabel(label);
+ checkbox_->SetLabel(label);
ResetLayoutManager();
}
void MessageBoxView::SetCheckBoxSelected(bool selected) {
- if (!check_box_)
+ if (!checkbox_)
return;
- check_box_->SetIsSelected(selected);
+ checkbox_->SetChecked(selected);
}
///////////////////////////////////////////////////////////////////////////////
@@ -160,7 +158,7 @@ void MessageBoxView::ResetLayoutManager() {
// Column set for checkbox, if one has been set.
const int checkbox_column_view_set_id = 2;
- if (check_box_) {
+ if (checkbox_) {
column_set = layout->AddColumnSet(checkbox_column_view_set_id);
if (icon_) {
column_set->AddPaddingColumn(0,
@@ -182,10 +180,10 @@ void MessageBoxView::ResetLayoutManager() {
layout->AddView(prompt_field_);
}
- if (check_box_) {
+ if (checkbox_) {
layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
layout->StartRow(0, checkbox_column_view_set_id);
- layout->AddView(check_box_);
+ layout->AddView(checkbox_);
}
layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
diff --git a/chrome/views/controls/message_box_view.h b/chrome/views/controls/message_box_view.h
index 2a8e18f..43589a9 100644
--- a/chrome/views/controls/message_box_view.h
+++ b/chrome/views/controls/message_box_view.h
@@ -8,12 +8,15 @@
#include <string>
#include "base/task.h"
-#include "chrome/views/controls/button/checkbox.h"
#include "chrome/views/controls/image_view.h"
#include "chrome/views/controls/label.h"
#include "chrome/views/controls/text_field.h"
#include "chrome/views/view.h"
+namespace views {
+class Checkbox;
+}
+
// This class displays the contents of a message box. It is intended for use
// within a constrained window, and has options for a message, prompt, OK
// and Cancel buttons.
@@ -106,7 +109,7 @@ class MessageBoxView : public views::View {
views::ImageView* icon_;
// Checkbox for the message box.
- views::CheckBox* check_box_;
+ views::Checkbox* checkbox_;
// Maximum width of the message label.
int message_width_;
diff --git a/chrome/views/controls/native_control_win.cc b/chrome/views/controls/native_control_win.cc
index 4e4f2f7..e8574f0 100644
--- a/chrome/views/controls/native_control_win.cc
+++ b/chrome/views/controls/native_control_win.cc
@@ -60,6 +60,9 @@ void NativeControlWin::ViewHierarchyChanged(bool is_add, View* parent,
// parent HWND to function properly.
if (is_add && GetWidget() && !GetHWND())
CreateNativeControl();
+
+ // Call the base class to hide the view if we're being removed.
+ HWNDView::ViewHierarchyChanged(is_add, parent, child);
}
void NativeControlWin::VisibilityChanged(View* starting_from, bool is_visible) {
diff --git a/chrome/views/focus/focus_manager_unittest.cc b/chrome/views/focus/focus_manager_unittest.cc
index 5a78f32..1246de7 100644
--- a/chrome/views/focus/focus_manager_unittest.cc
+++ b/chrome/views/focus/focus_manager_unittest.cc
@@ -242,8 +242,8 @@ void TestViewWindow::Init() {
WidgetWin::Init(NULL, bounds, true);
SetContentsView(contents_);
- views::CheckBox* cb =
- new views::CheckBox(L"This is a checkbox");
+ views::Checkbox* cb =
+ new views::Checkbox(L"This is a checkbox");
contents_->AddChildView(cb);
// In this fast paced world, who really has time for non hard-coded layout?
cb->SetBounds(10, 10, 200, 20);
@@ -317,14 +317,13 @@ void TestViewWindow::Init() {
y += label_height + gap_between_labels;
- views::NativeButton* button =
- new views::NativeButton(L"Click me");
+ views::NativeButton* button = new views::NativeButton(NULL, L"Click me");
button->SetBounds(label_x, y + 10, 50, 20);
button->SetID(kFruitButtonID);
left_container->AddChildView(button);
y += 40;
- cb = new views::CheckBox(L"This is another check box");
+ cb = new views::Checkbox(L"This is another check box");
cb->SetBounds(label_x + label_width + 5, y, 100, 20);
cb->SetID(kFruitCheckBoxID);
left_container->AddChildView(cb);
@@ -409,18 +408,18 @@ void TestViewWindow::Init() {
y = 250;
int width = 50;
- button = new views::NativeButton(L"OK");
+ button = new views::NativeButton(NULL, L"OK");
button->SetID(kOKButtonID);
contents_->AddChildView(button);
button->SetBounds(150, y, width, 20);
- button = new views::NativeButton(L"Cancel");
+ button = new views::NativeButton(NULL, L"Cancel");
button->SetID(kCancelButtonID);
contents_->AddChildView(button);
button->SetBounds(250, y, width, 20);
- button = new views::NativeButton(L"Help");
+ button = new views::NativeButton(NULL, L"Help");
button->SetID(kHelpButtonID);
contents_->AddChildView(button);
button->SetBounds(350, y, width, 20);
@@ -431,17 +430,17 @@ void TestViewWindow::Init() {
views::View* contents = new views::View();
contents->set_background(
views::Background::CreateSolidBackground(SK_ColorWHITE));
- cb = new views::CheckBox(L"Bold");
+ cb = new views::Checkbox(L"Bold");
contents->AddChildView(cb);
cb->SetBounds(10, 10, 50, 20);
cb->SetID(kBoldCheckBoxID);
- cb = new views::CheckBox(L"Italic");
+ cb = new views::Checkbox(L"Italic");
contents->AddChildView(cb);
cb->SetBounds(70, 10, 50, 20);
cb->SetID(kItalicCheckBoxID);
- cb = new views::CheckBox(L"Underlined");
+ cb = new views::Checkbox(L"Underlined");
contents->AddChildView(cb);
cb->SetBounds(130, 10, 70, 20);
cb->SetID(kUnderlinedCheckBoxID);
@@ -462,7 +461,7 @@ void TestViewWindow::Init() {
text_field->SetBounds(10, 10, 100, 20);
text_field->SetID(kSearchTextFieldID);
- button = new views::NativeButton(L"Search");
+ button = new views::NativeButton(NULL, L"Search");
contents->AddChildView(button);
button->SetBounds(115, 10, 50, 20);
button->SetID(kSearchButtonID);
@@ -486,11 +485,11 @@ void TestViewWindow::Init() {
contents->set_background(
views::Background::CreateSolidBackground(SK_ColorBLUE));
contents->SetID(kThumbnailContainerID);
- button = new views::NativeButton(L"Star");
+ button = new views::NativeButton(NULL, L"Star");
contents->AddChildView(button);
button->SetBounds(5, 5, 50, 20);
button->SetID(kThumbnailStarID);
- button = new views::NativeButton(L"SuperStar");
+ button = new views::NativeButton(NULL, L"SuperStar");
contents->AddChildView(button);
button->SetBounds(60, 5, 100, 20);
button->SetID(kThumbnailSuperStarID);
diff --git a/chrome/views/view_unittest.cc b/chrome/views/view_unittest.cc
index 36895fc..eee1f24 100644
--- a/chrome/views/view_unittest.cc
+++ b/chrome/views/view_unittest.cc
@@ -606,9 +606,9 @@ class TestDialogView : public views::View,
virtual View* GetContentsView() {
views::View* container = new views::View();
- button1_ = new views::NativeButton(L"Button1");
- button2_ = new views::NativeButton(L"Button2");
- checkbox_ = new views::CheckBox(L"My checkbox");
+ button1_ = new views::NativeButton(NULL, L"Button1");
+ button2_ = new views::NativeButton(NULL, L"Button2");
+ checkbox_ = new views::Checkbox(L"My checkbox");
container->AddChildView(button1_);
container->AddChildView(button2_);
container->AddChildView(checkbox_);
@@ -629,35 +629,35 @@ TEST_F(ViewTest, DialogDefaultButtonTest) {
views::NativeButton* ok_button = client_view->ok_button();
views::NativeButton* cancel_button = client_view->cancel_button();
- EXPECT_TRUE(ok_button->IsDefaultButton());
+ EXPECT_TRUE(ok_button->is_default());
// Simualte focusing another button, it should become the default button.
client_view->FocusWillChange(ok_button, dialog_view_->button1_);
- EXPECT_FALSE(ok_button->IsDefaultButton());
- EXPECT_TRUE(dialog_view_->button1_->IsDefaultButton());
+ EXPECT_FALSE(ok_button->is_default());
+ EXPECT_TRUE(dialog_view_->button1_->is_default());
// Now select something that is not a button, the OK should become the default
// button again.
client_view->FocusWillChange(dialog_view_->button1_, dialog_view_->checkbox_);
- EXPECT_TRUE(ok_button->IsDefaultButton());
- EXPECT_FALSE(dialog_view_->button1_->IsDefaultButton());
+ EXPECT_TRUE(ok_button->is_default());
+ EXPECT_FALSE(dialog_view_->button1_->is_default());
// Select yet another button.
client_view->FocusWillChange(dialog_view_->checkbox_, dialog_view_->button2_);
- EXPECT_FALSE(ok_button->IsDefaultButton());
- EXPECT_FALSE(dialog_view_->button1_->IsDefaultButton());
- EXPECT_TRUE(dialog_view_->button2_->IsDefaultButton());
+ EXPECT_FALSE(ok_button->is_default());
+ EXPECT_FALSE(dialog_view_->button1_->is_default());
+ EXPECT_TRUE(dialog_view_->button2_->is_default());
// Focus nothing.
client_view->FocusWillChange(dialog_view_->button2_, NULL);
- EXPECT_TRUE(ok_button->IsDefaultButton());
- EXPECT_FALSE(dialog_view_->button1_->IsDefaultButton());
- EXPECT_FALSE(dialog_view_->button2_->IsDefaultButton());
+ EXPECT_TRUE(ok_button->is_default());
+ EXPECT_FALSE(dialog_view_->button1_->is_default());
+ EXPECT_FALSE(dialog_view_->button2_->is_default());
// Focus the cancel button.
client_view->FocusWillChange(NULL, cancel_button);
- EXPECT_FALSE(ok_button->IsDefaultButton());
- EXPECT_TRUE(cancel_button->IsDefaultButton());
- EXPECT_FALSE(dialog_view_->button1_->IsDefaultButton());
- EXPECT_FALSE(dialog_view_->button2_->IsDefaultButton());
+ EXPECT_FALSE(ok_button->is_default());
+ EXPECT_TRUE(cancel_button->is_default());
+ EXPECT_FALSE(dialog_view_->button1_->is_default());
+ EXPECT_FALSE(dialog_view_->button2_->is_default());
}
diff --git a/chrome/views/views.vcproj b/chrome/views/views.vcproj
index 01e5770..29cf7bd 100644
--- a/chrome/views/views.vcproj
+++ b/chrome/views/views.vcproj
@@ -582,14 +582,6 @@
>
</File>
<File
- RelativePath=".\controls\button\checkbox2.cc"
- >
- </File>
- <File
- RelativePath=".\controls\button\checkbox2.h"
- >
- </File>
- <File
RelativePath=".\controls\button\custom_button.cc"
>
</File>
@@ -622,14 +614,6 @@
>
</File>
<File
- RelativePath=".\controls\button\native_button2.cc"
- >
- </File>
- <File
- RelativePath=".\controls\button\native_button2.h"
- >
- </File>
- <File
RelativePath=".\controls\button\native_button_win.cc"
>
</File>
@@ -650,14 +634,6 @@
>
</File>
<File
- RelativePath=".\controls\button\radio_button2.cc"
- >
- </File>
- <File
- RelativePath=".\controls\button\radio_button2.h"
- >
- </File>
- <File
RelativePath=".\controls\button\text_button.cc"
>
</File>
diff --git a/chrome/views/window/dialog_client_view.cc b/chrome/views/window/dialog_client_view.cc
index dbc3b179..100a409 100644
--- a/chrome/views/window/dialog_client_view.cc
+++ b/chrome/views/window/dialog_client_view.cc
@@ -15,6 +15,7 @@
#include "chrome/common/l10n_util.h"
#include "chrome/common/resource_bundle.h"
#include "chrome/common/win_util.h"
+#include "chrome/views/controls/button/native_button.h"
#include "chrome/views/window/dialog_delegate.h"
#include "chrome/views/window/window.h"
#include "grit/generated_resources.h"
@@ -47,11 +48,15 @@ void FillViewWithSysColor(ChromeCanvas* canvas, View* view, COLORREF color) {
class DialogButton : public NativeButton {
public:
- DialogButton(Window* owner,
+ DialogButton(ButtonListener* listener,
+ Window* owner,
DialogDelegate::DialogButton type,
const std::wstring& title,
bool is_default)
- : NativeButton(title, is_default), owner_(owner), type_(type) {
+ : NativeButton(listener, title),
+ owner_(owner),
+ type_(type) {
+ SetIsDefault(is_default);
}
// Overridden to forward to the delegate.
@@ -108,9 +113,9 @@ void DialogClientView::ShowDialogButtons() {
label = l10n_util::GetString(IDS_OK);
bool is_default_button =
(dd->GetDefaultDialogButton() & DialogDelegate::DIALOGBUTTON_OK) != 0;
- ok_button_ = new DialogButton(window(), DialogDelegate::DIALOGBUTTON_OK,
- label, is_default_button);
- ok_button_->SetListener(this);
+ ok_button_ = new DialogButton(this, window(),
+ DialogDelegate::DIALOGBUTTON_OK, label,
+ is_default_button);
ok_button_->SetGroup(kButtonGroup);
if (is_default_button)
default_button_ = ok_button_;
@@ -131,10 +136,9 @@ void DialogClientView::ShowDialogButtons() {
bool is_default_button =
(dd->GetDefaultDialogButton() & DialogDelegate::DIALOGBUTTON_CANCEL)
!= 0;
- cancel_button_ = new DialogButton(window(),
+ cancel_button_ = new DialogButton(this, window(),
DialogDelegate::DIALOGBUTTON_CANCEL,
label, is_default_button);
- cancel_button_->SetListener(this);
cancel_button_->SetGroup(kButtonGroup);
cancel_button_->AddAccelerator(Accelerator(VK_ESCAPE, false, false, false));
if (is_default_button)
@@ -150,13 +154,13 @@ void DialogClientView::ShowDialogButtons() {
void DialogClientView::SetDefaultButton(NativeButton* new_default_button) {
if (default_button_ && default_button_ != new_default_button) {
- default_button_->SetDefaultButton(false);
+ default_button_->SetIsDefault(false);
default_button_ = NULL;
}
if (new_default_button) {
default_button_ = new_default_button;
- default_button_->SetDefaultButton(true);
+ default_button_->SetIsDefault(true);
}
}
@@ -306,9 +310,9 @@ bool DialogClientView::AcceleratorPressed(const Accelerator& accelerator) {
}
////////////////////////////////////////////////////////////////////////////////
-// DialogClientView, NativeButton::Listener implementation:
+// DialogClientView, ButtonListener implementation:
-void DialogClientView::ButtonPressed(NativeButton* sender) {
+void DialogClientView::ButtonPressed(Button* sender) {
if (sender == ok_button_) {
AcceptWindow();
} else if (sender == cancel_button_) {
diff --git a/chrome/views/window/dialog_client_view.h b/chrome/views/window/dialog_client_view.h
index 5f1417c..bfea8e0 100644
--- a/chrome/views/window/dialog_client_view.h
+++ b/chrome/views/window/dialog_client_view.h
@@ -7,12 +7,13 @@
#include "chrome/common/gfx/chrome_font.h"
#include "chrome/views/focus/focus_manager.h"
-#include "chrome/views/controls/button/native_button.h"
+#include "chrome/views/controls/button/button.h"
#include "chrome/views/window/client_view.h"
namespace views {
class DialogDelegate;
+class NativeButton;
class Window;
///////////////////////////////////////////////////////////////////////////////
@@ -25,7 +26,7 @@ class Window;
// buttons.
//
class DialogClientView : public ClientView,
- public NativeButton::Listener,
+ public ButtonListener,
public FocusChangeListener {
public:
DialogClientView(Window* window, View* contents_view);
@@ -67,8 +68,8 @@ class DialogClientView : public ClientView,
virtual gfx::Size GetPreferredSize();
virtual bool AcceleratorPressed(const Accelerator& accelerator);
- // NativeButton::Listener implementation:
- virtual void ButtonPressed(NativeButton* sender);
+ // ButtonListener implementation:
+ virtual void ButtonPressed(Button* sender);
private:
// Paint the size box in the bottom right corner of the window if it is
@@ -114,7 +115,7 @@ class DialogClientView : public ClientView,
static void InitClass();
static ChromeFont dialog_button_font_;
- DISALLOW_EVIL_CONSTRUCTORS(DialogClientView);
+ DISALLOW_COPY_AND_ASSIGN(DialogClientView);
};
} // namespace views
diff --git a/chrome/views/window/dialog_delegate.cc b/chrome/views/window/dialog_delegate.cc
index 8a1c671..9778066 100644
--- a/chrome/views/window/dialog_delegate.cc
+++ b/chrome/views/window/dialog_delegate.cc
@@ -5,6 +5,7 @@
#include "chrome/views/window/dialog_delegate.h"
#include "base/logging.h"
+#include "chrome/views/controls/button/native_button.h"
#include "chrome/views/window/window.h"
namespace views {