| 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 | 7 |
| 8 #include <map> | |
| 9 #include <string> | 8 #include <string> |
| 10 #include <vector> | 9 #include <vector> |
| 11 | 10 |
| 12 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 13 #include "base/linked_ptr.h" | 12 #include "base/linked_ptr.h" |
| 14 #include "net/base/cookie_monster.h" | 13 #include "net/base/cookie_monster.h" |
| 15 #include "net/base/cookie_policy.h" | 14 #include "net/base/cookie_policy.h" |
| 16 #include "chrome/browser/appcache/chrome_appcache_service.h" | 15 #include "chrome/browser/appcache/chrome_appcache_service.h" |
| 17 #include "chrome/browser/host_content_settings_map.h" | 16 #include "chrome/browser/host_content_settings_map.h" |
| 18 #include "chrome/browser/host_zoom_map.h" | 17 #include "chrome/browser/host_zoom_map.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 45 class ChromeURLRequestContext : public URLRequestContext { | 44 class ChromeURLRequestContext : public URLRequestContext { |
| 46 public: | 45 public: |
| 47 // Maintains some extension-related state we need on the IO thread. | 46 // Maintains some extension-related state we need on the IO thread. |
| 48 // TODO(aa): It would be cool if the Extension objects in ExtensionsService | 47 // TODO(aa): It would be cool if the Extension objects in ExtensionsService |
| 49 // could be immutable and ref-counted so that we could use them directly from | 48 // could be immutable and ref-counted so that we could use them directly from |
| 50 // both threads. There is only a small amount of mutable state in Extension. | 49 // both threads. There is only a small amount of mutable state in Extension. |
| 51 struct ExtensionInfo { | 50 struct ExtensionInfo { |
| 52 ExtensionInfo(const std::string& name, const FilePath& path, | 51 ExtensionInfo(const std::string& name, const FilePath& path, |
| 53 const std::string& default_locale, | 52 const std::string& default_locale, |
| 54 const ExtensionExtent& extent, | 53 const ExtensionExtent& extent, |
| 55 const ExtensionExtent& effective_host_permissions, | |
| 56 const std::vector<std::string>& api_permissions) | 54 const std::vector<std::string>& api_permissions) |
| 57 : name(name), path(path), default_locale(default_locale), | 55 : name(name), path(path), default_locale(default_locale), |
| 58 extent(extent), | 56 extent(extent), api_permissions(api_permissions) { |
| 59 effective_host_permissions(effective_host_permissions), | |
| 60 api_permissions(api_permissions) { | |
| 61 } | 57 } |
| 62 const std::string name; | 58 const std::string name; |
| 63 const FilePath path; | 59 FilePath path; |
| 64 const std::string default_locale; | 60 std::string default_locale; |
| 65 const ExtensionExtent extent; | 61 ExtensionExtent extent; |
| 66 const ExtensionExtent effective_host_permissions; | |
| 67 std::vector<std::string> api_permissions; | 62 std::vector<std::string> api_permissions; |
| 68 }; | 63 }; |
| 69 | 64 |
| 70 // Map of extension info by extension id. | 65 // Map of extension info by extension id. |
| 71 typedef std::map<std::string, linked_ptr<ExtensionInfo> > ExtensionInfoMap; | 66 typedef std::map<std::string, linked_ptr<ExtensionInfo> > ExtensionInfoMap; |
| 72 | 67 |
| 73 ChromeURLRequestContext(); | 68 ChromeURLRequestContext(); |
| 74 | 69 |
| 75 // Gets the name for the specified extension. | 70 // Gets the name for the specified extension. |
| 76 std::string GetNameForExtension(const std::string& id); | 71 std::string GetNameForExtension(const std::string& id); |
| 77 | 72 |
| 78 // Gets the path to the directory for the specified extension. | 73 // Gets the path to the directory for the specified extension. |
| 79 FilePath GetPathForExtension(const std::string& id); | 74 FilePath GetPathForExtension(const std::string& id); |
| 80 | 75 |
| 81 // Returns an empty string if the extension with |id| doesn't have a default | 76 // Returns an empty string if the extension with |id| doesn't have a default |
| 82 // locale. | 77 // locale. |
| 83 std::string GetDefaultLocaleForExtension(const std::string& id); | 78 std::string GetDefaultLocaleForExtension(const std::string& id); |
| 84 | 79 |
| 85 // Gets the effective host permissions for the extension with |id|. | |
| 86 ExtensionExtent | |
| 87 GetEffectiveHostPermissionsForExtension(const std::string& id); | |
| 88 | |
| 89 // Determine whether a URL has access to the specified extension permission. | 80 // Determine whether a URL has access to the specified extension permission. |
| 90 bool CheckURLAccessToExtensionPermission(const GURL& url, | 81 bool CheckURLAccessToExtensionPermission(const GURL& url, |
| 91 const char* permission_name); | 82 const char* permission_name); |
| 92 | 83 |
| 93 // Gets the path to the directory user scripts are stored in. | 84 // Gets the path to the directory user scripts are stored in. |
| 94 FilePath user_script_dir_path() const { | 85 FilePath user_script_dir_path() const { |
| 95 return user_script_dir_path_; | 86 return user_script_dir_path_; |
| 96 } | 87 } |
| 97 | 88 |
| 98 // Gets the appcache service to be used for requests in this context. | 89 // Gets the appcache service to be used for requests in this context. |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 | 396 |
| 406 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextFactory); | 397 DISALLOW_COPY_AND_ASSIGN(ChromeURLRequestContextFactory); |
| 407 }; | 398 }; |
| 408 | 399 |
| 409 // Creates a proxy configuration from proxy-related preferences fetched | 400 // Creates a proxy configuration from proxy-related preferences fetched |
| 410 // from |pref_service|. The relevant preferences in |pref_service| are | 401 // from |pref_service|. The relevant preferences in |pref_service| are |
| 411 // initialized from the process' command line or by applicable proxy policies. | 402 // initialized from the process' command line or by applicable proxy policies. |
| 412 net::ProxyConfig* CreateProxyConfig(const PrefService* pref_service); | 403 net::ProxyConfig* CreateProxyConfig(const PrefService* pref_service); |
| 413 | 404 |
| 414 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ | 405 #endif // CHROME_BROWSER_NET_CHROME_URL_REQUEST_CONTEXT_H_ |
| OLD | NEW |