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

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: Fix bot issues 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..5081c2bc9fcf59d761d883292cc0411630e63c40 100644
--- a/chrome/browser/ui/cocoa/one_click_signin_view_controller.mm
+++ b/chrome/browser/ui/cocoa/one_click_signin_view_controller.mm
@@ -7,6 +7,7 @@
#include "base/callback_helpers.h"
#include "base/logging.h"
#include "base/mac/bundle_locations.h"
+#include "base/strings/sys_string_conversions.h"
#import "chrome/browser/ui/chrome_style.h"
#import "chrome/browser/ui/cocoa/hyperlink_text_view.h"
#include "chrome/common/url_constants.h"
@@ -35,42 +36,60 @@ 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:(const string16&)errorMessage {
if ((self = [super initWithNibName:nibName
bundle:base::mac::FrameworkBundle()])) {
webContents_ = webContents;
startSyncCallback_ = syncCallback;
closeCallback_ = closeCallback;
- DCHECK(!startSyncCallback_.is_null());
+ isSyncDialog_ = isSyncDialog;
+ errorMessage_ = base::SysUTF16ToNSString(errorMessage);
Alexei Svitkine (slow) 2013/04/19 19:54:15 Make the ctor param type NSString* and pass in nil
noms (inactive) 2013/04/22 15:28:07 I have changed the parameter to NSString* as it's
+
+ if (isSyncDialog_)
+ DCHECK(!startSyncCallback_.is_null());
}
return self;
}
- (void)viewWillClose {
- if (!startSyncCallback_.is_null()) {
+ if (isSyncDialog_ && !startSyncCallback_.is_null()) {
Alexei Svitkine (slow) 2013/04/19 19:54:15 If |isSyncDialog_| is YES, then you're already DCH
noms (inactive) 2013/04/22 15:28:07 Hmm, but you only DCHECK in the constructor, and t
Alexei Svitkine (slow) 2013/04/22 18:16:51 I guess you can add a DCHECK() here too, if you wa
noms (inactive) 2013/04/23 18:52:48 Ok, did some analysis: viewWillClose is called aft
Alexei Svitkine (slow) 2013/04/23 19:43:24 Okay, I understand the need for the NULL check giv
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 +117,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 +141,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:@" "];
- NSFont* font = ui::ResourceBundle::GetSharedInstance().GetFont(
+ NSString* messageText;
+
+ NSFont* font;
+
+ // the non-modal bubble already has a text content
Alexei Svitkine (slow) 2013/04/19 19:54:15 Comments should be full sentences.
noms (inactive) 2013/04/22 15:28:07 Done.
+ // and only needs the Learn More link (in a smaller font)
+ if (isSyncDialog_) {
+ messageText = l10n_util::GetNSStringWithFixup(IDS_ONE_CLICK_SIGNIN_DIALOG_MESSAGE);
Alexei Svitkine (slow) 2013/04/19 19:54:15 Wrap this so it doesn't excede 80 chars.
noms (inactive) 2013/04/22 15:28:07 Done.
+ messageText = [messageText stringByAppendingString:@" "];
+ font = ui::ResourceBundle::GetSharedInstance().GetFont(
chrome_style::kTextFontStyle).GetNativeFont();
+ } else {
+ messageText = @"";
+ font = ui::ResourceBundle::GetSharedInstance().GetFont(
+ ui::ResourceBundle::SmallFont).GetNativeFont();
Alexei Svitkine (slow) 2013/04/19 19:54:15 I suggest just having a fontSize local variable th
noms (inactive) 2013/04/22 15:28:07 Done.
+ }
+
NSColor* linkColor =
gfx::SkColorToCalibratedNSColor(chrome_style::GetLinkColor());
[informativeTextView_ setMessageAndLink:messageText
@@ -153,8 +187,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