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

Unified Diff: chrome/browser/ui/cocoa/one_click_signin_view_controller.mm

Issue 13845022: Mac: Display a native bubble (instead of the JS one) after the web signin flow. (branched from http… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ntpBubble
Patch Set: Created 7 years, 8 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/one_click_signin_view_controller.mm
diff --git a/chrome/browser/ui/cocoa/one_click_signin_view_controller.mm b/chrome/browser/ui/cocoa/one_click_signin_view_controller.mm
index 05a43e94d20ad86bfb515f2a455a9e5c7b5ad165..5251466e37afb9a42bf93b704621c22533deb16e 100644
--- a/chrome/browser/ui/cocoa/one_click_signin_view_controller.mm
+++ b/chrome/browser/ui/cocoa/one_click_signin_view_controller.mm
@@ -35,42 +35,63 @@ void ShiftOriginY(NSView* view, CGFloat amount) {
@implementation OneClickSigninViewController
+
- (id)initWithNibName:(NSString*)nibName
webContents:(content::WebContents*)webContents
syncCallback:(const BrowserWindow::StartSyncCallback&)syncCallback
- closeCallback:(const base::Closure&)closeCallback {
+ closeCallback:(const base::Closure&)closeCallback
+ isSyncDialog:(BOOL)isSyncDialog
+ errorMessage:(NSString*)errorMessage {
if ((self = [super initWithNibName:nibName
bundle:base::mac::FrameworkBundle()])) {
webContents_ = webContents;
startSyncCallback_ = syncCallback;
closeCallback_ = closeCallback;
- DCHECK(!startSyncCallback_.is_null());
+ isSyncDialog_ = isSyncDialog;
+ errorMessage_.reset([errorMessage retain]);
+
+ if (isSyncDialog_)
+ DCHECK(!startSyncCallback_.is_null());
}
return self;
}
- (void)viewWillClose {
- if (!startSyncCallback_.is_null()) {
+ // This is usually called after a click handler has initiated sync
+ // and has reset the callback. However, in the case that we are closing
+ // the window and nothing else has initiated the sync, we must do so here
+ if (isSyncDialog_ && !startSyncCallback_.is_null()) {
base::ResetAndReturn(&startSyncCallback_).Run(
OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS);
}
}
- (IBAction)ok:(id)sender {
- base::ResetAndReturn(&startSyncCallback_).Run(
+ if (isSyncDialog_) {
+ base::ResetAndReturn(&startSyncCallback_).Run(
OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS);
+ }
[self close];
}
- (IBAction)onClickUndo:(id)sender {
- base::ResetAndReturn(&startSyncCallback_).Run(
- OneClickSigninSyncStarter::UNDO_SYNC);
+ if (isSyncDialog_) {
+ base::ResetAndReturn(&startSyncCallback_).Run(
+ OneClickSigninSyncStarter::UNDO_SYNC);
+ }
[self close];
}
- (IBAction)onClickAdvancedLink:(id)sender {
- base::ResetAndReturn(&startSyncCallback_).Run(
- OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST);
+ if (isSyncDialog_) {
+ base::ResetAndReturn(&startSyncCallback_).Run(
+ OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST);
+ } else {
+ content::OpenURLParams params(GURL(chrome::kChromeUISettingsURL),
+ content::Referrer(), CURRENT_TAB,
+ content::PAGE_TRANSITION_LINK, false);
+ webContents_->OpenURL(params);
+ }
[self close];
}
@@ -98,6 +119,9 @@ void ShiftOriginY(NSView* view, CGFloat amount) {
NSSize delta = NSMakeSize(0.0, totalYOffset);
+ if (!isSyncDialog_ && [errorMessage_ length] != 0)
+ [messageTextField_ setStringValue:errorMessage_];
+
// Resize bubble and window to hold the controls.
[GTMUILocalizerAndLayoutTweaker
resizeViewWithoutAutoResizingSubViews:[self view]
@@ -119,11 +143,23 @@ void ShiftOriginY(NSView* view, CGFloat amount) {
// Set the text.
NSString* learnMoreText = l10n_util::GetNSStringWithFixup(IDS_LEARN_MORE);
- NSString* messageText =
- l10n_util::GetNSStringWithFixup(IDS_ONE_CLICK_SIGNIN_DIALOG_MESSAGE);
- messageText = [messageText stringByAppendingString:@" "];
+ NSString* messageText;
+
+ ui::ResourceBundle::FontStyle fontStyle = isSyncDialog_ ?
+ chrome_style::kTextFontStyle : ui::ResourceBundle::SmallFont;
NSFont* font = ui::ResourceBundle::GetSharedInstance().GetFont(
- chrome_style::kTextFontStyle).GetNativeFont();
+ fontStyle).GetNativeFont();
+
+ // The non-modal bubble already has a text content and only needs the
+ // Learn More link (in a smaller font).
+ if (isSyncDialog_) {
+ messageText = l10n_util::GetNSStringWithFixup(
+ IDS_ONE_CLICK_SIGNIN_DIALOG_MESSAGE);
+ messageText = [messageText stringByAppendingString:@" "];
+ } else {
+ messageText = @"";
+ }
+
NSColor* linkColor =
gfx::SkColorToCalibratedNSColor(chrome_style::GetLinkColor());
[informativeTextView_ setMessageAndLink:messageText
@@ -153,8 +189,11 @@ void ShiftOriginY(NSView* view, CGFloat amount) {
- (BOOL)textView:(NSTextView*)textView
clickedOnLink:(id)link
atIndex:(NSUInteger)charIndex {
+ WindowOpenDisposition location = isSyncDialog_ ?
+ NEW_WINDOW : NEW_FOREGROUND_TAB;
+
content::OpenURLParams params(GURL(chrome::kChromeSyncLearnMoreURL),
- content::Referrer(), NEW_WINDOW,
+ content::Referrer(), location,
content::PAGE_TRANSITION_LINK, false);
webContents_->OpenURL(params);
return YES;

Powered by Google App Engine
This is Rietveld 408576698