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

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: Move Params structure to auto_login_info_bar_delegate.h. 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
139 AutoLoginInfoBarDelegate::Params::Params() {}
Peter Kasting 2012/06/28 19:13:45 Nit: Make an AutoLoginInfoBarDelegate::Params sect
Philippe 2012/06/29 08:48:10 Done.
140 AutoLoginInfoBarDelegate::Params::~Params() {}
141
142 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate( 142 AutoLoginInfoBarDelegate::AutoLoginInfoBarDelegate(
143 InfoBarTabHelper* owner, 143 InfoBarTabHelper* owner,
144 const std::string& username, 144 const Params& params)
145 const std::string& args)
146 : ConfirmInfoBarDelegate(owner), 145 : ConfirmInfoBarDelegate(owner),
147 username_(username), 146 params_(params),
148 args_(args),
149 button_pressed_(false) { 147 button_pressed_(false) {
150 RecordHistogramAction(HISTOGRAM_SHOWN); 148 RecordHistogramAction(HISTOGRAM_SHOWN);
151 } 149 }
152 150
153 AutoLoginInfoBarDelegate::~AutoLoginInfoBarDelegate() { 151 AutoLoginInfoBarDelegate::~AutoLoginInfoBarDelegate() {
154 if (!button_pressed_) 152 if (!button_pressed_)
155 RecordHistogramAction(HISTOGRAM_IGNORED); 153 RecordHistogramAction(HISTOGRAM_IGNORED);
156 } 154 }
157 155
156 AutoLoginInfoBarDelegate*
157 AutoLoginInfoBarDelegate::AsAutoLoginInfoBarDelegate() {
158 return this;
159 }
160
158 void AutoLoginInfoBarDelegate::InfoBarDismissed() { 161 void AutoLoginInfoBarDelegate::InfoBarDismissed() {
159 RecordHistogramAction(HISTOGRAM_DISMISSED); 162 RecordHistogramAction(HISTOGRAM_DISMISSED);
160 button_pressed_ = true; 163 button_pressed_ = true;
161 } 164 }
162 165
163 gfx::Image* AutoLoginInfoBarDelegate::GetIcon() const { 166 gfx::Image* AutoLoginInfoBarDelegate::GetIcon() const {
164 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( 167 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
165 IDR_INFOBAR_AUTOLOGIN); 168 IDR_INFOBAR_AUTOLOGIN);
166 } 169 }
167 170
168 InfoBarDelegate::Type AutoLoginInfoBarDelegate::GetInfoBarType() const { 171 InfoBarDelegate::Type AutoLoginInfoBarDelegate::GetInfoBarType() const {
169 return PAGE_ACTION_TYPE; 172 return PAGE_ACTION_TYPE;
170 } 173 }
171 174
172 string16 AutoLoginInfoBarDelegate::GetMessageText() const { 175 string16 AutoLoginInfoBarDelegate::GetMessageText() const {
173 return l10n_util::GetStringFUTF16(IDS_AUTOLOGIN_INFOBAR_MESSAGE, 176 return GetMessageText(params_.username);
174 UTF8ToUTF16(username_));
175 } 177 }
176 178
177 string16 AutoLoginInfoBarDelegate::GetButtonLabel( 179 string16 AutoLoginInfoBarDelegate::GetButtonLabel(
178 InfoBarButton button) const { 180 InfoBarButton button) const {
179 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? 181 return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
180 IDS_AUTOLOGIN_INFOBAR_OK_BUTTON : IDS_AUTOLOGIN_INFOBAR_CANCEL_BUTTON); 182 IDS_AUTOLOGIN_INFOBAR_OK_BUTTON : IDS_AUTOLOGIN_INFOBAR_CANCEL_BUTTON);
181 } 183 }
182 184
183 bool AutoLoginInfoBarDelegate::Accept() { 185 bool AutoLoginInfoBarDelegate::Accept() {
184 // AutoLoginRedirector deletes itself. 186 // AutoLoginRedirector deletes itself.
185 new AutoLoginRedirector(&owner()->web_contents()->GetController(), args_); 187 new AutoLoginRedirector(&owner()->web_contents()->GetController(),
188 params_.args);
186 RecordHistogramAction(HISTOGRAM_ACCEPTED); 189 RecordHistogramAction(HISTOGRAM_ACCEPTED);
187 button_pressed_ = true; 190 button_pressed_ = true;
188 return true; 191 return true;
189 } 192 }
190 193
191 bool AutoLoginInfoBarDelegate::Cancel() { 194 bool AutoLoginInfoBarDelegate::Cancel() {
192 PrefService* pref_service = TabContents::FromWebContents( 195 PrefService* pref_service = TabContents::FromWebContents(
193 owner()->web_contents())->profile()->GetPrefs(); 196 owner()->web_contents())->profile()->GetPrefs();
194 pref_service->SetBoolean(prefs::kAutologinEnabled, false); 197 pref_service->SetBoolean(prefs::kAutologinEnabled, false);
195 RecordHistogramAction(HISTOGRAM_REJECTED); 198 RecordHistogramAction(HISTOGRAM_REJECTED);
196 button_pressed_ = true; 199 button_pressed_ = true;
197 return true; 200 return true;
198 } 201 }
199 202
203 string16 AutoLoginInfoBarDelegate::GetMessageText(
204 const std::string& username) const {
205 return l10n_util::GetStringFUTF16(IDS_AUTOLOGIN_INFOBAR_MESSAGE,
206 UTF8ToUTF16(username));
207 }
208
200 void AutoLoginInfoBarDelegate::RecordHistogramAction(int action) { 209 void AutoLoginInfoBarDelegate::RecordHistogramAction(int action) {
201 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Regular", action, HISTOGRAM_MAX); 210 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Regular", action, HISTOGRAM_MAX);
202 } 211 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698