Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/one_click_signin_view_controller.h" | 5 #import "chrome/browser/ui/cocoa/one_click_signin_view_controller.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/mac/bundle_locations.h" | 9 #include "base/mac/bundle_locations.h" |
| 10 #import "chrome/browser/ui/chrome_style.h" | 10 #import "chrome/browser/ui/chrome_style.h" |
| 11 #import "chrome/browser/ui/cocoa/hyperlink_text_view.h" | 11 #import "chrome/browser/ui/cocoa/hyperlink_text_view.h" |
| 12 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 12 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
| 13 #include "chrome/browser/ui/sync/one_click_signin_histogram.h" | 13 #include "chrome/browser/ui/sync/one_click_signin_histogram.h" |
| 14 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 16 #include "grit/chromium_strings.h" | 16 #include "grit/chromium_strings.h" |
| 17 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 18 #include "skia/ext/skia_utils_mac.h" | 18 #include "skia/ext/skia_utils_mac.h" |
| 19 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h" | 19 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h" |
| 20 #include "ui/base/l10n/l10n_util_mac.h" | 20 #include "ui/base/l10n/l10n_util_mac.h" |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 const CGFloat kTopErrorMsgMargin = 12; | |
|
groby-ooo-7-16
2014/01/27 21:28:18
Please don't abbreviate. Also, what is this consta
| |
| 25 | |
| 24 // Shift the origin of |view|'s frame by the given amount in the | 26 // Shift the origin of |view|'s frame by the given amount in the |
| 25 // positive y direction (up). | 27 // positive y direction (up). |
| 26 void ShiftOriginY(NSView* view, CGFloat amount) { | 28 void ShiftOriginY(NSView* view, CGFloat amount) { |
| 27 NSPoint origin = [view frame].origin; | 29 NSPoint origin = [view frame].origin; |
| 28 origin.y += amount; | 30 origin.y += amount; |
| 29 [view setFrameOrigin:origin]; | 31 [view setFrameOrigin:origin]; |
| 30 } | 32 } |
| 31 | 33 |
| 32 } // namespace | 34 } // namespace |
| 33 | 35 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 // Learn More link above. | 147 // Learn More link above. |
| 146 float advancedLinkHeightPlusPadding = | 148 float advancedLinkHeightPlusPadding = |
| 147 [informativePlaceholderTextField_ frame].origin.y - | 149 [informativePlaceholderTextField_ frame].origin.y - |
| 148 [advancedLink_ frame].origin.y; | 150 [advancedLink_ frame].origin.y; |
| 149 | 151 |
| 150 totalYOffset -= advancedLinkHeightPlusPadding; | 152 totalYOffset -= advancedLinkHeightPlusPadding; |
| 151 [advancedLink_ removeFromSuperview]; | 153 [advancedLink_ removeFromSuperview]; |
| 152 } | 154 } |
| 153 | 155 |
| 154 if (informativePlaceholderTextField_) { | 156 if (informativePlaceholderTextField_) { |
| 157 if (!isSyncDialog_ && ([errorMessage_ length] != 0)) { | |
| 158 // Move up the "Learn more" origin in error case to account for the | |
| 159 // smaller bubble.. | |
| 160 NSRect oldFrame = [informativePlaceholderTextField_ frame]; | |
| 161 oldFrame.origin.y += [titleTextField_ frame].size.height; | |
|
groby-ooo-7-16
2014/01/27 21:28:18
Use rectangle helpers instead:
oldFrame = NSOffse
Oren Blasberg
2014/01/29 23:52:19
Done.
| |
| 162 [informativePlaceholderTextField_ setFrame:oldFrame]; | |
| 163 } | |
| 164 | |
| 155 ShiftOriginY(informativePlaceholderTextField_, totalYOffset); | 165 ShiftOriginY(informativePlaceholderTextField_, totalYOffset); |
| 156 totalYOffset += [self initializeInformativeTextView]; | 166 totalYOffset += [self initializeInformativeTextView]; |
| 157 } | 167 } |
| 158 | 168 |
| 159 ShiftOriginY(messageTextField_, totalYOffset); | 169 ShiftOriginY(messageTextField_, totalYOffset); |
| 160 totalYOffset += | 170 totalYOffset += |
| 161 [GTMUILocalizerAndLayoutTweaker | 171 [GTMUILocalizerAndLayoutTweaker |
| 162 sizeToFitFixedWidthTextField:messageTextField_]; | 172 sizeToFitFixedWidthTextField:messageTextField_]; |
| 163 | 173 |
| 164 ShiftOriginY(titleTextField_, totalYOffset); | 174 ShiftOriginY(titleTextField_, totalYOffset); |
| 165 totalYOffset += | 175 totalYOffset += |
| 166 [GTMUILocalizerAndLayoutTweaker | 176 [GTMUILocalizerAndLayoutTweaker |
| 167 sizeToFitFixedWidthTextField:titleTextField_]; | 177 sizeToFitFixedWidthTextField:titleTextField_]; |
| 168 | 178 |
| 169 if (closeButton_) | |
| 170 ShiftOriginY(closeButton_, totalYOffset); | |
| 171 | |
| 172 NSSize delta = NSMakeSize(0.0, totalYOffset); | 179 NSSize delta = NSMakeSize(0.0, totalYOffset); |
| 173 | 180 |
| 174 if (isSyncDialog_) { | 181 if (isSyncDialog_) { |
| 175 [messageTextField_ setStringValue:l10n_util::GetNSStringWithFixup( | 182 [messageTextField_ setStringValue:l10n_util::GetNSStringWithFixup( |
| 176 IDS_ONE_CLICK_SIGNIN_DIALOG_TITLE_NEW)]; | 183 IDS_ONE_CLICK_SIGNIN_DIALOG_TITLE_NEW)]; |
| 177 } else if ([errorMessage_ length] != 0) { | 184 } else if ([errorMessage_ length] != 0) { |
| 185 [titleTextField_ setStringValue:@""]; | |
|
groby-ooo-7-16
2014/01/27 21:28:18
Can you set field values before doing the layout,
Oren Blasberg
2014/01/29 23:52:19
Could you elaborate on what you mean by "doing the
groby-ooo-7-16
2014/01/30 23:12:41
"Doing the layout" ==> Arranging where fields show
| |
| 178 [messageTextField_ setStringValue:errorMessage_]; | 186 [messageTextField_ setStringValue:errorMessage_]; |
| 187 | |
| 188 // Make the bubble less tall, as the title text will be hidden. | |
| 189 NSSize size = [[self view] frame].size; | |
| 190 size.height = size.height - [titleTextField_ frame].size.height; | |
| 191 [[self view] setFrameSize:size]; | |
|
groby-ooo-7-16
2014/01/27 21:28:18
If you do this as part of the layout flow, the cha
Oren Blasberg
2014/01/29 23:52:19
Same here: what do you mean by layout flow? Are y
groby-ooo-7-16
2014/01/30 23:12:41
Yep - arranging individual controls so they look n
| |
| 192 | |
| 193 // Shift the message text up to where the title text used to be. | |
|
groby-ooo-7-16
2014/01/27 21:28:18
Why shift the messageTextField at all? Won't the r
Oren Blasberg
2014/01/29 23:52:19
That is not happening for some reason. :/ Perhaps
groby-ooo-7-16
2014/01/30 23:12:41
Weird. If the field is outside the view's bounds,
| |
| 194 NSPoint origin = [titleTextField_ frame].origin; | |
| 195 [messageTextField_ setFrameOrigin:origin]; | |
| 196 ShiftOriginY(messageTextField_, -kTopErrorMsgMargin); | |
| 197 | |
| 198 // Use "OK" instead of "OK, got it" in the error case, and size the button | |
| 199 // accordingly. | |
| 200 [closeButton_ setTitle:l10n_util::GetNSStringWithFixup( | |
| 201 IDS_OK)]; | |
| 202 NSRect cbFrame = [closeButton_ frame]; | |
|
groby-ooo-7-16
2014/01/27 21:28:18
Please don't use abbreviations. closeButtonFrame w
Oren Blasberg
2014/01/29 23:52:19
Removed.
| |
| 203 [closeButton_ sizeToFit]; | |
| 204 NSRect fittedCbFrame = [closeButton_ frame]; | |
| 205 fittedCbFrame.origin.x += cbFrame.size.width - fittedCbFrame.size.width; | |
| 206 [closeButton_ setFrame:fittedCbFrame]; | |
|
groby-ooo-7-16
2014/01/27 21:28:18
Actually, since the view is already in a GTMWidthB
Oren Blasberg
2014/01/29 23:52:19
Done.
| |
| 179 } | 207 } |
| 180 | 208 |
| 181 // Resize bubble and window to hold the controls. | 209 // Resize bubble and window to hold the controls. |
| 182 [GTMUILocalizerAndLayoutTweaker | 210 [GTMUILocalizerAndLayoutTweaker |
| 183 resizeViewWithoutAutoResizingSubViews:[self view] | 211 resizeViewWithoutAutoResizingSubViews:[self view] |
| 184 delta:delta]; | 212 delta:delta]; |
| 185 | 213 |
| 186 if (isSyncDialog_) { | 214 if (isSyncDialog_) { |
| 187 OneClickSigninHelper::LogConfirmHistogramValue( | 215 OneClickSigninHelper::LogConfirmHistogramValue( |
| 188 one_click_signin::HISTOGRAM_CONFIRM_SHOWN); | 216 one_click_signin::HISTOGRAM_CONFIRM_SHOWN); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 content::PAGE_TRANSITION_LINK, false); | 296 content::PAGE_TRANSITION_LINK, false); |
| 269 webContents_->OpenURL(params); | 297 webContents_->OpenURL(params); |
| 270 return YES; | 298 return YES; |
| 271 } | 299 } |
| 272 | 300 |
| 273 - (void)close { | 301 - (void)close { |
| 274 base::ResetAndReturn(&closeCallback_).Run(); | 302 base::ResetAndReturn(&closeCallback_).Run(); |
| 275 } | 303 } |
| 276 | 304 |
| 277 @end | 305 @end |
| OLD | NEW |