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 "chrome/browser/profiles/profile_io_data.h" | 5 #include "chrome/browser/profiles/profile_io_data.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 29 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
30 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 30 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
31 #include "chrome/browser/download/download_service.h" | 31 #include "chrome/browser/download/download_service.h" |
32 #include "chrome/browser/download/download_service_factory.h" | 32 #include "chrome/browser/download/download_service_factory.h" |
33 #include "chrome/browser/extensions/extension_protocols.h" | 33 #include "chrome/browser/extensions/extension_protocols.h" |
34 #include "chrome/browser/extensions/extension_resource_protocols.h" | 34 #include "chrome/browser/extensions/extension_resource_protocols.h" |
35 #include "chrome/browser/extensions/extension_system.h" | 35 #include "chrome/browser/extensions/extension_system.h" |
36 #include "chrome/browser/io_thread.h" | 36 #include "chrome/browser/io_thread.h" |
37 #include "chrome/browser/media/media_device_id_salt.h" | 37 #include "chrome/browser/media/media_device_id_salt.h" |
38 #include "chrome/browser/net/about_protocol_handler.h" | 38 #include "chrome/browser/net/about_protocol_handler.h" |
39 #include "chrome/browser/net/chrome_cookie_notification_details.h" | |
40 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" | 39 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" |
41 #include "chrome/browser/net/chrome_http_user_agent_settings.h" | 40 #include "chrome/browser/net/chrome_http_user_agent_settings.h" |
42 #include "chrome/browser/net/chrome_net_log.h" | 41 #include "chrome/browser/net/chrome_net_log.h" |
43 #include "chrome/browser/net/chrome_network_delegate.h" | 42 #include "chrome/browser/net/chrome_network_delegate.h" |
44 #include "chrome/browser/net/evicted_domain_cookie_counter.h" | 43 #include "chrome/browser/net/cookie_store_util.h" |
45 #include "chrome/browser/net/proxy_service_factory.h" | 44 #include "chrome/browser/net/proxy_service_factory.h" |
46 #include "chrome/browser/profiles/profile.h" | 45 #include "chrome/browser/profiles/profile.h" |
47 #include "chrome/browser/profiles/profile_manager.h" | 46 #include "chrome/browser/profiles/profile_manager.h" |
48 #include "chrome/browser/signin/signin_names_io_thread.h" | 47 #include "chrome/browser/signin/signin_names_io_thread.h" |
49 #include "chrome/common/chrome_paths.h" | 48 #include "chrome/common/chrome_paths.h" |
50 #include "chrome/common/chrome_switches.h" | 49 #include "chrome/common/chrome_switches.h" |
51 #include "chrome/common/net/url_fixer_upper.h" | 50 #include "chrome/common/net/url_fixer_upper.h" |
52 #include "chrome/common/pref_names.h" | 51 #include "chrome/common/pref_names.h" |
53 #include "chrome/common/url_constants.h" | 52 #include "chrome/common/url_constants.h" |
54 #include "components/startup_metric_utils/startup_metric_utils.h" | 53 #include "components/startup_metric_utils/startup_metric_utils.h" |
55 #include "content/public/browser/browser_thread.h" | 54 #include "content/public/browser/browser_thread.h" |
56 #include "content/public/browser/host_zoom_map.h" | 55 #include "content/public/browser/host_zoom_map.h" |
57 #include "content/public/browser/notification_service.h" | 56 #include "content/public/browser/notification_service.h" |
58 #include "content/public/browser/resource_context.h" | 57 #include "content/public/browser/resource_context.h" |
59 #include "extensions/browser/info_map.h" | 58 #include "extensions/browser/info_map.h" |
60 #include "extensions/common/constants.h" | 59 #include "extensions/common/constants.h" |
61 #include "net/base/keygen_handler.h" | 60 #include "net/base/keygen_handler.h" |
62 #include "net/cookies/canonical_cookie.h" | 61 #include "net/cookies/canonical_cookie.h" |
63 #include "net/cookies/cookie_monster.h" | |
64 #include "net/http/http_transaction_factory.h" | 62 #include "net/http/http_transaction_factory.h" |
65 #include "net/http/http_util.h" | 63 #include "net/http/http_util.h" |
66 #include "net/http/transport_security_persister.h" | 64 #include "net/http/transport_security_persister.h" |
67 #include "net/proxy/proxy_config_service_fixed.h" | 65 #include "net/proxy/proxy_config_service_fixed.h" |
68 #include "net/proxy/proxy_script_fetcher_impl.h" | 66 #include "net/proxy/proxy_script_fetcher_impl.h" |
69 #include "net/proxy/proxy_service.h" | 67 #include "net/proxy/proxy_service.h" |
70 #include "net/ssl/client_cert_store.h" | 68 #include "net/ssl/client_cert_store.h" |
71 #include "net/ssl/server_bound_cert_service.h" | 69 #include "net/ssl/server_bound_cert_service.h" |
72 #include "net/url_request/data_protocol_handler.h" | 70 #include "net/url_request/data_protocol_handler.h" |
73 #include "net/url_request/file_protocol_handler.h" | 71 #include "net/url_request/file_protocol_handler.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 #if defined(OS_MACOSX) | 118 #if defined(OS_MACOSX) |
121 #include "net/ssl/client_cert_store_mac.h" | 119 #include "net/ssl/client_cert_store_mac.h" |
122 #endif | 120 #endif |
123 | 121 |
124 using content::BrowserContext; | 122 using content::BrowserContext; |
125 using content::BrowserThread; | 123 using content::BrowserThread; |
126 using content::ResourceContext; | 124 using content::ResourceContext; |
127 | 125 |
128 namespace { | 126 namespace { |
129 | 127 |
130 // ---------------------------------------------------------------------------- | |
131 // CookieMonster::Delegate implementation | |
132 // ---------------------------------------------------------------------------- | |
133 class ChromeCookieMonsterDelegate : public net::CookieMonster::Delegate { | |
134 public: | |
135 explicit ChromeCookieMonsterDelegate( | |
136 const base::Callback<Profile*(void)>& profile_getter) | |
137 : profile_getter_(profile_getter) { | |
138 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
139 } | |
140 | |
141 // net::CookieMonster::Delegate implementation. | |
142 virtual void OnCookieChanged( | |
143 const net::CanonicalCookie& cookie, | |
144 bool removed, | |
145 net::CookieMonster::Delegate::ChangeCause cause) OVERRIDE { | |
146 BrowserThread::PostTask( | |
147 BrowserThread::UI, FROM_HERE, | |
148 base::Bind(&ChromeCookieMonsterDelegate::OnCookieChangedAsyncHelper, | |
149 this, cookie, removed, cause)); | |
150 } | |
151 | |
152 private: | |
153 virtual ~ChromeCookieMonsterDelegate() {} | |
154 | |
155 void OnCookieChangedAsyncHelper( | |
156 const net::CanonicalCookie& cookie, | |
157 bool removed, | |
158 net::CookieMonster::Delegate::ChangeCause cause) { | |
159 Profile* profile = profile_getter_.Run(); | |
160 if (profile) { | |
161 ChromeCookieDetails cookie_details(&cookie, removed, cause); | |
162 content::NotificationService::current()->Notify( | |
163 chrome::NOTIFICATION_COOKIE_CHANGED, | |
164 content::Source<Profile>(profile), | |
165 content::Details<ChromeCookieDetails>(&cookie_details)); | |
166 } | |
167 } | |
168 | |
169 const base::Callback<Profile*(void)> profile_getter_; | |
170 }; | |
171 | |
172 Profile* GetProfileOnUI(ProfileManager* profile_manager, Profile* profile) { | |
173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
174 DCHECK(profile); | |
175 if (profile_manager->IsValidProfile(profile)) | |
176 return profile; | |
177 return NULL; | |
178 } | |
179 | |
180 #if defined(DEBUG_DEVTOOLS) | 128 #if defined(DEBUG_DEVTOOLS) |
181 bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) { | 129 bool IsSupportedDevToolsURL(const GURL& url, base::FilePath* path) { |
182 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath); | 130 std::string bundled_path_prefix(chrome::kChromeUIDevToolsBundledPath); |
183 bundled_path_prefix = "/" + bundled_path_prefix + "/"; | 131 bundled_path_prefix = "/" + bundled_path_prefix + "/"; |
184 | 132 |
185 if (!url.SchemeIs(chrome::kChromeDevToolsScheme) || | 133 if (!url.SchemeIs(chrome::kChromeDevToolsScheme) || |
186 url.host() != chrome::kChromeUIDevToolsHost || | 134 url.host() != chrome::kChromeUIDevToolsHost || |
187 !StartsWithASCII(url.path(), bundled_path_prefix, false)) { | 135 !StartsWithASCII(url.path(), bundled_path_prefix, false)) { |
188 return false; | 136 return false; |
189 } | 137 } |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 PrefService* local_state_pref_service = g_browser_process->local_state(); | 311 PrefService* local_state_pref_service = g_browser_process->local_state(); |
364 | 312 |
365 scoped_ptr<ProfileParams> params(new ProfileParams); | 313 scoped_ptr<ProfileParams> params(new ProfileParams); |
366 params->path = profile->GetPath(); | 314 params->path = profile->GetPath(); |
367 | 315 |
368 params->io_thread = g_browser_process->io_thread(); | 316 params->io_thread = g_browser_process->io_thread(); |
369 | 317 |
370 params->cookie_settings = CookieSettings::Factory::GetForProfile(profile); | 318 params->cookie_settings = CookieSettings::Factory::GetForProfile(profile); |
371 params->host_content_settings_map = profile->GetHostContentSettingsMap(); | 319 params->host_content_settings_map = profile->GetHostContentSettingsMap(); |
372 params->ssl_config_service = profile->GetSSLConfigService(); | 320 params->ssl_config_service = profile->GetSSLConfigService(); |
373 base::Callback<Profile*(void)> profile_getter = | |
374 base::Bind(&GetProfileOnUI, g_browser_process->profile_manager(), | |
375 profile); | |
376 params->cookie_monster_delegate = | 321 params->cookie_monster_delegate = |
377 new chrome_browser_net::EvictedDomainCookieCounter( | 322 chrome_browser_net::CreateCookieDelegate(profile); |
378 new ChromeCookieMonsterDelegate(profile_getter)); | |
379 params->extension_info_map = | 323 params->extension_info_map = |
380 extensions::ExtensionSystem::Get(profile)->info_map(); | 324 extensions::ExtensionSystem::Get(profile)->info_map(); |
381 | 325 |
382 ProtocolHandlerRegistry* protocol_handler_registry = | 326 ProtocolHandlerRegistry* protocol_handler_registry = |
383 ProtocolHandlerRegistryFactory::GetForProfile(profile); | 327 ProtocolHandlerRegistryFactory::GetForProfile(profile); |
384 DCHECK(protocol_handler_registry); | 328 DCHECK(protocol_handler_registry); |
385 | 329 |
386 // The profile instance is only available here in the InitializeOnUIThread | 330 // The profile instance is only available here in the InitializeOnUIThread |
387 // method, so we create the url job factory here, then save it for | 331 // method, so we create the url job factory here, then save it for |
388 // later delivery to the job factory in Init(). | 332 // later delivery to the job factory in Init(). |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 void ProfileIOData::SetCookieSettingsForTesting( | 1123 void ProfileIOData::SetCookieSettingsForTesting( |
1180 CookieSettings* cookie_settings) { | 1124 CookieSettings* cookie_settings) { |
1181 DCHECK(!cookie_settings_.get()); | 1125 DCHECK(!cookie_settings_.get()); |
1182 cookie_settings_ = cookie_settings; | 1126 cookie_settings_ = cookie_settings; |
1183 } | 1127 } |
1184 | 1128 |
1185 void ProfileIOData::set_signin_names_for_testing( | 1129 void ProfileIOData::set_signin_names_for_testing( |
1186 SigninNamesOnIOThread* signin_names) { | 1130 SigninNamesOnIOThread* signin_names) { |
1187 signin_names_.reset(signin_names); | 1131 signin_names_.reset(signin_names); |
1188 } | 1132 } |
OLD | NEW |