#include "base/logging.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/component_updater/component_updater_service.h"
+#include "chrome/browser/component_updater/component_updater_resource_throttle.h"
#include "chrome/browser/component_updater/pnacl/pnacl_component_installer.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/download/download_request_limiter.h"
#include "chrome/browser/download/download_resource_throttle.h"
-#include "chrome/browser/extensions/api/streams_private/streams_private_api.h"
-#include "chrome/browser/extensions/extension_renderer_state.h"
-#include "chrome/browser/extensions/user_script_listener.h"
-#include "chrome/browser/metrics/variations/variations_http_header_provider.h"
#include "chrome/browser/prefetch/prefetch.h"
#include "chrome/browser/prerender/prerender_manager.h"
#include "chrome/browser/prerender/prerender_manager_factory.h"
#include "chrome/browser/ui/login/login_prompt.h"
#include "chrome/browser/ui/sync/one_click_signin_helper.h"
#include "chrome/common/extensions/extension_constants.h"
-#include "chrome/common/extensions/manifest_handlers/mime_types_handler.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/url_constants.h"
#include "components/google/core/browser/google_util.h"
+#include "components/variations/variations_http_header_provider.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/stream_handle.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/resource_response.h"
-#include "extensions/browser/info_map.h"
-#include "extensions/common/constants.h"
-#include "extensions/common/user_script.h"
#include "net/base/load_flags.h"
#include "net/base/load_timing_info.h"
#include "net/base/request_priority.h"
#include "components/policy/core/common/cloud/policy_header_io_helper.h"
#endif
+#if defined(ENABLE_EXTENSIONS)
+#include "chrome/browser/apps/app_url_redirector.h"
+#include "chrome/browser/apps/ephemeral_app_throttle.h"
+#include "chrome/browser/extensions/api/streams_private/streams_private_api.h"
+#include "chrome/browser/extensions/user_script_listener.h"
+#include "chrome/browser/guest_view/web_view/web_view_renderer_state.h"
+#include "chrome/common/extensions/manifest_handlers/mime_types_handler.h"
+#include "extensions/browser/info_map.h"
+#include "extensions/common/constants.h"
+#include "extensions/common/user_script.h"
+#endif
+
#if defined(ENABLE_MANAGED_USERS)
#include "chrome/browser/supervised_user/supervised_user_resource_throttle.h"
#endif
#include "chrome/browser/android/intercept_download_resource_throttle.h"
#include "chrome/browser/ui/android/infobars/auto_login_prompter.h"
#include "components/navigation_interception/intercept_navigation_delegate.h"
-#else
-#include "chrome/browser/apps/app_url_redirector.h"
-#include "chrome/browser/apps/ephemeral_app_throttle.h"
#endif
#if defined(OS_CHROMEOS)
using content::RenderViewHost;
using content::ResourceDispatcherHostLoginDelegate;
using content::ResourceRequestInfo;
+using content::ResourceType;
+
+#if defined(ENABLE_EXTENSIONS)
using extensions::Extension;
using extensions::StreamsPrivateAPI;
+#endif
#if defined(OS_ANDROID)
using navigation_interception::InterceptNavigationDelegate;
prerender_manager->AddProfileNetworkBytesIfEnabled(bytes);
}
-#if !defined(OS_ANDROID)
+#if defined(ENABLE_EXTENSIONS)
void SendExecuteMimeTypeHandlerEvent(scoped_ptr<content::StreamHandle> stream,
int64 expected_content_size,
int render_process_id,
extension_id, web_contents, stream.Pass(), view_id,
expected_content_size);
}
+#endif // !defined(ENABLE_EXTENSIONS)
+#if !defined(OS_ANDROID)
void LaunchURL(const GURL& url, int render_process_id, int render_view_id) {
// If there is no longer a WebContents, the request may have raced with tab
// closing. Don't fire the external request. (It may have been a prerender.)
void AppendComponentUpdaterThrottles(
net::URLRequest* request,
content::ResourceContext* resource_context,
- ResourceType::Type resource_type,
+ ResourceType resource_type,
ScopedVector<content::ResourceThrottle>* throttles) {
const char* crx_id = NULL;
component_updater::ComponentUpdateService* cus =
if (!cus)
return;
// Check for PNaCl pexe request.
- if (resource_type == ResourceType::OBJECT) {
+ if (resource_type == content::RESOURCE_TYPE_OBJECT) {
const net::HttpRequestHeaders& headers = request->extra_request_headers();
std::string accept_headers;
if (headers.GetHeader("Accept", &accept_headers)) {
// We got a component we need to install, so throttle the resource
// until the component is installed.
throttles->push_back(
- cus->GetOnDemandUpdater().GetOnDemandResourceThrottle(request, crx_id));
+ component_updater::GetOnDemandResourceThrottle(cus, crx_id));
}
}
prerender::PrerenderTracker* prerender_tracker)
: download_request_limiter_(g_browser_process->download_request_limiter()),
safe_browsing_(g_browser_process->safe_browsing_service()),
+#if defined(ENABLE_EXTENSIONS)
user_script_listener_(new extensions::UserScriptListener()),
+#endif
prerender_tracker_(prerender_tracker) {
}
ChromeResourceDispatcherHostDelegate::~ChromeResourceDispatcherHostDelegate() {
+#if defined(ENABLE_EXTENSIONS)
CHECK(stream_target_info_.empty());
+#endif
}
bool ChromeResourceDispatcherHostDelegate::ShouldBeginRequest(
int route_id,
const std::string& method,
const GURL& url,
- ResourceType::Type resource_type,
+ ResourceType resource_type,
content::ResourceContext* resource_context) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
// Handle a PREFETCH resource type. If prefetch is disabled, squelch the
// request. Otherwise, do a normal request to warm the cache.
- if (resource_type == ResourceType::PREFETCH) {
+ if (resource_type == content::RESOURCE_TYPE_PREFETCH) {
// All PREFETCH requests should be GETs, but be defensive about it.
if (method != "GET")
return false;
void ChromeResourceDispatcherHostDelegate::RequestBeginning(
net::URLRequest* request,
content::ResourceContext* resource_context,
- appcache::AppCacheService* appcache_service,
- ResourceType::Type resource_type,
+ content::AppCacheService* appcache_service,
+ ResourceType resource_type,
int child_id,
int route_id,
ScopedVector<content::ResourceThrottle>* throttles) {
#if defined(OS_ANDROID)
// TODO(davidben): This is insufficient to integrate with prerender properly.
// https://crbug.com/370595
- if (resource_type == ResourceType::MAIN_FRAME && !is_prerendering) {
+ if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME && !is_prerendering) {
throttles->push_back(
InterceptNavigationDelegate::CreateThrottleFor(request));
}
#else
- if (resource_type == ResourceType::MAIN_FRAME) {
+ if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME) {
// Redirect some navigations to apps that have registered matching URL
// handlers ('url_handlers' in the manifest).
content::ResourceThrottle* url_to_app_throttle =
#if defined(OS_CHROMEOS)
// Check if we need to add offline throttle. This should be done only
// for main frames.
- if (resource_type == ResourceType::MAIN_FRAME) {
+ if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME) {
// We check offline first, then check safe browsing so that we still can
// block unsafe site after we remove offline page.
throttles->push_back(new OfflineResourceThrottle(request,
// Check if we need to add merge session throttle. This throttle will postpone
// loading of main frames and XHR request.
- if (resource_type == ResourceType::MAIN_FRAME ||
- resource_type == ResourceType::XHR) {
+ if (resource_type == content::RESOURCE_TYPE_MAIN_FRAME ||
+ resource_type == content::RESOURCE_TYPE_XHR) {
// Add interstitial page while merge session process (cookie
// reconstruction from OAuth2 refresh token in ChromeOS login) is still in
// progress while we are attempting to load a google property.
net::HttpRequestHeaders headers;
headers.CopyFrom(request->extra_request_headers());
bool is_off_the_record = io_data->IsOffTheRecord();
- chrome_variations::VariationsHttpHeaderProvider::GetInstance()->
+ variations::VariationsHttpHeaderProvider::GetInstance()->
AppendHeaders(request->url(),
is_off_the_record,
!is_off_the_record &&
if (!request->is_pending()) {
AppendStandardResourceThrottles(request,
resource_context,
- ResourceType::MAIN_FRAME,
+ content::RESOURCE_TYPE_MAIN_FRAME,
throttles);
}
}
return false;
#else
- ExtensionRendererState::WebViewInfo info;
- if (ExtensionRendererState::GetInstance()->GetWebViewInfo(child_id,
- route_id,
- &info)) {
+#if defined(ENABLE_EXTENSIONS)
+ if (extensions::WebViewRendererState::GetInstance()->IsGuest(child_id))
return false;
- }
+
+#endif // defined(ENABLE_EXTENSIONS)
BrowserThread::PostTask(BrowserThread::UI,
FROM_HERE,
void ChromeResourceDispatcherHostDelegate::AppendStandardResourceThrottles(
net::URLRequest* request,
content::ResourceContext* resource_context,
- ResourceType::Type resource_type,
+ ResourceType resource_type,
ScopedVector<content::ResourceThrottle>* throttles) {
ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
#if defined(FULL_SAFE_BROWSING) || defined(MOBILE_SAFE_BROWSING)
// policies first.
if (io_data->safe_browsing_enabled()->GetValue()
#if defined(OS_ANDROID)
- || io_data->data_reduction_proxy_enabled()->GetValue()
+ || io_data->IsDataReductionProxyEnabled()
#endif
) {
- bool is_subresource_request = resource_type != ResourceType::MAIN_FRAME;
+ bool is_subresource_request =
+ resource_type != content::RESOURCE_TYPE_MAIN_FRAME;
content::ResourceThrottle* throttle =
SafeBrowsingResourceThrottleFactory::Create(request,
resource_context,
#endif
#if defined(ENABLE_MANAGED_USERS)
- bool is_subresource_request = resource_type != ResourceType::MAIN_FRAME;
+ bool is_subresource_request =
+ resource_type != content::RESOURCE_TYPE_MAIN_FRAME;
throttles->push_back(new SupervisedUserResourceThrottle(
request, !is_subresource_request,
io_data->supervised_user_url_filter()));
#endif
+#if defined(ENABLE_EXTENSIONS)
content::ResourceThrottle* throttle =
user_script_listener_->CreateResourceThrottle(request->url(),
resource_type);
if (throttle)
throttles->push_back(throttle);
+#endif
const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
if (info->GetVisibilityState() == blink::WebPageVisibilityStatePrerender) {
bool ChromeResourceDispatcherHostDelegate::ShouldForceDownloadResource(
const GURL& url, const std::string& mime_type) {
+#if defined(ENABLE_EXTENSIONS)
// Special-case user scripts to get downloaded instead of viewed.
return extensions::UserScript::IsURLUserScript(url, mime_type);
+#else
+ return false;
+#endif
}
bool ChromeResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream(
const std::string& mime_type,
GURL* origin,
std::string* payload) {
-#if !defined(OS_ANDROID)
+#if defined(ENABLE_EXTENSIONS)
const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
ProfileIOData* io_data =
ProfileIOData::FromResourceContext(info->GetContext());
void ChromeResourceDispatcherHostDelegate::OnStreamCreated(
net::URLRequest* request,
scoped_ptr<content::StreamHandle> stream) {
-#if !defined(OS_ANDROID)
+#if defined(ENABLE_EXTENSIONS)
const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
std::map<net::URLRequest*, StreamTargetInfo>::iterator ix =
stream_target_info_.find(request);