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 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
11 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
12 #include "chrome/grit/chromium_strings.h" | 13 #include "chrome/grit/chromium_strings.h" |
13 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
14 #include "components/signin/core/browser/signin_metrics.h" | 15 #include "components/signin/core/browser/signin_metrics.h" |
15 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
16 #include "grit/components_strings.h" | 17 #include "grit/components_strings.h" |
17 #include "skia/ext/skia_utils_mac.h" | 18 #include "skia/ext/skia_utils_mac.h" |
18 #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" |
19 #import "ui/base/cocoa/controls/hyperlink_text_view.h" | 20 #import "ui/base/cocoa/controls/hyperlink_text_view.h" |
20 #include "ui/base/l10n/l10n_util_mac.h" | 21 #include "ui/base/l10n/l10n_util_mac.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 // and has reset the callback. However, in the case that we are closing | 71 // and has reset the callback. However, in the case that we are closing |
71 // the window and nothing else has initiated the sync, we must do so here | 72 // the window and nothing else has initiated the sync, we must do so here |
72 if (isSyncDialog_ && !startSyncCallback_.is_null()) { | 73 if (isSyncDialog_ && !startSyncCallback_.is_null()) { |
73 base::ResetAndReturn(&startSyncCallback_).Run( | 74 base::ResetAndReturn(&startSyncCallback_).Run( |
74 OneClickSigninSyncStarter::UNDO_SYNC); | 75 OneClickSigninSyncStarter::UNDO_SYNC); |
75 } | 76 } |
76 } | 77 } |
77 | 78 |
78 - (IBAction)ok:(id)sender { | 79 - (IBAction)ok:(id)sender { |
79 if (isSyncDialog_) { | 80 if (isSyncDialog_) { |
80 signin_metrics::LogSigninConfirmHistogramValue( | 81 OneClickSigninHelper::LogConfirmHistogramValue( |
81 clickedLearnMore_ ? | 82 clickedLearnMore_ ? |
82 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_OK : | 83 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_OK : |
83 signin_metrics::HISTOGRAM_CONFIRM_OK); | 84 signin_metrics::HISTOGRAM_CONFIRM_OK); |
84 | 85 |
85 base::ResetAndReturn(&startSyncCallback_).Run( | 86 base::ResetAndReturn(&startSyncCallback_).Run( |
86 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); | 87 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); |
87 } | 88 } |
88 [self close]; | 89 [self close]; |
89 } | 90 } |
90 | 91 |
91 - (IBAction)onClickUndo:(id)sender { | 92 - (IBAction)onClickUndo:(id)sender { |
92 if (isSyncDialog_) { | 93 if (isSyncDialog_) { |
93 signin_metrics::LogSigninConfirmHistogramValue( | 94 OneClickSigninHelper::LogConfirmHistogramValue( |
94 clickedLearnMore_ ? | 95 clickedLearnMore_ ? |
95 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_UNDO : | 96 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_UNDO : |
96 signin_metrics::HISTOGRAM_CONFIRM_UNDO); | 97 signin_metrics::HISTOGRAM_CONFIRM_UNDO); |
97 | 98 |
98 base::ResetAndReturn(&startSyncCallback_).Run( | 99 base::ResetAndReturn(&startSyncCallback_).Run( |
99 OneClickSigninSyncStarter::UNDO_SYNC); | 100 OneClickSigninSyncStarter::UNDO_SYNC); |
100 } | 101 } |
101 [self close]; | 102 [self close]; |
102 } | 103 } |
103 | 104 |
104 - (IBAction)onClickAdvancedLink:(id)sender { | 105 - (IBAction)onClickAdvancedLink:(id)sender { |
105 if (isSyncDialog_) { | 106 if (isSyncDialog_) { |
106 signin_metrics::LogSigninConfirmHistogramValue( | 107 OneClickSigninHelper::LogConfirmHistogramValue( |
107 clickedLearnMore_ ? | 108 clickedLearnMore_ ? |
108 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_ADVANCED : | 109 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_ADVANCED : |
109 signin_metrics::HISTOGRAM_CONFIRM_ADVANCED); | 110 signin_metrics::HISTOGRAM_CONFIRM_ADVANCED); |
110 | 111 |
111 base::ResetAndReturn(&startSyncCallback_).Run( | 112 base::ResetAndReturn(&startSyncCallback_).Run( |
112 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); | 113 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
113 } | 114 } |
114 else { | 115 else { |
115 content::OpenURLParams params(GURL(chrome::kChromeUISettingsURL), | 116 content::OpenURLParams params(GURL(chrome::kChromeUISettingsURL), |
116 content::Referrer(), CURRENT_TAB, | 117 content::Referrer(), CURRENT_TAB, |
117 ui::PAGE_TRANSITION_LINK, false); | 118 ui::PAGE_TRANSITION_LINK, false); |
118 webContents_->OpenURL(params); | 119 webContents_->OpenURL(params); |
119 } | 120 } |
120 [self close]; | 121 [self close]; |
121 } | 122 } |
122 | 123 |
123 - (IBAction)onClickClose:(id)sender { | 124 - (IBAction)onClickClose:(id)sender { |
124 if (isSyncDialog_) { | 125 if (isSyncDialog_) { |
125 signin_metrics::LogSigninConfirmHistogramValue( | 126 OneClickSigninHelper::LogConfirmHistogramValue( |
126 clickedLearnMore_ ? | 127 clickedLearnMore_ ? |
127 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_CLOSE : | 128 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_CLOSE : |
128 signin_metrics::HISTOGRAM_CONFIRM_CLOSE); | 129 signin_metrics::HISTOGRAM_CONFIRM_CLOSE); |
129 | 130 |
130 base::ResetAndReturn(&startSyncCallback_).Run( | 131 base::ResetAndReturn(&startSyncCallback_).Run( |
131 OneClickSigninSyncStarter::UNDO_SYNC); | 132 OneClickSigninSyncStarter::UNDO_SYNC); |
132 } | 133 } |
133 [self close]; | 134 [self close]; |
134 } | 135 } |
135 | 136 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 IDS_OK)]; | 204 IDS_OK)]; |
204 [GTMUILocalizerAndLayoutTweaker sizeToFitView:[closeButton_ superview]]; | 205 [GTMUILocalizerAndLayoutTweaker sizeToFitView:[closeButton_ superview]]; |
205 } | 206 } |
206 | 207 |
207 // Resize bubble and window to hold the controls. | 208 // Resize bubble and window to hold the controls. |
208 [GTMUILocalizerAndLayoutTweaker | 209 [GTMUILocalizerAndLayoutTweaker |
209 resizeViewWithoutAutoResizingSubViews:[self view] | 210 resizeViewWithoutAutoResizingSubViews:[self view] |
210 delta:delta]; | 211 delta:delta]; |
211 | 212 |
212 if (isSyncDialog_) { | 213 if (isSyncDialog_) { |
213 signin_metrics::LogSigninConfirmHistogramValue( | 214 OneClickSigninHelper::LogConfirmHistogramValue( |
214 signin_metrics::HISTOGRAM_CONFIRM_SHOWN); | 215 signin_metrics::HISTOGRAM_CONFIRM_SHOWN); |
215 } | 216 } |
216 } | 217 } |
217 | 218 |
218 - (CGFloat)initializeInformativeTextView { | 219 - (CGFloat)initializeInformativeTextView { |
219 NSRect oldFrame = [informativePlaceholderTextField_ frame]; | 220 NSRect oldFrame = [informativePlaceholderTextField_ frame]; |
220 | 221 |
221 // Replace the placeholder NSTextField with the real label NSTextView. The | 222 // Replace the placeholder NSTextField with the real label NSTextView. The |
222 // former doesn't show links in a nice way, but the latter can't be added in | 223 // former doesn't show links in a nice way, but the latter can't be added in |
223 // a xib without a containing scroll view, so create the NSTextView | 224 // a xib without a containing scroll view, so create the NSTextView |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 280 |
280 return NSHeight(newFrame) - NSHeight(oldFrame); | 281 return NSHeight(newFrame) - NSHeight(oldFrame); |
281 } | 282 } |
282 | 283 |
283 - (BOOL)textView:(NSTextView*)textView | 284 - (BOOL)textView:(NSTextView*)textView |
284 clickedOnLink:(id)link | 285 clickedOnLink:(id)link |
285 atIndex:(NSUInteger)charIndex { | 286 atIndex:(NSUInteger)charIndex { |
286 if (isSyncDialog_ && !clickedLearnMore_) { | 287 if (isSyncDialog_ && !clickedLearnMore_) { |
287 clickedLearnMore_ = YES; | 288 clickedLearnMore_ = YES; |
288 | 289 |
289 signin_metrics::LogSigninConfirmHistogramValue( | 290 OneClickSigninHelper::LogConfirmHistogramValue( |
290 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE); | 291 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE); |
291 } | 292 } |
292 WindowOpenDisposition location = isSyncDialog_ ? | 293 WindowOpenDisposition location = isSyncDialog_ ? |
293 NEW_WINDOW : NEW_FOREGROUND_TAB; | 294 NEW_WINDOW : NEW_FOREGROUND_TAB; |
294 content::OpenURLParams params(GURL(chrome::kChromeSyncLearnMoreURL), | 295 content::OpenURLParams params(GURL(chrome::kChromeSyncLearnMoreURL), |
295 content::Referrer(), location, | 296 content::Referrer(), location, |
296 ui::PAGE_TRANSITION_LINK, false); | 297 ui::PAGE_TRANSITION_LINK, false); |
297 webContents_->OpenURL(params); | 298 webContents_->OpenURL(params); |
298 return YES; | 299 return YES; |
299 } | 300 } |
300 | 301 |
301 - (void)close { | 302 - (void)close { |
302 base::ResetAndReturn(&closeCallback_).Run(); | 303 base::ResetAndReturn(&closeCallback_).Run(); |
303 } | 304 } |
304 | 305 |
305 @end | 306 @end |
OLD | NEW |