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

ifdef various extensions code to be used only when extensions are enabled.

BUG=349436

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282806 0039d316-1c4b-4281-b951-d872f2087c98
parent 7a4fa927
......@@ -12,8 +12,11 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#if defined(ENABLE_EXTENSIONS)
#include "extensions/browser/extension_system_provider.h"
#include "extensions/browser/extensions_browser_client.h"
#endif
// static
AutocompleteClassifier* AutocompleteClassifierFactory::GetForProfile(
......@@ -43,8 +46,10 @@ AutocompleteClassifierFactory::AutocompleteClassifierFactory()
: BrowserContextKeyedServiceFactory(
"AutocompleteClassifier",
BrowserContextDependencyManager::GetInstance()) {
#if defined(ENABLE_EXTENSIONS)
DependsOn(
extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
#endif
DependsOn(TemplateURLServiceFactory::GetInstance());
// TODO(pkasting): Uncomment these once they exist.
// DependsOn(PrefServiceFactory::GetInstance());
......
......@@ -16,7 +16,6 @@
#include "chrome/browser/status_icons/status_icon.h"
#include "chrome/browser/status_icons/status_tray.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
......@@ -24,8 +23,6 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
......@@ -34,11 +31,18 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image_skia.h"
#if defined(ENABLE_EXTENSIONS)
#include "chrome/common/extensions/extension_constants.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h"
#endif
using content::BrowserThread;
using content::WebContents;
namespace {
#if defined(ENABLE_EXTENSIONS)
const extensions::Extension* GetExtension(WebContents* web_contents) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
......@@ -51,8 +55,6 @@ const extensions::Extension* GetExtension(WebContents* web_contents) {
web_contents->GetURL());
}
#if !defined(OS_ANDROID)
bool IsWhitelistedExtension(const extensions::Extension* extension) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
......@@ -67,8 +69,7 @@ bool IsWhitelistedExtension(const extensions::Extension* extension) {
return false;
}
#endif // !defined(OS_ANDROID)
#endif // defined(ENABLE_EXTENSIONS)
// Gets the security originator of the tab. It returns a string with no '/'
// at the end to display in the UI.
......@@ -96,9 +97,11 @@ base::string16 GetTitle(WebContents* web_contents) {
if (!web_contents)
return base::string16();
#if defined(ENABLE_EXTENSIONS)
const extensions::Extension* const extension = GetExtension(web_contents);
if (extension)
return base::UTF8ToUTF16(extension->name());
#endif
base::string16 tab_title = web_contents->GetTitle();
......@@ -426,7 +429,7 @@ void MediaStreamCaptureIndicator::UpdateNotificationUserInterface() {
// The audio/video icon is shown only for non-whitelisted extensions or on
// Android. For regular tabs on desktop, we show an indicator in the tab
// icon.
#if !defined(OS_ANDROID)
#if defined(ENABLE_EXTENSIONS)
const extensions::Extension* extension = GetExtension(web_contents);
if (!extension || IsWhitelistedExtension(extension))
continue;
......
......@@ -10,7 +10,6 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
#include "components/nacl/common/nacl_process_type.h"
......@@ -24,11 +23,6 @@
#include "content/public/browser/render_widget_host_iterator.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/bindings_policy.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/process_map.h"
#include "extensions/browser/view_type_utils.h"
#include "extensions/common/extension.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
......@@ -37,6 +31,15 @@
#include "content/public/browser/zygote_host_linux.h"
#endif
#if defined(ENABLE_EXTENSIONS)
#include "chrome/browser/extensions/extension_service.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/process_map.h"
#include "extensions/browser/view_type_utils.h"
#include "extensions/common/extension.h"
#endif
using base::StringPrintf;
using content::BrowserChildProcessHostIterator;
using content::BrowserThread;
......@@ -44,7 +47,9 @@ using content::NavigationEntry;
using content::RenderViewHost;
using content::RenderWidgetHost;
using content::WebContents;
#if defined(ENABLE_EXTENSIONS)
using extensions::Extension;
#endif
// static
std::string ProcessMemoryInformation::GetRendererTypeNameInEnglish(
......@@ -268,15 +273,6 @@ void MemoryDetails::CollectChildInfoOnUIThread() {
process.pid != base::GetProcId(render_process_host->GetHandle())) {
continue;
}
process.process_type = content::PROCESS_TYPE_RENDERER;
content::BrowserContext* context =
render_process_host->GetBrowserContext();
ExtensionService* extension_service =
extensions::ExtensionSystem::Get(context)->extension_service();
extensions::ProcessMap* extension_process_map = NULL;
// No extensions on Android. So extension_service can be NULL.
if (extension_service)
extension_process_map = extensions::ProcessMap::Get(context);
// The RenderProcessHost may host multiple WebContentses. Any
// of them which contain diagnostics information make the whole
......@@ -284,7 +280,20 @@ void MemoryDetails::CollectChildInfoOnUIThread() {
if (!widget->IsRenderView())
continue;
process.process_type = content::PROCESS_TYPE_RENDERER;
bool is_extension = false;
RenderViewHost* host = RenderViewHost::From(widget);
#if defined(ENABLE_EXTENSIONS)
content::BrowserContext* context =
render_process_host->GetBrowserContext();
ExtensionService* extension_service =
extensions::ExtensionSystem::Get(context)->extension_service();
extensions::ProcessMap* extension_process_map =
extensions::ProcessMap::Get(context);
is_extension = extension_process_map->Contains(
host->GetProcess()->GetID());
#endif
WebContents* contents = WebContents::FromRenderViewHost(host);
GURL url;
if (contents) {
......@@ -293,11 +302,13 @@ void MemoryDetails::CollectChildInfoOnUIThread() {
&chrome_browser->site_data[contents->GetBrowserContext()];
SiteDetails::CollectSiteInfo(contents, site_data);
}
#if defined(ENABLE_EXTENSIONS)
extensions::ViewType type = extensions::GetViewType(contents);
#endif
if (host->GetEnabledBindings() & content::BINDINGS_POLICY_WEB_UI) {
process.renderer_type = ProcessMemoryInformation::RENDERER_CHROME;
} else if (extension_process_map &&
extension_process_map->Contains(host->GetProcess()->GetID())) {
} else if (is_extension) {
#if defined(ENABLE_EXTENSIONS)
// For our purposes, don't count processes containing only hosted apps
// as extension processes. See also: crbug.com/102533.
std::set<std::string> extension_ids =
......@@ -313,9 +324,10 @@ void MemoryDetails::CollectChildInfoOnUIThread() {
break;
}
}
#endif
}
if (extension_process_map &&
extension_process_map->Contains(host->GetProcess()->GetID())) {
#if defined(ENABLE_EXTENSIONS)
if (is_extension) {
const Extension* extension =
extension_service->extensions()->GetByID(url.host());
if (extension) {
......@@ -326,6 +338,7 @@ void MemoryDetails::CollectChildInfoOnUIThread() {
continue;
}
}
#endif
if (!contents) {
process.renderer_type =
......@@ -333,12 +346,14 @@ void MemoryDetails::CollectChildInfoOnUIThread() {
continue;
}
#if defined(ENABLE_EXTENSIONS)
if (type == extensions::VIEW_TYPE_BACKGROUND_CONTENTS) {
process.titles.push_back(base::UTF8ToUTF16(url.spec()));
process.renderer_type =
ProcessMemoryInformation::RENDERER_BACKGROUND_APP;
continue;
}
#endif
// Since we have a WebContents and and the renderer type hasn't been
// set yet, it must be a normal tabbed renderer.
......
......@@ -29,15 +29,11 @@
#include "policy/policy_constants.h"
#if !defined(OS_IOS)
#include "chrome/browser/extensions/api/messaging/native_messaging_policy_handler.h"
#include "chrome/browser/extensions/policy_handlers.h"
#include "chrome/browser/net/disk_cache_dir_policy_handler.h"
#include "chrome/browser/policy/file_selection_dialogs_policy_handler.h"
#include "chrome/browser/policy/javascript_policy_handler.h"
#include "chrome/browser/sessions/restore_on_startup_policy_handler.h"
#include "chrome/browser/sync/sync_policy_handler.h"
#include "extensions/browser/pref_names.h"
#include "extensions/common/manifest.h"
#endif
#if defined(OS_CHROMEOS)
......@@ -56,6 +52,13 @@
#include "apps/pref_names.h"
#endif
#if defined(ENABLE_EXTENSIONS)
#include "chrome/browser/extensions/api/messaging/native_messaging_policy_handler.h"
#include "chrome/browser/extensions/policy_handlers.h"
#include "extensions/browser/pref_names.h"
#include "extensions/common/manifest.h"
#endif
namespace policy {
namespace {
......@@ -487,7 +490,7 @@ const PolicyToPreferenceMapEntry kSimplePolicyMap[] = {
#endif // !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
};
#if !defined(OS_IOS)
#if defined(ENABLE_EXTENSIONS)
void GetExtensionAllowedTypesMap(
ScopedVector<StringMappingListPolicyHandler::MappingEntry>* result) {
// Mapping from extension type names to Manifest::Type.
......@@ -510,7 +513,9 @@ void GetExtensionAllowedTypesMap(
"platform_app", scoped_ptr<base::Value>(new base::FundamentalValue(
extensions::Manifest::TYPE_PLATFORM_APP))));
}
#endif
#if !defined(OS_IOS)
void GetDeprecatedFeaturesMap(
ScopedVector<StringMappingListPolicyHandler::MappingEntry>* result) {
// Maps feature tags as specified in policy to the corresponding switch to
......@@ -571,6 +576,14 @@ scoped_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
new browser_sync::SyncPolicyHandler()));
handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
new StringMappingListPolicyHandler(
key::kEnableDeprecatedWebPlatformFeatures,
prefs::kEnableDeprecatedWebPlatformFeatures,
base::Bind(GetDeprecatedFeaturesMap))));
#endif // !defined(OS_IOS)
#if defined(ENABLE_EXTENSIONS)
handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
new extensions::ExtensionListPolicyHandler(
key::kExtensionInstallWhitelist,
......@@ -592,12 +605,7 @@ scoped_ptr<ConfigurationPolicyHandlerList> BuildHandlerList(
key::kExtensionAllowedTypes,
extensions::pref_names::kAllowedTypes,
base::Bind(GetExtensionAllowedTypesMap))));
handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
new StringMappingListPolicyHandler(
key::kEnableDeprecatedWebPlatformFeatures,
prefs::kEnableDeprecatedWebPlatformFeatures,
base::Bind(GetDeprecatedFeaturesMap))));
#endif // !defined(OS_IOS)
#endif
#if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) && !defined(OS_IOS)
handlers->AddHandler(make_scoped_ptr<ConfigurationPolicyHandler>(
......
......@@ -43,7 +43,6 @@
#include "components/sync_driver/pref_names.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/pref_names.h"
#include "grit/browser_resources.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
......@@ -55,6 +54,10 @@
#include "components/policy/core/common/policy_types.h"
#endif
#if defined(ENABLE_EXTENSIONS)
#include "extensions/browser/pref_names.h"
#endif
#if defined(ENABLE_MANAGED_USERS)
#include "chrome/browser/supervised_user/supervised_user_pref_store.h"
#endif
......@@ -107,11 +110,13 @@ const PrefHashFilter::TrackedPreferenceMetadata kTrackedPrefs[] = {
PrefHashFilter::ENFORCE_ON_LOAD,
PrefHashFilter::TRACKING_STRATEGY_ATOMIC
},
#if defined(ENABLE_EXTENSIONS)
{
5, extensions::pref_names::kExtensions,
PrefHashFilter::NO_ENFORCEMENT,
PrefHashFilter::TRACKING_STRATEGY_SPLIT
},
#endif
{
6, prefs::kGoogleServicesLastUsername,
PrefHashFilter::ENFORCE_ON_LOAD,
......@@ -144,6 +149,7 @@ const PrefHashFilter::TrackedPreferenceMetadata kTrackedPrefs[] = {
PrefHashFilter::TRACKING_STRATEGY_ATOMIC
},
#endif
#if defined(ENABLE_EXTENSIONS)
{
// This pref has been deprecated, leave it here for now for it to be
// properly mapped back to Preferences and cleaned up from there.
......@@ -151,6 +157,7 @@ const PrefHashFilter::TrackedPreferenceMetadata kTrackedPrefs[] = {
PrefHashFilter::NO_ENFORCEMENT,
PrefHashFilter::TRACKING_STRATEGY_ATOMIC
},
#endif
{
13, prefs::kProfileResetPromptMemento,
PrefHashFilter::ENFORCE_ON_LOAD,
......@@ -292,11 +299,13 @@ GetTrackingConfiguration() {
data.enforcement_level = PrefHashFilter::ENFORCE_ON_LOAD;
}
#if defined(ENABLE_EXTENSIONS)
if (enforcement_group >= GROUP_ENFORCE_ALWAYS_WITH_EXTENSIONS_AND_DSE &&
data.name == extensions::pref_names::kExtensions) {
// Specifically enable extension settings enforcement.
data.enforcement_level = PrefHashFilter::ENFORCE_ON_LOAD;
}
#endif
result.push_back(data);
}
......
......@@ -30,15 +30,12 @@
#include "components/dom_distiller/content/web_contents_main_frame_observer.h"
#include "components/password_manager/core/browser/password_manager.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/view_type_utils.h"
#if defined(OS_ANDROID)
#include "chrome/browser/android/webapps/single_tab_mode_tab_helper.h"
#include "chrome/browser/ui/android/context_menu_helper.h"
#include "chrome/browser/ui/android/window_android_helper.h"
#else
#include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h"
#include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
#include "chrome/browser/net/predictor_tab_helper.h"
#include "chrome/browser/plugins/plugin_observer.h"
#include "chrome/browser/safe_browsing/safe_browsing_tab_observer.h"
......@@ -63,7 +60,10 @@
#endif
#if defined(ENABLE_EXTENSIONS)
#include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h"
#include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "extensions/browser/view_type_utils.h"
#endif
#if defined(ENABLE_MANAGED_USERS)
......@@ -104,8 +104,10 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) {
web_contents->SetUserData(&kTabContentsAttachedTabHelpersUserDataKey,
new base::SupportsUserData::Data());
#if defined(ENABLE_EXTENSIONS)
// Set the view type.
extensions::SetViewType(web_contents, extensions::VIEW_TYPE_TAB_CONTENTS);
#endif
// Create all the tab helpers.
......
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