OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/autologin_infobar_delegate.h" | 5 #include "chrome/browser/ui/autologin_infobar_delegate.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 // TODO(rogerta): what is the correct page transition? | 131 // TODO(rogerta): what is the correct page transition? |
132 tab_contents_wrapper_->tab_contents()->controller().LoadURL(GURL(url), | 132 tab_contents_wrapper_->tab_contents()->controller().LoadURL(GURL(url), |
133 GURL(), PageTransition::AUTO_BOOKMARK); | 133 GURL(), PageTransition::AUTO_BOOKMARK); |
134 } | 134 } |
135 | 135 |
136 // static | 136 // static |
137 void AutoLoginInfoBarDelegate::ShowIfAutoLoginRequested( | 137 void AutoLoginInfoBarDelegate::ShowIfAutoLoginRequested( |
138 net::URLRequest* request, | 138 net::URLRequest* request, |
139 int child_id, | 139 int child_id, |
140 int route_id) { | 140 int route_id) { |
| 141 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 142 switches::kEnableAutologin)) { |
| 143 return; |
| 144 } |
| 145 |
141 // See if the response contains the X-Auto-Login header. If so, this was | 146 // See if the response contains the X-Auto-Login header. If so, this was |
142 // a request for a login page, and the server is allowing the browser to | 147 // a request for a login page, and the server is allowing the browser to |
143 // suggest auto-login, if available. | 148 // suggest auto-login, if available. |
144 std::string value; | 149 std::string value; |
145 request->GetResponseHeaderByName("X-Auto-Login", &value); | 150 request->GetResponseHeaderByName("X-Auto-Login", &value); |
146 if (value.empty()) | 151 if (value.empty()) |
147 return; | 152 return; |
148 | 153 |
149 std::vector<std::pair<std::string, std::string> > pairs; | 154 std::vector<std::pair<std::string, std::string> > pairs; |
150 if (!base::SplitStringIntoKeyValuePairs(value, '=', '&', &pairs)) | 155 if (!base::SplitStringIntoKeyValuePairs(value, '=', '&', &pairs)) |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 new AutoLoginRedirector(tab_contents_wrapper_, args_); | 289 new AutoLoginRedirector(tab_contents_wrapper_, args_); |
285 return true; | 290 return true; |
286 } | 291 } |
287 | 292 |
288 bool AutoLoginInfoBarDelegate::Cancel() { | 293 bool AutoLoginInfoBarDelegate::Cancel() { |
289 PrefService* user_prefs = tab_contents_wrapper_->profile()->GetPrefs(); | 294 PrefService* user_prefs = tab_contents_wrapper_->profile()->GetPrefs(); |
290 user_prefs->SetBoolean(prefs::kAutologinEnabled, false); | 295 user_prefs->SetBoolean(prefs::kAutologinEnabled, false); |
291 user_prefs->ScheduleSavePersistentPrefs(); | 296 user_prefs->ScheduleSavePersistentPrefs(); |
292 return true; | 297 return true; |
293 } | 298 } |
OLD | NEW |