| 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/shell_browser_context.h" | 5 #include "content/shell/shell_browser_context.h" | 
| 6 | 6 | 
| 7 #include "base/bind.h" | 7 #include "base/bind.h" | 
| 8 #include "base/environment.h" | 8 #include "base/environment.h" | 
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" | 
| 10 #include "base/logging.h" | 10 #include "base/logging.h" | 
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" | 
| 12 #include "base/threading/thread.h" | 12 #include "base/threading/thread.h" | 
| 13 #include "content/browser/appcache/chrome_appcache_service.h" |  | 
| 14 #include "content/browser/chrome_blob_storage_context.h" |  | 
| 15 #include "content/browser/download/download_manager_impl.h" | 13 #include "content/browser/download/download_manager_impl.h" | 
| 16 #include "content/browser/file_system/browser_file_system_helper.h" |  | 
| 17 #include "content/browser/host_zoom_map_impl.h" | 14 #include "content/browser/host_zoom_map_impl.h" | 
| 18 #include "content/browser/in_process_webkit/webkit_context.h" | 15 #include "content/browser/in_process_webkit/webkit_context.h" | 
| 19 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" | 
| 20 #include "content/public/browser/geolocation_permission_context.h" | 17 #include "content/public/browser/geolocation_permission_context.h" | 
| 21 #include "content/public/browser/speech_input_preferences.h" | 18 #include "content/public/browser/speech_input_preferences.h" | 
| 22 #include "content/shell/shell_browser_main.h" | 19 #include "content/shell/shell_browser_main.h" | 
| 23 #include "content/shell/shell_download_manager_delegate.h" | 20 #include "content/shell/shell_download_manager_delegate.h" | 
| 24 #include "content/shell/shell_resource_context.h" | 21 #include "content/shell/shell_resource_context.h" | 
| 25 #include "content/shell/shell_url_request_context_getter.h" | 22 #include "content/shell/shell_url_request_context_getter.h" | 
| 26 #include "webkit/database/database_tracker.h" |  | 
| 27 #include "webkit/quota/quota_manager.h" |  | 
| 28 | 23 | 
| 29 #if defined(OS_WIN) | 24 #if defined(OS_WIN) | 
| 30 #include "base/base_paths_win.h" | 25 #include "base/base_paths_win.h" | 
| 31 #elif defined(OS_LINUX) | 26 #elif defined(OS_LINUX) | 
| 32 #include "base/nix/xdg_util.h" | 27 #include "base/nix/xdg_util.h" | 
| 33 #endif | 28 #endif | 
| 34 | 29 | 
| 35 using content::BrowserThread; | 30 using content::BrowserThread; | 
| 36 | 31 | 
| 37 namespace content { | 32 namespace content { | 
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 157 | 152 | 
| 158 net::URLRequestContextGetter* | 153 net::URLRequestContextGetter* | 
| 159     ShellBrowserContext::GetRequestContextForMedia()  { | 154     ShellBrowserContext::GetRequestContextForMedia()  { | 
| 160   return GetRequestContext(); | 155   return GetRequestContext(); | 
| 161 } | 156 } | 
| 162 | 157 | 
| 163 ResourceContext* ShellBrowserContext::GetResourceContext()  { | 158 ResourceContext* ShellBrowserContext::GetResourceContext()  { | 
| 164   if (!resource_context_.get()) { | 159   if (!resource_context_.get()) { | 
| 165     resource_context_.reset(new ShellResourceContext( | 160     resource_context_.reset(new ShellResourceContext( | 
| 166         static_cast<ShellURLRequestContextGetter*>(GetRequestContext()), | 161         static_cast<ShellURLRequestContextGetter*>(GetRequestContext()), | 
| 167         GetBlobStorageContext())); | 162         BrowserContext::GetBlobStorageContext(this))); | 
| 168   } | 163   } | 
| 169   return resource_context_.get(); | 164   return resource_context_.get(); | 
| 170 } | 165 } | 
| 171 | 166 | 
| 172 HostZoomMap* ShellBrowserContext::GetHostZoomMap()  { | 167 HostZoomMap* ShellBrowserContext::GetHostZoomMap()  { | 
| 173   if (!host_zoom_map_) | 168   if (!host_zoom_map_) | 
| 174     host_zoom_map_ = HostZoomMap::Create(); | 169     host_zoom_map_ = HostZoomMap::Create(); | 
| 175   return host_zoom_map_.get(); | 170   return host_zoom_map_.get(); | 
| 176 } | 171 } | 
| 177 | 172 | 
| 178 GeolocationPermissionContext* | 173 GeolocationPermissionContext* | 
| 179     ShellBrowserContext::GetGeolocationPermissionContext()  { | 174     ShellBrowserContext::GetGeolocationPermissionContext()  { | 
| 180   if (!geolocation_permission_context_) { | 175   if (!geolocation_permission_context_) { | 
| 181     geolocation_permission_context_ = | 176     geolocation_permission_context_ = | 
| 182         new ShellGeolocationPermissionContext(); | 177         new ShellGeolocationPermissionContext(); | 
| 183   } | 178   } | 
| 184   return geolocation_permission_context_; | 179   return geolocation_permission_context_; | 
| 185 } | 180 } | 
| 186 | 181 | 
| 187 SpeechInputPreferences* ShellBrowserContext::GetSpeechInputPreferences() { | 182 SpeechInputPreferences* ShellBrowserContext::GetSpeechInputPreferences() { | 
| 188   if (!speech_input_preferences_.get()) | 183   if (!speech_input_preferences_.get()) | 
| 189     speech_input_preferences_ = new ShellSpeechInputPreferences(); | 184     speech_input_preferences_ = new ShellSpeechInputPreferences(); | 
| 190   return speech_input_preferences_.get(); | 185   return speech_input_preferences_.get(); | 
| 191 } | 186 } | 
| 192 | 187 | 
| 193 bool ShellBrowserContext::DidLastSessionExitCleanly()  { | 188 bool ShellBrowserContext::DidLastSessionExitCleanly()  { | 
| 194   return true; | 189   return true; | 
| 195 } | 190 } | 
| 196 | 191 | 
| 197 quota::QuotaManager* ShellBrowserContext::GetQuotaManager()  { | 192 quota::SpecialStoragePolicy* ShellBrowserContext::GetSpecialStoragePolicy() { | 
| 198   CreateQuotaManagerAndClients(); | 193   return NULL; | 
| 199   return quota_manager_.get(); |  | 
| 200 } |  | 
| 201 |  | 
| 202 WebKitContext* ShellBrowserContext::GetWebKitContext()  { |  | 
| 203   CreateQuotaManagerAndClients(); |  | 
| 204   return webkit_context_.get(); |  | 
| 205 } |  | 
| 206 |  | 
| 207 webkit_database::DatabaseTracker* ShellBrowserContext::GetDatabaseTracker()  { |  | 
| 208   CreateQuotaManagerAndClients(); |  | 
| 209   return db_tracker_; |  | 
| 210 } |  | 
| 211 |  | 
| 212 ChromeBlobStorageContext* ShellBrowserContext::GetBlobStorageContext()  { |  | 
| 213   if (!blob_storage_context_) { |  | 
| 214     blob_storage_context_ = new ChromeBlobStorageContext(); |  | 
| 215     BrowserThread::PostTask( |  | 
| 216         BrowserThread::IO, FROM_HERE, |  | 
| 217         base::Bind( |  | 
| 218             &ChromeBlobStorageContext::InitializeOnIOThread, |  | 
| 219             blob_storage_context_.get())); |  | 
| 220   } |  | 
| 221   return blob_storage_context_; |  | 
| 222 } |  | 
| 223 |  | 
| 224 ChromeAppCacheService* ShellBrowserContext::GetAppCacheService()  { |  | 
| 225   CreateQuotaManagerAndClients(); |  | 
| 226   return appcache_service_; |  | 
| 227 } |  | 
| 228 |  | 
| 229 fileapi::FileSystemContext* ShellBrowserContext::GetFileSystemContext()  { |  | 
| 230   CreateQuotaManagerAndClients(); |  | 
| 231   return file_system_context_.get(); |  | 
| 232 } |  | 
| 233 |  | 
| 234 void ShellBrowserContext::CreateQuotaManagerAndClients() { |  | 
| 235   if (quota_manager_.get()) |  | 
| 236     return; |  | 
| 237   quota_manager_ = new quota::QuotaManager( |  | 
| 238       IsOffTheRecord(), |  | 
| 239       GetPath(), |  | 
| 240       BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |  | 
| 241       BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), |  | 
| 242       NULL); |  | 
| 243 |  | 
| 244   file_system_context_ = CreateFileSystemContext( |  | 
| 245       GetPath(), IsOffTheRecord(), NULL, quota_manager_->proxy()); |  | 
| 246   db_tracker_ = new webkit_database::DatabaseTracker( |  | 
| 247       GetPath(), IsOffTheRecord(), false, NULL, quota_manager_->proxy(), |  | 
| 248       BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)); |  | 
| 249   webkit_context_ = new WebKitContext( |  | 
| 250       IsOffTheRecord(), GetPath(), NULL, false, quota_manager_->proxy(), |  | 
| 251       BrowserThread::GetMessageLoopProxyForThread( |  | 
| 252           BrowserThread::WEBKIT_DEPRECATED)); |  | 
| 253   appcache_service_ = new ChromeAppCacheService(quota_manager_->proxy()); |  | 
| 254   scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy; |  | 
| 255   BrowserThread::PostTask( |  | 
| 256     BrowserThread::IO, FROM_HERE, |  | 
| 257     base::Bind( |  | 
| 258         &ChromeAppCacheService::InitializeOnIOThread, |  | 
| 259         appcache_service_.get(), |  | 
| 260         IsOffTheRecord() |  | 
| 261             ? FilePath() : GetPath().Append(FILE_PATH_LITERAL("AppCache")), |  | 
| 262         GetResourceContext(), |  | 
| 263         special_storage_policy)); |  | 
| 264 } | 194 } | 
| 265 | 195 | 
| 266 }  // namespace content | 196 }  // namespace content | 
| OLD | NEW | 
|---|