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 { ...@@ -46,6 +46,7 @@ class SigninViewControllerDelegate : public content::WebContentsDelegate {
SigninViewController* signin_view_controller, SigninViewController* signin_view_controller,
Browser* browser); Browser* browser);
// Closes the modal sign-in dialog.
void CloseModalSignin(); void CloseModalSignin();
// Either navigates back in the signin flow if the history state allows it or // Either navigates back in the signin flow if the history state allows it or
......
...@@ -42,17 +42,21 @@ SigninViewControllerDelegateViews::SigninViewControllerDelegateViews( ...@@ -42,17 +42,21 @@ SigninViewControllerDelegateViews::SigninViewControllerDelegateViews(
SigninViewController* signin_view_controller, SigninViewController* signin_view_controller,
std::unique_ptr<views::WebView> content_view, std::unique_ptr<views::WebView> content_view,
Browser* browser, Browser* browser,
ui::ModalType dialog_modal_type,
bool wait_for_size) bool wait_for_size)
: SigninViewControllerDelegate(signin_view_controller, : SigninViewControllerDelegate(signin_view_controller,
content_view->GetWebContents()), content_view->GetWebContents()),
content_view_(content_view.release()), content_view_(content_view.release()),
modal_signin_widget_(nullptr), modal_signin_widget_(nullptr),
dialog_modal_type_(dialog_modal_type),
wait_for_size_(wait_for_size), wait_for_size_(wait_for_size),
browser_(browser) { browser_(browser) {
DCHECK(browser_); DCHECK(browser_);
DCHECK(browser_->tab_strip_model()->GetActiveWebContents()) DCHECK(browser_->tab_strip_model()->GetActiveWebContents())
<< "A tab must be active to present the sign-in modal dialog."; << "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_) if (!wait_for_size_)
DisplayModal(); DisplayModal();
} }
...@@ -78,7 +82,7 @@ void SigninViewControllerDelegateViews::DeleteDelegate() { ...@@ -78,7 +82,7 @@ void SigninViewControllerDelegateViews::DeleteDelegate() {
} }
ui::ModalType SigninViewControllerDelegateViews::GetModalType() const { ui::ModalType SigninViewControllerDelegateViews::GetModalType() const {
return ui::MODAL_TYPE_WINDOW; return dialog_modal_type_;
} }
bool SigninViewControllerDelegateViews::ShouldShowCloseButton() const { bool SigninViewControllerDelegateViews::ShouldShowCloseButton() const {
...@@ -121,9 +125,20 @@ void SigninViewControllerDelegateViews::DisplayModal() { ...@@ -121,9 +125,20 @@ void SigninViewControllerDelegateViews::DisplayModal() {
return; return;
gfx::NativeWindow window = host_web_contents->GetTopLevelNativeWindow(); gfx::NativeWindow window = host_web_contents->GetTopLevelNativeWindow();
modal_signin_widget_ = switch (dialog_modal_type_) {
constrained_window::CreateBrowserModalDialogViews(this, window); case ui::MODAL_TYPE_WINDOW:
modal_signin_widget_->Show(); 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 // static
...@@ -206,7 +221,7 @@ SigninViewControllerDelegate::CreateModalSigninDelegate( ...@@ -206,7 +221,7 @@ SigninViewControllerDelegate::CreateModalSigninDelegate(
signin_view_controller, signin_view_controller,
SigninViewControllerDelegateViews::CreateGaiaWebView( SigninViewControllerDelegateViews::CreateGaiaWebView(
nullptr, mode, browser, access_point), nullptr, mode, browser, access_point),
browser, false); browser, ui::MODAL_TYPE_CHILD, false);
} }
SigninViewControllerDelegate* SigninViewControllerDelegate*
...@@ -216,7 +231,7 @@ SigninViewControllerDelegate::CreateSyncConfirmationDelegate( ...@@ -216,7 +231,7 @@ SigninViewControllerDelegate::CreateSyncConfirmationDelegate(
return new SigninViewControllerDelegateViews( return new SigninViewControllerDelegateViews(
signin_view_controller, signin_view_controller,
SigninViewControllerDelegateViews::CreateSyncConfirmationWebView(browser), SigninViewControllerDelegateViews::CreateSyncConfirmationWebView(browser),
browser, true); browser, ui::MODAL_TYPE_WINDOW, true);
} }
SigninViewControllerDelegate* SigninViewControllerDelegate*
...@@ -226,5 +241,5 @@ SigninViewControllerDelegate::CreateSigninErrorDelegate( ...@@ -226,5 +241,5 @@ SigninViewControllerDelegate::CreateSigninErrorDelegate(
return new SigninViewControllerDelegateViews( return new SigninViewControllerDelegateViews(
signin_view_controller, signin_view_controller,
SigninViewControllerDelegateViews::CreateSigninErrorWebView(browser), SigninViewControllerDelegateViews::CreateSigninErrorWebView(browser),
browser, true); browser, ui::MODAL_TYPE_WINDOW, true);
} }
...@@ -31,15 +31,6 @@ class WebView; ...@@ -31,15 +31,6 @@ class WebView;
class SigninViewControllerDelegateViews : public views::DialogDelegateView, class SigninViewControllerDelegateViews : public views::DialogDelegateView,
public SigninViewControllerDelegate { public SigninViewControllerDelegate {
public: 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 // 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 // |profile| as the web content's profile, then sets |delegate| as the created
// web content's delegate. // web content's delegate.
...@@ -65,15 +56,27 @@ class SigninViewControllerDelegateViews : public views::DialogDelegateView, ...@@ -65,15 +56,27 @@ class SigninViewControllerDelegateViews : public views::DialogDelegateView,
int GetDialogButtons() const override; int GetDialogButtons() const override;
private: 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 PerformClose() override;
void ResizeNativeView(int height) override; void ResizeNativeView(int height) override;
void DisplayModal(); void DisplayModal();
~SigninViewControllerDelegateViews() override;
views::WebView* content_view_; views::WebView* content_view_;
views::Widget* modal_signin_widget_; // Not owned. 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 // 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 // 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