| 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/signin/token_service.h" | 5 #include "chrome/browser/signin/token_service.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 10 #include "chrome/common/chrome_notification_types.h" | 11 #include "chrome/common/chrome_notification_types.h" |
| 11 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" | 13 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" |
| 13 #include "chrome/common/net/gaia/gaia_constants.h" | 14 #include "chrome/common/net/gaia/gaia_constants.h" |
| 14 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
| 16 #include "content/public/browser/notification_source.h" | 17 #include "content/public/browser/notification_source.h" |
| 17 #include "net/url_request/url_request_context_getter.h" | 18 #include "net/url_request/url_request_context_getter.h" |
| 18 | 19 |
| 19 using content::BrowserThread; | 20 using content::BrowserThread; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 53 if (!source_.empty()) { | 54 if (!source_.empty()) { |
| 54 // Already initialized. | 55 // Already initialized. |
| 55 return; | 56 return; |
| 56 } | 57 } |
| 57 DCHECK(!profile_); | 58 DCHECK(!profile_); |
| 58 profile_ = profile; | 59 profile_ = profile; |
| 59 getter_ = profile->GetRequestContext(); | 60 getter_ = profile->GetRequestContext(); |
| 60 // Since the user can create a bookmark in incognito, sync may be running. | 61 // Since the user can create a bookmark in incognito, sync may be running. |
| 61 // Thus we have to go for explicit access. | 62 // Thus we have to go for explicit access. |
| 62 web_data_service_ = profile->GetWebDataService(Profile::EXPLICIT_ACCESS); | 63 web_data_service_ = WebDataServiceFactory::GetForProfile( |
| 64 profile, Profile::EXPLICIT_ACCESS); |
| 63 source_ = std::string(source); | 65 source_ = std::string(source); |
| 64 | 66 |
| 65 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 67 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 66 // Allow the token service to be cleared from the command line. | 68 // Allow the token service to be cleared from the command line. |
| 67 if (cmd_line->HasSwitch(switches::kClearTokenService)) | 69 if (cmd_line->HasSwitch(switches::kClearTokenService)) |
| 68 EraseTokensFromDB(); | 70 EraseTokensFromDB(); |
| 69 | 71 |
| 70 // Allow a token to be injected from the command line. | 72 // Allow a token to be injected from the command line. |
| 71 if (cmd_line->HasSwitch(switches::kSetToken)) { | 73 if (cmd_line->HasSwitch(switches::kSetToken)) { |
| 72 std::string value = cmd_line->GetSwitchValueASCII(switches::kSetToken); | 74 std::string value = cmd_line->GetSwitchValueASCII(switches::kSetToken); |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 } | 362 } |
| 361 | 363 |
| 362 void TokenService::Observe(int type, | 364 void TokenService::Observe(int type, |
| 363 const content::NotificationSource& source, | 365 const content::NotificationSource& source, |
| 364 const content::NotificationDetails& details) { | 366 const content::NotificationDetails& details) { |
| 365 DCHECK_EQ(type, chrome::NOTIFICATION_TOKEN_UPDATED); | 367 DCHECK_EQ(type, chrome::NOTIFICATION_TOKEN_UPDATED); |
| 366 TokenAvailableDetails* tok_details = | 368 TokenAvailableDetails* tok_details = |
| 367 content::Details<TokenAvailableDetails>(details).ptr(); | 369 content::Details<TokenAvailableDetails>(details).ptr(); |
| 368 OnIssueAuthTokenSuccess(tok_details->service(), tok_details->token()); | 370 OnIssueAuthTokenSuccess(tok_details->service(), tok_details->token()); |
| 369 } | 371 } |
| OLD | NEW |