Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1990)

Unified Diff: chrome/browser/ui/cocoa/profiles/signin_view_controller_delegate_mac.mm

Issue 2617583006: Using native sheet to display modal dialogs for sign in (Closed)
Patch Set: Using ui::ModalType Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/profiles/signin_view_controller_delegate_mac.mm
diff --git a/chrome/browser/ui/cocoa/profiles/signin_view_controller_delegate_mac.mm b/chrome/browser/ui/cocoa/profiles/signin_view_controller_delegate_mac.mm
index 537b68bf3221a458be51c04d5f92d06083f582f5..70f9af8688b23bd2d67671ea2e08e29dd2616e3e 100644
--- a/chrome/browser/ui/cocoa/profiles/signin_view_controller_delegate_mac.mm
+++ b/chrome/browser/ui/cocoa/profiles/signin_view_controller_delegate_mac.mm
@@ -55,11 +55,13 @@ SigninViewControllerDelegateMac::SigninViewControllerDelegateMac(
std::unique_ptr<content::WebContents> web_contents,
content::WebContents* host_web_contents,
NSRect frame,
+ ui::ModalType dialog_modal_type,
bool wait_for_size)
: SigninViewControllerDelegate(signin_view_controller, web_contents.get()),
web_contents_(std::move(web_contents)),
wait_for_size_(wait_for_size),
host_web_contents_(host_web_contents),
+ dialog_modal_type_(dialog_modal_type),
window_frame_(frame) {
if (!wait_for_size_)
DisplayModal();
@@ -69,8 +71,7 @@ SigninViewControllerDelegateMac::~SigninViewControllerDelegateMac() {}
void SigninViewControllerDelegateMac::OnConstrainedWindowClosed(
ConstrainedWindowMac* window) {
- ResetSigninViewControllerDelegate();
- delete this;
+ DeleteThis();
}
// static
@@ -145,8 +146,21 @@ SigninViewControllerDelegateMac::CreateSigninErrorWebContents(
}
void SigninViewControllerDelegateMac::PerformClose() {
- if (constrained_window_.get())
- constrained_window_->CloseWebContentsModalDialog();
+ switch (dialog_modal_type_) {
+ case ui::MODAL_TYPE_CHILD:
+ if (constrained_window_.get())
+ constrained_window_->CloseWebContentsModalDialog();
+ break;
+ case ui::MODAL_TYPE_WINDOW:
+ if (window_.get()) {
+ [host_web_contents_->GetTopLevelNativeWindow() endSheet:window_];
+ window_.reset(nil);
+ DeleteThis();
+ }
+ break;
+ default:
+ NOTREACHED() << "Unsupported dialog modal type " << dialog_modal_type_;
+ }
}
void SigninViewControllerDelegateMac::ResizeNativeView(int height) {
@@ -167,8 +181,18 @@ void SigninViewControllerDelegateMac::DisplayModal() {
window_.get().contentView = web_contents_->GetNativeView();
base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
[[CustomConstrainedWindowSheet alloc] initWithCustomWindow:window_]);
- constrained_window_ =
- CreateAndShowWebModalDialogMac(this, host_web_contents_, sheet);
+ switch (dialog_modal_type_) {
+ case ui::MODAL_TYPE_CHILD:
+ constrained_window_ =
+ CreateAndShowWebModalDialogMac(this, host_web_contents_, sheet);
+ break;
+ case ui::MODAL_TYPE_WINDOW:
+ [host_web_contents_->GetTopLevelNativeWindow() beginSheet:window_
+ completionHandler:nil];
+ break;
+ default:
+ NOTREACHED() << "Unsupported dialog modal type " << dialog_modal_type_;
+ }
}
void SigninViewControllerDelegateMac::HandleKeyboardEvent(
@@ -184,6 +208,11 @@ void SigninViewControllerDelegateMac::HandleKeyboardEvent(
}
}
+void SigninViewControllerDelegateMac::DeleteThis() {
+ ResetSigninViewControllerDelegate();
+ delete this;
+}
+
// static
SigninViewControllerDelegate*
SigninViewControllerDelegate::CreateModalSigninDelegate(
@@ -192,12 +221,12 @@ SigninViewControllerDelegate::CreateModalSigninDelegate(
Browser* browser,
signin_metrics::AccessPoint access_point) {
return new SigninViewControllerDelegateMac(
- signin_view_controller,
- SigninViewControllerDelegateMac::CreateGaiaWebContents(
- nullptr, mode, browser->profile(), access_point),
- browser->tab_strip_model()->GetActiveWebContents(),
- NSMakeRect(0, 0, kModalDialogWidth, kFixedGaiaViewHeight),
- false);
+ signin_view_controller,
+ SigninViewControllerDelegateMac::CreateGaiaWebContents(
+ nullptr, mode, browser->profile(), access_point),
+ browser->tab_strip_model()->GetActiveWebContents(),
+ NSMakeRect(0, 0, kModalDialogWidth, kFixedGaiaViewHeight),
+ ui::MODAL_TYPE_CHILD, false);
}
// static
@@ -212,7 +241,7 @@ SigninViewControllerDelegate::CreateSyncConfirmationDelegate(
browser->tab_strip_model()->GetActiveWebContents(),
NSMakeRect(0, 0, kModalDialogWidth,
GetSyncConfirmationDialogPreferredHeight(browser->profile())),
- true);
+ ui::MODAL_TYPE_WINDOW, true);
}
// static
@@ -225,5 +254,6 @@ SigninViewControllerDelegate::CreateSigninErrorDelegate(
SigninViewControllerDelegateMac::CreateSigninErrorWebContents(
browser->profile()),
browser->tab_strip_model()->GetActiveWebContents(),
- NSMakeRect(0, 0, kModalDialogWidth, kSigninErrorDialogHeight), true);
+ NSMakeRect(0, 0, kModalDialogWidth, kSigninErrorDialogHeight),
+ ui::MODAL_TYPE_WINDOW, true);
}

Powered by Google App Engine
This is Rietveld 408576698