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/geolocation/chrome_access_token_store.h" | 5 #include "chrome/browser/geolocation/chrome_access_token_store.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/string_piece.h" | 8 #include "base/string_piece.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 if (spec == "https://maps.googleapis.com/maps/api/browserlocation/json") | 31 if (spec == "https://maps.googleapis.com/maps/api/browserlocation/json") |
32 return true; | 32 return true; |
33 | 33 |
34 return false; | 34 return false; |
35 } | 35 } |
36 | 36 |
37 // Loads access tokens and other necessary data on the UI thread, and | 37 // Loads access tokens and other necessary data on the UI thread, and |
38 // calls back to the originator on the originating threaad. | 38 // calls back to the originator on the originating threaad. |
39 class TokenLoadingJob : public base::RefCountedThreadSafe<TokenLoadingJob> { | 39 class TokenLoadingJob : public base::RefCountedThreadSafe<TokenLoadingJob> { |
40 public: | 40 public: |
41 TokenLoadingJob( | 41 explicit TokenLoadingJob( |
42 const AccessTokenStore::LoadAccessTokensCallbackType& callback) | 42 const AccessTokenStore::LoadAccessTokensCallbackType& callback) |
43 : callback_(callback), | 43 : callback_(callback), |
44 system_request_context_(NULL) { | 44 system_request_context_(NULL) { |
45 } | 45 } |
46 | 46 |
47 void Run() { | 47 void Run() { |
48 BrowserThread::PostTaskAndReply( | 48 BrowserThread::PostTaskAndReply( |
49 BrowserThread::UI, | 49 BrowserThread::UI, |
50 FROM_HERE, | 50 FROM_HERE, |
51 base::Bind(&TokenLoadingJob::PerformWorkOnUIThread, this), | 51 base::Bind(&TokenLoadingJob::PerformWorkOnUIThread, this), |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 access_token_dictionary->SetWithoutPathExpansion( | 121 access_token_dictionary->SetWithoutPathExpansion( |
122 server_url.spec(), Value::CreateStringValue(token)); | 122 server_url.spec(), Value::CreateStringValue(token)); |
123 } | 123 } |
124 | 124 |
125 void ChromeAccessTokenStore::SaveAccessToken(const GURL& server_url, | 125 void ChromeAccessTokenStore::SaveAccessToken(const GURL& server_url, |
126 const string16& access_token) { | 126 const string16& access_token) { |
127 BrowserThread::PostTask( | 127 BrowserThread::PostTask( |
128 BrowserThread::UI, FROM_HERE, | 128 BrowserThread::UI, FROM_HERE, |
129 base::Bind(&SetAccessTokenOnUIThread, server_url, access_token)); | 129 base::Bind(&SetAccessTokenOnUIThread, server_url, access_token)); |
130 } | 130 } |
OLD | NEW |