| Index: ui/views/window/dialog_client_view.cc
|
| diff --git a/ui/views/window/dialog_client_view.cc b/ui/views/window/dialog_client_view.cc
|
| index 1e85ab05160bf362f91a612ac0011ee56f79f096..a185c20439e5609edae2bc9c48554136c83360ac 100644
|
| --- a/ui/views/window/dialog_client_view.cc
|
| +++ b/ui/views/window/dialog_client_view.cc
|
| @@ -93,32 +93,8 @@ void DialogClientView::CancelWindow() {
|
| }
|
|
|
| void DialogClientView::UpdateDialogButtons() {
|
| - const int buttons = GetDialogDelegate()->GetDialogButtons();
|
| -
|
| - if (buttons & ui::DIALOG_BUTTON_OK) {
|
| - if (!ok_button_) {
|
| - ok_button_ = CreateDialogButton(ui::DIALOG_BUTTON_OK);
|
| - AddChildView(ok_button_);
|
| - }
|
| -
|
| - GetDialogDelegate()->UpdateButton(ok_button_, ui::DIALOG_BUTTON_OK);
|
| - } else if (ok_button_) {
|
| - delete ok_button_;
|
| - ok_button_ = nullptr;
|
| - }
|
| -
|
| - if (buttons & ui::DIALOG_BUTTON_CANCEL) {
|
| - if (!cancel_button_) {
|
| - cancel_button_ = CreateDialogButton(ui::DIALOG_BUTTON_CANCEL);
|
| - AddChildView(cancel_button_);
|
| - }
|
| -
|
| - GetDialogDelegate()->UpdateButton(cancel_button_, ui::DIALOG_BUTTON_CANCEL);
|
| - } else if (cancel_button_) {
|
| - delete cancel_button_;
|
| - cancel_button_ = nullptr;
|
| - }
|
| -
|
| + SetupLayout();
|
| + SetupViews();
|
| SetupFocusChain();
|
| }
|
|
|
| @@ -240,7 +216,6 @@ void DialogClientView::ViewHierarchyChanged(
|
| ClientView::ViewHierarchyChanged(details);
|
| if (details.is_add && details.child == this) {
|
| UpdateDialogButtons();
|
| - CreateExtraView();
|
| } else if (!details.is_add && details.child != this) {
|
| if (details.child == ok_button_)
|
| ok_button_ = nullptr;
|
| @@ -279,31 +254,12 @@ void DialogClientView::ButtonPressed(Button* sender, const ui::Event& event) {
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| -// DialogClientView, protected:
|
| -
|
| -DialogClientView::DialogClientView(View* contents_view)
|
| - : ClientView(nullptr, contents_view),
|
| - ok_button_(nullptr),
|
| - cancel_button_(nullptr),
|
| - extra_view_(nullptr),
|
| - delegate_allowed_close_(false) {}
|
| +// DialogClientView, private:
|
|
|
| DialogDelegate* DialogClientView::GetDialogDelegate() const {
|
| return GetWidget()->widget_delegate()->AsDialogDelegate();
|
| }
|
|
|
| -void DialogClientView::CreateExtraView() {
|
| - if (extra_view_)
|
| - return;
|
| -
|
| - extra_view_ = GetDialogDelegate()->CreateExtraView();
|
| - if (extra_view_) {
|
| - extra_view_->SetGroup(kButtonGroup);
|
| - AddChildView(extra_view_);
|
| - SetupFocusChain();
|
| - }
|
| -}
|
| -
|
| void DialogClientView::ChildPreferredSizeChanged(View* child) {
|
| if (child == extra_view_)
|
| Layout();
|
| @@ -313,9 +269,6 @@ void DialogClientView::ChildVisibilityChanged(View* child) {
|
| ChildPreferredSizeChanged(child);
|
| }
|
|
|
| -////////////////////////////////////////////////////////////////////////////////
|
| -// DialogClientView, private:
|
| -
|
| LabelButton* DialogClientView::CreateDialogButton(ui::DialogButton type) {
|
| const base::string16 title = GetDialogDelegate()->GetDialogButtonLabel(type);
|
| LabelButton* button = nullptr;
|
| @@ -374,6 +327,47 @@ gfx::Insets DialogClientView::GetButtonRowInsets() const {
|
| button_row_insets_.bottom(), button_row_insets_.right());
|
| }
|
|
|
| +void DialogClientView::SetupLayout() {
|
| + // TODO(tapted): Use a LayoutManager.
|
| +}
|
| +
|
| +void DialogClientView::SetupViews() {
|
| + const int buttons = GetDialogDelegate()->GetDialogButtons();
|
| +
|
| + if (buttons & ui::DIALOG_BUTTON_OK) {
|
| + if (!ok_button_) {
|
| + ok_button_ = CreateDialogButton(ui::DIALOG_BUTTON_OK);
|
| + AddChildView(ok_button_);
|
| + }
|
| +
|
| + GetDialogDelegate()->UpdateButton(ok_button_, ui::DIALOG_BUTTON_OK);
|
| + } else if (ok_button_) {
|
| + delete ok_button_;
|
| + ok_button_ = nullptr;
|
| + }
|
| +
|
| + if (buttons & ui::DIALOG_BUTTON_CANCEL) {
|
| + if (!cancel_button_) {
|
| + cancel_button_ = CreateDialogButton(ui::DIALOG_BUTTON_CANCEL);
|
| + AddChildView(cancel_button_);
|
| + }
|
| +
|
| + GetDialogDelegate()->UpdateButton(cancel_button_, ui::DIALOG_BUTTON_CANCEL);
|
| + } else if (cancel_button_) {
|
| + delete cancel_button_;
|
| + cancel_button_ = nullptr;
|
| + }
|
| +
|
| + if (extra_view_)
|
| + return;
|
| +
|
| + extra_view_ = GetDialogDelegate()->CreateExtraView();
|
| + if (extra_view_) {
|
| + extra_view_->SetGroup(kButtonGroup);
|
| + AddChildView(extra_view_);
|
| + }
|
| +}
|
| +
|
| void DialogClientView::SetupFocusChain() {
|
| // Create a vector of child views in the order of intended focus.
|
| std::vector<View*> child_views;
|
|
|