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

Side by Side Diff: chrome/browser/ui/auto_login_info_bar_delegate.cc

Issue 10690006: Upstream changes needed by Android auto-login. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Nico's comments Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
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 #include "chrome/browser/ui/auto_login_info_bar_delegate.h" 5 #include "chrome/browser/ui/auto_login_info_bar_delegate.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 116 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
117 } 117 }
118 118
119 void AutoLoginRedirector::OnUbertokenFailure( 119 void AutoLoginRedirector::OnUbertokenFailure(
120 const GoogleServiceAuthError& error) { 120 const GoogleServiceAuthError& error) {
121 LOG(WARNING) << "AutoLoginRedirector: token request failed"; 121 LOG(WARNING) << "AutoLoginRedirector: token request failed";
122 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 122 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
123 } 123 }
124 124
125 void AutoLoginRedirector::RedirectToMergeSession(const std::string& token) { 125 void AutoLoginRedirector::RedirectToMergeSession(const std::string& token) {
126 // The args are URL encoded, so we need to decode them before use.
127 std::string unescaped_args =
128 net::UnescapeURLComponent(args_, net::UnescapeRule::URL_SPECIAL_CHARS);
129 // TODO(rogerta): what is the correct page transition? 126 // TODO(rogerta): what is the correct page transition?
130 navigation_controller_->LoadURL( 127 navigation_controller_->LoadURL(
131 GURL(GaiaUrls::GetInstance()->merge_session_url() + 128 GURL(GaiaUrls::GetInstance()->merge_session_url() +
132 "?source=chrome&uberauth=" + token + "&" + unescaped_args), 129 "?source=chrome&uberauth=" + token + "&" + args_),
133 content::Referrer(), content::PAGE_TRANSITION_AUTO_BOOKMARK, 130 content::Referrer(), content::PAGE_TRANSITION_AUTO_BOOKMARK,
134 std::string()); 131 std::string());
135 } 132 }
136 133
137 } // namepsace 134 } // namepsace
138 135
139 136
140 // AutoLoginInfoBarDelegate --------------------------------------------------- 137 // AutoLoginInfoBarDelegate ---------------------------------------------------
141 138
142 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate( 139 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate(
143 InfoBarTabHelper* owner, 140 InfoBarTabHelper* owner,
144 const std::string& username, 141 const std::string& realm,
145 const std::string& args) 142 const std::string& account,
143 const std::string& args,
144 const std::string& username)
146 : ConfirmInfoBarDelegate(owner), 145 : ConfirmInfoBarDelegate(owner),
146 realm_(realm),
147 account_(account),
148 args_(args),
147 username_(username), 149 username_(username),
148 args_(args),
149 button_pressed_(false) { 150 button_pressed_(false) {
150 RecordHistogramAction(HISTOGRAM_SHOWN); 151 RecordHistogramAction(HISTOGRAM_SHOWN);
151 } 152 }
152 153
153 AutoLoginInfoBarDelegate::~AutoLoginInfoBarDelegate() { 154 AutoLoginInfoBarDelegate::~AutoLoginInfoBarDelegate() {
154 if (!button_pressed_) 155 if (!button_pressed_)
155 RecordHistogramAction(HISTOGRAM_IGNORED); 156 RecordHistogramAction(HISTOGRAM_IGNORED);
156 } 157 }
157 158
159 AutoLoginInfoBarDelegate*
160 AutoLoginInfoBarDelegate::AsAutoLoginInfoBarDelegate() {
Peter Kasting 2012/06/27 17:39:05 Nit: Indent 4
Philippe 2012/06/28 09:24:00 Done.
161 return this;
162 }
163
158 void AutoLoginInfoBarDelegate::InfoBarDismissed() { 164 void AutoLoginInfoBarDelegate::InfoBarDismissed() {
159 RecordHistogramAction(HISTOGRAM_DISMISSED); 165 RecordHistogramAction(HISTOGRAM_DISMISSED);
160 button_pressed_ = true; 166 button_pressed_ = true;
161 } 167 }
162 168
163 gfx::Image* AutoLoginInfoBarDelegate::GetIcon() const { 169 gfx::Image* AutoLoginInfoBarDelegate::GetIcon() const {
164 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( 170 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
165 IDR_INFOBAR_AUTOLOGIN); 171 IDR_INFOBAR_AUTOLOGIN);
166 } 172 }
167 173
168 InfoBarDelegate::Type AutoLoginInfoBarDelegate::GetInfoBarType() const { 174 InfoBarDelegate::Type AutoLoginInfoBarDelegate::GetInfoBarType() const {
169 return PAGE_ACTION_TYPE; 175 return PAGE_ACTION_TYPE;
170 } 176 }
171 177
172 string16 AutoLoginInfoBarDelegate::GetMessageText() const { 178 string16 AutoLoginInfoBarDelegate::GetMessageText() const {
173 return l10n_util::GetStringFUTF16(IDS_AUTOLOGIN_INFOBAR_MESSAGE, 179 return GetMessageText(username_);
174 UTF8ToUTF16(username_));
175 } 180 }
176 181
177 string16 AutoLoginInfoBarDelegate::GetButtonLabel( 182 string16 AutoLoginInfoBarDelegate::GetButtonLabel(
178 InfoBarButton button) const { 183 InfoBarButton button) const {
179 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? 184 return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
180 IDS_AUTOLOGIN_INFOBAR_OK_BUTTON : IDS_AUTOLOGIN_INFOBAR_CANCEL_BUTTON); 185 IDS_AUTOLOGIN_INFOBAR_OK_BUTTON : IDS_AUTOLOGIN_INFOBAR_CANCEL_BUTTON);
181 } 186 }
182 187
183 bool AutoLoginInfoBarDelegate::Accept() { 188 bool AutoLoginInfoBarDelegate::Accept() {
184 // AutoLoginRedirector deletes itself. 189 // AutoLoginRedirector deletes itself.
185 new AutoLoginRedirector(&owner()->web_contents()->GetController(), args_); 190 new AutoLoginRedirector(&owner()->web_contents()->GetController(), args_);
186 RecordHistogramAction(HISTOGRAM_ACCEPTED); 191 RecordHistogramAction(HISTOGRAM_ACCEPTED);
187 button_pressed_ = true; 192 button_pressed_ = true;
188 return true; 193 return true;
189 } 194 }
190 195
191 bool AutoLoginInfoBarDelegate::Cancel() { 196 bool AutoLoginInfoBarDelegate::Cancel() {
192 PrefService* pref_service = TabContents::FromWebContents( 197 PrefService* pref_service = TabContents::FromWebContents(
193 owner()->web_contents())->profile()->GetPrefs(); 198 owner()->web_contents())->profile()->GetPrefs();
194 pref_service->SetBoolean(prefs::kAutologinEnabled, false); 199 pref_service->SetBoolean(prefs::kAutologinEnabled, false);
195 RecordHistogramAction(HISTOGRAM_REJECTED); 200 RecordHistogramAction(HISTOGRAM_REJECTED);
196 button_pressed_ = true; 201 button_pressed_ = true;
197 return true; 202 return true;
198 } 203 }
199 204
205 string16 AutoLoginInfoBarDelegate::GetMessageText(
206 const std::string& username) const {
207 return l10n_util::GetStringFUTF16(IDS_AUTOLOGIN_INFOBAR_MESSAGE,
208 UTF8ToUTF16(username));
209 }
210
200 void AutoLoginInfoBarDelegate::RecordHistogramAction(int action) { 211 void AutoLoginInfoBarDelegate::RecordHistogramAction(int action) {
201 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Regular", action, HISTOGRAM_MAX); 212 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Regular", action, HISTOGRAM_MAX);
202 } 213 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698