summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-05 00:44:13 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-05 00:44:13 +0000
commitdeacc1e3067cf667bd1653a5ca0aedd6d5f74e6d (patch)
treec65e580d1c09499f2a5cda285daab4650d02a0e8
parent9c2fd4b882fd801e607d48befc8b4cac50865393 (diff)
downloadchromium_src-deacc1e3067cf667bd1653a5ca0aedd6d5f74e6d.zip
chromium_src-deacc1e3067cf667bd1653a5ca0aedd6d5f74e6d.tar.gz
chromium_src-deacc1e3067cf667bd1653a5ca0aedd6d5f74e6d.tar.bz2
views: add a "footnote view" to DialogClientView.
This will be used for the Terms of Service banner in AutofillDialogViews. BUG=170511 Review URL: https://codereview.chromium.org/12047102 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180585 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/views/autofill/autofill_dialog_views.cc6
-rw-r--r--chrome/browser/ui/views/autofill/autofill_dialog_views.h1
-rw-r--r--ui/views/window/dialog_client_view.cc44
-rw-r--r--ui/views/window/dialog_client_view.h11
-rw-r--r--ui/views/window/dialog_delegate.cc4
-rw-r--r--ui/views/window/dialog_delegate.h5
6 files changed, 67 insertions, 4 deletions
diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
index b19765d..5c5d64b 100644
--- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
+++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc
@@ -504,6 +504,11 @@ views::View* AutofillDialogViews::GetExtraView() {
return button_strip_extra_view_;
}
+views::View* AutofillDialogViews::GetFootnoteView() {
+ // TODO(estade): add a view to contain the terms of service.
+ return NULL;
+}
+
bool AutofillDialogViews::Cancel() {
return true;
}
@@ -603,7 +608,6 @@ void AutofillDialogViews::InitChildViews() {
button_strip_extra_view_->SetLayoutManager(
new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
- // TODO(estade): i18n.
save_in_chrome_checkbox_ =
new views::Checkbox(controller_->SaveLocallyText());
button_strip_extra_view_->AddChildView(save_in_chrome_checkbox_);
diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.h b/chrome/browser/ui/views/autofill/autofill_dialog_views.h
index 012ee43..22b8f7b 100644
--- a/chrome/browser/ui/views/autofill/autofill_dialog_views.h
+++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.h
@@ -85,6 +85,7 @@ class AutofillDialogViews : public AutofillDialogView,
virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE;
virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE;
virtual views::View* GetExtraView() OVERRIDE;
+ virtual views::View* GetFootnoteView() OVERRIDE;
virtual bool Cancel() OVERRIDE;
virtual bool Accept() OVERRIDE;
diff --git a/ui/views/window/dialog_client_view.cc b/ui/views/window/dialog_client_view.cc
index df2c83b..ba16988 100644
--- a/ui/views/window/dialog_client_view.cc
+++ b/ui/views/window/dialog_client_view.cc
@@ -119,6 +119,7 @@ DialogClientView::DialogClientView(Widget* owner, View* contents_view)
cancel_button_(NULL),
default_button_(NULL),
extra_view_(NULL),
+ footnote_view_(NULL),
size_extra_view_height_to_buttons_(false),
notified_delegate_(false),
listening_to_focus_(false),
@@ -222,9 +223,8 @@ void DialogClientView::UpdateDialogButtons() {
if (buttons & ui::DIALOG_BUTTON_OK)
UpdateButtonHelper(ok_button_, dd, ui::DIALOG_BUTTON_OK);
- if (buttons & ui::DIALOG_BUTTON_CANCEL) {
+ if (buttons & ui::DIALOG_BUTTON_CANCEL)
UpdateButtonHelper(cancel_button_, dd, ui::DIALOG_BUTTON_CANCEL);
- }
LayoutDialogButtons();
SchedulePaint();
@@ -318,6 +318,10 @@ void DialogClientView::PaintChildren(gfx::Canvas* canvas) {
void DialogClientView::Layout() {
if (has_dialog_buttons())
LayoutDialogButtons();
+
+ if (footnote_view_)
+ LayoutFootnoteView();
+
LayoutContentsView();
}
@@ -335,6 +339,7 @@ void DialogClientView::ViewHierarchyChanged(bool is_add, View* parent,
// The "extra view" must be created and installed after the contents view
// has been inserted into the view hierarchy.
CreateExtraView();
+ CreateFootnoteView();
UpdateDialogButtons();
Layout();
}
@@ -365,6 +370,13 @@ gfx::Size DialogClientView::GetPreferredSize() {
}
}
prefsize.Enlarge(0, button_height);
+
+ if (footnote_view_) {
+ gfx::Size footnote_size = footnote_view_->GetPreferredSize();
+ prefsize.Enlarge(0, footnote_size.height());
+ prefsize.set_width(std::max(prefsize.width(), footnote_size.width()));
+ }
+
return prefsize;
}
@@ -481,10 +493,17 @@ int DialogClientView::GetDialogButtonsAreaHeight() const {
style_params_.button_vedge_margin;
}
+int DialogClientView::GetFootnoteViewHeight() const {
+ return footnote_view_ ? footnote_view_->GetPreferredSize().height() : 0;
+}
+
void DialogClientView::LayoutDialogButtons() {
gfx::Rect lb = GetContentsBounds();
gfx::Rect extra_bounds;
int bottom_y = lb.bottom() - style_params_.button_vedge_margin;
+ if (footnote_view_)
+ bottom_y -= footnote_view_->GetPreferredSize().height();
+
int button_height = GetButtonsHeight();
if (cancel_button_) {
gfx::Size ps = cancel_button_->GetPreferredSize();
@@ -521,11 +540,21 @@ void DialogClientView::LayoutDialogButtons() {
void DialogClientView::LayoutContentsView() {
gfx::Rect lb = GetContentsBounds();
- lb.set_height(std::max(0, lb.height() - GetDialogButtonsAreaHeight()));
+ lb.set_height(std::max(0, lb.height() - GetDialogButtonsAreaHeight() -
+ GetFootnoteViewHeight()));
contents_view()->SetBoundsRect(lb);
contents_view()->Layout();
}
+void DialogClientView::LayoutFootnoteView() {
+ int height = GetFootnoteViewHeight();
+ gfx::Rect bounds = GetContentsBounds();
+ bounds.set_y(bounds.height() - height);
+ bounds.set_height(height);
+ footnote_view_->SetBoundsRect(bounds);
+ footnote_view_->Layout();
+}
+
void DialogClientView::CreateExtraView() {
View* extra_view = GetDialogDelegate()->GetExtraView();
if (extra_view && !extra_view_) {
@@ -537,6 +566,15 @@ void DialogClientView::CreateExtraView() {
}
}
+void DialogClientView::CreateFootnoteView() {
+ if (footnote_view_)
+ return;
+
+ footnote_view_ = GetDialogDelegate()->GetFootnoteView();
+ if (footnote_view_)
+ AddChildView(footnote_view_);
+}
+
DialogDelegate* DialogClientView::GetDialogDelegate() const {
return GetWidget()->widget_delegate()->AsDialogDelegate();
}
diff --git a/ui/views/window/dialog_client_view.h b/ui/views/window/dialog_client_view.h
index 6550819..c8136d4 100644
--- a/ui/views/window/dialog_client_view.h
+++ b/ui/views/window/dialog_client_view.h
@@ -119,9 +119,14 @@ class VIEWS_EXPORT DialogClientView : public ClientView,
// and the spacing between bottom of buttons to end of the dialog.
int GetDialogButtonsAreaHeight() const;
+ // Returns the preferred height of |footnote_view_|, or 0 if that view is
+ // NULL.
+ int GetFootnoteViewHeight() const;
+
// Position and size various sub-views.
void LayoutDialogButtons();
void LayoutContentsView();
+ void LayoutFootnoteView();
// Makes the specified button the default button.
void SetDefaultButton(TextButton* button);
@@ -131,6 +136,9 @@ class VIEWS_EXPORT DialogClientView : public ClientView,
// Create and add the extra view, if supplied by the delegate.
void CreateExtraView();
+ // Creates and adds the footnote view, if supplied by the delegate.
+ void CreateFootnoteView();
+
// Returns the DialogDelegate for the window.
DialogDelegate* GetDialogDelegate() const;
@@ -153,6 +161,9 @@ class VIEWS_EXPORT DialogClientView : public ClientView,
// The button-level extra view, NULL unless the dialog delegate supplies one.
View* extra_view_;
+ // The view that resides beneath the dialog buttons, or NULL.
+ View* footnote_view_;
+
// See description of DialogDelegate::GetSizeExtraViewHeightToButtons for
// details on this.
bool size_extra_view_height_to_buttons_;
diff --git a/ui/views/window/dialog_delegate.cc b/ui/views/window/dialog_delegate.cc
index d9b0517..80606fc 100644
--- a/ui/views/window/dialog_delegate.cc
+++ b/ui/views/window/dialog_delegate.cc
@@ -92,6 +92,10 @@ bool DialogDelegate::GetSizeExtraViewHeightToButtons() {
return false;
}
+View* DialogDelegate::GetFootnoteView() {
+ return NULL;
+}
+
bool DialogDelegate::Cancel() {
return true;
}
diff --git a/ui/views/window/dialog_delegate.h b/ui/views/window/dialog_delegate.h
index 174648b..a039e8f 100644
--- a/ui/views/window/dialog_delegate.h
+++ b/ui/views/window/dialog_delegate.h
@@ -74,6 +74,11 @@ class VIEWS_EXPORT DialogDelegate : public WidgetDelegate {
// max(extra_view preferred height, buttons preferred height).
virtual bool GetSizeExtraViewHeightToButtons();
+ // Like GetExtraView, this function can be overridden to display an auxiliary
+ // view in the dialog. This view will be placed beneath the dialog buttons and
+ // will extend all the way from the left to the right of the dialog.
+ virtual View* GetFootnoteView();
+
// For Dialog boxes, if there is a "Cancel" button or no dialog button at all,
// this is called when the user presses the "Cancel" button or the Close
// button on the window or in the system menu, or presses the Esc key.