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

Side by Side Diff: chrome/browser/ui/cocoa/one_click_signin_view_controller.mm

Issue 777143003: Clean up straggler classes to use embedded signin in page in the new profiles world. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years 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 unified diff | Download patch
OLDNEW
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/browser/ui/sync/one_click_signin_helper.h"
12 #include "chrome/browser/ui/sync/one_click_signin_histogram.h"
13 #include "chrome/common/url_constants.h" 12 #include "chrome/common/url_constants.h"
14 #include "chrome/grit/chromium_strings.h" 13 #include "chrome/grit/chromium_strings.h"
15 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
15 #include "components/signin/core/browser/signin_metrics.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "grit/components_strings.h" 17 #include "grit/components_strings.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 #import "ui/base/cocoa/controls/hyperlink_text_view.h" 20 #import "ui/base/cocoa/controls/hyperlink_text_view.h"
21 #include "ui/base/l10n/l10n_util_mac.h" 21 #include "ui/base/l10n/l10n_util_mac.h"
22 22
23 namespace { 23 namespace {
24 24
25 // The margin between the top edge of the border and the error message text in 25 // The margin between the top edge of the border and the error message text in
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 if (isSyncDialog_ && !startSyncCallback_.is_null()) { 73 if (isSyncDialog_ && !startSyncCallback_.is_null()) {
74 base::ResetAndReturn(&startSyncCallback_).Run( 74 base::ResetAndReturn(&startSyncCallback_).Run(
75 OneClickSigninSyncStarter::UNDO_SYNC); 75 OneClickSigninSyncStarter::UNDO_SYNC);
76 } 76 }
77 } 77 }
78 78
79 - (IBAction)ok:(id)sender { 79 - (IBAction)ok:(id)sender {
80 if (isSyncDialog_) { 80 if (isSyncDialog_) {
81 OneClickSigninHelper::LogConfirmHistogramValue( 81 OneClickSigninHelper::LogConfirmHistogramValue(
82 clickedLearnMore_ ? 82 clickedLearnMore_ ?
83 one_click_signin::HISTOGRAM_CONFIRM_LEARN_MORE_OK : 83 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_OK :
84 one_click_signin::HISTOGRAM_CONFIRM_OK); 84 signin_metrics::HISTOGRAM_CONFIRM_OK);
85 85
86 base::ResetAndReturn(&startSyncCallback_).Run( 86 base::ResetAndReturn(&startSyncCallback_).Run(
87 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); 87 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS);
88 } 88 }
89 [self close]; 89 [self close];
90 } 90 }
91 91
92 - (IBAction)onClickUndo:(id)sender { 92 - (IBAction)onClickUndo:(id)sender {
93 if (isSyncDialog_) { 93 if (isSyncDialog_) {
94 OneClickSigninHelper::LogConfirmHistogramValue( 94 OneClickSigninHelper::LogConfirmHistogramValue(
95 clickedLearnMore_ ? 95 clickedLearnMore_ ?
96 one_click_signin::HISTOGRAM_CONFIRM_LEARN_MORE_UNDO : 96 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_UNDO :
97 one_click_signin::HISTOGRAM_CONFIRM_UNDO); 97 signin_metrics::HISTOGRAM_CONFIRM_UNDO);
98 98
99 base::ResetAndReturn(&startSyncCallback_).Run( 99 base::ResetAndReturn(&startSyncCallback_).Run(
100 OneClickSigninSyncStarter::UNDO_SYNC); 100 OneClickSigninSyncStarter::UNDO_SYNC);
101 } 101 }
102 [self close]; 102 [self close];
103 } 103 }
104 104
105 - (IBAction)onClickAdvancedLink:(id)sender { 105 - (IBAction)onClickAdvancedLink:(id)sender {
106 if (isSyncDialog_) { 106 if (isSyncDialog_) {
107 OneClickSigninHelper::LogConfirmHistogramValue( 107 OneClickSigninHelper::LogConfirmHistogramValue(
108 clickedLearnMore_ ? 108 clickedLearnMore_ ?
109 one_click_signin::HISTOGRAM_CONFIRM_LEARN_MORE_ADVANCED : 109 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_ADVANCED :
110 one_click_signin::HISTOGRAM_CONFIRM_ADVANCED); 110 signin_metrics::HISTOGRAM_CONFIRM_ADVANCED);
111 111
112 base::ResetAndReturn(&startSyncCallback_).Run( 112 base::ResetAndReturn(&startSyncCallback_).Run(
113 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); 113 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST);
114 } 114 }
115 else { 115 else {
116 content::OpenURLParams params(GURL(chrome::kChromeUISettingsURL), 116 content::OpenURLParams params(GURL(chrome::kChromeUISettingsURL),
117 content::Referrer(), CURRENT_TAB, 117 content::Referrer(), CURRENT_TAB,
118 ui::PAGE_TRANSITION_LINK, false); 118 ui::PAGE_TRANSITION_LINK, false);
119 webContents_->OpenURL(params); 119 webContents_->OpenURL(params);
120 } 120 }
121 [self close]; 121 [self close];
122 } 122 }
123 123
124 - (IBAction)onClickClose:(id)sender { 124 - (IBAction)onClickClose:(id)sender {
125 if (isSyncDialog_) { 125 if (isSyncDialog_) {
126 OneClickSigninHelper::LogConfirmHistogramValue( 126 OneClickSigninHelper::LogConfirmHistogramValue(
127 clickedLearnMore_ ? 127 clickedLearnMore_ ?
128 one_click_signin::HISTOGRAM_CONFIRM_LEARN_MORE_CLOSE : 128 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE_CLOSE :
129 one_click_signin::HISTOGRAM_CONFIRM_CLOSE); 129 signin_metrics::HISTOGRAM_CONFIRM_CLOSE);
130 130
131 base::ResetAndReturn(&startSyncCallback_).Run( 131 base::ResetAndReturn(&startSyncCallback_).Run(
132 OneClickSigninSyncStarter::UNDO_SYNC); 132 OneClickSigninSyncStarter::UNDO_SYNC);
133 } 133 }
134 [self close]; 134 [self close];
135 } 135 }
136 136
137 - (void)awakeFromNib { 137 - (void)awakeFromNib {
138 // Lay out the text controls from the bottom up. 138 // Lay out the text controls from the bottom up.
139 CGFloat totalYOffset = 0.0; 139 CGFloat totalYOffset = 0.0;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 [GTMUILocalizerAndLayoutTweaker sizeToFitView:[closeButton_ superview]]; 205 [GTMUILocalizerAndLayoutTweaker sizeToFitView:[closeButton_ superview]];
206 } 206 }
207 207
208 // Resize bubble and window to hold the controls. 208 // Resize bubble and window to hold the controls.
209 [GTMUILocalizerAndLayoutTweaker 209 [GTMUILocalizerAndLayoutTweaker
210 resizeViewWithoutAutoResizingSubViews:[self view] 210 resizeViewWithoutAutoResizingSubViews:[self view]
211 delta:delta]; 211 delta:delta];
212 212
213 if (isSyncDialog_) { 213 if (isSyncDialog_) {
214 OneClickSigninHelper::LogConfirmHistogramValue( 214 OneClickSigninHelper::LogConfirmHistogramValue(
215 one_click_signin::HISTOGRAM_CONFIRM_SHOWN); 215 signin_metrics::HISTOGRAM_CONFIRM_SHOWN);
216 } 216 }
217 } 217 }
218 218
219 - (CGFloat)initializeInformativeTextView { 219 - (CGFloat)initializeInformativeTextView {
220 NSRect oldFrame = [informativePlaceholderTextField_ frame]; 220 NSRect oldFrame = [informativePlaceholderTextField_ frame];
221 221
222 // Replace the placeholder NSTextField with the real label NSTextView. The 222 // Replace the placeholder NSTextField with the real label NSTextView. The
223 // 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
224 // a xib without a containing scroll view, so create the NSTextView 224 // a xib without a containing scroll view, so create the NSTextView
225 // programmatically. 225 // programmatically.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 return NSHeight(newFrame) - NSHeight(oldFrame); 279 return NSHeight(newFrame) - NSHeight(oldFrame);
280 } 280 }
281 281
282 - (BOOL)textView:(NSTextView*)textView 282 - (BOOL)textView:(NSTextView*)textView
283 clickedOnLink:(id)link 283 clickedOnLink:(id)link
284 atIndex:(NSUInteger)charIndex { 284 atIndex:(NSUInteger)charIndex {
285 if (isSyncDialog_ && !clickedLearnMore_) { 285 if (isSyncDialog_ && !clickedLearnMore_) {
286 clickedLearnMore_ = YES; 286 clickedLearnMore_ = YES;
287 287
288 OneClickSigninHelper::LogConfirmHistogramValue( 288 OneClickSigninHelper::LogConfirmHistogramValue(
289 one_click_signin::HISTOGRAM_CONFIRM_LEARN_MORE); 289 signin_metrics::HISTOGRAM_CONFIRM_LEARN_MORE);
290 } 290 }
291 WindowOpenDisposition location = isSyncDialog_ ? 291 WindowOpenDisposition location = isSyncDialog_ ?
292 NEW_WINDOW : NEW_FOREGROUND_TAB; 292 NEW_WINDOW : NEW_FOREGROUND_TAB;
293 content::OpenURLParams params(GURL(chrome::kChromeSyncLearnMoreURL), 293 content::OpenURLParams params(GURL(chrome::kChromeSyncLearnMoreURL),
294 content::Referrer(), location, 294 content::Referrer(), location,
295 ui::PAGE_TRANSITION_LINK, false); 295 ui::PAGE_TRANSITION_LINK, false);
296 webContents_->OpenURL(params); 296 webContents_->OpenURL(params);
297 return YES; 297 return YES;
298 } 298 }
299 299
300 - (void)close { 300 - (void)close {
301 base::ResetAndReturn(&closeCallback_).Run(); 301 base::ResetAndReturn(&closeCallback_).Run();
302 } 302 }
303 303
304 @end 304 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698