| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ |
| 6 #define CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ | 6 #define CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // | 44 // |
| 45 // All methods of this class must be called from the IO thread, | 45 // All methods of this class must be called from the IO thread, |
| 46 // including the constructor and destructor. | 46 // including the constructor and destructor. |
| 47 class ChromeURLRequestContext : public URLRequestContext { | 47 class ChromeURLRequestContext : public URLRequestContext { |
| 48 public: | 48 public: |
| 49 // Maintains some extension-related state we need on the IO thread. | 49 // Maintains some extension-related state we need on the IO thread. |
| 50 // TODO(aa): It would be cool if the Extension objects in ExtensionsService | 50 // TODO(aa): It would be cool if the Extension objects in ExtensionsService |
| 51 // could be immutable and ref-counted so that we could use them directly from | 51 // could be immutable and ref-counted so that we could use them directly from |
| 52 // both threads. There is only a small amount of mutable state in Extension. | 52 // both threads. There is only a small amount of mutable state in Extension. |
| 53 struct ExtensionInfo { | 53 struct ExtensionInfo { |
| 54 ExtensionInfo(const std::string& name, const FilePath& path, | 54 ExtensionInfo(const std::string& name, |
| 55 const FilePath& path, |
| 55 const std::string& default_locale, | 56 const std::string& default_locale, |
| 57 bool incognito_split_mode, |
| 56 const ExtensionExtent& extent, | 58 const ExtensionExtent& extent, |
| 57 const ExtensionExtent& effective_host_permissions, | 59 const ExtensionExtent& effective_host_permissions, |
| 58 const std::vector<std::string>& api_permissions) | 60 const std::vector<std::string>& api_permissions) |
| 59 : name(name), path(path), default_locale(default_locale), | 61 : name(name), |
| 62 path(path), |
| 63 default_locale(default_locale), |
| 64 incognito_split_mode(incognito_split_mode), |
| 60 extent(extent), | 65 extent(extent), |
| 61 effective_host_permissions(effective_host_permissions), | 66 effective_host_permissions(effective_host_permissions), |
| 62 api_permissions(api_permissions) { | 67 api_permissions(api_permissions) { |
| 63 } | 68 } |
| 64 const std::string name; | 69 const std::string name; |
| 65 const FilePath path; | 70 const FilePath path; |
| 66 const std::string default_locale; | 71 const std::string default_locale; |
| 72 const bool incognito_split_mode; |
| 67 const ExtensionExtent extent; | 73 const ExtensionExtent extent; |
| 68 const ExtensionExtent effective_host_permissions; | 74 const ExtensionExtent effective_host_permissions; |
| 69 std::vector<std::string> api_permissions; | 75 std::vector<std::string> api_permissions; |
| 70 }; | 76 }; |
| 71 | 77 |
| 72 // Map of extension info by extension id. | 78 // Map of extension info by extension id. |
| 73 typedef std::map<std::string, linked_ptr<ExtensionInfo> > ExtensionInfoMap; | 79 typedef std::map<std::string, linked_ptr<ExtensionInfo> > ExtensionInfoMap; |
| 74 | 80 |
| 75 ChromeURLRequestContext(); | 81 ChromeURLRequestContext(); |
| 76 | 82 |
| 77 // Gets the name for the specified extension. | 83 // Gets the name for the specified extension. |
| 78 std::string GetNameForExtension(const std::string& id); | 84 std::string GetNameForExtension(const std::string& id); |
| 79 | 85 |
| 80 // Gets the path to the directory for the specified extension. | 86 // Gets the path to the directory for the specified extension. |
| 81 FilePath GetPathForExtension(const std::string& id); | 87 FilePath GetPathForExtension(const std::string& id); |
| 82 | 88 |
| 83 // Returns true if the specified extension exists and has a non-empty web | 89 // Returns true if the specified extension exists and has a non-empty web |
| 84 // extent. | 90 // extent. |
| 85 bool ExtensionHasWebExtent(const std::string& id); | 91 bool ExtensionHasWebExtent(const std::string& id); |
| 86 | 92 |
| 93 // Returns true if the specified extension exists and can load in incognito |
| 94 // contexts. |
| 95 bool ExtensionCanLoadInIncognito(const std::string& id); |
| 96 |
| 87 // Returns an empty string if the extension with |id| doesn't have a default | 97 // Returns an empty string if the extension with |id| doesn't have a default |
| 88 // locale. | 98 // locale. |
| 89 std::string GetDefaultLocaleForExtension(const std::string& id); | 99 std::string GetDefaultLocaleForExtension(const std::string& id); |
| 90 | 100 |
| 91 // Gets the effective host permissions for the extension with |id|. | 101 // Gets the effective host permissions for the extension with |id|. |
| 92 ExtensionExtent | 102 ExtensionExtent |
| 93 GetEffectiveHostPermissionsForExtension(const std::string& id); | 103 GetEffectiveHostPermissionsForExtension(const std::string& id); |
| 94 | 104 |
| 95 // Determine whether a URL has access to the specified extension permission. | 105 // Determine whether a URL has access to the specified extension permission. |
| 96 bool CheckURLAccessToExtensionPermission(const GURL& url, | 106 bool CheckURLAccessToExtensionPermission(const GURL& url, |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 | 315 |
| 306 // Create an instance for an original profile for extensions. This is expected | 316 // Create an instance for an original profile for extensions. This is expected |
| 307 // to get called on UI thread. | 317 // to get called on UI thread. |
| 308 static ChromeURLRequestContextGetter* CreateOriginalForExtensions( | 318 static ChromeURLRequestContextGetter* CreateOriginalForExtensions( |
| 309 Profile* profile, const FilePath& cookie_store_path); | 319 Profile* profile, const FilePath& cookie_store_path); |
| 310 | 320 |
| 311 // Create an instance for use with an OTR profile. This is expected to get | 321 // Create an instance for use with an OTR profile. This is expected to get |
| 312 // called on the UI thread. | 322 // called on the UI thread. |
| 313 static ChromeURLRequestContextGetter* CreateOffTheRecord(Profile* profile); | 323 static ChromeURLRequestContextGetter* CreateOffTheRecord(Profile* profile); |
| 314 | 324 |
| 325 // Create an instance for an OTR profile for extensions. This is expected |
| 326 // to get called on UI thread. |
| 327 static ChromeURLRequestContextGetter* CreateOffTheRecordForExtensions( |
| 328 Profile* profile); |
| 329 |
| 315 // Clean up UI thread resources. This is expected to get called on the UI | 330 // Clean up UI thread resources. This is expected to get called on the UI |
| 316 // thread before the instance is deleted on the IO thread. | 331 // thread before the instance is deleted on the IO thread. |
| 317 void CleanupOnUIThread(); | 332 void CleanupOnUIThread(); |
| 318 | 333 |
| 319 // These methods simply forward to the corresponding methods on | 334 // These methods simply forward to the corresponding methods on |
| 320 // ChromeURLRequestContext. Takes ownership of |extension_info|. | 335 // ChromeURLRequestContext. Takes ownership of |extension_info|. |
| 321 void OnNewExtensions( | 336 void OnNewExtensions( |
| 322 const std::string& extension_id, | 337 const std::string& extension_id, |
| 323 ChromeURLRequestContext::ExtensionInfo* extension_info); | 338 ChromeURLRequestContext::ExtensionInfo* extension_info); |
| 324 void OnUnloadedExtension(const std::string& id); | 339 void OnUnloadedExtension(const std::string& id); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 | 434 |
| 420 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextFactory); | 435 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextFactory); |
| 421 }; | 436 }; |
| 422 | 437 |
| 423 // Creates a proxy configuration from proxy-related preferences fetched | 438 // Creates a proxy configuration from proxy-related preferences fetched |
| 424 // from |pref_service|. The relevant preferences in |pref_service| are | 439 // from |pref_service|. The relevant preferences in |pref_service| are |
| 425 // initialized from the process' command line or by applicable proxy policies. | 440 // initialized from the process' command line or by applicable proxy policies. |
| 426 net::ProxyConfig* CreateProxyConfig(const PrefService* pref_service); | 441 net::ProxyConfig* CreateProxyConfig(const PrefService* pref_service); |
| 427 | 442 |
| 428 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ | 443 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ |
| OLD | NEW |