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 #include "chrome/browser/profile.h" | 5 #include "chrome/browser/profile.h" |
6 | 6 |
7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "app/theme_provider.h" | 8 #include "app/theme_provider.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 FilePath GetMediaCachePath(const FilePath& base) { | 124 FilePath GetMediaCachePath(const FilePath& base) { |
125 return base.Append(chrome::kMediaCacheDirname); | 125 return base.Append(chrome::kMediaCacheDirname); |
126 } | 126 } |
127 | 127 |
128 bool HasACacheSubdir(const FilePath &dir) { | 128 bool HasACacheSubdir(const FilePath &dir) { |
129 return file_util::PathExists(GetCachePath(dir)) || | 129 return file_util::PathExists(GetCachePath(dir)) || |
130 file_util::PathExists(GetMediaCachePath(dir)); | 130 file_util::PathExists(GetMediaCachePath(dir)); |
131 } | 131 } |
132 | 132 |
| 133 void PostExtensionLoadedToContextGetter(ChromeURLRequestContextGetter* getter, |
| 134 Extension* extension) { |
| 135 if (!getter) |
| 136 return; |
| 137 // Callee takes ownership of new ExtensionInfo struct. |
| 138 ChromeThread::PostTask( |
| 139 ChromeThread::IO, FROM_HERE, |
| 140 NewRunnableMethod(getter, |
| 141 &ChromeURLRequestContextGetter::OnNewExtensions, |
| 142 extension->id(), |
| 143 new ChromeURLRequestContext::ExtensionInfo( |
| 144 extension->path(), |
| 145 extension->default_locale(), |
| 146 extension->web_extent(), |
| 147 extension->api_permissions()))); |
| 148 } |
| 149 |
| 150 void PostExtensionUnloadedToContextGetter(ChromeURLRequestContextGetter* getter, |
| 151 Extension* extension) { |
| 152 if (!getter) |
| 153 return; |
| 154 ChromeThread::PostTask( |
| 155 ChromeThread::IO, FROM_HERE, |
| 156 NewRunnableMethod(getter, |
| 157 &ChromeURLRequestContextGetter::OnUnloadedExtension, |
| 158 extension->id())); |
| 159 } |
| 160 |
133 } // namespace | 161 } // namespace |
134 | 162 |
135 // A pointer to the request context for the default profile. See comments on | 163 // A pointer to the request context for the default profile. See comments on |
136 // Profile::GetDefaultRequestContext. | 164 // Profile::GetDefaultRequestContext. |
137 URLRequestContextGetter* Profile::default_request_context_; | 165 URLRequestContextGetter* Profile::default_request_context_; |
138 | 166 |
139 static void CleanupRequestContext(ChromeURLRequestContextGetter* context) { | 167 static void CleanupRequestContext(ChromeURLRequestContextGetter* context) { |
140 if (context) | 168 if (context) |
141 context->CleanupOnUIThread(); | 169 context->CleanupOnUIThread(); |
142 } | 170 } |
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 cookie_path = cookie_path.Append(chrome::kExtensionsCookieFilename); | 998 cookie_path = cookie_path.Append(chrome::kExtensionsCookieFilename); |
971 | 999 |
972 extensions_request_context_ = | 1000 extensions_request_context_ = |
973 ChromeURLRequestContextGetter::CreateOriginalForExtensions( | 1001 ChromeURLRequestContextGetter::CreateOriginalForExtensions( |
974 this, cookie_path); | 1002 this, cookie_path); |
975 } | 1003 } |
976 | 1004 |
977 return extensions_request_context_; | 1005 return extensions_request_context_; |
978 } | 1006 } |
979 | 1007 |
| 1008 void ProfileImpl::RegisterExtensionWithRequestContexts( |
| 1009 Extension* extension) { |
| 1010 // Notify the default, extension and media contexts on the IO thread. |
| 1011 PostExtensionLoadedToContextGetter( |
| 1012 static_cast<ChromeURLRequestContextGetter*>(GetRequestContext()), |
| 1013 extension); |
| 1014 PostExtensionLoadedToContextGetter( |
| 1015 static_cast<ChromeURLRequestContextGetter*>( |
| 1016 GetRequestContextForExtensions()), |
| 1017 extension); |
| 1018 PostExtensionLoadedToContextGetter( |
| 1019 static_cast<ChromeURLRequestContextGetter*>( |
| 1020 GetRequestContextForMedia()), |
| 1021 extension); |
| 1022 } |
| 1023 |
| 1024 void ProfileImpl::UnregisterExtensionWithRequestContexts( |
| 1025 Extension* extension) { |
| 1026 // Notify the default, extension and media contexts on the IO thread. |
| 1027 PostExtensionUnloadedToContextGetter( |
| 1028 static_cast<ChromeURLRequestContextGetter*>(GetRequestContext()), |
| 1029 extension); |
| 1030 PostExtensionUnloadedToContextGetter( |
| 1031 static_cast<ChromeURLRequestContextGetter*>( |
| 1032 GetRequestContextForExtensions()), |
| 1033 extension); |
| 1034 PostExtensionUnloadedToContextGetter( |
| 1035 static_cast<ChromeURLRequestContextGetter*>( |
| 1036 GetRequestContextForMedia()), |
| 1037 extension); |
| 1038 } |
| 1039 |
980 net::SSLConfigService* ProfileImpl::GetSSLConfigService() { | 1040 net::SSLConfigService* ProfileImpl::GetSSLConfigService() { |
981 return ssl_config_service_manager_->Get(); | 1041 return ssl_config_service_manager_->Get(); |
982 } | 1042 } |
983 | 1043 |
984 HostContentSettingsMap* ProfileImpl::GetHostContentSettingsMap() { | 1044 HostContentSettingsMap* ProfileImpl::GetHostContentSettingsMap() { |
985 if (!host_content_settings_map_.get()) | 1045 if (!host_content_settings_map_.get()) |
986 host_content_settings_map_ = new HostContentSettingsMap(this); | 1046 host_content_settings_map_ = new HostContentSettingsMap(this); |
987 return host_content_settings_map_.get(); | 1047 return host_content_settings_map_.get(); |
988 } | 1048 } |
989 | 1049 |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1355 } | 1415 } |
1356 | 1416 |
1357 void ProfileImpl::InitSyncService() { | 1417 void ProfileImpl::InitSyncService() { |
1358 profile_sync_factory_.reset( | 1418 profile_sync_factory_.reset( |
1359 new ProfileSyncFactoryImpl(this, | 1419 new ProfileSyncFactoryImpl(this, |
1360 CommandLine::ForCurrentProcess())); | 1420 CommandLine::ForCurrentProcess())); |
1361 sync_service_.reset( | 1421 sync_service_.reset( |
1362 profile_sync_factory_->CreateProfileSyncService()); | 1422 profile_sync_factory_->CreateProfileSyncService()); |
1363 sync_service_->Initialize(); | 1423 sync_service_->Initialize(); |
1364 } | 1424 } |
OLD | NEW |