Commit c7e3b469 authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

Delete unused ExtensionProtocolHandler since network service is launched

Network service is on by default on all platforms that support
extensions, so ExtensionProtocolHandler is no longer needed since it is
only used in the non-network service path.

Bug: 934009
Change-Id: Id9021b5319677cd98a35343fdfa40761f989b678
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1655987Reviewed-by: default avatarKaran Bhatia <karandeepb@chromium.org>
Reviewed-by: default avatarYuchen Liu <yucliu@chromium.org>
Reviewed-by: default avatarJunbo Ke <juke@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#668969}
parent 929746b6
......@@ -291,8 +291,6 @@ cast_source_set("browser") {
"cast_extension_url_loader_factory.h",
"extension_page.cc",
"extension_page.h",
"extension_request_protocol_handler.cc",
"extension_request_protocol_handler.h",
"extensions/api/accessibility_private/accessibility_extension_api.cc",
"extensions/api/accessibility_private/accessibility_extension_api.h",
"extensions/api/automation_internal/chromecast_automation_internal_api_delegate.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMECAST_BROWSER_EXTENION_REQUEST_PROTOCOL_HANDLER_H_
#define CHROMECAST_BROWSER_EXTENION_REQUEST_PROTOCOL_HANDLER_H_
#include "net/url_request/url_request_job_factory.h"
namespace content {
class BrowserContext;
} // namespace content
namespace extensions {
class InfoMap;
}
namespace chromecast {
class ExtensionRequestProtocolHandler
: public net::URLRequestJobFactory::ProtocolHandler {
public:
explicit ExtensionRequestProtocolHandler(
content::BrowserContext* browser_context);
~ExtensionRequestProtocolHandler() override;
net::URLRequestJob* MaybeCreateJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate) const override;
private:
content::BrowserContext* const browser_context_;
mutable const extensions::InfoMap* info_map_ = nullptr;
mutable std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>
default_handler_;
};
} // namespace chromecast
#endif // CHROMECAST_BROWSER_EXTENION_REQUEST_PROTOCOL_HANDLER_H_
......@@ -48,13 +48,6 @@
#include "net/url_request/url_request_job_factory_impl.h"
#include "services/network/public/cpp/features.h"
#if BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS)
#include "chromecast/browser/extension_request_protocol_handler.h"
#include "extensions/browser/extension_protocols.h" // nogncheck
#include "extensions/browser/extension_system.h" // nogncheck
#include "extensions/common/constants.h" // nogncheck
#endif
namespace chromecast {
namespace shell {
......@@ -199,10 +192,6 @@ net::URLRequestContextGetter* URLRequestContextFactory::CreateMainGetter(
content::URLRequestInterceptorScopedVector request_interceptors) {
DCHECK(!main_getter_.get())
<< "Main URLRequestContextGetter already initialized";
#if BUILDFLAG(ENABLE_CHROMECAST_EXTENSIONS)
(*protocol_handlers)[extensions::kExtensionScheme] =
std::make_unique<ExtensionRequestProtocolHandler>(browser_context);
#endif
main_getter_ =
new MainURLRequestContextGetter(this, browser_context, protocol_handlers,
std::move(request_interceptors));
......
This diff is collapsed.
......@@ -10,7 +10,6 @@
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "net/url_request/url_request_job_factory.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
namespace base {
......@@ -27,7 +26,6 @@ class HttpResponseHeaders;
}
namespace extensions {
class InfoMap;
using ExtensionProtocolTestHandler =
base::Callback<void(base::FilePath* directory_path,
......@@ -40,12 +38,6 @@ scoped_refptr<net::HttpResponseHeaders> BuildHttpHeaders(
bool send_cors_header,
const base::Time& last_modified_time);
// Creates the handlers for the chrome-extension:// scheme. Pass true for
// |is_incognito| only for incognito profiles and not for Chrome OS guest mode
// profiles.
std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>
CreateExtensionProtocolHandler(bool is_incognito, InfoMap* extension_info_map);
// Allows tests to set a special handler for chrome-extension:// urls. Note
// that this goes through all the normal security checks; it's essentially a
// way to map extra resources to be included in extensions.
......
......@@ -24,24 +24,13 @@
namespace extensions {
namespace {
bool IgnoreCertificateErrors() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
::switches::kIgnoreCertificateErrors);
}
} // namespace
// Create a normal recording browser context. If we used an incognito context
// then app_shell would also have to create a normal context and manage both.
ShellBrowserContext::ShellBrowserContext(
ShellBrowserMainParts* browser_main_parts)
ShellBrowserContext::ShellBrowserContext()
: content::ShellBrowserContext(false /* off_the_record */,
nullptr /* net_log */,
true /* delay_services_creation */),
storage_policy_(new ShellSpecialStoragePolicy),
browser_main_parts_(browser_main_parts) {}
storage_policy_(new ShellSpecialStoragePolicy) {}
ShellBrowserContext::~ShellBrowserContext() {
content::BrowserContext::NotifyWillBeDestroyed(this);
......@@ -55,29 +44,6 @@ storage::SpecialStoragePolicy* ShellBrowserContext::GetSpecialStoragePolicy() {
return storage_policy_.get();
}
net::URLRequestContextGetter* ShellBrowserContext::CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) {
DCHECK(!url_request_context_getter());
// Handle only chrome-extension:// requests.
InfoMap* extension_info_map =
browser_main_parts_->extension_system()->info_map();
(*protocol_handlers)[kExtensionScheme] = CreateExtensionProtocolHandler(
false /* is_incognito */, extension_info_map);
set_url_request_context_getter(new ShellURLRequestContextGetter(
this, IgnoreCertificateErrors(), GetPath(),
base::CreateSingleThreadTaskRunnerWithTraits(
{content::BrowserThread::IO}),
protocol_handlers, std::move(request_interceptors), nullptr /* net_log */,
extension_info_map));
base::PostTaskWithTraits(
FROM_HERE, {content::BrowserThread::IO},
base::BindOnce(&ShellBrowserContext::InitURLRequestContextOnIOThread,
base::Unretained(this)));
return url_request_context_getter();
}
void ShellBrowserContext::SetCorsOriginAccessListForOrigin(
const url::Origin& source_origin,
std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns,
......@@ -88,12 +54,4 @@ void ShellBrowserContext::SetCorsOriginAccessListForOrigin(
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, std::move(closure));
}
void ShellBrowserContext::InitURLRequestContextOnIOThread() {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
// GetURLRequestContext() will create a URLRequestContext if it isn't
// initialized.
url_request_context_getter()->GetURLRequestContext();
}
} // namespace extensions
......@@ -12,21 +12,16 @@
namespace extensions {
class ShellBrowserMainParts;
// The BrowserContext used by the content, apps and extensions systems in
// app_shell.
class ShellBrowserContext final : public content::ShellBrowserContext {
public:
explicit ShellBrowserContext(ShellBrowserMainParts* browser_main_parts);
explicit ShellBrowserContext();
~ShellBrowserContext() override;
// content::BrowserContext implementation.
content::BrowserPluginGuestManager* GetGuestManager() override;
storage::SpecialStoragePolicy* GetSpecialStoragePolicy() override;
net::URLRequestContextGetter* CreateRequestContext(
content::ProtocolHandlerMap* protocol_handlers,
content::URLRequestInterceptorScopedVector request_interceptors) override;
void SetCorsOriginAccessListForOrigin(
const url::Origin& source_origin,
std::vector<network::mojom::CorsOriginPatternPtr> allow_patterns,
......@@ -34,10 +29,7 @@ class ShellBrowserContext final : public content::ShellBrowserContext {
base::OnceClosure closure) override;
private:
void InitURLRequestContextOnIOThread();
scoped_refptr<storage::SpecialStoragePolicy> storage_policy_;
ShellBrowserMainParts* browser_main_parts_;
DISALLOW_COPY_AND_ASSIGN(ShellBrowserContext);
};
......
......@@ -184,7 +184,7 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
shell::EnsureBrowserContextKeyedServiceFactoriesBuilt();
// Initialize our "profile" equivalent.
browser_context_ = std::make_unique<ShellBrowserContext>(this);
browser_context_ = std::make_unique<ShellBrowserContext>();
// app_shell only supports a single user, so all preferences live in the user
// data directory, including the device-wide local state.
......
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