Commit dfc0424c authored by thestig@chromium.org's avatar thestig@chromium.org

One more round of extensions code ifdefing in profiles code.

BUG=349436

Review URL: https://codereview.chromium.org/399593003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285686 0039d316-1c4b-4281-b951-d872f2087c98
parent 804dd61c
......@@ -40,8 +40,6 @@
#include "chrome/browser/download/chrome_download_manager_delegate.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_special_storage_policy.h"
#include "chrome/browser/history/top_sites.h"
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/net/net_pref_observer.h"
......@@ -71,7 +69,6 @@
#include "chrome/browser/services/gcm/push_messaging_service_impl.h"
#include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/ui/startup/startup_browser_creator.h"
#include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/chrome_switches.h"
......@@ -98,10 +95,6 @@
#include "content/public/browser/user_metrics.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/page_zoom.h"
#include "extensions/browser/extension_pref_store.h"
#include "extensions/browser/extension_pref_value_map.h"
#include "extensions/browser/extension_pref_value_map_factory.h"
#include "extensions/browser/extension_system.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -133,7 +126,14 @@
#endif
#if defined(ENABLE_EXTENSIONS)
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_special_storage_policy.h"
#include "chrome/browser/guest_view/guest_view_manager.h"
#include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
#include "extensions/browser/extension_pref_store.h"
#include "extensions/browser/extension_pref_value_map.h"
#include "extensions/browser/extension_pref_value_map_factory.h"
#include "extensions/browser/extension_system.h"
#endif
#if defined(ENABLE_MANAGED_USERS)
......@@ -152,20 +152,20 @@ namespace {
#if defined(ENABLE_SESSION_SERVICE)
// Delay, in milliseconds, before we explicitly create the SessionService.
static const int kCreateSessionServiceDelayMS = 500;
const int kCreateSessionServiceDelayMS = 500;
#endif
// Text content of README file created in each profile directory. Both %s
// placeholders must contain the product name. This is not localizable and hence
// not in resources.
static const char kReadmeText[] =
const char kReadmeText[] =
"%s settings and storage represent user-selected preferences and "
"information and MUST not be extracted, overwritten or modified except "
"through %s defined APIs.";
// Value written to prefs for EXIT_CRASHED and EXIT_SESSION_ENDED.
const char* const kPrefExitTypeCrashed = "Crashed";
const char* const kPrefExitTypeSessionEnded = "SessionEnded";
const char kPrefExitTypeCrashed[] = "Crashed";
const char kPrefExitTypeSessionEnded[] = "SessionEnded";
// Helper method needed because PostTask cannot currently take a Callback
// function with non-void return type.
......@@ -260,6 +260,17 @@ void RegisterDomDistillerViewerSource(Profile* profile) {
}
}
PrefStore* CreateExtensionPrefStore(Profile* profile,
bool incognito_pref_store) {
#if defined(ENABLE_EXTENSIONS)
return new ExtensionPrefStore(
ExtensionPrefValueMapFactory::GetForBrowserContext(profile),
incognito_pref_store);
#else
return NULL;
#endif
}
} // namespace
// static
......@@ -469,8 +480,7 @@ ProfileImpl::ProfileImpl(
pref_validation_delegate_.get(),
profile_policy_connector_->policy_service(),
supervised_user_settings,
new ExtensionPrefStore(
ExtensionPrefValueMapFactory::GetForBrowserContext(this), false),
CreateExtensionPrefStore(this, false),
pref_registry_,
async_prefs).Pass();
// Register on BrowserContext.
......@@ -737,8 +747,10 @@ ProfileImpl::~ProfileImpl() {
ProfileDestroyer::DestroyOffTheRecordProfileNow(
off_the_record_profile_.get());
} else {
#if defined(ENABLE_EXTENSIONS)
ExtensionPrefValueMapFactory::GetForBrowserContext(this)->
ClearAllIncognitoSessionOnlyPreferences();
#endif
}
BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(
......@@ -794,8 +806,10 @@ Profile* ProfileImpl::GetOffTheRecordProfile() {
void ProfileImpl::DestroyOffTheRecordProfile() {
off_the_record_profile_.reset();
#if defined(ENABLE_EXTENSIONS)
ExtensionPrefValueMapFactory::GetForBrowserContext(this)->
ClearAllIncognitoSessionOnlyPreferences();
#endif
}
bool ProfileImpl::HasOffTheRecordProfile() {
......@@ -812,12 +826,16 @@ bool ProfileImpl::IsSupervised() {
ExtensionSpecialStoragePolicy*
ProfileImpl::GetExtensionSpecialStoragePolicy() {
#if defined(ENABLE_EXTENSIONS)
if (!extension_special_storage_policy_.get()) {
TRACE_EVENT0("browser", "ProfileImpl::GetExtensionSpecialStoragePolicy")
extension_special_storage_policy_ = new ExtensionSpecialStoragePolicy(
CookieSettings::Factory::GetForProfile(this).get());
}
return extension_special_storage_policy_.get();
#else
return NULL;
#endif
}
void ProfileImpl::OnPrefsLoaded(bool success) {
......@@ -925,8 +943,7 @@ PrefService* ProfileImpl::GetOffTheRecordPrefs() {
// The new ExtensionPrefStore is ref_counted and the new PrefService
// stores a reference so that we do not leak memory here.
otr_prefs_.reset(prefs_->CreateIncognitoPrefService(
new ExtensionPrefStore(
ExtensionPrefValueMapFactory::GetForBrowserContext(this), true)));
CreateExtensionPrefStore(this, true)));
}
return otr_prefs_.get();
}
......@@ -1029,7 +1046,11 @@ DownloadManagerDelegate* ProfileImpl::GetDownloadManagerDelegate() {
}
quota::SpecialStoragePolicy* ProfileImpl::GetSpecialStoragePolicy() {
#if defined(ENABLE_EXTENSIONS)
return GetExtensionSpecialStoragePolicy();
#else
return NULL;
#endif
}
content::PushMessagingService* ProfileImpl::GetPushMessagingService() {
......
......@@ -235,8 +235,10 @@ class ProfileImpl : public Profile {
scoped_ptr<PrefServiceSyncable> prefs_;
scoped_ptr<PrefServiceSyncable> otr_prefs_;
ProfileImplIOData::Handle io_data_;
#if defined(ENABLE_EXTENSIONS)
scoped_refptr<ExtensionSpecialStoragePolicy>
extension_special_storage_policy_;
#endif
scoped_ptr<NetPrefObserver> net_pref_observer_;
scoped_ptr<SSLConfigServiceManager> ssl_config_service_manager_;
scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
......
......@@ -32,7 +32,6 @@
#include "chrome/browser/devtools/devtools_network_transaction_factory.h"
#include "chrome/browser/download/download_service.h"
#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/extensions/extension_resource_protocols.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/media/media_device_id_salt.h"
#include "chrome/browser/net/about_protocol_handler.h"
......@@ -56,10 +55,6 @@
#include "content/public/browser/host_zoom_map.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/resource_context.h"
#include "extensions/browser/extension_protocols.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/info_map.h"
#include "extensions/common/constants.h"
#include "net/base/keygen_handler.h"
#include "net/cookies/canonical_cookie.h"
#include "net/http/http_transaction_factory.h"
......@@ -88,6 +83,14 @@
#include "components/policy/core/common/cloud/user_cloud_policy_manager.h"
#endif
#if defined(ENABLE_EXTENSIONS)
#include "chrome/browser/extensions/extension_resource_protocols.h"
#include "extensions/browser/extension_protocols.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/info_map.h"
#include "extensions/common/constants.h"
#endif
#if defined(ENABLE_MANAGED_USERS)
#include "chrome/browser/supervised_user/supervised_user_service.h"
#include "chrome/browser/supervised_user/supervised_user_service_factory.h"
......@@ -335,8 +338,10 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) {
params->ssl_config_service = profile->GetSSLConfigService();
params->cookie_monster_delegate =
chrome_browser_net::CreateCookieDelegate(profile);
#if defined(ENABLE_EXTENSIONS)
params->extension_info_map =
extensions::ExtensionSystem::Get(profile)->info_map();
#endif
ProtocolHandlerRegistry* protocol_handler_registry =
ProtocolHandlerRegistryFactory::GetForProfile(profile);
......@@ -675,8 +680,10 @@ bool ProfileIOData::IsHandledProtocol(const std::string& scheme) {
url::kFileScheme,
content::kChromeDevToolsScheme,
chrome::kDomDistillerScheme,
#if defined(ENABLE_EXTENSIONS)
extensions::kExtensionScheme,
extensions::kExtensionResourceScheme,
#endif
content::kChromeUIScheme,
url::kDataScheme,
#if defined(OS_CHROMEOS)
......@@ -785,7 +792,11 @@ ChromeURLRequestContext* ProfileIOData::GetIsolatedMediaRequestContext(
extensions::InfoMap* ProfileIOData::GetExtensionInfoMap() const {
DCHECK(initialized_) << "ExtensionSystem not initialized";
#if defined(ENABLE_EXTENSIONS)
return extension_info_map_.get();
#else
return NULL;
#endif
}
CookieSettings* ProfileIOData::GetCookieSettings() const {
......@@ -1018,8 +1029,10 @@ void ProfileIOData::Init(
io_thread_globals->on_resolve_proxy_handler);
if (command_line.HasSwitch(switches::kEnableClientHints))
network_delegate->SetEnableClientHints();
#if defined(ENABLE_EXTENSIONS)
network_delegate->set_extension_info_map(
profile_params_->extension_info_map.get());
#endif
#if defined(ENABLE_CONFIGURATION_POLICY)
network_delegate->set_url_blacklist_manager(url_blacklist_manager_.get());
#endif
......@@ -1061,7 +1074,9 @@ void ProfileIOData::Init(
// Take ownership over these parameters.
cookie_settings_ = profile_params_->cookie_settings;
host_content_settings_map_ = profile_params_->host_content_settings_map;
#if defined(ENABLE_EXTENSIONS)
extension_info_map_ = profile_params_->extension_info_map;
#endif
resource_context_->host_resolver_ = io_thread_globals->host_resolver.get();
resource_context_->request_context_ = main_request_context_.get();
......@@ -1121,6 +1136,7 @@ scoped_ptr<net::URLRequestJobFactory> ProfileIOData::SetUpJobFactoryDefaults(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
DCHECK(set_protocol);
#if defined(ENABLE_EXTENSIONS)
DCHECK(extension_info_map_.get());
// Check only for incognito (and not Chrome OS guest mode GUEST_PROFILE).
bool is_incognito = profile_type() == Profile::INCOGNITO_PROFILE;
......@@ -1133,6 +1149,7 @@ scoped_ptr<net::URLRequestJobFactory> ProfileIOData::SetUpJobFactoryDefaults(
extensions::kExtensionResourceScheme,
CreateExtensionResourceProtocolHandler());
DCHECK(set_protocol);
#endif
set_protocol = job_factory->SetProtocolHandler(
url::kDataScheme, new net::DataProtocolHandler());
DCHECK(set_protocol);
......
......@@ -304,7 +304,9 @@ class ProfileIOData {
scoped_refptr<HostContentSettingsMap> host_content_settings_map;
scoped_refptr<net::SSLConfigService> ssl_config_service;
scoped_refptr<net::CookieMonster::Delegate> cookie_monster_delegate;
#if defined(ENABLE_EXTENSIONS)
scoped_refptr<extensions::InfoMap> extension_info_map;
#endif
// This pointer exists only as a means of conveying a url job factory
// pointer from the protocol handler registry on the UI thread to the
......@@ -573,7 +575,9 @@ class ProfileIOData {
#endif
// Pointed to by URLRequestContext.
#if defined(ENABLE_EXTENSIONS)
mutable scoped_refptr<extensions::InfoMap> extension_info_map_;
#endif
mutable scoped_ptr<net::ChannelIDService> channel_id_service_;
mutable scoped_ptr<ChromeNetworkDelegate> network_delegate_;
mutable scoped_ptr<net::FraudulentCertificateReporter>
......
......@@ -61,7 +61,6 @@
#include "components/sync_driver/shared_change_processor.h"
#include "components/sync_driver/ui_data_type_controller.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/extension_system.h"
#include "google_apis/gaia/oauth2_token_service_request.h"
#include "net/url_request/url_request_context_getter.h"
#include "sync/api/attachments/attachment_downloader.h"
......@@ -71,18 +70,18 @@
#include "sync/internal_api/public/attachments/attachment_uploader_impl.h"
#include "sync/internal_api/public/attachments/fake_attachment_store.h"
#if defined(ENABLE_EXTENSIONS)
#include "chrome/browser/extensions/api/storage/settings_sync_util.h"
#include "chrome/browser/extensions/api/synced_notifications_private/synced_notifications_shim.h"
#include "chrome/browser/extensions/extension_sync_service.h"
#endif
#if defined(ENABLE_APP_LIST)
#include "chrome/browser/ui/app_list/app_list_syncable_service.h"
#include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
#include "ui/app_list/app_list_switches.h"
#endif
#if defined(ENABLE_EXTENSIONS)
#include "chrome/browser/extensions/api/storage/settings_sync_util.h"
#include "chrome/browser/extensions/api/synced_notifications_private/synced_notifications_shim.h"
#include "chrome/browser/extensions/extension_sync_service.h"
#endif
#if defined(ENABLE_MANAGED_USERS)
#include "chrome/browser/supervised_user/supervised_user_settings_service.h"
#include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h"
......@@ -155,7 +154,6 @@ ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl(
net::URLRequestContextGetter* url_request_context_getter)
: profile_(profile),
command_line_(command_line),
extension_system_(extensions::ExtensionSystem::Get(profile)),
web_data_service_(WebDataServiceFactory::GetAutofillWebDataForProfile(
profile_, Profile::EXPLICIT_ACCESS)),
sync_service_url_(sync_service_url),
......@@ -351,7 +349,6 @@ void ProfileSyncComponentsFactoryImpl::RegisterDesktopDataTypes(
MakeDisableCallbackFor(syncer::PREFERENCES),
syncer::PREFERENCES,
this));
}
if (!disabled_types.Has(syncer::PRIORITY_PREFERENCES)) {
......
......@@ -102,10 +102,6 @@ class ProfileSyncComponentsFactoryImpl : public ProfileSyncComponentsFactory {
Profile* profile_;
base::CommandLine* command_line_;
// Set on the UI thread (since extensions::ExtensionSystemFactory is
// non-threadsafe); accessed on both the UI and FILE threads in
// GetSyncableServiceForType.
extensions::ExtensionSystem* extension_system_;
scoped_refptr<autofill::AutofillWebDataService> web_data_service_;
const GURL sync_service_url_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment