OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/file_path.h" |
| 6 #include "chrome/common/net/cookie_monster_sqlite.h" |
| 7 #include "chrome/common/notification_service.h" |
| 8 #include "chrome/common/pref_service.h" |
| 9 #include "net/url_request/url_request_context.h" |
| 10 |
| 11 class Profile; |
| 12 |
| 13 // A URLRequestContext subclass used by the browser. This can be used to store |
| 14 // extra information about requests, beyond what is supported by the base |
| 15 // URLRequestContext class. |
| 16 // |
| 17 // All methods are expected to be called on the IO thread except the |
| 18 // constructor and factories (CreateOriginal, CreateOffTheRecord), which are |
| 19 // expected to be called on the UI thread. |
| 20 class ChromeURLRequestContext : public URLRequestContext, |
| 21 public NotificationObserver { |
| 22 public: |
| 23 typedef std::map<std::string, FilePath> ExtensionPaths; |
| 24 |
| 25 // Create an instance for use with an 'original' (non-OTR) profile. This is |
| 26 // expected to get called on the UI thread. |
| 27 static ChromeURLRequestContext* CreateOriginal( |
| 28 Profile* profile, const std::wstring& cookie_store_path, |
| 29 const std::wstring& disk_cache_path); |
| 30 |
| 31 // Create an instance for use with an OTR profile. This is expected to get |
| 32 // called on the UI thread. |
| 33 static ChromeURLRequestContext* CreateOffTheRecord(Profile* profile); |
| 34 |
| 35 // Clean up UI thread resources. This is expected to get called on the UI |
| 36 // thread before the instance is deleted on the IO thread. |
| 37 void CleanupOnUIThread(); |
| 38 |
| 39 // Gets the path to the directory for the specified extension. |
| 40 FilePath GetPathForExtension(const std::string& id); |
| 41 |
| 42 private: |
| 43 // Private constructor, use the static factory methods instead. This is |
| 44 // expected to be called on the UI thread. |
| 45 ChromeURLRequestContext(Profile* profile); |
| 46 |
| 47 // NotificationObserver implementation. |
| 48 virtual void Observe(NotificationType type, |
| 49 const NotificationSource& source, |
| 50 const NotificationDetails& details); |
| 51 |
| 52 // Callback for when the accept language changes. |
| 53 void OnAcceptLanguageChange(std::string accept_language); |
| 54 |
| 55 // Callback for when the cookie policy changes. |
| 56 void OnCookiePolicyChange(net::CookiePolicy::Type type); |
| 57 |
| 58 // Callback for when new extensions are loaded. |
| 59 void OnNewExtensions(ExtensionPaths* new_paths); |
| 60 |
| 61 // Destructor. |
| 62 virtual ~ChromeURLRequestContext(); |
| 63 |
| 64 // Maps extension IDs to paths on disk. This is initialized in the |
| 65 // construtor and updated when extensions changed. |
| 66 ExtensionPaths extension_paths_; |
| 67 |
| 68 scoped_ptr<SQLitePersistentCookieStore> cookie_db_; |
| 69 PrefService* prefs_; |
| 70 bool is_off_the_record_; |
| 71 }; |
OLD | NEW |