13f50c38dc070f4bb515c1b64450dae14f316474eKristian Monsen// Copyright (c) 2011 The Chromium Authors. All rights reserved. 2c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Use of this source code is governed by a BSD-style license that can be 3c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// found in the LICENSE file. 4c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 5c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#ifndef CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ 6c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#define CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ 73345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#pragma once 8c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 9c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <string> 10c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <vector> 11c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 12c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "base/file_path.h" 1321d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#include "chrome/browser/content_settings/host_content_settings_map.h" 14731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick#include "chrome/browser/extensions/extension_info_map.h" 1572a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#include "chrome/browser/extensions/extension_webrequest_api.h" 163345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#include "chrome/browser/prefs/pref_change_registrar.h" 173345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#include "chrome/browser/prefs/pref_service.h" 1872a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#include "chrome/browser/prerender/prerender_manager.h" 193345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#include "chrome/common/extensions/extension_icon_set.h" 20dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen#include "content/browser/appcache/chrome_appcache_service.h" 21dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen#include "content/browser/chrome_blob_storage_context.h" 22dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen#include "content/browser/host_zoom_map.h" 233345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#include "net/base/cookie_policy.h" 24c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "net/url_request/url_request_context.h" 25ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "net/url_request/url_request_context_getter.h" 2672a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#include "webkit/fileapi/file_system_context.h" 27c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 28dc0f95d653279beabeb9817299e2902918ba123eKristian Monsenclass ChromeURLDataManagerBackend; 29dc0f95d653279beabeb9817299e2902918ba123eKristian Monsenclass ChromeURLRequestContextFactory; 30dc0f95d653279beabeb9817299e2902918ba123eKristian Monsenclass IOThread; 31c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochnamespace net { 32201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdochclass DnsCertProvenanceChecker; 33c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochclass NetworkDelegate; 34c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch} 35dc0f95d653279beabeb9817299e2902918ba123eKristian Monsenclass PrefService; 36dc0f95d653279beabeb9817299e2902918ba123eKristian Monsenclass Profile; 37dc0f95d653279beabeb9817299e2902918ba123eKristian Monsenclass ProfileIOData; 38c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 3972a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen// Subclass of net::URLRequestContext which can be used to store extra 4072a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen// information for requests. 41c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// 42c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// All methods of this class must be called from the IO thread, 43c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// including the constructor and destructor. 443f50c38dc070f4bb515c1b64450dae14f316474eKristian Monsenclass ChromeURLRequestContext : public net::URLRequestContext { 45c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch public: 46c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch ChromeURLRequestContext(); 47c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 48ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // Copies the state from |other| into this context. 49ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen void CopyFrom(ChromeURLRequestContext* other); 50ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 51c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Gets the path to the directory user scripts are stored in. 52c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FilePath user_script_dir_path() const { 53c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch return user_script_dir_path_; 54c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 55c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 56c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Gets the appcache service to be used for requests in this context. 57c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // May be NULL if requests for this context aren't subject to appcaching. 58c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch ChromeAppCacheService* appcache_service() const { 59c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch return appcache_service_.get(); 60c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 61c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 623345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick // Gets the blob storage context associated with this context's profile. 633345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick ChromeBlobStorageContext* blob_storage_context() const { 643345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick return blob_storage_context_.get(); 653345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick } 663345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick 673345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick // Gets the file system host context with this context's profile. 6872a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen fileapi::FileSystemContext* file_system_context() const { 6921d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen return file_system_context_.get(); 703345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick } 713345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick 72ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen bool is_incognito() const { 73ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen return is_incognito_; 74c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 75c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 76c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch virtual const std::string& GetUserAgent(const GURL& url) const; 77c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 78c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch HostContentSettingsMap* host_content_settings_map() { 79c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch return host_content_settings_map_; 80c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 81c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 82c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch const HostZoomMap* host_zoom_map() const { return host_zoom_map_; } 83c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 84731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick const ExtensionInfoMap* extension_info_map() const { 85731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick return extension_info_map_; 86731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick } 87c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 88dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen prerender::PrerenderManager* prerender_manager() { 89dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen return prerender_manager_.get(); 9072a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen } 9172a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen 9272a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen ChromeURLDataManagerBackend* GetChromeURLDataManagerBackend(); 93c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 94c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Setters to simplify initializing from factory objects. 95c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch void set_user_script_dir_path(const FilePath& path) { 96c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch user_script_dir_path_ = path; 97c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 98ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen void set_is_incognito(bool is_incognito) { 99ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen is_incognito_ = is_incognito; 100c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 101c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch void set_host_content_settings_map( 102c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch HostContentSettingsMap* host_content_settings_map) { 103c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch host_content_settings_map_ = host_content_settings_map; 104c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 105c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch void set_host_zoom_map(HostZoomMap* host_zoom_map) { 106c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch host_zoom_map_ = host_zoom_map; 107c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 108c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch void set_appcache_service(ChromeAppCacheService* service) { 109c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch appcache_service_ = service; 110c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 1113345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick void set_blob_storage_context(ChromeBlobStorageContext* context) { 1123345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick blob_storage_context_ = context; 1133345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick } 11472a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen void set_file_system_context(fileapi::FileSystemContext* context) { 11521d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen file_system_context_ = context; 1163345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick } 117731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick void set_extension_info_map(ExtensionInfoMap* map) { 118731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick extension_info_map_ = map; 119731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick } 120dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen void set_prerender_manager(prerender::PrerenderManager* prerender_manager) { 12172a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen prerender_manager_ = prerender_manager; 122c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 123c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 124c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Callback for when the accept language changes. 125c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch void OnAcceptLanguageChange(const std::string& accept_language); 126c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 127c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Callback for when the default charset changes. 128c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch void OnDefaultCharsetChange(const std::string& default_charset); 129c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 130c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch protected: 131dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen virtual ~ChromeURLRequestContext(); 132dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen 133dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen private: 134ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // --------------------------------------------------------------------------- 135ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // Important: When adding any new members below, consider whether they need to 136ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // be added to CopyFrom. 137ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // --------------------------------------------------------------------------- 138ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 139c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Path to the directory user scripts are stored in. 140c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch FilePath user_script_dir_path_; 141c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 14272a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen // TODO(willchan): Make these non-refcounted. 143c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch scoped_refptr<ChromeAppCacheService> appcache_service_; 144c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch scoped_refptr<HostContentSettingsMap> host_content_settings_map_; 145c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch scoped_refptr<HostZoomMap> host_zoom_map_; 1463345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; 14772a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen scoped_refptr<fileapi::FileSystemContext> file_system_context_; 14872a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen // TODO(aa): This should use chrome/common/extensions/extension_set.h. 149731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick scoped_refptr<ExtensionInfoMap> extension_info_map_; 150dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen scoped_refptr<prerender::PrerenderManager> prerender_manager_; 15172a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen scoped_ptr<ChromeURLDataManagerBackend> chrome_url_data_manager_backend_; 152c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 153ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen bool is_incognito_; 154ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 155ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // --------------------------------------------------------------------------- 156ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // Important: When adding any new members above, consider whether they need to 157ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // be added to CopyFrom. 158ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // --------------------------------------------------------------------------- 159c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 160c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContext); 161c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}; 162c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 163ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// A net::URLRequestContextGetter subclass used by the browser. This returns a 16472a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen// subclass of net::URLRequestContext which can be used to store extra 16572a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen// information about requests. 166c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// 167c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Most methods are expected to be called on the UI thread, except for 168c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// the destructor and GetURLRequestContext(). 169ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenclass ChromeURLRequestContextGetter : public net::URLRequestContextGetter, 170c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch public NotificationObserver { 171c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch public: 172c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Constructs a ChromeURLRequestContextGetter that will use |factory| to 173c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // create the ChromeURLRequestContext. If |profile| is non-NULL, then the 174c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // ChromeURLRequestContextGetter will additionally watch the preferences for 175c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // changes to charset/language and CleanupOnUIThread() will need to be 176c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // called to unregister. 177c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch ChromeURLRequestContextGetter(Profile* profile, 178c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch ChromeURLRequestContextFactory* factory); 179c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 180c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Note that GetURLRequestContext() can only be called from the IO 181ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // thread (it will assert otherwise). DONTUSEME_GetCookieStore() and 182c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // GetIOMessageLoopProxy however can be called from any thread. 183c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // 184ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // net::URLRequestContextGetter implementation. 1853f50c38dc070f4bb515c1b64450dae14f316474eKristian Monsen virtual net::URLRequestContext* GetURLRequestContext(); 186ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen virtual net::CookieStore* DONTUSEME_GetCookieStore(); 187513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const; 188513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch 189513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch // Releases |url_request_context_|. It's invalid to call 190513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch // GetURLRequestContext() after this point. 191513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch void ReleaseURLRequestContext(); 192c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 193c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Convenience overload of GetURLRequestContext() that returns a 19472a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen // ChromeURLRequestContext* rather than a net::URLRequestContext*. 195c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch ChromeURLRequestContext* GetIOContext() { 196c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch return reinterpret_cast<ChromeURLRequestContext*>(GetURLRequestContext()); 197c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch } 198c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 199c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Create an instance for use with an 'original' (non-OTR) profile. This is 200c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // expected to get called on the UI thread. 201c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch static ChromeURLRequestContextGetter* CreateOriginal( 20272a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen Profile* profile, const ProfileIOData* profile_io_data); 203c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 204c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Create an instance for an original profile for media. This is expected to 205c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // get called on UI thread. This method takes a profile and reuses the 20672a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen // 'original' net::URLRequestContext for common files. 207c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch static ChromeURLRequestContextGetter* CreateOriginalForMedia( 20872a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen Profile* profile, const ProfileIOData* profile_io_data); 209c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 210c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Create an instance for an original profile for extensions. This is expected 211c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // to get called on UI thread. 212c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch static ChromeURLRequestContextGetter* CreateOriginalForExtensions( 21372a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen Profile* profile, const ProfileIOData* profile_io_data); 214c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 215ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // Create an instance for an original profile for an app with isolated 216ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // storage. This is expected to get called on UI thread. 217ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen static ChromeURLRequestContextGetter* CreateOriginalForIsolatedApp( 218ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen Profile* profile, 219ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const ProfileIOData* profile_io_data, 220ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const std::string& app_id); 221ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 222c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Create an instance for use with an OTR profile. This is expected to get 223c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // called on the UI thread. 224dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen static ChromeURLRequestContextGetter* CreateOffTheRecord( 225dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen Profile* profile, const ProfileIOData* profile_io_data); 226c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 2273345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick // Create an instance for an OTR profile for extensions. This is expected 2283345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick // to get called on UI thread. 2293345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick static ChromeURLRequestContextGetter* CreateOffTheRecordForExtensions( 230dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen Profile* profile, const ProfileIOData* profile_io_data); 2313345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick 232ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // Create an instance for an OTR profile for an app with isolated storage. 233ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen // This is expected to get called on UI thread. 234ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen static ChromeURLRequestContextGetter* CreateOffTheRecordForIsolatedApp( 235ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen Profile* profile, 236ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const ProfileIOData* profile_io_data, 237ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen const std::string& app_id); 238ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen 239c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Clean up UI thread resources. This is expected to get called on the UI 240c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // thread before the instance is deleted on the IO thread. 241c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch void CleanupOnUIThread(); 242c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 243c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // NotificationObserver implementation. 244c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch virtual void Observe(NotificationType type, 245c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch const NotificationSource& source, 246c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch const NotificationDetails& details); 247c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 248c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch private: 249c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Must be called on the IO thread. 250c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch virtual ~ChromeURLRequestContextGetter(); 251c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 252c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Registers an observer on |profile|'s preferences which will be used 253c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // to update the context when the default language and charset change. 254c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch void RegisterPrefsObserver(Profile* profile); 255c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 256c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // These methods simply forward to the corresponding method on 257c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // ChromeURLRequestContext. 258c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch void OnAcceptLanguageChange(const std::string& accept_language); 259c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch void OnDefaultCharsetChange(const std::string& default_charset); 26021d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen void OnClearSiteDataOnExitChange(bool clear_site_data); 261c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 262c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Saves the cookie store to |result| and signals |completion|. 263c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch void GetCookieStoreAsyncHelper(base::WaitableEvent* completion, 264c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch net::CookieStore** result); 265c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 2663345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick PrefChangeRegistrar registrar_; 267c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 268513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch // |io_thread_| is always valid during the lifetime of |this| since |this| is 269513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch // deleted on the IO thread. 270513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch IOThread* const io_thread_; 271513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch 272c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Deferred logic for creating a ChromeURLRequestContext. 273c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Access only from the IO thread. 274c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch scoped_ptr<ChromeURLRequestContextFactory> factory_; 275c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 27672a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen // NULL if not yet initialized. Otherwise, it is the net::URLRequestContext 277c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // instance that was lazilly created by GetURLRequestContext. 278c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch // Access only from the IO thread. 2793f50c38dc070f4bb515c1b64450dae14f316474eKristian Monsen scoped_refptr<net::URLRequestContext> url_request_context_; 280c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 281c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextGetter); 282c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}; 283c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch 284c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ 285