summaryrefslogtreecommitdiffstats
path: root/ui/views
diff options
context:
space:
mode:
authorfdoray@chromium.org <fdoray@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-14 17:52:59 +0000
committerfdoray@chromium.org <fdoray@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-14 17:52:59 +0000
commit129781364dbc2e34b2cd191de368900558a61cc8 (patch)
treed7f3ce9e6f4dd3eb95ec2a141853ff5bbbd16f9d /ui/views
parentd41ba0d545d0dd315ea5f1a1189f8924ed9a7891 (diff)
downloadchromium_src-129781364dbc2e34b2cd191de368900558a61cc8.zip
chromium_src-129781364dbc2e34b2cd191de368900558a61cc8.tar.gz
chromium_src-129781364dbc2e34b2cd191de368900558a61cc8.tar.bz2
Add a link in tab modal dialogs.
Allow an optional link below the message of tab modal dialogs. BUG=175647 Review URL: https://chromiumcodereview.appspot.com/16588002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206436 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views')
-rw-r--r--ui/views/controls/message_box_view.cc50
-rw-r--r--ui/views/controls/message_box_view.h9
2 files changed, 40 insertions, 19 deletions
diff --git a/ui/views/controls/message_box_view.cc b/ui/views/controls/message_box_view.cc
index 4ee81c3..601a2ba 100644
--- a/ui/views/controls/message_box_view.cc
+++ b/ui/views/controls/message_box_view.cc
@@ -14,11 +14,13 @@
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
+#include "ui/views/controls/link.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/client_view.h"
+#include "ui/views/window/dialog_delegate.h"
namespace {
@@ -76,6 +78,7 @@ MessageBoxView::MessageBoxView(const InitParams& params)
: prompt_field_(NULL),
icon_(NULL),
checkbox_(NULL),
+ link_(NULL),
message_width_(params.message_width) {
Init(params);
}
@@ -112,6 +115,23 @@ void MessageBoxView::SetCheckBoxSelected(bool selected) {
checkbox_->SetChecked(selected);
}
+void MessageBoxView::SetLink(const string16& text, LinkListener* listener) {
+ if (text.empty()) {
+ DCHECK(!listener);
+ delete link_;
+ link_ = NULL;
+ } else {
+ DCHECK(listener);
+ if (!link_) {
+ link_ = new Link();
+ link_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
+ }
+ link_->SetText(text);
+ link_->set_listener(listener);
+ }
+ ResetLayoutManager();
+}
+
void MessageBoxView::GetAccessibleState(ui::AccessibleViewState* state) {
state->role = ui::AccessibilityTypes::ROLE_ALERT;
}
@@ -213,22 +233,10 @@ void MessageBoxView::ResetLayoutManager() {
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
GridLayout::FIXED, message_width_, 0);
- // Column set for prompt Textfield, if one has been set.
- const int textfield_column_view_set_id = 1;
- if (prompt_field_) {
- column_set = layout->AddColumnSet(textfield_column_view_set_id);
- if (icon_) {
- column_set->AddPaddingColumn(
- 0, icon_size.width() + kUnrelatedControlHorizontalSpacing);
- }
- column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
- }
-
- // Column set for checkbox, if one has been set.
- const int checkbox_column_view_set_id = 2;
- if (checkbox_) {
- column_set = layout->AddColumnSet(checkbox_column_view_set_id);
+ // Column set for extra elements, if any.
+ const int extra_column_view_set_id = 1;
+ if (prompt_field_ || checkbox_ || link_) {
+ column_set = layout->AddColumnSet(extra_column_view_set_id);
if (icon_) {
column_set->AddPaddingColumn(
0, icon_size.width() + kUnrelatedControlHorizontalSpacing);
@@ -250,17 +258,21 @@ void MessageBoxView::ResetLayoutManager() {
if (prompt_field_) {
layout->AddPaddingRow(0, inter_row_vertical_spacing_);
- layout->StartRow(0, textfield_column_view_set_id);
+ layout->StartRow(0, extra_column_view_set_id);
layout->AddView(prompt_field_);
}
if (checkbox_) {
layout->AddPaddingRow(0, inter_row_vertical_spacing_);
- layout->StartRow(0, checkbox_column_view_set_id);
+ layout->StartRow(0, extra_column_view_set_id);
layout->AddView(checkbox_);
}
- layout->AddPaddingRow(0, inter_row_vertical_spacing_);
+ if (link_) {
+ layout->AddPaddingRow(0, inter_row_vertical_spacing_);
+ layout->StartRow(0, extra_column_view_set_id);
+ layout->AddView(link_);
+ }
}
} // namespace views
diff --git a/ui/views/controls/message_box_view.h b/ui/views/controls/message_box_view.h
index 540d96d..1d92a37 100644
--- a/ui/views/controls/message_box_view.h
+++ b/ui/views/controls/message_box_view.h
@@ -19,6 +19,8 @@ namespace views {
class Checkbox;
class ImageView;
class Label;
+class Link;
+class LinkListener;
class Textfield;
// This class displays the contents of a message box. It is intended for use
@@ -76,6 +78,10 @@ class VIEWS_EXPORT MessageBoxView : public View {
// Sets the state of the check-box.
void SetCheckBoxSelected(bool selected);
+ // Sets the text and the listener of the link. If |text| is empty, the link
+ // is removed.
+ void SetLink(const string16& text, LinkListener* listener);
+
// View:
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
@@ -107,6 +113,9 @@ class VIEWS_EXPORT MessageBoxView : public View {
// Checkbox for the message box.
Checkbox* checkbox_;
+ // Link displayed at the bottom of the view.
+ Link* link_;
+
// Maximum width of the message label.
int message_width_;