mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update to Chromium revision fc6ad471 (#342568)
This commit is contained in:
@@ -66,7 +66,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
#include "chrome/browser/spellchecker/spellcheck_platform_mac.h"
|
||||
#include "chrome/browser/spellchecker/spellcheck_platform.h"
|
||||
#endif
|
||||
|
||||
#if defined(USE_AURA)
|
||||
@@ -1080,7 +1080,7 @@ void CefBrowserHostImpl::AddWordToDictionary(const CefString& word) {
|
||||
spellcheck->GetCustomDictionary()->AddWord(word);
|
||||
}
|
||||
#if defined(OS_MACOSX)
|
||||
spellcheck_mac::AddWord(word);
|
||||
spellcheck_platform::AddWord(word);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2796,6 +2796,11 @@ void CefBrowserHostImpl::FrameDeleted(
|
||||
focused_frame_id_ = CefFrameHostImpl::kInvalidFrameId;
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::TitleWasSet(content::NavigationEntry* entry,
|
||||
bool explicit_set) {
|
||||
OnTitleChange(entry->GetTitle());
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::PluginCrashed(const base::FilePath& plugin_path,
|
||||
base::ProcessId plugin_pid) {
|
||||
if (client_.get()) {
|
||||
@@ -2960,28 +2965,12 @@ void CefBrowserHostImpl::Observe(int type,
|
||||
const content::NotificationSource& source,
|
||||
const content::NotificationDetails& details) {
|
||||
DCHECK(type == content::NOTIFICATION_LOAD_STOP ||
|
||||
type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE ||
|
||||
type == content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED);
|
||||
type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE);
|
||||
|
||||
if (type == content::NOTIFICATION_LOAD_STOP ||
|
||||
type == content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED) {
|
||||
base::string16 title;
|
||||
|
||||
if (type == content::NOTIFICATION_LOAD_STOP) {
|
||||
content::NavigationController* controller =
|
||||
content::Source<content::NavigationController>(source).ptr();
|
||||
title = controller->GetWebContents()->GetTitle();
|
||||
} else {
|
||||
content::WebContents* web_contents =
|
||||
content::Source<content::WebContents>(source).ptr();
|
||||
title = web_contents->GetTitle();
|
||||
}
|
||||
|
||||
if (client_.get()) {
|
||||
CefRefPtr<CefDisplayHandler> handler = client_->GetDisplayHandler();
|
||||
if (handler.get())
|
||||
handler->OnTitleChange(this, title);
|
||||
}
|
||||
if (type == content::NOTIFICATION_LOAD_STOP) {
|
||||
content::NavigationController* controller =
|
||||
content::Source<content::NavigationController>(source).ptr();
|
||||
OnTitleChange(controller->GetWebContents()->GetTitle());
|
||||
} else if (type == content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE) {
|
||||
focus_on_editable_field_ = *content::Details<bool>(details).ptr();
|
||||
}
|
||||
@@ -3040,8 +3029,6 @@ CefBrowserHostImpl::CefBrowserHostImpl(
|
||||
g_manager.Get().AddImpl(this);
|
||||
|
||||
registrar_.reset(new content::NotificationRegistrar);
|
||||
registrar_->Add(this, content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED,
|
||||
content::Source<content::WebContents>(web_contents));
|
||||
|
||||
// When navigating through the history, the restored NavigationEntry's title
|
||||
// will be used. If the entry ends up having the same title after we return
|
||||
@@ -3230,6 +3217,14 @@ void CefBrowserHostImpl::OnFullscreenModeChange(bool fullscreen) {
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::OnTitleChange(const base::string16& title) {
|
||||
if (client_.get()) {
|
||||
CefRefPtr<CefDisplayHandler> handler = client_->GetDisplayHandler();
|
||||
if (handler.get())
|
||||
handler->OnTitleChange(this, title);
|
||||
}
|
||||
}
|
||||
|
||||
void CefBrowserHostImpl::RunFileChooserOnUIThread(
|
||||
const FileChooserParams& params,
|
||||
const RunFileChooserCallback& callback) {
|
||||
|
@@ -471,6 +471,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
bool was_ignored_by_handler) override;
|
||||
void FrameDeleted(
|
||||
content::RenderFrameHost* render_frame_host) override;
|
||||
void TitleWasSet(content::NavigationEntry* entry, bool explicit_set) override;
|
||||
void PluginCrashed(const base::FilePath& plugin_path,
|
||||
base::ProcessId plugin_pid) override;
|
||||
void DidUpdateFaviconURL(
|
||||
@@ -596,6 +597,7 @@ class CefBrowserHostImpl : public CefBrowserHost,
|
||||
const GURL& url,
|
||||
int http_status_code);
|
||||
void OnFullscreenModeChange(bool fullscreen);
|
||||
void OnTitleChange(const base::string16& title);
|
||||
|
||||
// Continuation from RunFileChooser.
|
||||
void RunFileChooserOnUIThread(const FileChooserParams& params,
|
||||
|
@@ -278,3 +278,9 @@ memory::OomPriorityManager* ChromeBrowserProcessStub::GetOomPriorityManager() {
|
||||
NOTIMPLEMENTED();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ShellIntegration::DefaultWebClientState
|
||||
ChromeBrowserProcessStub::CachedDefaultWebClientState() {
|
||||
NOTIMPLEMENTED();
|
||||
return ShellIntegration::UNKNOWN_DEFAULT;
|
||||
}
|
||||
|
@@ -97,6 +97,8 @@ class ChromeBrowserProcessStub : public BrowserProcess {
|
||||
network_time::NetworkTimeTracker* network_time_tracker() override;
|
||||
gcm::GCMDriver* gcm_driver() override;
|
||||
memory::OomPriorityManager* GetOomPriorityManager() override;
|
||||
ShellIntegration::DefaultWebClientState
|
||||
CachedDefaultWebClientState() override;
|
||||
|
||||
private:
|
||||
std::string locale_;
|
||||
|
@@ -209,7 +209,8 @@ const ResourcesMap* CreateResourcesMap() {
|
||||
const int resource_id = kWebuiResources[i].value;
|
||||
AddResource(resource_name, resource_id, result);
|
||||
for (const char* (&alias)[2]: kPathAliases) {
|
||||
if (base::StartsWithASCII(resource_name, alias[0], true)) {
|
||||
if (base::StartsWith(resource_name, alias[0],
|
||||
base::CompareCase::SENSITIVE)) {
|
||||
AddResource(alias[1] + resource_name.substr(strlen(alias[0])),
|
||||
resource_id, result);
|
||||
}
|
||||
|
@@ -63,7 +63,7 @@
|
||||
#include "url/gurl.h"
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
#include "chrome/browser/spellchecker/spellcheck_message_filter_mac.h"
|
||||
#include "chrome/browser/spellchecker/spellcheck_message_filter_platform.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
||||
@@ -568,7 +568,7 @@ void CefContentBrowserClient::RenderProcessWillLaunch(
|
||||
if (!command_line->HasSwitch(switches::kDisableSpellChecking)) {
|
||||
host->AddFilter(new SpellCheckMessageFilter(id));
|
||||
#if defined(OS_MACOSX)
|
||||
host->AddFilter(new SpellCheckMessageFilterMac(id));
|
||||
host->AddFilter(new SpellCheckMessageFilterPlatform(id));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -668,6 +668,16 @@ bool CefContentBrowserClient::IsHandledURL(const GURL& url) {
|
||||
return CefContentClient::Get()->HasCustomScheme(scheme);
|
||||
}
|
||||
|
||||
bool CefContentBrowserClient::IsNPAPIEnabled() {
|
||||
#if defined(OS_WIN) || defined(OS_MACOSX)
|
||||
const base::CommandLine* command_line =
|
||||
base::CommandLine::ForCurrentProcess();
|
||||
return command_line->HasSwitch(switches::kEnableNPAPI);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CefContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
base::CommandLine* command_line, int child_process_id) {
|
||||
const base::CommandLine* browser_cmd =
|
||||
|
@@ -89,6 +89,7 @@ class CefContentBrowserClient : public content::ContentBrowserClient {
|
||||
content::URLRequestInterceptorScopedVector request_interceptors)
|
||||
override;
|
||||
bool IsHandledURL(const GURL& url) override;
|
||||
bool IsNPAPIEnabled() override;
|
||||
void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
|
||||
int child_process_id) override;
|
||||
content::QuotaPermissionContext*
|
||||
|
@@ -225,7 +225,7 @@ void CefDevToolsFrontend::HandleMessageFromDevToolsFrontend(
|
||||
params->GetSize() == 1 && params->GetString(0, &browser_message)) {
|
||||
agent_host_->DispatchProtocolMessage(browser_message);
|
||||
} else if (method == "loadCompleted") {
|
||||
web_contents()->GetMainFrame()->ExecuteJavaScript(
|
||||
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(
|
||||
base::ASCIIToUTF16("DevToolsAPI.setUseSoftMenu(true);"));
|
||||
} else if (method == "loadNetworkResource" && params->GetSize() == 3) {
|
||||
// TODO(pfeldman): handle some of the embedder messages in content.
|
||||
@@ -292,7 +292,7 @@ void CefDevToolsFrontend::DispatchProtocolMessage(
|
||||
if (message.length() < kMaxMessageChunkSize) {
|
||||
base::string16 javascript = base::UTF8ToUTF16(
|
||||
"DevToolsAPI.dispatchMessage(" + message + ");");
|
||||
web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
|
||||
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ void CefDevToolsFrontend::DispatchProtocolMessage(
|
||||
base::StringValue(message.substr(pos, kMaxMessageChunkSize)), ¶m);
|
||||
std::string code = "DevToolsAPI.dispatchMessageChunk(" + param + ");";
|
||||
base::string16 javascript = base::UTF8ToUTF16(code);
|
||||
web_contents()->GetMainFrame()->ExecuteJavaScript(javascript);
|
||||
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(javascript);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ void CefDevToolsFrontend::CallClientFunction(
|
||||
}
|
||||
}
|
||||
javascript.append(");");
|
||||
web_contents()->GetMainFrame()->ExecuteJavaScript(
|
||||
web_contents()->GetMainFrame()->ExecuteJavaScriptForTests(
|
||||
base::UTF8ToUTF16(javascript));
|
||||
}
|
||||
|
||||
|
@@ -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());
|
||||
|
@@ -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()) {
|
||||
|
@@ -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,
|
||||
|
@@ -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,
|
||||
|
@@ -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);
|
||||
};
|
||||
|
||||
|
@@ -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() {
|
||||
|
@@ -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;
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "components/url_formatter/url_formatter.h"
|
||||
#include "net/base/net_util.h"
|
||||
|
||||
namespace {
|
||||
@@ -119,7 +120,8 @@ void CefJavaScriptDialogManager::RunJavaScriptDialog(
|
||||
return;
|
||||
}
|
||||
|
||||
base::string16 display_url = net::FormatUrl(origin_url, accept_lang);
|
||||
base::string16 display_url =
|
||||
url_formatter::FormatUrl(origin_url, accept_lang);
|
||||
|
||||
dialog_.reset(new CefJavaScriptDialog(this,
|
||||
message_type,
|
||||
|
@@ -6,10 +6,14 @@
|
||||
|
||||
#include "libcef/browser/content_browser_client.h"
|
||||
|
||||
#include "base/auto_reset.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/location.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/prefs/pref_service.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/thread_task_runner_handle.h"
|
||||
#include "base/timer/timer.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/chrome_notification_types.h"
|
||||
@@ -35,11 +39,9 @@ using content::BrowserThread;
|
||||
namespace printing {
|
||||
|
||||
PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents)
|
||||
: content::WebContentsObserver(web_contents),
|
||||
number_pages_(0),
|
||||
: PrintManager(web_contents),
|
||||
printing_succeeded_(false),
|
||||
inside_inner_message_loop_(false),
|
||||
cookie_(0),
|
||||
queue_(g_browser_process->print_job_manager()->queue()) {
|
||||
DCHECK(queue_.get());
|
||||
#if !defined(OS_MACOSX)
|
||||
@@ -75,6 +77,7 @@ void PrintViewManagerBase::NavigationStopped() {
|
||||
}
|
||||
|
||||
void PrintViewManagerBase::RenderProcessGone(base::TerminationStatus status) {
|
||||
PrintManager::RenderProcessGone(status);
|
||||
ReleasePrinterQuery();
|
||||
|
||||
if (!print_job_.get())
|
||||
@@ -98,16 +101,10 @@ base::string16 PrintViewManagerBase::RenderSourceName() {
|
||||
|
||||
void PrintViewManagerBase::OnDidGetPrintedPagesCount(int cookie,
|
||||
int number_pages) {
|
||||
DCHECK_GT(cookie, 0);
|
||||
DCHECK_GT(number_pages, 0);
|
||||
number_pages_ = number_pages;
|
||||
PrintManager::OnDidGetPrintedPagesCount(cookie, number_pages);
|
||||
OpportunisticallyCreatePrintJob(cookie);
|
||||
}
|
||||
|
||||
void PrintViewManagerBase::OnDidGetDocumentCookie(int cookie) {
|
||||
cookie_ = cookie;
|
||||
}
|
||||
|
||||
void PrintViewManagerBase::OnDidPrintPage(
|
||||
const PrintHostMsg_DidPrintPage_Params& params) {
|
||||
if (!OpportunisticallyCreatePrintJob(params.document_cookie))
|
||||
@@ -167,10 +164,7 @@ void PrintViewManagerBase::OnDidPrintPage(
|
||||
}
|
||||
|
||||
void PrintViewManagerBase::OnPrintingFailed(int cookie) {
|
||||
if (cookie != cookie_) {
|
||||
NOTREACHED();
|
||||
return;
|
||||
}
|
||||
PrintManager::OnPrintingFailed(cookie);
|
||||
|
||||
ReleasePrinterQuery();
|
||||
|
||||
@@ -190,17 +184,12 @@ void PrintViewManagerBase::DidStartLoading() {
|
||||
bool PrintViewManagerBase::OnMessageReceived(const IPC::Message& message) {
|
||||
bool handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(PrintViewManagerBase, message)
|
||||
IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetPrintedPagesCount,
|
||||
OnDidGetPrintedPagesCount)
|
||||
IPC_MESSAGE_HANDLER(PrintHostMsg_DidGetDocumentCookie,
|
||||
OnDidGetDocumentCookie)
|
||||
IPC_MESSAGE_HANDLER(PrintHostMsg_DidPrintPage, OnDidPrintPage)
|
||||
IPC_MESSAGE_HANDLER(PrintHostMsg_PrintingFailed, OnPrintingFailed)
|
||||
IPC_MESSAGE_HANDLER(PrintHostMsg_ShowInvalidPrinterSettingsError,
|
||||
OnShowInvalidPrinterSettingsError);
|
||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||
IPC_END_MESSAGE_MAP()
|
||||
return handled;
|
||||
return handled || PrintManager::OnMessageReceived(message);
|
||||
}
|
||||
|
||||
void PrintViewManagerBase::Observe(
|
||||
|
@@ -8,10 +8,9 @@
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/prefs/pref_member.h"
|
||||
#include "base/strings/string16.h"
|
||||
#include "components/printing/browser/print_manager.h"
|
||||
#include "content/public/browser/notification_observer.h"
|
||||
#include "content/public/browser/notification_registrar.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "content/public/browser/web_contents_user_data.h"
|
||||
#include "printing/printed_pages_source.h"
|
||||
|
||||
struct PrintHostMsg_DidPrintPage_Params;
|
||||
@@ -31,7 +30,7 @@ class PrintQueriesQueue;
|
||||
// Base class for managing the print commands for a WebContents.
|
||||
class PrintViewManagerBase : public content::NotificationObserver,
|
||||
public PrintedPagesSource,
|
||||
public content::WebContentsObserver {
|
||||
public PrintManager {
|
||||
public:
|
||||
~PrintViewManagerBase() override;
|
||||
|
||||
@@ -63,9 +62,6 @@ class PrintViewManagerBase : public content::NotificationObserver,
|
||||
// content::WebContentsObserver implementation.
|
||||
bool OnMessageReceived(const IPC::Message& message) override;
|
||||
|
||||
// IPC Message handlers.
|
||||
virtual void OnPrintingFailed(int cookie);
|
||||
|
||||
private:
|
||||
// content::NotificationObserver implementation.
|
||||
void Observe(int type,
|
||||
@@ -76,9 +72,9 @@ class PrintViewManagerBase : public content::NotificationObserver,
|
||||
void DidStartLoading() override;
|
||||
|
||||
// IPC Message handlers.
|
||||
void OnDidGetPrintedPagesCount(int cookie, int number_pages);
|
||||
void OnDidGetDocumentCookie(int cookie);
|
||||
void OnDidGetPrintedPagesCount(int cookie, int number_pages) override;
|
||||
void OnDidPrintPage(const PrintHostMsg_DidPrintPage_Params& params);
|
||||
void OnPrintingFailed(int cookie) override;
|
||||
void OnShowInvalidPrinterSettingsError();
|
||||
|
||||
// Processes a NOTIFY_PRINT_JOB_EVENT notification.
|
||||
@@ -137,9 +133,6 @@ class PrintViewManagerBase : public content::NotificationObserver,
|
||||
// Manages the low-level talk to the printer.
|
||||
scoped_refptr<PrintJob> print_job_;
|
||||
|
||||
// Number of pages to print in the print job.
|
||||
int number_pages_;
|
||||
|
||||
// Indication of success of the print job.
|
||||
bool printing_succeeded_;
|
||||
|
||||
@@ -153,9 +146,6 @@ class PrintViewManagerBase : public content::NotificationObserver,
|
||||
bool expecting_first_page_;
|
||||
#endif // OS_MACOSX
|
||||
|
||||
// The document cookie of the current PrinterQuery.
|
||||
int cookie_;
|
||||
|
||||
// Whether printing is enabled.
|
||||
BooleanPrefMember printing_enabled_;
|
||||
|
||||
|
@@ -10,79 +10,17 @@
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/printing/print_job_manager.h"
|
||||
#include "chrome/browser/printing/printer_query.h"
|
||||
#include "components/printing/browser/print_manager_utils.h"
|
||||
#include "components/printing/common/print_messages.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/child_process_host.h"
|
||||
|
||||
#if defined(OS_CHROMEOS)
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "chrome/browser/printing/print_dialog_cloud.h"
|
||||
#endif
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "chrome/browser/printing/print_view_manager_basic.h"
|
||||
#include "printing/printing_context_android.h"
|
||||
#endif
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace printing {
|
||||
|
||||
namespace {
|
||||
|
||||
#if defined(OS_CHROMEOS)
|
||||
typedef std::map<int, base::FilePath> SequenceToPathMap;
|
||||
|
||||
struct PrintingSequencePathMap {
|
||||
SequenceToPathMap map;
|
||||
int sequence;
|
||||
};
|
||||
|
||||
// No locking, only access on the FILE thread.
|
||||
static base::LazyInstance<PrintingSequencePathMap>
|
||||
g_printing_file_descriptor_map = LAZY_INSTANCE_INITIALIZER;
|
||||
#endif
|
||||
|
||||
void RenderParamsFromPrintSettings(const PrintSettings& settings,
|
||||
PrintMsg_Print_Params* params) {
|
||||
params->page_size = settings.page_setup_device_units().physical_size();
|
||||
params->content_size.SetSize(
|
||||
settings.page_setup_device_units().content_area().width(),
|
||||
settings.page_setup_device_units().content_area().height());
|
||||
params->printable_area.SetRect(
|
||||
settings.page_setup_device_units().printable_area().x(),
|
||||
settings.page_setup_device_units().printable_area().y(),
|
||||
settings.page_setup_device_units().printable_area().width(),
|
||||
settings.page_setup_device_units().printable_area().height());
|
||||
params->margin_top = settings.page_setup_device_units().content_area().y();
|
||||
params->margin_left = settings.page_setup_device_units().content_area().x();
|
||||
params->dpi = settings.dpi();
|
||||
// Currently hardcoded at 1.25. See PrintSettings' constructor.
|
||||
params->min_shrink = settings.min_shrink();
|
||||
// Currently hardcoded at 2.0. See PrintSettings' constructor.
|
||||
params->max_shrink = settings.max_shrink();
|
||||
// Currently hardcoded at 72dpi. See PrintSettings' constructor.
|
||||
params->desired_dpi = settings.desired_dpi();
|
||||
// Always use an invalid cookie.
|
||||
params->document_cookie = 0;
|
||||
params->selection_only = settings.selection_only();
|
||||
params->supports_alpha_blend = settings.supports_alpha_blend();
|
||||
params->should_print_backgrounds = settings.should_print_backgrounds();
|
||||
params->display_header_footer = settings.display_header_footer();
|
||||
params->title = settings.title();
|
||||
params->url = settings.url();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
PrintingMessageFilter::PrintingMessageFilter(int render_process_id)
|
||||
: content::BrowserMessageFilter(PrintMsgStart),
|
||||
render_process_id_(render_process_id),
|
||||
@@ -95,17 +33,6 @@ PrintingMessageFilter::~PrintingMessageFilter() {
|
||||
|
||||
void PrintingMessageFilter::OverrideThreadForMessage(
|
||||
const IPC::Message& message, BrowserThread::ID* thread) {
|
||||
#if defined(OS_CHROMEOS)
|
||||
if (message.type() == PrintHostMsg_AllocateTempFileForPrinting::ID ||
|
||||
message.type() == PrintHostMsg_TempFileForPrintingWritten::ID) {
|
||||
*thread = BrowserThread::FILE;
|
||||
}
|
||||
#elif defined(OS_ANDROID)
|
||||
if (message.type() == PrintHostMsg_AllocateTempFileForPrinting::ID ||
|
||||
message.type() == PrintHostMsg_TempFileForPrintingWritten::ID) {
|
||||
*thread = BrowserThread::UI;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PrintingMessageFilter::OnMessageReceived(const IPC::Message& message) {
|
||||
@@ -113,12 +40,6 @@ bool PrintingMessageFilter::OnMessageReceived(const IPC::Message& message) {
|
||||
IPC_BEGIN_MESSAGE_MAP(PrintingMessageFilter, message)
|
||||
#if defined(OS_WIN)
|
||||
IPC_MESSAGE_HANDLER(PrintHostMsg_DuplicateSection, OnDuplicateSection)
|
||||
#endif
|
||||
#if defined(OS_CHROMEOS) || defined(OS_ANDROID)
|
||||
IPC_MESSAGE_HANDLER(PrintHostMsg_AllocateTempFileForPrinting,
|
||||
OnAllocateTempFileForPrinting)
|
||||
IPC_MESSAGE_HANDLER(PrintHostMsg_TempFileForPrintingWritten,
|
||||
OnTempFileForPrintingWritten)
|
||||
#endif
|
||||
IPC_MESSAGE_HANDLER(PrintHostMsg_IsPrintingEnabled, OnIsPrintingEnabled)
|
||||
IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_GetDefaultPrintSettings,
|
||||
@@ -143,109 +64,6 @@ void PrintingMessageFilter::OnDuplicateSection(
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(OS_CHROMEOS) || defined(OS_ANDROID)
|
||||
void PrintingMessageFilter::OnAllocateTempFileForPrinting(
|
||||
int render_view_id,
|
||||
base::FileDescriptor* temp_file_fd,
|
||||
int* sequence_number) {
|
||||
#if defined(OS_CHROMEOS)
|
||||
// TODO(thestig): Use |render_view_id| for Chrome OS.
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
|
||||
temp_file_fd->fd = *sequence_number = -1;
|
||||
temp_file_fd->auto_close = false;
|
||||
|
||||
SequenceToPathMap* map = &g_printing_file_descriptor_map.Get().map;
|
||||
*sequence_number = g_printing_file_descriptor_map.Get().sequence++;
|
||||
|
||||
base::FilePath path;
|
||||
if (base::CreateTemporaryFile(&path)) {
|
||||
int fd = open(path.value().c_str(), O_WRONLY);
|
||||
if (fd >= 0) {
|
||||
SequenceToPathMap::iterator it = map->find(*sequence_number);
|
||||
if (it != map->end()) {
|
||||
NOTREACHED() << "Sequence number already in use. seq=" <<
|
||||
*sequence_number;
|
||||
} else {
|
||||
(*map)[*sequence_number] = path;
|
||||
temp_file_fd->fd = fd;
|
||||
temp_file_fd->auto_close = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#elif defined(OS_ANDROID)
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
content::WebContents* wc = GetWebContentsForRenderView(render_view_id);
|
||||
if (!wc)
|
||||
return;
|
||||
PrintViewManagerBasic* print_view_manager =
|
||||
PrintViewManagerBasic::FromWebContents(wc);
|
||||
// The file descriptor is originally created in & passed from the Android
|
||||
// side, and it will handle the closing.
|
||||
const base::FileDescriptor& file_descriptor =
|
||||
print_view_manager->file_descriptor();
|
||||
temp_file_fd->fd = file_descriptor.fd;
|
||||
temp_file_fd->auto_close = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void PrintingMessageFilter::OnTempFileForPrintingWritten(int render_view_id,
|
||||
int sequence_number) {
|
||||
#if defined(OS_CHROMEOS)
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
|
||||
SequenceToPathMap* map = &g_printing_file_descriptor_map.Get().map;
|
||||
SequenceToPathMap::iterator it = map->find(sequence_number);
|
||||
if (it == map->end()) {
|
||||
NOTREACHED() << "Got a sequence that we didn't pass to the "
|
||||
"renderer: " << sequence_number;
|
||||
return;
|
||||
}
|
||||
BrowserThread::PostTask(
|
||||
BrowserThread::UI, FROM_HERE,
|
||||
base::Bind(&PrintingMessageFilter::CreatePrintDialogForFile,
|
||||
this, render_view_id, it->second));
|
||||
|
||||
// Erase the entry in the map.
|
||||
map->erase(it);
|
||||
#elif defined(OS_ANDROID)
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
content::WebContents* wc = GetWebContentsForRenderView(render_view_id);
|
||||
if (!wc)
|
||||
return;
|
||||
PrintViewManagerBasic* print_view_manager =
|
||||
PrintViewManagerBasic::FromWebContents(wc);
|
||||
const base::FileDescriptor& file_descriptor =
|
||||
print_view_manager->file_descriptor();
|
||||
PrintingContextAndroid::PdfWritingDone(file_descriptor.fd, true);
|
||||
// Invalidate the file descriptor so it doesn't accidentally get reused.
|
||||
print_view_manager->set_file_descriptor(base::FileDescriptor(-1, false));
|
||||
#endif
|
||||
}
|
||||
#endif // defined(OS_CHROMEOS) || defined(OS_ANDROID)
|
||||
|
||||
#if defined(OS_CHROMEOS)
|
||||
void PrintingMessageFilter::CreatePrintDialogForFile(
|
||||
int render_view_id,
|
||||
const base::FilePath& path) {
|
||||
content::WebContents* wc = GetWebContentsForRenderView(render_view_id);
|
||||
if (!wc)
|
||||
return;
|
||||
print_dialog_cloud::CreatePrintDialogForFile(
|
||||
wc->GetBrowserContext(),
|
||||
wc->GetTopLevelNativeWindow(),
|
||||
path,
|
||||
wc->GetTitle(),
|
||||
base::string16(),
|
||||
std::string("application/pdf"));
|
||||
}
|
||||
#endif // defined(OS_CHROMEOS)
|
||||
|
||||
content::WebContents* PrintingMessageFilter::GetWebContentsForRenderView(
|
||||
int render_view_id) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
content::RenderViewHost* view = content::RenderViewHost::FromID(
|
||||
render_process_id_, render_view_id);
|
||||
return view ? content::WebContents::FromRenderViewHost(view) : NULL;
|
||||
}
|
||||
|
||||
void PrintingMessageFilter::OnIsPrintingEnabled(bool* is_enabled) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||
@@ -356,18 +174,6 @@ void PrintingMessageFilter::OnScriptedPrintReply(
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
void PrintingMessageFilter::UpdateFileDescriptor(int render_view_id, int fd) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
content::WebContents* wc = GetWebContentsForRenderView(render_view_id);
|
||||
if (!wc)
|
||||
return;
|
||||
PrintViewManagerBasic* print_view_manager =
|
||||
PrintViewManagerBasic::FromWebContents(wc);
|
||||
print_view_manager->set_file_descriptor(base::FileDescriptor(fd, false));
|
||||
}
|
||||
#endif
|
||||
|
||||
void PrintingMessageFilter::OnUpdatePrintSettings(
|
||||
int document_cookie, const base::DictionaryValue& job_settings,
|
||||
IPC::Message* reply_msg) {
|
||||
@@ -424,7 +230,7 @@ void PrintingMessageFilter::OnUpdatePrintSettingsReply(
|
||||
void PrintingMessageFilter::OnCheckForCancel(int32 preview_ui_id,
|
||||
int preview_request_id,
|
||||
bool* cancel) {
|
||||
*cancel = false;
|
||||
*cancel = false;
|
||||
}
|
||||
|
||||
} // namespace printing
|
||||
|
@@ -51,29 +51,6 @@ class PrintingMessageFilter : public content::BrowserMessageFilter {
|
||||
base::SharedMemoryHandle* browser_handle);
|
||||
#endif
|
||||
|
||||
#if defined(OS_CHROMEOS) || defined(OS_ANDROID)
|
||||
// Used to ask the browser allocate a temporary file for the renderer
|
||||
// to fill in resulting PDF in renderer.
|
||||
void OnAllocateTempFileForPrinting(int render_view_id,
|
||||
base::FileDescriptor* temp_file_fd,
|
||||
int* sequence_number);
|
||||
void OnTempFileForPrintingWritten(int render_view_id, int sequence_number);
|
||||
#endif
|
||||
|
||||
#if defined(OS_CHROMEOS)
|
||||
void CreatePrintDialogForFile(int render_view_id, const base::FilePath& path);
|
||||
#endif
|
||||
|
||||
#if defined(OS_ANDROID)
|
||||
// Updates the file descriptor for the PrintViewManagerBasic of a given
|
||||
// render_view_id.
|
||||
void UpdateFileDescriptor(int render_view_id, int fd);
|
||||
#endif
|
||||
|
||||
// Given a render_view_id get the corresponding WebContents.
|
||||
// Must be called on the UI thread.
|
||||
content::WebContents* GetWebContentsForRenderView(int render_view_id);
|
||||
|
||||
// GetPrintSettingsForRenderView must be called via PostTask and
|
||||
// base::Bind. Collapse the settings-specific params into a
|
||||
// struct to avoid running into issues with too many params
|
||||
|
@@ -649,7 +649,8 @@ void CefRenderWidgetHostViewOSR::OnSwapCompositorFrame(
|
||||
output_surface_id,
|
||||
frame->delegated_frame_data.Pass(),
|
||||
frame->metadata.device_scale_factor,
|
||||
frame->metadata.latency_info);
|
||||
frame->metadata.latency_info,
|
||||
&frame->metadata.satisfies_sequences);
|
||||
} else {
|
||||
if (!copy_frame_generator_.get()) {
|
||||
copy_frame_generator_.reset(
|
||||
@@ -668,7 +669,8 @@ void CefRenderWidgetHostViewOSR::OnSwapCompositorFrame(
|
||||
output_surface_id,
|
||||
frame->delegated_frame_data.Pass(),
|
||||
frame->metadata.device_scale_factor,
|
||||
frame->metadata.latency_info);
|
||||
frame->metadata.latency_info,
|
||||
&frame->metadata.satisfies_sequences);
|
||||
|
||||
// Request a copy of the last compositor frame which will eventually call
|
||||
// OnPaint asynchronously.
|
||||
@@ -677,16 +679,6 @@ void CefRenderWidgetHostViewOSR::OnSwapCompositorFrame(
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (frame->software_frame_data) {
|
||||
DLOG(ERROR) << "Unable to use software frame in CEF windowless rendering";
|
||||
if (render_widget_host_) {
|
||||
content::bad_message::ReceivedBadMessage(
|
||||
render_widget_host_->GetProcess(),
|
||||
content::bad_message::RWHVM_UNEXPECTED_FRAME_TYPE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::InitAsPopup(
|
||||
@@ -783,10 +775,8 @@ void CefRenderWidgetHostViewOSR::SetIsLoading(bool is_loading) {
|
||||
}
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
void CefRenderWidgetHostViewOSR::TextInputTypeChanged(ui::TextInputType type,
|
||||
ui::TextInputMode mode,
|
||||
bool can_compose_inline,
|
||||
int flags) {
|
||||
void CefRenderWidgetHostViewOSR::TextInputStateChanged(
|
||||
const ViewHostMsg_TextInputState_Params& params) {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::ImeCancelComposition() {
|
||||
|
@@ -126,10 +126,8 @@ class CefRenderWidgetHostViewOSR
|
||||
const std::vector<content::WebPluginGeometry>& moves) override;
|
||||
void UpdateCursor(const content::WebCursor& cursor) override;
|
||||
void SetIsLoading(bool is_loading) override;
|
||||
void TextInputTypeChanged(ui::TextInputType type,
|
||||
ui::TextInputMode mode,
|
||||
bool can_compose_inline,
|
||||
int flags) override;
|
||||
void TextInputStateChanged(
|
||||
const ViewHostMsg_TextInputState_Params& params) override;
|
||||
void ImeCancelComposition() override;
|
||||
void RenderProcessGone(base::TerminationStatus status,
|
||||
int error_code) override;
|
||||
|
@@ -54,10 +54,8 @@ bool CefRenderWidgetHostViewOSR::IsSpeaking() const {
|
||||
void CefRenderWidgetHostViewOSR::StopSpeaking() {
|
||||
}
|
||||
|
||||
void CefRenderWidgetHostViewOSR::TextInputTypeChanged(ui::TextInputType type,
|
||||
ui::TextInputMode mode,
|
||||
bool can_compose_inline,
|
||||
int flags) {
|
||||
void CefRenderWidgetHostViewOSR::TextInputStateChanged(
|
||||
const ViewHostMsg_TextInputState_Params& params) {
|
||||
[NSApp updateWindows];
|
||||
}
|
||||
|
||||
|
@@ -61,36 +61,6 @@ bool NavigationOnUIThread(
|
||||
return ignore_navigation;
|
||||
}
|
||||
|
||||
// TODO(raymes): This won't return the right result if plugins haven't been
|
||||
// loaded yet. Fixing this properly really requires fixing crbug.com/443466.
|
||||
bool IsPluginEnabledForExtension(const extensions::Extension* extension,
|
||||
const content::ResourceRequestInfo* info,
|
||||
const std::string& mime_type,
|
||||
const GURL& url) {
|
||||
content::PluginService* service = content::PluginService::GetInstance();
|
||||
std::vector<content::WebPluginInfo> plugins;
|
||||
service->GetPluginInfoArray(url, mime_type, true, &plugins, nullptr);
|
||||
content::PluginServiceFilter* filter = service->GetFilter();
|
||||
|
||||
for (auto& plugin : plugins) {
|
||||
// Check that the plugin is running the extension.
|
||||
if (plugin.path !=
|
||||
base::FilePath::FromUTF8Unsafe(extension->url().spec())) {
|
||||
continue;
|
||||
}
|
||||
// Check that the plugin is actually enabled.
|
||||
if (!filter || filter->IsPluginAvailable(info->GetChildID(),
|
||||
info->GetRenderFrameID(),
|
||||
info->GetContext(),
|
||||
url,
|
||||
GURL(),
|
||||
&plugin)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SendExecuteMimeTypeHandlerEvent(scoped_ptr<content::StreamInfo> stream,
|
||||
int64 expected_content_size,
|
||||
int render_process_id,
|
||||
@@ -184,6 +154,7 @@ bool CefResourceDispatcherHostDelegate::HandleExternalProtocol(
|
||||
// ChromeResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream.
|
||||
bool CefResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream(
|
||||
net::URLRequest* request,
|
||||
const base::FilePath& plugin_path,
|
||||
const std::string& mime_type,
|
||||
GURL* origin,
|
||||
std::string* payload) {
|
||||
@@ -213,23 +184,32 @@ bool CefResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream(
|
||||
}
|
||||
|
||||
MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension);
|
||||
if (handler && handler->CanHandleMIMEType(mime_type)) {
|
||||
StreamTargetInfo target_info;
|
||||
*origin = extensions::Extension::GetBaseURLFromExtensionId(extension_id);
|
||||
target_info.extension_id = extension_id;
|
||||
if (!handler->handler_url().empty()) {
|
||||
// This is reached in the case of MimeHandlerViews. If the
|
||||
// MimeHandlerView plugin is disabled, then we shouldn't intercept the
|
||||
// stream.
|
||||
if (!IsPluginEnabledForExtension(extension, info, mime_type,
|
||||
request->url())) {
|
||||
continue;
|
||||
}
|
||||
if (!handler)
|
||||
continue;
|
||||
|
||||
// If a plugin path is provided then a stream is being intercepted for the
|
||||
// mimeHandlerPrivate API. Otherwise a stream is being intercepted for the
|
||||
// streamsPrivate API.
|
||||
if (!plugin_path.empty()) {
|
||||
if (handler->HasPlugin() && plugin_path == handler->GetPluginPath()) {
|
||||
StreamTargetInfo target_info;
|
||||
*origin =
|
||||
extensions::Extension::GetBaseURLFromExtensionId(extension_id);
|
||||
target_info.extension_id = extension_id;
|
||||
target_info.view_id = base::GenerateGUID();
|
||||
*payload = target_info.view_id;
|
||||
stream_target_info_[request] = target_info;
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (!handler->HasPlugin() && handler->CanHandleMIMEType(mime_type)) {
|
||||
StreamTargetInfo target_info;
|
||||
*origin =
|
||||
extensions::Extension::GetBaseURLFromExtensionId(extension_id);
|
||||
target_info.extension_id = extension_id;
|
||||
stream_target_info_[request] = target_info;
|
||||
return true;
|
||||
}
|
||||
stream_target_info_[request] = target_info;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -33,6 +33,7 @@ class CefResourceDispatcherHostDelegate
|
||||
ui::PageTransition page_transition,
|
||||
bool has_user_gesture) override;
|
||||
bool ShouldInterceptResourceAsStream(net::URLRequest* request,
|
||||
const base::FilePath& plugin_path,
|
||||
const std::string& mime_type,
|
||||
GURL* origin,
|
||||
std::string* payload) override;
|
||||
|
@@ -66,16 +66,15 @@ SkCanvas* CefSoftwareOutputDeviceOSR::BeginPaint(const gfx::Rect& damage_rect) {
|
||||
return canvas_.get();
|
||||
}
|
||||
|
||||
void CefSoftwareOutputDeviceOSR::EndPaint(cc::SoftwareFrameData* frame_data) {
|
||||
void CefSoftwareOutputDeviceOSR::EndPaint() {
|
||||
CEF_REQUIRE_UIT();
|
||||
DCHECK(canvas_.get());
|
||||
DCHECK(bitmap_.get());
|
||||
DCHECK(frame_data);
|
||||
|
||||
if (!bitmap_.get())
|
||||
return;
|
||||
|
||||
cc::SoftwareOutputDevice::EndPaint(frame_data);
|
||||
cc::SoftwareOutputDevice::EndPaint();
|
||||
|
||||
if (active_)
|
||||
OnPaint(damage_rect_);
|
||||
|
@@ -30,7 +30,7 @@ class CefSoftwareOutputDeviceOSR : public cc::SoftwareOutputDevice {
|
||||
void Resize(const gfx::Size& viewport_pixel_size,
|
||||
float scale_factor) override;
|
||||
SkCanvas* BeginPaint(const gfx::Rect& damage_rect) override;
|
||||
void EndPaint(cc::SoftwareFrameData* frame_data) override;
|
||||
void EndPaint() override;
|
||||
|
||||
void SetActive(bool active);
|
||||
|
||||
|
@@ -120,7 +120,7 @@ extern "C" {
|
||||
// We ignore commands that insert characters, because this was causing
|
||||
// strange behavior (e.g. tab always inserted a tab rather than moving to
|
||||
// the next field on the page).
|
||||
if (!base::StartsWithASCII(command, "insert", false))
|
||||
if (!base::StartsWith(command, "insert", base::CompareCase::SENSITIVE))
|
||||
editCommands_.push_back(content::EditCommand(command, ""));
|
||||
} else {
|
||||
renderWidgetHostView_->render_widget_host()->Send(
|
||||
|
Reference in New Issue
Block a user