| 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 "content/shell/browser/shell_access_token_store.h" | 5 #include "content/shell/browser/shell_access_token_store.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 11 #include "content/public/browser/storage_partition.h" |
| 11 #include "content/shell/browser/shell_browser_context.h" | 12 #include "content/shell/browser/shell_browser_context.h" |
| 12 | 13 |
| 13 namespace content { | 14 namespace content { |
| 14 | 15 |
| 15 ShellAccessTokenStore::ShellAccessTokenStore( | 16 ShellAccessTokenStore::ShellAccessTokenStore( |
| 16 content::ShellBrowserContext* shell_browser_context) | 17 content::ShellBrowserContext* shell_browser_context) |
| 17 : shell_browser_context_(shell_browser_context), | 18 : shell_browser_context_(shell_browser_context), |
| 18 system_request_context_(NULL) { | 19 system_request_context_(NULL) { |
| 19 } | 20 } |
| 20 | 21 |
| 21 ShellAccessTokenStore::~ShellAccessTokenStore() { | 22 ShellAccessTokenStore::~ShellAccessTokenStore() { |
| 22 } | 23 } |
| 23 | 24 |
| 24 void ShellAccessTokenStore::LoadAccessTokens( | 25 void ShellAccessTokenStore::LoadAccessTokens( |
| 25 const LoadAccessTokensCallback& callback) { | 26 const LoadAccessTokensCallback& callback) { |
| 26 BrowserThread::PostTaskAndReply( | 27 BrowserThread::PostTaskAndReply( |
| 27 BrowserThread::UI, | 28 BrowserThread::UI, |
| 28 FROM_HERE, | 29 FROM_HERE, |
| 29 base::Bind(&ShellAccessTokenStore::GetRequestContextOnUIThread, | 30 base::Bind(&ShellAccessTokenStore::GetRequestContextOnUIThread, |
| 30 this, | 31 this, |
| 31 shell_browser_context_), | 32 shell_browser_context_), |
| 32 base::Bind(&ShellAccessTokenStore::RespondOnOriginatingThread, | 33 base::Bind(&ShellAccessTokenStore::RespondOnOriginatingThread, |
| 33 this, | 34 this, |
| 34 callback)); | 35 callback)); |
| 35 } | 36 } |
| 36 | 37 |
| 37 void ShellAccessTokenStore::GetRequestContextOnUIThread( | 38 void ShellAccessTokenStore::GetRequestContextOnUIThread( |
| 38 content::ShellBrowserContext* shell_browser_context) { | 39 content::ShellBrowserContext* shell_browser_context) { |
| 39 system_request_context_ = shell_browser_context->GetRequestContext(); | 40 system_request_context_ = |
| 41 BrowserContext::GetDefaultStoragePartition(shell_browser_context)-> |
| 42 GetURLRequestContext(); |
| 40 } | 43 } |
| 41 | 44 |
| 42 void ShellAccessTokenStore::RespondOnOriginatingThread( | 45 void ShellAccessTokenStore::RespondOnOriginatingThread( |
| 43 const LoadAccessTokensCallback& callback) { | 46 const LoadAccessTokensCallback& callback) { |
| 44 // Since content_shell is a test executable, rather than an end user program, | 47 // Since content_shell is a test executable, rather than an end user program, |
| 45 // we provide a dummy access_token set to avoid hitting the server. | 48 // we provide a dummy access_token set to avoid hitting the server. |
| 46 AccessTokenMap access_token_map; | 49 AccessTokenMap access_token_map; |
| 47 access_token_map[GURL()] = base::ASCIIToUTF16("chromium_content_shell"); | 50 access_token_map[GURL()] = base::ASCIIToUTF16("chromium_content_shell"); |
| 48 callback.Run(access_token_map, system_request_context_.get()); | 51 callback.Run(access_token_map, system_request_context_.get()); |
| 49 system_request_context_ = NULL; | 52 system_request_context_ = NULL; |
| 50 } | 53 } |
| 51 | 54 |
| 52 void ShellAccessTokenStore::SaveAccessToken( | 55 void ShellAccessTokenStore::SaveAccessToken( |
| 53 const GURL& server_url, const base::string16& access_token) { | 56 const GURL& server_url, const base::string16& access_token) { |
| 54 } | 57 } |
| 55 | 58 |
| 56 } // namespace content | 59 } // namespace content |
| OLD | NEW |