Commit c713c645 authored by msarda's avatar msarda Committed by Commit bot

Change the views sign-in dialog to be tab modal.

This CL changes the views sign-in dialod to be tab modal and keeps the
views sync confirmation dialog and the sign-in erorr dialogs as window modal.

BUG=677012

Review-Url: https://codereview.chromium.org/2619963003
Cr-Commit-Position: refs/heads/master@{#442875}
parent 8b090304
......@@ -46,6 +46,7 @@ class SigninViewControllerDelegate : public content::WebContentsDelegate {
SigninViewController* signin_view_controller,
Browser* browser);
// Closes the modal sign-in dialog.
void CloseModalSignin();
// Either navigates back in the signin flow if the history state allows it or
......
......@@ -42,17 +42,21 @@ SigninViewControllerDelegateViews::SigninViewControllerDelegateViews(
SigninViewController* signin_view_controller,
std::unique_ptr<views::WebView> content_view,
Browser* browser,
ui::ModalType dialog_modal_type,
bool wait_for_size)
: SigninViewControllerDelegate(signin_view_controller,
content_view->GetWebContents()),
content_view_(content_view.release()),
modal_signin_widget_(nullptr),
dialog_modal_type_(dialog_modal_type),
wait_for_size_(wait_for_size),
browser_(browser) {
DCHECK(browser_);
DCHECK(browser_->tab_strip_model()->GetActiveWebContents())
<< "A tab must be active to present the sign-in modal dialog.";
DCHECK(dialog_modal_type == ui::MODAL_TYPE_CHILD ||
dialog_modal_type == ui::MODAL_TYPE_WINDOW)
<< "Unsupported dialog modal type " << dialog_modal_type;
if (!wait_for_size_)
DisplayModal();
}
......@@ -78,7 +82,7 @@ void SigninViewControllerDelegateViews::DeleteDelegate() {
}
ui::ModalType SigninViewControllerDelegateViews::GetModalType() const {
return ui::MODAL_TYPE_WINDOW;
return dialog_modal_type_;
}
bool SigninViewControllerDelegateViews::ShouldShowCloseButton() const {
......@@ -121,9 +125,20 @@ void SigninViewControllerDelegateViews::DisplayModal() {
return;
gfx::NativeWindow window = host_web_contents->GetTopLevelNativeWindow();
modal_signin_widget_ =
constrained_window::CreateBrowserModalDialogViews(this, window);
modal_signin_widget_->Show();
switch (dialog_modal_type_) {
case ui::MODAL_TYPE_WINDOW:
modal_signin_widget_ =
constrained_window::CreateBrowserModalDialogViews(this, window);
modal_signin_widget_->Show();
break;
case ui::MODAL_TYPE_CHILD:
modal_signin_widget_ = constrained_window::ShowWebModalDialogViews(
this, browser_->tab_strip_model()->GetActiveWebContents());
break;
default:
NOTREACHED() << "Unsupported dialog modal type " << dialog_modal_type_;
}
content_view_->RequestFocus();
}
// static
......@@ -206,7 +221,7 @@ SigninViewControllerDelegate::CreateModalSigninDelegate(
signin_view_controller,
SigninViewControllerDelegateViews::CreateGaiaWebView(
nullptr, mode, browser, access_point),
browser, false);
browser, ui::MODAL_TYPE_CHILD, false);
}
SigninViewControllerDelegate*
......@@ -216,7 +231,7 @@ SigninViewControllerDelegate::CreateSyncConfirmationDelegate(
return new SigninViewControllerDelegateViews(
signin_view_controller,
SigninViewControllerDelegateViews::CreateSyncConfirmationWebView(browser),
browser, true);
browser, ui::MODAL_TYPE_WINDOW, true);
}
SigninViewControllerDelegate*
......@@ -226,5 +241,5 @@ SigninViewControllerDelegate::CreateSigninErrorDelegate(
return new SigninViewControllerDelegateViews(
signin_view_controller,
SigninViewControllerDelegateViews::CreateSigninErrorWebView(browser),
browser, true);
browser, ui::MODAL_TYPE_WINDOW, true);
}
......@@ -31,15 +31,6 @@ class WebView;
class SigninViewControllerDelegateViews : public views::DialogDelegateView,
public SigninViewControllerDelegate {
public:
// Creates and displays a constrained window containing |web_contents|. If
// |wait_for_size| is true, the delegate will wait for ResizeNativeView() to
// be called by the base class before displaying the constrained window.
SigninViewControllerDelegateViews(
SigninViewController* signin_view_controller,
std::unique_ptr<views::WebView> content_view,
Browser* browser,
bool wait_for_size);
// Creates the web view that contains the signin flow in |mode| using
// |profile| as the web content's profile, then sets |delegate| as the created
// web content's delegate.
......@@ -65,15 +56,27 @@ class SigninViewControllerDelegateViews : public views::DialogDelegateView,
int GetDialogButtons() const override;
private:
friend SigninViewControllerDelegate;
// Creates and displays a constrained window containing |web_contents|. If
// |wait_for_size| is true, the delegate will wait for ResizeNativeView() to
// be called by the base class before displaying the constrained window.
SigninViewControllerDelegateViews(
SigninViewController* signin_view_controller,
std::unique_ptr<views::WebView> content_view,
Browser* browser,
ui::ModalType dialog_modal_type,
bool wait_for_size);
~SigninViewControllerDelegateViews() override;
void PerformClose() override;
void ResizeNativeView(int height) override;
void DisplayModal();
~SigninViewControllerDelegateViews() override;
views::WebView* content_view_;
views::Widget* modal_signin_widget_; // Not owned.
ui::ModalType dialog_modal_type_;
// wait_for_size_ stores whether the dialog should only be shown after its
// content's size has been laid out and measured so that the constrained
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment