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" |
11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/infobars/infobar_tab_helper.h" |
13 #include "chrome/browser/net/gaia/token_service.h" | 14 #include "chrome/browser/net/gaia/token_service.h" |
14 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
17 #include "chrome/browser/sync/profile_sync_service.h" | 18 #include "chrome/browser/sync/profile_sync_service.h" |
18 #include "chrome/browser/sync/signin_manager.h" | 19 #include "chrome/browser/sync/signin_manager.h" |
19 #include "chrome/browser/tab_contents/tab_util.h" | 20 #include "chrome/browser/tab_contents/tab_util.h" |
20 #include "chrome/common/chrome_notification_types.h" | 21 #include "chrome/common/chrome_notification_types.h" |
21 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/common/net/gaia/gaia_constants.h" | 23 #include "chrome/common/net/gaia/gaia_constants.h" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 } | 238 } |
238 | 239 |
239 AutoLoginInfoBarDelegate::~AutoLoginInfoBarDelegate() { | 240 AutoLoginInfoBarDelegate::~AutoLoginInfoBarDelegate() { |
240 } | 241 } |
241 | 242 |
242 void AutoLoginInfoBarDelegate::Observe(int type, | 243 void AutoLoginInfoBarDelegate::Observe(int type, |
243 const NotificationSource& source, | 244 const NotificationSource& source, |
244 const NotificationDetails& details) { | 245 const NotificationDetails& details) { |
245 if (type == content::NOTIFICATION_LOAD_STOP) { | 246 if (type == content::NOTIFICATION_LOAD_STOP) { |
246 // The wrapper takes ownership of this delegate. | 247 // The wrapper takes ownership of this delegate. |
247 tab_contents_wrapper_->AddInfoBar(this); | 248 tab_contents_wrapper_->infobar_tab_helper()->AddInfoBar(this); |
248 registrar_.RemoveAll(); | 249 registrar_.RemoveAll(); |
249 } else if (type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED) { | 250 } else if (type == content::NOTIFICATION_TAB_CONTENTS_DESTROYED) { |
250 // The tab contents was destroyed before the naviagation completed, so | 251 // The tab contents was destroyed before the naviagation completed, so |
251 // just cleanup this delegate. | 252 // just cleanup this delegate. |
252 delete this; | 253 delete this; |
253 } else { | 254 } else { |
254 NOTREACHED() << "Unexpected notification type"; | 255 NOTREACHED() << "Unexpected notification type"; |
255 } | 256 } |
256 } | 257 } |
257 | 258 |
(...skipping 26 matching lines...) Expand all Loading... |
284 new AutoLoginRedirector(tab_contents_wrapper_, args_); | 285 new AutoLoginRedirector(tab_contents_wrapper_, args_); |
285 return true; | 286 return true; |
286 } | 287 } |
287 | 288 |
288 bool AutoLoginInfoBarDelegate::Cancel() { | 289 bool AutoLoginInfoBarDelegate::Cancel() { |
289 PrefService* user_prefs = tab_contents_wrapper_->profile()->GetPrefs(); | 290 PrefService* user_prefs = tab_contents_wrapper_->profile()->GetPrefs(); |
290 user_prefs->SetBoolean(prefs::kAutologinEnabled, false); | 291 user_prefs->SetBoolean(prefs::kAutologinEnabled, false); |
291 user_prefs->ScheduleSavePersistentPrefs(); | 292 user_prefs->ScheduleSavePersistentPrefs(); |
292 return true; | 293 return true; |
293 } | 294 } |
OLD | NEW |