| OLD | NEW |
| 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_prompter.h" | 5 #include "chrome/browser/ui/auto_login_prompter.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
| 11 #include "chrome/browser/infobars/infobar_tab_helper.h" | 11 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 12 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/signin/signin_manager.h" | 14 #include "chrome/browser/signin/signin_manager.h" |
| 15 #include "chrome/browser/signin/signin_manager_factory.h" |
| 15 #include "chrome/browser/signin/token_service.h" | 16 #include "chrome/browser/signin/token_service.h" |
| 16 #include "chrome/browser/sync/profile_sync_service.h" | 17 #include "chrome/browser/sync/profile_sync_service.h" |
| 18 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 17 #include "chrome/browser/tab_contents/tab_util.h" | 19 #include "chrome/browser/tab_contents/tab_util.h" |
| 18 #include "chrome/browser/ui/auto_login_info_bar_delegate.h" | 20 #include "chrome/browser/ui/auto_login_info_bar_delegate.h" |
| 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 20 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
| 21 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 23 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
| 24 #include "content/public/browser/notification_details.h" | 26 #include "content/public/browser/notification_details.h" |
| 25 #include "content/public/browser/notification_observer.h" | 27 #include "content/public/browser/notification_observer.h" |
| 26 #include "content/public/browser/notification_registrar.h" | 28 #include "content/public/browser/notification_registrar.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 107 |
| 106 WebContents* web_contents = tab_util::GetWebContentsByID(child_id, route_id); | 108 WebContents* web_contents = tab_util::GetWebContentsByID(child_id, route_id); |
| 107 if (!web_contents) | 109 if (!web_contents) |
| 108 return; | 110 return; |
| 109 | 111 |
| 110 Profile* profile = | 112 Profile* profile = |
| 111 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 113 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 112 | 114 |
| 113 // In an incognito window, there may not be a profile sync service and/or | 115 // In an incognito window, there may not be a profile sync service and/or |
| 114 // signin manager. | 116 // signin manager. |
| 115 if (!profile->HasProfileSyncService()) | 117 if (!ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService( |
| 118 profile)) { |
| 116 return; | 119 return; |
| 120 } |
| 117 | 121 |
| 118 SigninManager* signin_manager = profile->GetProfileSyncService()->signin(); | 122 SigninManager* signin_manager = |
| 123 SigninManagerFactory::GetInstance()->GetForProfile(profile); |
| 119 if (!signin_manager) | 124 if (!signin_manager) |
| 120 return; | 125 return; |
| 121 | 126 |
| 122 // If there are credentials in the token manager, then we want to show the | 127 // If there are credentials in the token manager, then we want to show the |
| 123 // user the regular auto-login infobar, asking if they want to turn on | 128 // user the regular auto-login infobar, asking if they want to turn on |
| 124 // auto-login. If there are no credentials in the token manager, then we | 129 // auto-login. If there are no credentials in the token manager, then we |
| 125 // want to show the reverse auto-login infobar, asking if they want to | 130 // want to show the reverse auto-login infobar, asking if they want to |
| 126 // connect their profile to a Google account. | 131 // connect their profile to a Google account. |
| 127 bool use_normal_auto_login_infobar = | 132 bool use_normal_auto_login_infobar = |
| 128 profile->GetTokenService()->AreCredentialsValid(); | 133 profile->GetTokenService()->AreCredentialsValid(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 } | 181 } |
| 177 | 182 |
| 178 infobar_helper->AddInfoBar(delegate); | 183 infobar_helper->AddInfoBar(delegate); |
| 179 } | 184 } |
| 180 } | 185 } |
| 181 // Either we couldn't add the infobar, we added the infobar, or the tab | 186 // Either we couldn't add the infobar, we added the infobar, or the tab |
| 182 // contents was destroyed before the navigation completed. In any case | 187 // contents was destroyed before the navigation completed. In any case |
| 183 // there's no reason to live further. | 188 // there's no reason to live further. |
| 184 delete this; | 189 delete this; |
| 185 } | 190 } |
| OLD | NEW |