Update to Chromium revision fc6ad471 (#342568)

This commit is contained in:
Marshall Greenblatt
2015-08-14 10:41:08 -04:00
parent a08686e6a6
commit a63d646e3b
61 changed files with 460 additions and 600 deletions

View File

@@ -78,7 +78,7 @@ void StreamsPrivateAPI::ExecuteMimeTypeHandler(
// If the mime handler uses MimeHandlerViewGuest, the MimeHandlerViewGuest
// will take ownership of the stream. Otherwise, store the stream handle in
// |streams_| and fire an event notifying the extension.
if (!handler->handler_url().empty()) {
if (handler->HasPlugin()) {
GURL handler_url(Extension::GetBaseURLFromExtensionId(extension_id).spec() +
handler->handler_url());
scoped_ptr<StreamContainer> stream_container(new StreamContainer(
@@ -108,9 +108,10 @@ void StreamsPrivateAPI::ExecuteMimeTypeHandler(
CreateResponseHeadersDictionary(stream->response_headers.get(),
&info.response_headers.additional_properties);
scoped_ptr<Event> event(new Event(
events::UNKNOWN, streams_private::OnExecuteMimeTypeHandler::kEventName,
streams_private::OnExecuteMimeTypeHandler::Create(info)));
scoped_ptr<Event> event(
new Event(events::STREAMS_PRIVATE_ON_EXECUTE_MIME_TYPE_HANDLER,
streams_private::OnExecuteMimeTypeHandler::kEventName,
streams_private::OnExecuteMimeTypeHandler::Create(info)));
EventRouter::Get(browser_context_)
->DispatchEventToExtension(extension_id, event.Pass());

View File

@@ -23,13 +23,16 @@ EventRouterForwarder::~EventRouterForwarder() {
}
void EventRouterForwarder::BroadcastEventToRenderers(
events::HistogramValue histogram_value,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
const GURL& event_url) {
HandleEvent(std::string(), event_name, event_args.Pass(), 0, true, event_url);
HandleEvent(std::string(), histogram_value, event_name, event_args.Pass(), 0,
true, event_url);
}
void EventRouterForwarder::DispatchEventToRenderers(
events::HistogramValue histogram_value,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
void* profile,
@@ -37,24 +40,23 @@ void EventRouterForwarder::DispatchEventToRenderers(
const GURL& event_url) {
if (!profile)
return;
HandleEvent(std::string(),
event_name,
event_args.Pass(),
profile,
use_profile_to_restrict_events,
event_url);
HandleEvent(std::string(), histogram_value, event_name, event_args.Pass(),
profile, use_profile_to_restrict_events, event_url);
}
void EventRouterForwarder::BroadcastEventToExtension(
const std::string& extension_id,
events::HistogramValue histogram_value,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
const GURL& event_url) {
HandleEvent(extension_id, event_name, event_args.Pass(), 0, true, event_url);
HandleEvent(extension_id, histogram_value, event_name, event_args.Pass(), 0,
true, event_url);
}
void EventRouterForwarder::DispatchEventToExtension(
const std::string& extension_id,
events::HistogramValue histogram_value,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
void* profile,
@@ -62,11 +64,12 @@ void EventRouterForwarder::DispatchEventToExtension(
const GURL& event_url) {
if (!profile)
return;
HandleEvent(extension_id, event_name, event_args.Pass(), profile,
use_profile_to_restrict_events, event_url);
HandleEvent(extension_id, histogram_value, event_name, event_args.Pass(),
profile, use_profile_to_restrict_events, event_url);
}
void EventRouterForwarder::HandleEvent(const std::string& extension_id,
events::HistogramValue histogram_value,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
void* profile_ptr,
@@ -75,8 +78,8 @@ void EventRouterForwarder::HandleEvent(const std::string& extension_id,
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&EventRouterForwarder::HandleEvent, this,
extension_id, event_name, base::Passed(&event_args),
base::Bind(&EventRouterForwarder::HandleEvent, this, extension_id,
histogram_value, event_name, base::Passed(&event_args),
profile_ptr, use_profile_to_restrict_events, event_url));
return;
}
@@ -88,7 +91,8 @@ void EventRouterForwarder::HandleEvent(const std::string& extension_id,
return;
}
if (profile) {
CallEventRouter(profile, extension_id, event_name, event_args.Pass(),
CallEventRouter(profile, extension_id, histogram_value, event_name,
event_args.Pass(),
use_profile_to_restrict_events ? profile : NULL, event_url);
} else {
std::vector<CefBrowserContextImpl*> profiles(
@@ -96,9 +100,10 @@ void EventRouterForwarder::HandleEvent(const std::string& extension_id,
for (size_t i = 0; i < profiles.size(); ++i) {
scoped_ptr<base::ListValue> per_profile_event_args(
event_args->DeepCopy());
CallEventRouter(
profiles[i], extension_id, event_name, per_profile_event_args.Pass(),
use_profile_to_restrict_events ? profiles[i] : NULL, event_url);
CallEventRouter(profiles[i], extension_id, histogram_value, event_name,
per_profile_event_args.Pass(),
use_profile_to_restrict_events ? profiles[i] : NULL,
event_url);
}
}
}
@@ -106,12 +111,13 @@ void EventRouterForwarder::HandleEvent(const std::string& extension_id,
void EventRouterForwarder::CallEventRouter(
content::BrowserContext* profile,
const std::string& extension_id,
events::HistogramValue histogram_value,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
content::BrowserContext* restrict_to_profile,
const GURL& event_url) {
scoped_ptr<Event> event(
new Event(events::UNKNOWN, event_name, event_args.Pass()));
new Event(histogram_value, event_name, event_args.Pass()));
event->restrict_to_browser_context = restrict_to_profile;
event->event_url = event_url;
if (extension_id.empty()) {

View File

@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/values.h"
#include "extensions/browser/extension_event_histogram_value.h"
class GURL;
@@ -37,7 +38,8 @@ class EventRouterForwarder
// DispatchEventToRenderers(event_name, event_args, profile, event_url)
// on all (original) profiles' EventRouters.
// May be called on any thread.
void BroadcastEventToRenderers(const std::string& event_name,
void BroadcastEventToRenderers(events::HistogramValue histogram_value,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
const GURL& event_url);
@@ -47,6 +49,7 @@ class EventRouterForwarder
// on all (original) profiles' EventRouters.
// May be called on any thread.
void BroadcastEventToExtension(const std::string& extension_id,
events::HistogramValue histogram_value,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
const GURL& event_url);
@@ -55,7 +58,8 @@ class EventRouterForwarder
// DispatchEventToRenderers(event_name, event_args,
// use_profile_to_restrict_events ? profile : NULL, event_url)
// on |profile|'s EventRouter. May be called on any thread.
void DispatchEventToRenderers(const std::string& event_name,
void DispatchEventToRenderers(events::HistogramValue histogram_value,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
void* profile,
bool use_profile_to_restrict_events,
@@ -66,6 +70,7 @@ class EventRouterForwarder
// use_profile_to_restrict_events ? profile : NULL, event_url)
// on |profile|'s EventRouter. May be called on any thread.
void DispatchEventToExtension(const std::string& extension_id,
events::HistogramValue histogram_value,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
void* profile,
@@ -79,6 +84,7 @@ class EventRouterForwarder
// Helper function for {Broadcast,Dispatch}EventTo{Extension,Renderers}.
// Virtual for testing.
virtual void HandleEvent(const std::string& extension_id,
events::HistogramValue histogram_value,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
void* profile,
@@ -91,6 +97,7 @@ class EventRouterForwarder
// Virtual for testing.
virtual void CallEventRouter(content::BrowserContext* profile,
const std::string& extension_id,
events::HistogramValue histogram_value,
const std::string& event_name,
scoped_ptr<base::ListValue> event_args,
content::BrowserContext* restrict_to_profile,

View File

@@ -32,6 +32,7 @@
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/info_map.h"
#include "extensions/browser/notification_types.h"
#include "extensions/browser/null_app_sorting.h"
#include "extensions/browser/quota_service.h"
#include "extensions/browser/runtime_data.h"
#include "extensions/common/constants.h"
@@ -77,7 +78,8 @@ base::DictionaryValue* ParseManifest(
CefExtensionSystem::CefExtensionSystem(BrowserContext* browser_context)
: browser_context_(browser_context),
registry_(ExtensionRegistry::Get(browser_context)) {
registry_(ExtensionRegistry::Get(browser_context)),
weak_ptr_factory_(this) {
}
CefExtensionSystem::~CefExtensionSystem() {
@@ -128,6 +130,9 @@ void CefExtensionSystem::Init() {
// kPDFPluginOutOfProcessMimeType which loads the PDF PPAPI plugin.
// 10.Routing of print-related commands are handled by ChromePDFPrintClient
// and CefPrintWebViewHelperDelegate in the renderer process.
// 11.The PDF extension is granted access to chrome://resources via
// CefExtensionsDispatcherDelegate::InitOriginPermissions in the renderer
// process.
if (PdfExtensionEnabled()) {
AddExtension(pdf_extension_util::GetManifest(),
base::FilePath(FILE_PATH_LITERAL("pdf")));
@@ -166,6 +171,7 @@ void CefExtensionSystem::Shutdown() {
void CefExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
runtime_data_.reset(new RuntimeData(registry_));
quota_service_.reset(new QuotaService);
app_sorting_.reset(new NullAppSorting);
}
ExtensionService* CefExtensionSystem::extension_service() {
@@ -202,13 +208,18 @@ QuotaService* CefExtensionSystem::quota_service() {
return quota_service_.get();
}
AppSorting* CefExtensionSystem::app_sorting() {
return app_sorting_.get();
}
// Implementation based on
// ExtensionSystemImpl::RegisterExtensionWithRequestContexts.
void CefExtensionSystem::RegisterExtensionWithRequestContexts(
const Extension* extension) {
const Extension* extension,
const base::Closure& callback) {
// TODO(extensions): The |incognito_enabled| value should be set based on
// manifest settings.
BrowserThread::PostTask(
BrowserThread::PostTaskAndReply(
BrowserThread::IO,
FROM_HERE,
base::Bind(&InfoMap::AddExtension,
@@ -216,7 +227,8 @@ void CefExtensionSystem::RegisterExtensionWithRequestContexts(
make_scoped_refptr(extension),
base::Time::Now(),
true, // incognito_enabled
false)); // notifications_disabled
false), // notifications_disabled
callback);
}
// Implementation based on
@@ -336,7 +348,11 @@ void CefExtensionSystem::NotifyExtensionLoaded(const Extension* extension) {
// that the request context doesn't yet know about. The profile is responsible
// for ensuring its URLRequestContexts appropriately discover the loaded
// extension.
RegisterExtensionWithRequestContexts(extension);
RegisterExtensionWithRequestContexts(
extension,
base::Bind(&CefExtensionSystem::OnExtensionRegisteredWithRequestContexts,
weak_ptr_factory_.GetWeakPtr(),
make_scoped_refptr(extension)));
// Tell renderers about the new extension, unless it's a theme (renderers
// don't need to know about themes).
@@ -400,6 +416,13 @@ void CefExtensionSystem::NotifyExtensionLoaded(const Extension* extension) {
content::Details<const Extension>(extension));
}
void CefExtensionSystem::OnExtensionRegisteredWithRequestContexts(
scoped_refptr<const extensions::Extension> extension) {
registry_->AddReady(extension);
if (registry_->enabled_extensions().Contains(extension->id()))
registry_->TriggerOnReady(extension.get());
}
// Implementation based on ExtensionService::NotifyExtensionUnloaded.
void CefExtensionSystem::NotifyExtensionUnloaded(
const Extension* extension,

View File

@@ -9,6 +9,7 @@
#include <vector>
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/one_shot_event.h"
@@ -60,8 +61,10 @@ class CefExtensionSystem : public ExtensionSystem {
StateStore* rules_store() override;
InfoMap* info_map() override;
QuotaService* quota_service() override;
AppSorting* app_sorting() override;
void RegisterExtensionWithRequestContexts(
const Extension* extension) override;
const Extension* extension,
const base::Closure& callback) override;
void UnregisterExtensionWithRequestContexts(
const std::string& extension_id,
const UnloadedExtensionInfo::Reason reason) override;
@@ -105,6 +108,11 @@ class CefExtensionSystem : public ExtensionSystem {
const Extension* extension,
UnloadedExtensionInfo::Reason reason);
// Completes extension loading after URLRequestContexts have been updated
// on the IO thread.
void OnExtensionRegisteredWithRequestContexts(
scoped_refptr<const extensions::Extension> extension);
content::BrowserContext* browser_context_; // Not owned.
// Data to be accessed on the IO thread. Must outlive process_manager_.
@@ -112,6 +120,7 @@ class CefExtensionSystem : public ExtensionSystem {
scoped_ptr<RuntimeData> runtime_data_;
scoped_ptr<QuotaService> quota_service_;
scoped_ptr<AppSorting> app_sorting_;
// Signaled when the extension system has completed its startup tasks.
OneShotEvent ready_;
@@ -119,6 +128,9 @@ class CefExtensionSystem : public ExtensionSystem {
// Sets of enabled/disabled/terminated/blacklisted extensions. Not owned.
ExtensionRegistry* registry_;
// Must be the last member.
base::WeakPtrFactory<CefExtensionSystem> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(CefExtensionSystem);
};

View File

@@ -24,7 +24,6 @@
#include "extensions/browser/extension_function_registry.h"
#include "extensions/browser/extension_host_delegate.h"
#include "extensions/browser/mojo/service_registration.h"
#include "extensions/browser/null_app_sorting.h"
#include "extensions/browser/url_request_util.h"
using content::BrowserContext;
@@ -154,10 +153,6 @@ bool CefExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) {
void CefExtensionsBrowserClient::PermitExternalProtocolHandler() {
}
scoped_ptr<AppSorting> CefExtensionsBrowserClient::CreateAppSorting() {
return scoped_ptr<AppSorting>(new NullAppSorting);
}
bool CefExtensionsBrowserClient::IsRunningInForcedAppMode() {
return false;
}
@@ -176,10 +171,10 @@ CefExtensionsBrowserClient::GetExtensionSystemFactory() {
void CefExtensionsBrowserClient::RegisterExtensionFunctions(
ExtensionFunctionRegistry* registry) const {
// Register core extension-system APIs.
core_api::GeneratedFunctionRegistry::RegisterAll(registry);
api::GeneratedFunctionRegistry::RegisterAll(registry);
// CEF-only APIs.
api::GeneratedFunctionRegistry::RegisterAll(registry);
api::ChromeGeneratedFunctionRegistry::RegisterAll(registry);
}
void CefExtensionsBrowserClient::RegisterMojoServices(
@@ -202,10 +197,11 @@ CefExtensionsBrowserClient::GetComponentExtensionResourceManager() {
}
void CefExtensionsBrowserClient::BroadcastEventToRenderers(
events::HistogramValue histogram_value,
const std::string& event_name,
scoped_ptr<base::ListValue> args) {
event_router_forwarder_->BroadcastEventToRenderers(
event_name, args.Pass(), GURL());
histogram_value, event_name, args.Pass(), GURL());
}
net::NetLog* CefExtensionsBrowserClient::GetNetLog() {

View File

@@ -62,7 +62,6 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
CreateExtensionHostDelegate() override;
bool DidVersionUpdate(content::BrowserContext* context) override;
void PermitExternalProtocolHandler() override;
scoped_ptr<AppSorting> CreateAppSorting() override;
bool IsRunningInForcedAppMode() override;
ApiActivityMonitor* GetApiActivityMonitor(
content::BrowserContext* context) override;
@@ -75,7 +74,8 @@ class CefExtensionsBrowserClient : public ExtensionsBrowserClient {
content::BrowserContext* context) const override;
const ComponentExtensionResourceManager*
GetComponentExtensionResourceManager() override;
void BroadcastEventToRenderers(const std::string& event_name,
void BroadcastEventToRenderers(events::HistogramValue histogram_value,
const std::string& event_name,
scoped_ptr<base::ListValue> args) override;
net::NetLog* GetNetLog() override;
ExtensionCache* GetExtensionCache() override;