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/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/webdata/web_data_service_factory.h" |
12 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
13 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" | 15 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" |
15 #include "chrome/common/net/gaia/gaia_constants.h" | 16 #include "chrome/common/net/gaia/gaia_constants.h" |
16 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
19 #include "content/public/browser/notification_source.h" | 20 #include "content/public/browser/notification_source.h" |
20 #include "net/url_request/url_request_context_getter.h" | 21 #include "net/url_request/url_request_context_getter.h" |
21 | 22 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
58 if (!source_.empty()) { | 59 if (!source_.empty()) { |
59 // Already initialized. | 60 // Already initialized. |
60 return; | 61 return; |
61 } | 62 } |
62 DCHECK(!profile_); | 63 DCHECK(!profile_); |
63 profile_ = profile; | 64 profile_ = profile; |
64 getter_ = profile->GetRequestContext(); | 65 getter_ = profile->GetRequestContext(); |
65 // Since the user can create a bookmark in incognito, sync may be running. | 66 // Since the user can create a bookmark in incognito, sync may be running. |
66 // Thus we have to go for explicit access. | 67 // Thus we have to go for explicit access. |
67 web_data_service_ = profile->GetWebDataService(Profile::EXPLICIT_ACCESS); | 68 web_data_service_ = WebDataServiceFactory::GetForProfile( |
| 69 profile, Profile::EXPLICIT_ACCESS); |
68 source_ = std::string(source); | 70 source_ = std::string(source); |
69 | 71 |
70 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 72 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
71 // Allow the token service to be cleared from the command line. We rely on | 73 // Allow the token service to be cleared from the command line. We rely on |
72 // SigninManager::Initialize() being called to clear out the | 74 // SigninManager::Initialize() being called to clear out the |
73 // kGoogleServicesUsername pref before we call EraseTokensFromDB() as | 75 // kGoogleServicesUsername pref before we call EraseTokensFromDB() as |
74 // otherwise the system would be in an invalid state. | 76 // otherwise the system would be in an invalid state. |
75 if (cmd_line->HasSwitch(switches::kClearTokenService)) | 77 if (cmd_line->HasSwitch(switches::kClearTokenService)) |
76 EraseTokensFromDB(); | 78 EraseTokensFromDB(); |
77 | 79 |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 } | 383 } |
382 | 384 |
383 void TokenService::Observe(int type, | 385 void TokenService::Observe(int type, |
384 const content::NotificationSource& source, | 386 const content::NotificationSource& source, |
385 const content::NotificationDetails& details) { | 387 const content::NotificationDetails& details) { |
386 DCHECK_EQ(type, chrome::NOTIFICATION_TOKEN_UPDATED); | 388 DCHECK_EQ(type, chrome::NOTIFICATION_TOKEN_UPDATED); |
387 TokenAvailableDetails* tok_details = | 389 TokenAvailableDetails* tok_details = |
388 content::Details<TokenAvailableDetails>(details).ptr(); | 390 content::Details<TokenAvailableDetails>(details).ptr(); |
389 OnIssueAuthTokenSuccess(tok_details->service(), tok_details->token()); | 391 OnIssueAuthTokenSuccess(tok_details->service(), tok_details->token()); |
390 } | 392 } |
OLD | NEW |