commit
7d3b58aab1
97 changed files with 1201 additions and 807 deletions
|
@ -93,9 +93,9 @@ content::PepperPluginInfo CreateWidevineCdmInfo(const base::FilePath& path,
|
||||||
std::vector<std::string> codecs;
|
std::vector<std::string> codecs;
|
||||||
codecs.push_back(kCdmSupportedCodecVp8);
|
codecs.push_back(kCdmSupportedCodecVp8);
|
||||||
codecs.push_back(kCdmSupportedCodecVp9);
|
codecs.push_back(kCdmSupportedCodecVp9);
|
||||||
#if defined(USE_PROPRIETARY_CODECS)
|
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||||
codecs.push_back(kCdmSupportedCodecAvc1);
|
codecs.push_back(kCdmSupportedCodecAvc1);
|
||||||
#endif // defined(USE_PROPRIETARY_CODECS)
|
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||||
std::string codec_string = base::JoinString(
|
std::string codec_string = base::JoinString(
|
||||||
codecs, std::string(1, kCdmSupportedCodecsValueDelimiter));
|
codecs, std::string(1, kCdmSupportedCodecsValueDelimiter));
|
||||||
widevine_cdm_mime_type.additional_param_names.push_back(
|
widevine_cdm_mime_type.additional_param_names.push_back(
|
||||||
|
@ -198,11 +198,19 @@ base::string16 AtomContentClient::GetLocalizedString(int message_id) const {
|
||||||
return l10n_util::GetStringUTF16(message_id);
|
return l10n_util::GetStringUTF16(message_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomContentClient::AddAdditionalSchemes(
|
void AtomContentClient::AddAdditionalSchemes(Schemes* schemes) {
|
||||||
std::vector<url::SchemeWithType>* standard_schemes,
|
schemes->standard_schemes.push_back("chrome-extension");
|
||||||
std::vector<url::SchemeWithType>* referrer_schemes,
|
|
||||||
std::vector<std::string>* savable_schemes) {
|
std::vector<std::string> splited;
|
||||||
standard_schemes->push_back({"chrome-extension", url::SCHEME_WITHOUT_PORT});
|
ConvertStringWithSeparatorToVector(&splited, ",",
|
||||||
|
switches::kRegisterServiceWorkerSchemes);
|
||||||
|
for (const std::string& scheme : splited)
|
||||||
|
schemes->service_worker_schemes.push_back(scheme);
|
||||||
|
schemes->service_worker_schemes.push_back(url::kFileScheme);
|
||||||
|
|
||||||
|
ConvertStringWithSeparatorToVector(&splited, ",", switches::kSecureSchemes);
|
||||||
|
for (const std::string& scheme : splited)
|
||||||
|
schemes->secure_schemes.push_back(scheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomContentClient::AddPepperPlugins(
|
void AtomContentClient::AddPepperPlugins(
|
||||||
|
@ -214,25 +222,4 @@ void AtomContentClient::AddPepperPlugins(
|
||||||
ComputeBuiltInPlugins(plugins);
|
ComputeBuiltInPlugins(plugins);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomContentClient::AddServiceWorkerSchemes(
|
|
||||||
std::set<std::string>* service_worker_schemes) {
|
|
||||||
std::vector<std::string> schemes;
|
|
||||||
ConvertStringWithSeparatorToVector(&schemes, ",",
|
|
||||||
switches::kRegisterServiceWorkerSchemes);
|
|
||||||
for (const std::string& scheme : schemes)
|
|
||||||
service_worker_schemes->insert(scheme);
|
|
||||||
|
|
||||||
service_worker_schemes->insert(url::kFileScheme);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AtomContentClient::AddSecureSchemesAndOrigins(
|
|
||||||
std::set<std::string>* secure_schemes,
|
|
||||||
std::set<GURL>* secure_origins) {
|
|
||||||
std::vector<std::string> schemes;
|
|
||||||
ConvertStringWithSeparatorToVector(&schemes, ",", switches::kSecureSchemes);
|
|
||||||
for (const std::string& scheme : schemes)
|
|
||||||
secure_schemes->insert(scheme);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -23,17 +23,9 @@ class AtomContentClient : public brightray::ContentClient {
|
||||||
std::string GetProduct() const override;
|
std::string GetProduct() const override;
|
||||||
std::string GetUserAgent() const override;
|
std::string GetUserAgent() const override;
|
||||||
base::string16 GetLocalizedString(int message_id) const override;
|
base::string16 GetLocalizedString(int message_id) const override;
|
||||||
void AddAdditionalSchemes(
|
void AddAdditionalSchemes(Schemes* schemes) override;
|
||||||
std::vector<url::SchemeWithType>* standard_schemes,
|
|
||||||
std::vector<url::SchemeWithType>* referrer_schemes,
|
|
||||||
std::vector<std::string>* savable_schemes) override;
|
|
||||||
void AddPepperPlugins(
|
void AddPepperPlugins(
|
||||||
std::vector<content::PepperPluginInfo>* plugins) override;
|
std::vector<content::PepperPluginInfo>* plugins) override;
|
||||||
void AddServiceWorkerSchemes(
|
|
||||||
std::set<std::string>* service_worker_schemes) override;
|
|
||||||
void AddSecureSchemesAndOrigins(
|
|
||||||
std::set<std::string>* secure_schemes,
|
|
||||||
std::set<GURL>* secure_origins) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(AtomContentClient);
|
DISALLOW_COPY_AND_ASSIGN(AtomContentClient);
|
||||||
|
|
|
@ -464,8 +464,8 @@ int ImportIntoCertStore(
|
||||||
|
|
||||||
if (!cert_path.empty()) {
|
if (!cert_path.empty()) {
|
||||||
if (base::ReadFileToString(base::FilePath(cert_path), &file_data)) {
|
if (base::ReadFileToString(base::FilePath(cert_path), &file_data)) {
|
||||||
auto module = model->cert_db()->GetPublicModule();
|
auto module = model->cert_db()->GetPrivateSlot();
|
||||||
rv = model->ImportFromPKCS12(module,
|
rv = model->ImportFromPKCS12(module.get(),
|
||||||
file_data,
|
file_data,
|
||||||
password,
|
password,
|
||||||
true,
|
true,
|
||||||
|
|
|
@ -62,6 +62,10 @@ struct Converter<net::CookieStore::ChangeCause> {
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case net::CookieStore::ChangeCause::INSERTED:
|
case net::CookieStore::ChangeCause::INSERTED:
|
||||||
case net::CookieStore::ChangeCause::EXPLICIT:
|
case net::CookieStore::ChangeCause::EXPLICIT:
|
||||||
|
case net::CookieStore::ChangeCause::EXPLICIT_DELETE_BETWEEN:
|
||||||
|
case net::CookieStore::ChangeCause::EXPLICIT_DELETE_PREDICATE:
|
||||||
|
case net::CookieStore::ChangeCause::EXPLICIT_DELETE_SINGLE:
|
||||||
|
case net::CookieStore::ChangeCause::EXPLICIT_DELETE_CANONICAL:
|
||||||
return mate::StringToV8(isolate, "explicit");
|
return mate::StringToV8(isolate, "explicit");
|
||||||
case net::CookieStore::ChangeCause::OVERWRITE:
|
case net::CookieStore::ChangeCause::OVERWRITE:
|
||||||
return mate::StringToV8(isolate, "overwrite");
|
return mate::StringToV8(isolate, "overwrite");
|
||||||
|
@ -228,8 +232,8 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||||
GetCookieStore(getter)->SetCookieWithDetailsAsync(
|
GetCookieStore(getter)->SetCookieWithDetailsAsync(
|
||||||
GURL(url), name, value, domain, path, creation_time,
|
GURL(url), name, value, domain, path, creation_time,
|
||||||
expiration_time, last_access_time, secure, http_only,
|
expiration_time, last_access_time, secure, http_only,
|
||||||
net::CookieSameSite::DEFAULT_MODE, false,
|
net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT,
|
||||||
net::COOKIE_PRIORITY_DEFAULT, base::Bind(OnSetCookie, callback));
|
base::Bind(OnSetCookie, callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
#include "atom/browser/api/atom_api_desktop_capturer.h"
|
#include "atom/browser/api/atom_api_desktop_capturer.h"
|
||||||
|
|
||||||
|
using base::PlatformThreadRef;
|
||||||
|
|
||||||
#include "atom/common/api/atom_api_native_image.h"
|
#include "atom/common/api/atom_api_native_image.h"
|
||||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
|
|
|
@ -50,20 +50,25 @@ void RegisterStandardSchemes(const std::vector<std::string>& schemes,
|
||||||
mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
g_standard_schemes = schemes;
|
g_standard_schemes = schemes;
|
||||||
|
|
||||||
|
mate::Dictionary opts;
|
||||||
|
bool secure = false;
|
||||||
|
args->GetNext(&opts) && opts.Get("secure", &secure);
|
||||||
|
|
||||||
|
// Dynamically register the schemes.
|
||||||
auto* policy = content::ChildProcessSecurityPolicy::GetInstance();
|
auto* policy = content::ChildProcessSecurityPolicy::GetInstance();
|
||||||
for (const std::string& scheme : schemes) {
|
for (const std::string& scheme : schemes) {
|
||||||
url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITHOUT_PORT);
|
url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITHOUT_PORT);
|
||||||
|
if (secure) {
|
||||||
|
url::AddSecureScheme(scheme.c_str());
|
||||||
|
}
|
||||||
policy->RegisterWebSafeScheme(scheme);
|
policy->RegisterWebSafeScheme(scheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add switches to register as standard
|
// Add the schemes to command line switches, so child processes can also
|
||||||
|
// register them.
|
||||||
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
||||||
atom::switches::kStandardSchemes, base::JoinString(schemes, ","));
|
atom::switches::kStandardSchemes, base::JoinString(schemes, ","));
|
||||||
|
if (secure) {
|
||||||
mate::Dictionary opts;
|
|
||||||
bool secure = false;
|
|
||||||
if (args->GetNext(&opts) && opts.Get("secure", &secure) && secure) {
|
|
||||||
// add switches to register as secure
|
|
||||||
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
||||||
atom::switches::kSecureSchemes, base::JoinString(schemes, ","));
|
atom::switches::kSecureSchemes, base::JoinString(schemes, ","));
|
||||||
}
|
}
|
||||||
|
|
|
@ -432,7 +432,8 @@ void DownloadIdCallback(content::DownloadManager* download_manager,
|
||||||
last_modified, offset, length, std::string(),
|
last_modified, offset, length, std::string(),
|
||||||
content::DownloadItem::INTERRUPTED,
|
content::DownloadItem::INTERRUPTED,
|
||||||
content::DownloadDangerType::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
|
content::DownloadDangerType::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
|
||||||
content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT, false);
|
content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT, false,
|
||||||
|
std::vector<content::DownloadItem::ReceivedSlice>());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -76,6 +76,7 @@
|
||||||
#include "third_party/WebKit/public/platform/WebInputEvent.h"
|
#include "third_party/WebKit/public/platform/WebInputEvent.h"
|
||||||
#include "third_party/WebKit/public/web/WebFindOptions.h"
|
#include "third_party/WebKit/public/web/WebFindOptions.h"
|
||||||
#include "ui/display/screen.h"
|
#include "ui/display/screen.h"
|
||||||
|
#include "ui/events/base_event_utils.h"
|
||||||
|
|
||||||
#if !defined(OS_MACOSX)
|
#if !defined(OS_MACOSX)
|
||||||
#include "ui/aura/window.h"
|
#include "ui/aura/window.h"
|
||||||
|
@ -567,8 +568,8 @@ bool WebContents::PreHandleKeyboardEvent(
|
||||||
content::WebContents* source,
|
content::WebContents* source,
|
||||||
const content::NativeWebKeyboardEvent& event,
|
const content::NativeWebKeyboardEvent& event,
|
||||||
bool* is_keyboard_shortcut) {
|
bool* is_keyboard_shortcut) {
|
||||||
if (event.type == blink::WebInputEvent::Type::RawKeyDown
|
if (event.type() == blink::WebInputEvent::Type::RawKeyDown ||
|
||||||
|| event.type == blink::WebInputEvent::Type::KeyUp)
|
event.type() == blink::WebInputEvent::Type::KeyUp)
|
||||||
return Emit("before-input-event", event);
|
return Emit("before-input-event", event);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
@ -897,7 +898,7 @@ void WebContents::DevToolsOpened() {
|
||||||
devtools_web_contents_.Reset(isolate(), handle.ToV8());
|
devtools_web_contents_.Reset(isolate(), handle.ToV8());
|
||||||
|
|
||||||
// Set inspected tabID.
|
// Set inspected tabID.
|
||||||
base::FundamentalValue tab_id(ID());
|
base::Value tab_id(ID());
|
||||||
managed_web_contents()->CallClientFunction(
|
managed_web_contents()->CallClientFunction(
|
||||||
"DevToolsAPI.setInspectedTabId", &tab_id, nullptr, nullptr);
|
"DevToolsAPI.setInspectedTabId", &tab_id, nullptr, nullptr);
|
||||||
|
|
||||||
|
@ -970,7 +971,7 @@ void WebContents::NavigationEntryCommitted(
|
||||||
|
|
||||||
int64_t WebContents::GetID() const {
|
int64_t WebContents::GetID() const {
|
||||||
int64_t process_id = web_contents()->GetRenderProcessHost()->GetID();
|
int64_t process_id = web_contents()->GetRenderProcessHost()->GetID();
|
||||||
int64_t routing_id = web_contents()->GetRoutingID();
|
int64_t routing_id = web_contents()->GetRenderViewHost()->GetRoutingID();
|
||||||
int64_t rv = (process_id << 32) + routing_id;
|
int64_t rv = (process_id << 32) + routing_id;
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -1326,7 +1327,7 @@ void WebContents::SelectAll() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::Unselect() {
|
void WebContents::Unselect() {
|
||||||
web_contents()->Unselect();
|
web_contents()->CollapseSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::Replace(const base::string16& word) {
|
void WebContents::Replace(const base::string16& word) {
|
||||||
|
@ -1416,7 +1417,10 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (blink::WebInputEvent::isKeyboardEventType(type)) {
|
} else if (blink::WebInputEvent::isKeyboardEventType(type)) {
|
||||||
content::NativeWebKeyboardEvent keyboard_event;
|
content::NativeWebKeyboardEvent keyboard_event(
|
||||||
|
blink::WebKeyboardEvent::RawKeyDown,
|
||||||
|
blink::WebInputEvent::NoModifiers,
|
||||||
|
ui::EventTimeForNow());
|
||||||
if (mate::ConvertFromV8(isolate, input_event, &keyboard_event)) {
|
if (mate::ConvertFromV8(isolate, input_event, &keyboard_event)) {
|
||||||
host->ForwardKeyboardEvent(keyboard_event);
|
host->ForwardKeyboardEvent(keyboard_event);
|
||||||
return;
|
return;
|
||||||
|
@ -1506,8 +1510,7 @@ void WebContents::CapturePage(mate::Arguments* args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto view = web_contents()->GetRenderWidgetHostView();
|
const auto view = web_contents()->GetRenderWidgetHostView();
|
||||||
const auto host = view ? view->GetRenderWidgetHost() : nullptr;
|
if (!view) {
|
||||||
if (!view || !host) {
|
|
||||||
callback.Run(gfx::Image());
|
callback.Run(gfx::Image());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1527,10 +1530,10 @@ void WebContents::CapturePage(mate::Arguments* args) {
|
||||||
if (scale > 1.0f)
|
if (scale > 1.0f)
|
||||||
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
|
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
|
||||||
|
|
||||||
host->CopyFromBackingStore(gfx::Rect(rect.origin(), view_size),
|
view->CopyFromSurface(gfx::Rect(rect.origin(), view_size),
|
||||||
bitmap_size,
|
bitmap_size,
|
||||||
base::Bind(&OnCapturePageDone, callback),
|
base::Bind(&OnCapturePageDone, callback),
|
||||||
kBGRA_8888_SkColorType);
|
kBGRA_8888_SkColorType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::OnCursorChange(const content::WebCursor& cursor) {
|
void WebContents::OnCursorChange(const content::WebCursor& cursor) {
|
||||||
|
|
|
@ -24,6 +24,7 @@ FrameSubscriber::FrameSubscriber(v8::Isolate* isolate,
|
||||||
view_(view),
|
view_(view),
|
||||||
callback_(callback),
|
callback_(callback),
|
||||||
only_dirty_(only_dirty),
|
only_dirty_(only_dirty),
|
||||||
|
source_id_for_copy_request_(base::UnguessableToken::Create()),
|
||||||
weak_factory_(this) {
|
weak_factory_(this) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,8 +33,7 @@ bool FrameSubscriber::ShouldCaptureFrame(
|
||||||
base::TimeTicks present_time,
|
base::TimeTicks present_time,
|
||||||
scoped_refptr<media::VideoFrame>* storage,
|
scoped_refptr<media::VideoFrame>* storage,
|
||||||
DeliverFrameCallback* callback) {
|
DeliverFrameCallback* callback) {
|
||||||
const auto host = view_ ? view_->GetRenderWidgetHost() : nullptr;
|
if (!view_)
|
||||||
if (!view_ || !host)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (dirty_rect.IsEmpty())
|
if (dirty_rect.IsEmpty())
|
||||||
|
@ -54,7 +54,7 @@ bool FrameSubscriber::ShouldCaptureFrame(
|
||||||
|
|
||||||
rect = gfx::Rect(rect.origin(), bitmap_size);
|
rect = gfx::Rect(rect.origin(), bitmap_size);
|
||||||
|
|
||||||
host->CopyFromBackingStore(
|
view_->CopyFromSurface(
|
||||||
rect,
|
rect,
|
||||||
rect.size(),
|
rect.size(),
|
||||||
base::Bind(&FrameSubscriber::OnFrameDelivered,
|
base::Bind(&FrameSubscriber::OnFrameDelivered,
|
||||||
|
@ -64,6 +64,10 @@ bool FrameSubscriber::ShouldCaptureFrame(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const base::UnguessableToken& FrameSubscriber::GetSourceIdForCopyRequest() {
|
||||||
|
return source_id_for_copy_request_;
|
||||||
|
}
|
||||||
|
|
||||||
void FrameSubscriber::OnFrameDelivered(const FrameCaptureCallback& callback,
|
void FrameSubscriber::OnFrameDelivered(const FrameCaptureCallback& callback,
|
||||||
const gfx::Rect& damage_rect,
|
const gfx::Rect& damage_rect,
|
||||||
const SkBitmap& bitmap,
|
const SkBitmap& bitmap,
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
#include "base/callback.h"
|
#include "base/callback.h"
|
||||||
#include "base/memory/weak_ptr.h"
|
#include "base/memory/weak_ptr.h"
|
||||||
|
#include "content/browser/renderer_host/render_widget_host_view_frame_subscriber.h"
|
||||||
#include "content/public/browser/readback_types.h"
|
#include "content/public/browser/readback_types.h"
|
||||||
#include "content/public/browser/render_widget_host_view.h"
|
#include "content/public/browser/render_widget_host_view.h"
|
||||||
#include "content/public/browser/render_widget_host_view_frame_subscriber.h"
|
|
||||||
#include "third_party/skia/include/core/SkBitmap.h"
|
#include "third_party/skia/include/core/SkBitmap.h"
|
||||||
#include "ui/gfx/geometry/size.h"
|
#include "ui/gfx/geometry/size.h"
|
||||||
#include "v8/include/v8.h"
|
#include "v8/include/v8.h"
|
||||||
|
@ -32,6 +32,7 @@ class FrameSubscriber : public content::RenderWidgetHostViewFrameSubscriber {
|
||||||
base::TimeTicks present_time,
|
base::TimeTicks present_time,
|
||||||
scoped_refptr<media::VideoFrame>* storage,
|
scoped_refptr<media::VideoFrame>* storage,
|
||||||
DeliverFrameCallback* callback) override;
|
DeliverFrameCallback* callback) override;
|
||||||
|
const base::UnguessableToken& GetSourceIdForCopyRequest() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnFrameDelivered(const FrameCaptureCallback& callback,
|
void OnFrameDelivered(const FrameCaptureCallback& callback,
|
||||||
|
@ -44,6 +45,8 @@ class FrameSubscriber : public content::RenderWidgetHostViewFrameSubscriber {
|
||||||
FrameCaptureCallback callback_;
|
FrameCaptureCallback callback_;
|
||||||
bool only_dirty_;
|
bool only_dirty_;
|
||||||
|
|
||||||
|
base::UnguessableToken source_id_for_copy_request_;
|
||||||
|
|
||||||
base::WeakPtrFactory<FrameSubscriber> weak_factory_;
|
base::WeakPtrFactory<FrameSubscriber> weak_factory_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(FrameSubscriber);
|
DISALLOW_COPY_AND_ASSIGN(FrameSubscriber);
|
||||||
|
|
|
@ -296,27 +296,26 @@ void AtomBrowserClient::ResourceDispatcherHostCreated() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AtomBrowserClient::CanCreateWindow(
|
bool AtomBrowserClient::CanCreateWindow(
|
||||||
|
int opener_render_process_id,
|
||||||
|
int opener_render_frame_id,
|
||||||
const GURL& opener_url,
|
const GURL& opener_url,
|
||||||
const GURL& opener_top_level_frame_url,
|
const GURL& opener_top_level_frame_url,
|
||||||
const GURL& source_origin,
|
const GURL& source_origin,
|
||||||
WindowContainerType container_type,
|
content::mojom::WindowContainerType container_type,
|
||||||
const GURL& target_url,
|
const GURL& target_url,
|
||||||
const content::Referrer& referrer,
|
const content::Referrer& referrer,
|
||||||
const std::string& frame_name,
|
const std::string& frame_name,
|
||||||
WindowOpenDisposition disposition,
|
WindowOpenDisposition disposition,
|
||||||
const blink::WebWindowFeatures& features,
|
const blink::mojom::WindowFeatures& features,
|
||||||
const std::vector<std::string>& additional_features,
|
const std::vector<std::string>& additional_features,
|
||||||
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
|
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
|
||||||
bool user_gesture,
|
bool user_gesture,
|
||||||
bool opener_suppressed,
|
bool opener_suppressed,
|
||||||
content::ResourceContext* context,
|
content::ResourceContext* context,
|
||||||
int render_process_id,
|
|
||||||
int opener_render_view_id,
|
|
||||||
int opener_render_frame_id,
|
|
||||||
bool* no_javascript_access) {
|
bool* no_javascript_access) {
|
||||||
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
||||||
|
|
||||||
if (IsRendererSandboxed(render_process_id)) {
|
if (IsRendererSandboxed(opener_render_process_id)) {
|
||||||
*no_javascript_access = false;
|
*no_javascript_access = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -330,7 +329,7 @@ bool AtomBrowserClient::CanCreateWindow(
|
||||||
disposition,
|
disposition,
|
||||||
additional_features,
|
additional_features,
|
||||||
body,
|
body,
|
||||||
render_process_id,
|
opener_render_process_id,
|
||||||
opener_render_frame_id));
|
opener_render_frame_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,23 +80,22 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||||
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
|
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
|
||||||
void ResourceDispatcherHostCreated() override;
|
void ResourceDispatcherHostCreated() override;
|
||||||
bool CanCreateWindow(
|
bool CanCreateWindow(
|
||||||
|
int opener_render_process_id,
|
||||||
|
int opener_render_frame_id,
|
||||||
const GURL& opener_url,
|
const GURL& opener_url,
|
||||||
const GURL& opener_top_level_frame_url,
|
const GURL& opener_top_level_frame_url,
|
||||||
const GURL& source_origin,
|
const GURL& source_origin,
|
||||||
WindowContainerType container_type,
|
content::mojom::WindowContainerType container_type,
|
||||||
const GURL& target_url,
|
const GURL& target_url,
|
||||||
const content::Referrer& referrer,
|
const content::Referrer& referrer,
|
||||||
const std::string& frame_name,
|
const std::string& frame_name,
|
||||||
WindowOpenDisposition disposition,
|
WindowOpenDisposition disposition,
|
||||||
const blink::WebWindowFeatures& features,
|
const blink::mojom::WindowFeatures& features,
|
||||||
const std::vector<std::string>& additional_features,
|
const std::vector<std::string>& additional_features,
|
||||||
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
|
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
|
||||||
bool user_gesture,
|
bool user_gesture,
|
||||||
bool opener_suppressed,
|
bool opener_suppressed,
|
||||||
content::ResourceContext* context,
|
content::ResourceContext* context,
|
||||||
int render_process_id,
|
|
||||||
int opener_render_view_id,
|
|
||||||
int opener_render_frame_id,
|
|
||||||
bool* no_javascript_access) override;
|
bool* no_javascript_access) override;
|
||||||
void GetAdditionalAllowedSchemesForFileSystem(
|
void GetAdditionalAllowedSchemesForFileSystem(
|
||||||
std::vector<std::string>* schemes) override;
|
std::vector<std::string>* schemes) override;
|
||||||
|
|
|
@ -13,27 +13,27 @@
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "ui/gfx/image/image_skia.h"
|
#include "ui/gfx/image/image_skia.h"
|
||||||
|
|
||||||
using content::JavaScriptMessageType;
|
using content::JavaScriptDialogType;
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
void AtomJavaScriptDialogManager::RunJavaScriptDialog(
|
void AtomJavaScriptDialogManager::RunJavaScriptDialog(
|
||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
const GURL& origin_url,
|
const GURL& origin_url,
|
||||||
JavaScriptMessageType message_type,
|
JavaScriptDialogType dialog_type,
|
||||||
const base::string16& message_text,
|
const base::string16& message_text,
|
||||||
const base::string16& default_prompt_text,
|
const base::string16& default_prompt_text,
|
||||||
const DialogClosedCallback& callback,
|
const DialogClosedCallback& callback,
|
||||||
bool* did_suppress_message) {
|
bool* did_suppress_message) {
|
||||||
|
|
||||||
if (message_type != JavaScriptMessageType::JAVASCRIPT_MESSAGE_TYPE_ALERT &&
|
if (dialog_type != JavaScriptDialogType::JAVASCRIPT_DIALOG_TYPE_ALERT &&
|
||||||
message_type != JavaScriptMessageType::JAVASCRIPT_MESSAGE_TYPE_CONFIRM) {
|
dialog_type != JavaScriptDialogType::JAVASCRIPT_DIALOG_TYPE_CONFIRM) {
|
||||||
callback.Run(false, base::string16());
|
callback.Run(false, base::string16());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> buttons = {"OK"};
|
std::vector<std::string> buttons = {"OK"};
|
||||||
if (message_type == JavaScriptMessageType::JAVASCRIPT_MESSAGE_TYPE_CONFIRM) {
|
if (dialog_type == JavaScriptDialogType::JAVASCRIPT_DIALOG_TYPE_CONFIRM) {
|
||||||
buttons.push_back("Cancel");
|
buttons.push_back("Cancel");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,6 @@ void AtomJavaScriptDialogManager::RunBeforeUnloadDialog(
|
||||||
|
|
||||||
void AtomJavaScriptDialogManager::CancelDialogs(
|
void AtomJavaScriptDialogManager::CancelDialogs(
|
||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
bool suppress_callbacks,
|
|
||||||
bool reset_state) {
|
bool reset_state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
|
||||||
void RunJavaScriptDialog(
|
void RunJavaScriptDialog(
|
||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
const GURL& origin_url,
|
const GURL& origin_url,
|
||||||
content::JavaScriptMessageType javascript_message_type,
|
content::JavaScriptDialogType dialog_type,
|
||||||
const base::string16& message_text,
|
const base::string16& message_text,
|
||||||
const base::string16& default_prompt_text,
|
const base::string16& default_prompt_text,
|
||||||
const DialogClosedCallback& callback,
|
const DialogClosedCallback& callback,
|
||||||
|
@ -27,7 +27,6 @@ class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
|
||||||
bool is_reload,
|
bool is_reload,
|
||||||
const DialogClosedCallback& callback) override;
|
const DialogClosedCallback& callback) override;
|
||||||
void CancelDialogs(content::WebContents* web_contents,
|
void CancelDialogs(content::WebContents* web_contents,
|
||||||
bool suppress_callbacks,
|
|
||||||
bool reset_state) override;
|
bool reset_state) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -131,7 +131,7 @@ int AtomPermissionManager::RequestPermissions(
|
||||||
|
|
||||||
auto web_contents =
|
auto web_contents =
|
||||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||||
int request_id = pending_requests_.Add(new PendingRequest(
|
int request_id = pending_requests_.Add(base::MakeUnique<PendingRequest>(
|
||||||
render_frame_host, permissions, response_callback));
|
render_frame_host, permissions, response_callback));
|
||||||
|
|
||||||
for (size_t i = 0; i < permissions.size(); ++i) {
|
for (size_t i = 0; i < permissions.size(); ++i) {
|
||||||
|
@ -187,12 +187,6 @@ blink::mojom::PermissionStatus AtomPermissionManager::GetPermissionStatus(
|
||||||
return blink::mojom::PermissionStatus::GRANTED;
|
return blink::mojom::PermissionStatus::GRANTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomPermissionManager::RegisterPermissionUsage(
|
|
||||||
content::PermissionType permission,
|
|
||||||
const GURL& requesting_origin,
|
|
||||||
const GURL& embedding_origin) {
|
|
||||||
}
|
|
||||||
|
|
||||||
int AtomPermissionManager::SubscribePermissionStatusChange(
|
int AtomPermissionManager::SubscribePermissionStatusChange(
|
||||||
content::PermissionType permission,
|
content::PermissionType permission,
|
||||||
const GURL& requesting_origin,
|
const GURL& requesting_origin,
|
||||||
|
|
|
@ -66,9 +66,6 @@ class AtomPermissionManager : public content::PermissionManager {
|
||||||
content::PermissionType permission,
|
content::PermissionType permission,
|
||||||
const GURL& requesting_origin,
|
const GURL& requesting_origin,
|
||||||
const GURL& embedding_origin) override;
|
const GURL& embedding_origin) override;
|
||||||
void RegisterPermissionUsage(content::PermissionType permission,
|
|
||||||
const GURL& requesting_origin,
|
|
||||||
const GURL& embedding_origin) override;
|
|
||||||
int SubscribePermissionStatusChange(
|
int SubscribePermissionStatusChange(
|
||||||
content::PermissionType permission,
|
content::PermissionType permission,
|
||||||
const GURL& requesting_origin,
|
const GURL& requesting_origin,
|
||||||
|
@ -79,7 +76,7 @@ class AtomPermissionManager : public content::PermissionManager {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class PendingRequest;
|
class PendingRequest;
|
||||||
using PendingRequestsMap = IDMap<PendingRequest, IDMapOwnPointer>;
|
using PendingRequestsMap = IDMap<std::unique_ptr<PendingRequest>>;
|
||||||
|
|
||||||
RequestHandler request_handler_;
|
RequestHandler request_handler_;
|
||||||
|
|
||||||
|
|
|
@ -494,9 +494,9 @@ void CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated(
|
||||||
int request_id,
|
int request_id,
|
||||||
const std::string& file_system_path,
|
const std::string& file_system_path,
|
||||||
int total_work) {
|
int total_work) {
|
||||||
base::FundamentalValue request_id_value(request_id);
|
base::Value request_id_value(request_id);
|
||||||
base::StringValue file_system_path_value(file_system_path);
|
base::StringValue file_system_path_value(file_system_path);
|
||||||
base::FundamentalValue total_work_value(total_work);
|
base::Value total_work_value(total_work);
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.indexingTotalWorkCalculated",
|
web_contents_->CallClientFunction("DevToolsAPI.indexingTotalWorkCalculated",
|
||||||
&request_id_value,
|
&request_id_value,
|
||||||
&file_system_path_value,
|
&file_system_path_value,
|
||||||
|
@ -507,9 +507,9 @@ void CommonWebContentsDelegate::OnDevToolsIndexingWorked(
|
||||||
int request_id,
|
int request_id,
|
||||||
const std::string& file_system_path,
|
const std::string& file_system_path,
|
||||||
int worked) {
|
int worked) {
|
||||||
base::FundamentalValue request_id_value(request_id);
|
base::Value request_id_value(request_id);
|
||||||
base::StringValue file_system_path_value(file_system_path);
|
base::StringValue file_system_path_value(file_system_path);
|
||||||
base::FundamentalValue worked_value(worked);
|
base::Value worked_value(worked);
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.indexingWorked",
|
web_contents_->CallClientFunction("DevToolsAPI.indexingWorked",
|
||||||
&request_id_value,
|
&request_id_value,
|
||||||
&file_system_path_value,
|
&file_system_path_value,
|
||||||
|
@ -520,7 +520,7 @@ void CommonWebContentsDelegate::OnDevToolsIndexingDone(
|
||||||
int request_id,
|
int request_id,
|
||||||
const std::string& file_system_path) {
|
const std::string& file_system_path) {
|
||||||
devtools_indexing_jobs_.erase(request_id);
|
devtools_indexing_jobs_.erase(request_id);
|
||||||
base::FundamentalValue request_id_value(request_id);
|
base::Value request_id_value(request_id);
|
||||||
base::StringValue file_system_path_value(file_system_path);
|
base::StringValue file_system_path_value(file_system_path);
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.indexingDone",
|
web_contents_->CallClientFunction("DevToolsAPI.indexingDone",
|
||||||
&request_id_value,
|
&request_id_value,
|
||||||
|
@ -536,7 +536,7 @@ void CommonWebContentsDelegate::OnDevToolsSearchCompleted(
|
||||||
for (const auto& file_path : file_paths) {
|
for (const auto& file_path : file_paths) {
|
||||||
file_paths_value.AppendString(file_path);
|
file_paths_value.AppendString(file_path);
|
||||||
}
|
}
|
||||||
base::FundamentalValue request_id_value(request_id);
|
base::Value request_id_value(request_id);
|
||||||
base::StringValue file_system_path_value(file_system_path);
|
base::StringValue file_system_path_value(file_system_path);
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.searchCompleted",
|
web_contents_->CallClientFunction("DevToolsAPI.searchCompleted",
|
||||||
&request_id_value,
|
&request_id_value,
|
||||||
|
|
|
@ -20,7 +20,7 @@ void CommonWebContentsDelegate::HandleKeyboardEvent(
|
||||||
content::WebContents* source,
|
content::WebContents* source,
|
||||||
const content::NativeWebKeyboardEvent& event) {
|
const content::NativeWebKeyboardEvent& event) {
|
||||||
if (event.skip_in_browser ||
|
if (event.skip_in_browser ||
|
||||||
event.type == content::NativeWebKeyboardEvent::Char)
|
event.type() == content::NativeWebKeyboardEvent::Char)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Escape exits tabbed fullscreen mode.
|
// Escape exits tabbed fullscreen mode.
|
||||||
|
|
|
@ -8,16 +8,45 @@
|
||||||
|
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
#include "base/message_loop/message_loop.h"
|
#include "base/message_loop/message_loop.h"
|
||||||
|
#include "base/threading/thread_task_runner_handle.h"
|
||||||
#include "content/public/common/content_switches.h"
|
#include "content/public/common/content_switches.h"
|
||||||
#include "gin/array_buffer.h"
|
|
||||||
#include "gin/v8_initializer.h"
|
#include "gin/v8_initializer.h"
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
#include "atom/node/osfhandle.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "atom/common/node_includes.h"
|
#include "atom/common/node_includes.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
void* ArrayBufferAllocator::Allocate(size_t length) {
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
return node::ArrayBufferCalloc(length);
|
||||||
|
#else
|
||||||
|
return calloc(1, length);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void* ArrayBufferAllocator::AllocateUninitialized(size_t length) {
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
return node::ArrayBufferMalloc(length);
|
||||||
|
#else
|
||||||
|
return malloc(length);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArrayBufferAllocator::Free(void* data, size_t length) {
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
node::ArrayBufferFree(data, length);
|
||||||
|
#else
|
||||||
|
free(data);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
JavascriptEnvironment::JavascriptEnvironment()
|
JavascriptEnvironment::JavascriptEnvironment()
|
||||||
: initialized_(Initialize()),
|
: initialized_(Initialize()),
|
||||||
|
isolate_holder_(base::ThreadTaskRunnerHandle::Get()),
|
||||||
isolate_(isolate_holder_.isolate()),
|
isolate_(isolate_holder_.isolate()),
|
||||||
isolate_scope_(isolate_),
|
isolate_scope_(isolate_),
|
||||||
locker_(isolate_),
|
locker_(isolate_),
|
||||||
|
@ -44,7 +73,7 @@ bool JavascriptEnvironment::Initialize() {
|
||||||
|
|
||||||
gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
|
gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
|
||||||
gin::IsolateHolder::kStableV8Extras,
|
gin::IsolateHolder::kStableV8Extras,
|
||||||
gin::ArrayBufferAllocator::SharedInstance());
|
&allocator_);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,14 @@ class Environment;
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
// ArrayBuffer's allocator, used on Chromium's side.
|
||||||
|
class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
|
||||||
|
public:
|
||||||
|
void* Allocate(size_t length) override;
|
||||||
|
void* AllocateUninitialized(size_t length) override;
|
||||||
|
void Free(void* data, size_t length) override;
|
||||||
|
};
|
||||||
|
|
||||||
// Manage the V8 isolate and context automatically.
|
// Manage the V8 isolate and context automatically.
|
||||||
class JavascriptEnvironment {
|
class JavascriptEnvironment {
|
||||||
public:
|
public:
|
||||||
|
@ -31,6 +39,7 @@ class JavascriptEnvironment {
|
||||||
bool Initialize();
|
bool Initialize();
|
||||||
|
|
||||||
bool initialized_;
|
bool initialized_;
|
||||||
|
ArrayBufferAllocator allocator_;
|
||||||
gin::IsolateHolder isolate_holder_;
|
gin::IsolateHolder isolate_holder_;
|
||||||
v8::Isolate* isolate_;
|
v8::Isolate* isolate_;
|
||||||
v8::Isolate::Scope isolate_scope_;
|
v8::Isolate::Scope isolate_scope_;
|
||||||
|
|
|
@ -15,12 +15,12 @@ LayeredResourceHandler::LayeredResourceHandler(
|
||||||
|
|
||||||
LayeredResourceHandler::~LayeredResourceHandler() {}
|
LayeredResourceHandler::~LayeredResourceHandler() {}
|
||||||
|
|
||||||
bool LayeredResourceHandler::OnResponseStarted(
|
void LayeredResourceHandler::OnResponseStarted(
|
||||||
content::ResourceResponse* response,
|
content::ResourceResponse* response,
|
||||||
bool* defer) {
|
std::unique_ptr<content::ResourceController> controller) {
|
||||||
if (delegate_)
|
if (delegate_)
|
||||||
delegate_->OnResponseStarted(response);
|
delegate_->OnResponseStarted(response);
|
||||||
return next_handler_->OnResponseStarted(response, defer);
|
next_handler_->OnResponseStarted(response, std::move(controller));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -26,8 +26,9 @@ class LayeredResourceHandler : public content::LayeredResourceHandler {
|
||||||
~LayeredResourceHandler() override;
|
~LayeredResourceHandler() override;
|
||||||
|
|
||||||
// content::LayeredResourceHandler:
|
// content::LayeredResourceHandler:
|
||||||
bool OnResponseStarted(content::ResourceResponse* response,
|
void OnResponseStarted(
|
||||||
bool* defer) override;
|
content::ResourceResponse* response,
|
||||||
|
std::unique_ptr<content::ResourceController> controller) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Delegate* delegate_;
|
Delegate* delegate_;
|
||||||
|
|
|
@ -1458,7 +1458,7 @@ void NativeWindowMac::SetEscapeTouchBarItem(const mate::PersistentDictionary& it
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::OnInputEvent(const blink::WebInputEvent& event) {
|
void NativeWindowMac::OnInputEvent(const blink::WebInputEvent& event) {
|
||||||
switch (event.type) {
|
switch (event.type()) {
|
||||||
case blink::WebInputEvent::GestureScrollBegin:
|
case blink::WebInputEvent::GestureScrollBegin:
|
||||||
case blink::WebInputEvent::GestureScrollUpdate:
|
case blink::WebInputEvent::GestureScrollUpdate:
|
||||||
case blink::WebInputEvent::GestureScrollEnd:
|
case blink::WebInputEvent::GestureScrollEnd:
|
||||||
|
|
|
@ -86,7 +86,7 @@ bool IsAltKey(const content::NativeWebKeyboardEvent& event) {
|
||||||
|
|
||||||
bool IsAltModifier(const content::NativeWebKeyboardEvent& event) {
|
bool IsAltModifier(const content::NativeWebKeyboardEvent& event) {
|
||||||
typedef content::NativeWebKeyboardEvent::Modifiers Modifiers;
|
typedef content::NativeWebKeyboardEvent::Modifiers Modifiers;
|
||||||
int modifiers = event.modifiers;
|
int modifiers = event.modifiers();
|
||||||
modifiers &= ~Modifiers::NumLockOn;
|
modifiers &= ~Modifiers::NumLockOn;
|
||||||
modifiers &= ~Modifiers::CapsLockOn;
|
modifiers &= ~Modifiers::CapsLockOn;
|
||||||
return (modifiers == Modifiers::AltKey) ||
|
return (modifiers == Modifiers::AltKey) ||
|
||||||
|
@ -767,13 +767,14 @@ void NativeWindowViews::SetBackgroundColor(const std::string& color_name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowViews::SetHasShadow(bool has_shadow) {
|
void NativeWindowViews::SetHasShadow(bool has_shadow) {
|
||||||
wm::SetShadowType(
|
wm::SetShadowElevation(
|
||||||
GetNativeWindow(),
|
GetNativeWindow(),
|
||||||
has_shadow ? wm::SHADOW_TYPE_RECTANGULAR : wm::SHADOW_TYPE_NONE);
|
has_shadow ? wm::ShadowElevation::MEDIUM : wm::ShadowElevation::NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeWindowViews::HasShadow() {
|
bool NativeWindowViews::HasShadow() {
|
||||||
return wm::GetShadowType(GetNativeWindow()) != wm::SHADOW_TYPE_NONE;
|
return GetNativeWindow()->GetProperty(wm::kShadowElevationKey)
|
||||||
|
!= wm::ShadowElevation::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowViews::SetIgnoreMouseEvents(bool ignore) {
|
void NativeWindowViews::SetIgnoreMouseEvents(bool ignore) {
|
||||||
|
@ -1234,10 +1235,10 @@ void NativeWindowViews::HandleKeyboardEvent(
|
||||||
// Show accelerator when "Alt" is pressed.
|
// Show accelerator when "Alt" is pressed.
|
||||||
if (menu_bar_visible_ && IsAltKey(event))
|
if (menu_bar_visible_ && IsAltKey(event))
|
||||||
menu_bar_->SetAcceleratorVisibility(
|
menu_bar_->SetAcceleratorVisibility(
|
||||||
event.type == blink::WebInputEvent::RawKeyDown);
|
event.type() == blink::WebInputEvent::RawKeyDown);
|
||||||
|
|
||||||
// Show the submenu when "Alt+Key" is pressed.
|
// Show the submenu when "Alt+Key" is pressed.
|
||||||
if (event.type == blink::WebInputEvent::RawKeyDown && !IsAltKey(event) &&
|
if (event.type() == blink::WebInputEvent::RawKeyDown && !IsAltKey(event) &&
|
||||||
IsAltModifier(event)) {
|
IsAltModifier(event)) {
|
||||||
if (!menu_bar_visible_ &&
|
if (!menu_bar_visible_ &&
|
||||||
(menu_bar_->GetAcceleratorIndex(event.windowsKeyCode) != -1))
|
(menu_bar_->GetAcceleratorIndex(event.windowsKeyCode) != -1))
|
||||||
|
@ -1250,10 +1251,10 @@ void NativeWindowViews::HandleKeyboardEvent(
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Toggle the menu bar only when a single Alt is released.
|
// Toggle the menu bar only when a single Alt is released.
|
||||||
if (event.type == blink::WebInputEvent::RawKeyDown && IsAltKey(event)) {
|
if (event.type() == blink::WebInputEvent::RawKeyDown && IsAltKey(event)) {
|
||||||
// When a single Alt is pressed:
|
// When a single Alt is pressed:
|
||||||
menu_bar_alt_pressed_ = true;
|
menu_bar_alt_pressed_ = true;
|
||||||
} else if (event.type == blink::WebInputEvent::KeyUp && IsAltKey(event) &&
|
} else if (event.type() == blink::WebInputEvent::KeyUp && IsAltKey(event) &&
|
||||||
menu_bar_alt_pressed_) {
|
menu_bar_alt_pressed_) {
|
||||||
// When a single Alt is released right after a Alt is pressed:
|
// When a single Alt is released right after a Alt is pressed:
|
||||||
menu_bar_alt_pressed_ = false;
|
menu_bar_alt_pressed_ = false;
|
||||||
|
|
|
@ -50,15 +50,16 @@ bool AtomURLRequestJobFactory::InterceptProtocol(
|
||||||
return false;
|
return false;
|
||||||
ProtocolHandler* original_protocol_handler = protocol_handler_map_[scheme];
|
ProtocolHandler* original_protocol_handler = protocol_handler_map_[scheme];
|
||||||
protocol_handler_map_[scheme] = protocol_handler.release();
|
protocol_handler_map_[scheme] = protocol_handler.release();
|
||||||
original_protocols_.set(scheme, base::WrapUnique(original_protocol_handler));
|
original_protocols_[scheme].reset(original_protocol_handler);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AtomURLRequestJobFactory::UninterceptProtocol(const std::string& scheme) {
|
bool AtomURLRequestJobFactory::UninterceptProtocol(const std::string& scheme) {
|
||||||
if (!original_protocols_.contains(scheme))
|
auto it = original_protocols_.find(scheme);
|
||||||
|
if (it == original_protocols_.end())
|
||||||
return false;
|
return false;
|
||||||
protocol_handler_map_[scheme] =
|
protocol_handler_map_[scheme] = it->second.release();
|
||||||
original_protocols_.take_and_erase(scheme).release();
|
original_protocols_.erase(it);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +79,9 @@ bool AtomURLRequestJobFactory::HasProtocolHandler(
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomURLRequestJobFactory::Clear() {
|
void AtomURLRequestJobFactory::Clear() {
|
||||||
base::STLDeleteValues(&protocol_handler_map_);
|
for (auto& it : protocol_handler_map_)
|
||||||
|
delete it.second;
|
||||||
|
protocol_handler_map_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
net::URLRequestJob* AtomURLRequestJobFactory::MaybeCreateJobWithProtocolHandler(
|
net::URLRequestJob* AtomURLRequestJobFactory::MaybeCreateJobWithProtocolHandler(
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/containers/scoped_ptr_hash_map.h"
|
|
||||||
#include "net/url_request/url_request_job_factory.h"
|
#include "net/url_request/url_request_job_factory.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
@ -64,7 +64,7 @@ class AtomURLRequestJobFactory : public net::URLRequestJobFactory {
|
||||||
ProtocolHandlerMap protocol_handler_map_;
|
ProtocolHandlerMap protocol_handler_map_;
|
||||||
|
|
||||||
// Map that stores the original protocols of schemes.
|
// Map that stores the original protocols of schemes.
|
||||||
using OriginalProtocolsMap = base::ScopedPtrHashMap<
|
using OriginalProtocolsMap = std::unordered_map<
|
||||||
std::string, std::unique_ptr<ProtocolHandler>>;
|
std::string, std::unique_ptr<ProtocolHandler>>;
|
||||||
// Can only be accessed in IO thread.
|
// Can only be accessed in IO thread.
|
||||||
OriginalProtocolsMap original_protocols_;
|
OriginalProtocolsMap original_protocols_;
|
||||||
|
|
|
@ -59,11 +59,11 @@ void AskForOptions(v8::Isolate* isolate,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsErrorOptions(base::Value* value, int* error) {
|
bool IsErrorOptions(base::Value* value, int* error) {
|
||||||
if (value->IsType(base::Value::TYPE_DICTIONARY)) {
|
if (value->IsType(base::Value::Type::DICTIONARY)) {
|
||||||
base::DictionaryValue* dict = static_cast<base::DictionaryValue*>(value);
|
base::DictionaryValue* dict = static_cast<base::DictionaryValue*>(value);
|
||||||
if (dict->GetInteger("error", error))
|
if (dict->GetInteger("error", error))
|
||||||
return true;
|
return true;
|
||||||
} else if (value->IsType(base::Value::TYPE_INTEGER)) {
|
} else if (value->IsType(base::Value::Type::INTEGER)) {
|
||||||
if (value->GetAsInteger(error))
|
if (value->GetAsInteger(error))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "atom/common/atom_constants.h"
|
#include "atom/common/atom_constants.h"
|
||||||
|
#include "base/threading/sequenced_worker_pool.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
@ -18,10 +19,10 @@ URLRequestAsyncAsarJob::URLRequestAsyncAsarJob(
|
||||||
|
|
||||||
void URLRequestAsyncAsarJob::StartAsync(std::unique_ptr<base::Value> options) {
|
void URLRequestAsyncAsarJob::StartAsync(std::unique_ptr<base::Value> options) {
|
||||||
base::FilePath::StringType file_path;
|
base::FilePath::StringType file_path;
|
||||||
if (options->IsType(base::Value::TYPE_DICTIONARY)) {
|
if (options->IsType(base::Value::Type::DICTIONARY)) {
|
||||||
static_cast<base::DictionaryValue*>(options.get())->GetString(
|
static_cast<base::DictionaryValue*>(options.get())->GetString(
|
||||||
"path", &file_path);
|
"path", &file_path);
|
||||||
} else if (options->IsType(base::Value::TYPE_STRING)) {
|
} else if (options->IsType(base::Value::Type::STRING)) {
|
||||||
options->GetAsString(&file_path);
|
options->GetAsString(&file_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,13 +34,13 @@ URLRequestBufferJob::URLRequestBufferJob(
|
||||||
|
|
||||||
void URLRequestBufferJob::StartAsync(std::unique_ptr<base::Value> options) {
|
void URLRequestBufferJob::StartAsync(std::unique_ptr<base::Value> options) {
|
||||||
const base::BinaryValue* binary = nullptr;
|
const base::BinaryValue* binary = nullptr;
|
||||||
if (options->IsType(base::Value::TYPE_DICTIONARY)) {
|
if (options->IsType(base::Value::Type::DICTIONARY)) {
|
||||||
base::DictionaryValue* dict =
|
base::DictionaryValue* dict =
|
||||||
static_cast<base::DictionaryValue*>(options.get());
|
static_cast<base::DictionaryValue*>(options.get());
|
||||||
dict->GetString("mimeType", &mime_type_);
|
dict->GetString("mimeType", &mime_type_);
|
||||||
dict->GetString("charset", &charset_);
|
dict->GetString("charset", &charset_);
|
||||||
dict->GetBinary("data", &binary);
|
dict->GetBinary("data", &binary);
|
||||||
} else if (options->IsType(base::Value::TYPE_BINARY)) {
|
} else if (options->IsType(base::Value::Type::BINARY)) {
|
||||||
options->GetAsBinary(&binary);
|
options->GetAsBinary(&binary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ void URLRequestFetchJob::BeforeStartInUI(
|
||||||
}
|
}
|
||||||
|
|
||||||
void URLRequestFetchJob::StartAsync(std::unique_ptr<base::Value> options) {
|
void URLRequestFetchJob::StartAsync(std::unique_ptr<base::Value> options) {
|
||||||
if (!options->IsType(base::Value::TYPE_DICTIONARY)) {
|
if (!options->IsType(base::Value::Type::DICTIONARY)) {
|
||||||
NotifyStartError(net::URLRequestStatus(
|
NotifyStartError(net::URLRequestStatus(
|
||||||
net::URLRequestStatus::FAILED, net::ERR_NOT_IMPLEMENTED));
|
net::URLRequestStatus::FAILED, net::ERR_NOT_IMPLEMENTED));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -17,13 +17,13 @@ URLRequestStringJob::URLRequestStringJob(
|
||||||
}
|
}
|
||||||
|
|
||||||
void URLRequestStringJob::StartAsync(std::unique_ptr<base::Value> options) {
|
void URLRequestStringJob::StartAsync(std::unique_ptr<base::Value> options) {
|
||||||
if (options->IsType(base::Value::TYPE_DICTIONARY)) {
|
if (options->IsType(base::Value::Type::DICTIONARY)) {
|
||||||
base::DictionaryValue* dict =
|
base::DictionaryValue* dict =
|
||||||
static_cast<base::DictionaryValue*>(options.get());
|
static_cast<base::DictionaryValue*>(options.get());
|
||||||
dict->GetString("mimeType", &mime_type_);
|
dict->GetString("mimeType", &mime_type_);
|
||||||
dict->GetString("charset", &charset_);
|
dict->GetString("charset", &charset_);
|
||||||
dict->GetString("data", &data_);
|
dict->GetString("data", &data_);
|
||||||
} else if (options->IsType(base::Value::TYPE_STRING)) {
|
} else if (options->IsType(base::Value::Type::STRING)) {
|
||||||
options->GetAsString(&data_);
|
options->GetAsString(&data_);
|
||||||
}
|
}
|
||||||
net::URLRequestSimpleJob::Start();
|
net::URLRequestSimpleJob::Start();
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include "atom/browser/osr/osr_output_device.h"
|
#include "atom/browser/osr/osr_output_device.h"
|
||||||
|
|
||||||
#include "third_party/skia/include/core/SkDevice.h"
|
#include "third_party/skia/src/core/SkDevice.h"
|
||||||
#include "ui/gfx/skia_util.h"
|
#include "ui/gfx/skia_util.h"
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
|
@ -16,10 +16,11 @@
|
||||||
#include "components/display_compositor/gl_helper.h"
|
#include "components/display_compositor/gl_helper.h"
|
||||||
#include "content/browser/renderer_host/render_widget_host_delegate.h"
|
#include "content/browser/renderer_host/render_widget_host_delegate.h"
|
||||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||||
|
#include "content/browser/renderer_host/render_widget_host_view_frame_subscriber.h"
|
||||||
#include "content/common/view_messages.h"
|
#include "content/common/view_messages.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "content/public/browser/context_factory.h"
|
#include "content/public/browser/context_factory.h"
|
||||||
#include "content/public/browser/render_widget_host_view_frame_subscriber.h"
|
#include "media/base/video_frame.h"
|
||||||
#include "ui/compositor/compositor.h"
|
#include "ui/compositor/compositor.h"
|
||||||
#include "ui/compositor/layer.h"
|
#include "ui/compositor/layer.h"
|
||||||
#include "ui/compositor/layer_type.h"
|
#include "ui/compositor/layer_type.h"
|
||||||
|
@ -337,6 +338,7 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
|
||||||
bool transparent,
|
bool transparent,
|
||||||
const OnPaintCallback& callback,
|
const OnPaintCallback& callback,
|
||||||
content::RenderWidgetHost* host,
|
content::RenderWidgetHost* host,
|
||||||
|
bool is_guest_view_hack,
|
||||||
NativeWindow* native_window)
|
NativeWindow* native_window)
|
||||||
: render_widget_host_(content::RenderWidgetHostImpl::From(host)),
|
: render_widget_host_(content::RenderWidgetHostImpl::From(host)),
|
||||||
native_window_(native_window),
|
native_window_(native_window),
|
||||||
|
@ -355,19 +357,23 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
|
||||||
render_widget_host_->SetView(this);
|
render_widget_host_->SetView(this);
|
||||||
|
|
||||||
#if !defined(OS_MACOSX)
|
#if !defined(OS_MACOSX)
|
||||||
content::ImageTransportFactory* factory =
|
|
||||||
content::ImageTransportFactory::GetInstance();
|
|
||||||
delegated_frame_host_ = base::MakeUnique<content::DelegatedFrameHost>(
|
delegated_frame_host_ = base::MakeUnique<content::DelegatedFrameHost>(
|
||||||
factory->GetContextFactory()->AllocateFrameSinkId(), this);
|
AllocateFrameSinkId(is_guest_view_hack), this);
|
||||||
|
|
||||||
root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
|
root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
CreatePlatformWidget();
|
CreatePlatformWidget(is_guest_view_hack);
|
||||||
#else
|
#else
|
||||||
|
// On macOS the ui::Compositor is created/owned by the platform view.
|
||||||
|
content::ImageTransportFactory* factory =
|
||||||
|
content::ImageTransportFactory::GetInstance();
|
||||||
|
ui::ContextFactoryPrivate* context_factory_private =
|
||||||
|
factory->GetContextFactoryPrivate();
|
||||||
compositor_.reset(
|
compositor_.reset(
|
||||||
new ui::Compositor(content::GetContextFactory(),
|
new ui::Compositor(context_factory_private->AllocateFrameSinkId(),
|
||||||
|
content::GetContextFactory(), context_factory_private,
|
||||||
base::ThreadTaskRunnerHandle::Get()));
|
base::ThreadTaskRunnerHandle::Get()));
|
||||||
compositor_->SetAcceleratedWidget(native_window_->GetAcceleratedWidget());
|
compositor_->SetAcceleratedWidget(native_window_->GetAcceleratedWidget());
|
||||||
compositor_->SetRootLayer(root_layer_.get());
|
compositor_->SetRootLayer(root_layer_.get());
|
||||||
|
@ -399,6 +405,17 @@ OffScreenRenderWidgetHostView::~OffScreenRenderWidgetHostView() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OffScreenRenderWidgetHostView::OnWindowResize() {
|
||||||
|
// In offscreen mode call RenderWidgetHostView's SetSize explicitly
|
||||||
|
auto size = native_window_->GetSize();
|
||||||
|
SetSize(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OffScreenRenderWidgetHostView::OnWindowClosed() {
|
||||||
|
native_window_->RemoveObserver(this);
|
||||||
|
native_window_ = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void OffScreenRenderWidgetHostView::OnBeginFrameTimerTick() {
|
void OffScreenRenderWidgetHostView::OnBeginFrameTimerTick() {
|
||||||
const base::TimeTicks frame_time = base::TimeTicks::Now();
|
const base::TimeTicks frame_time = base::TimeTicks::Now();
|
||||||
const base::TimeDelta vsync_period =
|
const base::TimeDelta vsync_period =
|
||||||
|
@ -416,10 +433,17 @@ void OffScreenRenderWidgetHostView::SendBeginFrame(
|
||||||
|
|
||||||
base::TimeTicks deadline = display_time - estimated_browser_composite_time;
|
base::TimeTicks deadline = display_time - estimated_browser_composite_time;
|
||||||
|
|
||||||
|
const cc::BeginFrameArgs& begin_frame_args =
|
||||||
|
cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE,
|
||||||
|
begin_frame_source_.source_id(),
|
||||||
|
begin_frame_number_, frame_time, deadline,
|
||||||
|
vsync_period, cc::BeginFrameArgs::NORMAL);
|
||||||
|
DCHECK(begin_frame_args.IsValid());
|
||||||
|
begin_frame_number_++;
|
||||||
|
|
||||||
render_widget_host_->Send(new ViewMsg_BeginFrame(
|
render_widget_host_->Send(new ViewMsg_BeginFrame(
|
||||||
render_widget_host_->GetRoutingID(),
|
render_widget_host_->GetRoutingID(),
|
||||||
cc::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE, frame_time, deadline,
|
begin_frame_args));
|
||||||
vsync_period, cc::BeginFrameArgs::NORMAL)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OffScreenRenderWidgetHostView::OnMessageReceived(
|
bool OffScreenRenderWidgetHostView::OnMessageReceived(
|
||||||
|
@ -481,7 +505,7 @@ bool OffScreenRenderWidgetHostView::HasFocus() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OffScreenRenderWidgetHostView::IsSurfaceAvailableForCopy() const {
|
bool OffScreenRenderWidgetHostView::IsSurfaceAvailableForCopy() const {
|
||||||
return GetDelegatedFrameHost()->CanCopyToBitmap();
|
return GetDelegatedFrameHost()->CanCopyFromCompositingSurface();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffScreenRenderWidgetHostView::Show() {
|
void OffScreenRenderWidgetHostView::Show() {
|
||||||
|
@ -561,7 +585,7 @@ void OffScreenRenderWidgetHostView::OnSwapCompositorFrame(
|
||||||
last_scroll_offset_ = frame.metadata.root_scroll_offset;
|
last_scroll_offset_ = frame.metadata.root_scroll_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frame.delegated_frame_data) {
|
if (!frame.render_pass_list.empty()) {
|
||||||
if (software_output_device_) {
|
if (software_output_device_) {
|
||||||
if (!begin_frame_timer_.get()) {
|
if (!begin_frame_timer_.get()) {
|
||||||
software_output_device_->SetActive(painting_);
|
software_output_device_->SetActive(painting_);
|
||||||
|
@ -569,13 +593,11 @@ void OffScreenRenderWidgetHostView::OnSwapCompositorFrame(
|
||||||
|
|
||||||
// The compositor will draw directly to the SoftwareOutputDevice which
|
// The compositor will draw directly to the SoftwareOutputDevice which
|
||||||
// then calls OnPaint.
|
// then calls OnPaint.
|
||||||
#if defined(OS_MACOSX)
|
// We would normally call BrowserCompositorMac::SwapCompositorFrame on
|
||||||
browser_compositor_->SwapCompositorFrame(output_surface_id,
|
// macOS, however it contains compositor resize logic that we don't want.
|
||||||
std::move(frame));
|
// Consequently we instead call the SwapDelegatedFrame method directly.
|
||||||
#else
|
GetDelegatedFrameHost()->SwapDelegatedFrame(output_surface_id,
|
||||||
delegated_frame_host_->SwapDelegatedFrame(output_surface_id,
|
std::move(frame));
|
||||||
std::move(frame));
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
if (!copy_frame_generator_.get()) {
|
if (!copy_frame_generator_.get()) {
|
||||||
copy_frame_generator_.reset(
|
copy_frame_generator_.reset(
|
||||||
|
@ -584,20 +606,17 @@ void OffScreenRenderWidgetHostView::OnSwapCompositorFrame(
|
||||||
|
|
||||||
// Determine the damage rectangle for the current frame. This is the same
|
// Determine the damage rectangle for the current frame. This is the same
|
||||||
// calculation that SwapDelegatedFrame uses.
|
// calculation that SwapDelegatedFrame uses.
|
||||||
cc::RenderPass* root_pass =
|
cc::RenderPass* root_pass = frame.render_pass_list.back().get();
|
||||||
frame.delegated_frame_data->render_pass_list.back().get();
|
|
||||||
gfx::Size frame_size = root_pass->output_rect.size();
|
gfx::Size frame_size = root_pass->output_rect.size();
|
||||||
gfx::Rect damage_rect =
|
gfx::Rect damage_rect =
|
||||||
gfx::ToEnclosingRect(gfx::RectF(root_pass->damage_rect));
|
gfx::ToEnclosingRect(gfx::RectF(root_pass->damage_rect));
|
||||||
damage_rect.Intersect(gfx::Rect(frame_size));
|
damage_rect.Intersect(gfx::Rect(frame_size));
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
// We would normally call BrowserCompositorMac::SwapCompositorFrame on
|
||||||
browser_compositor_->SwapCompositorFrame(output_surface_id,
|
// macOS, however it contains compositor resize logic that we don't want.
|
||||||
std::move(frame));
|
// Consequently we instead call the SwapDelegatedFrame method directly.
|
||||||
#else
|
GetDelegatedFrameHost()->SwapDelegatedFrame(output_surface_id,
|
||||||
delegated_frame_host_->SwapDelegatedFrame(output_surface_id,
|
std::move(frame));
|
||||||
std::move(frame));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Request a copy of the last compositor frame which will eventually call
|
// Request a copy of the last compositor frame which will eventually call
|
||||||
// OnPaint asynchronously.
|
// OnPaint asynchronously.
|
||||||
|
@ -647,7 +666,7 @@ void OffScreenRenderWidgetHostView::SelectionBoundsChanged(
|
||||||
const ViewHostMsg_SelectionBounds_Params &) {
|
const ViewHostMsg_SelectionBounds_Params &) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffScreenRenderWidgetHostView::CopyFromCompositingSurface(
|
void OffScreenRenderWidgetHostView::CopyFromSurface(
|
||||||
const gfx::Rect& src_subrect,
|
const gfx::Rect& src_subrect,
|
||||||
const gfx::Size& dst_size,
|
const gfx::Size& dst_size,
|
||||||
const content::ReadbackRequestCallback& callback,
|
const content::ReadbackRequestCallback& callback,
|
||||||
|
@ -656,18 +675,14 @@ void OffScreenRenderWidgetHostView::CopyFromCompositingSurface(
|
||||||
src_subrect, dst_size, callback, preferred_color_type);
|
src_subrect, dst_size, callback, preferred_color_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffScreenRenderWidgetHostView::CopyFromCompositingSurfaceToVideoFrame(
|
void OffScreenRenderWidgetHostView::CopyFromSurfaceToVideoFrame(
|
||||||
const gfx::Rect& src_subrect,
|
const gfx::Rect& src_subrect,
|
||||||
const scoped_refptr<media::VideoFrame>& target,
|
scoped_refptr<media::VideoFrame> target,
|
||||||
const base::Callback<void(const gfx::Rect&, bool)>& callback) {
|
const base::Callback<void(const gfx::Rect&, bool)>& callback) {
|
||||||
GetDelegatedFrameHost()->CopyFromCompositingSurfaceToVideoFrame(
|
GetDelegatedFrameHost()->CopyFromCompositingSurfaceToVideoFrame(
|
||||||
src_subrect, target, callback);
|
src_subrect, target, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OffScreenRenderWidgetHostView::CanCopyToVideoFrame() const {
|
|
||||||
return GetDelegatedFrameHost()->CanCopyToVideoFrame();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OffScreenRenderWidgetHostView::BeginFrameSubscription(
|
void OffScreenRenderWidgetHostView::BeginFrameSubscription(
|
||||||
std::unique_ptr<content::RenderWidgetHostViewFrameSubscriber> subscriber) {
|
std::unique_ptr<content::RenderWidgetHostViewFrameSubscriber> subscriber) {
|
||||||
GetDelegatedFrameHost()->BeginFrameSubscription(std::move(subscriber));
|
GetDelegatedFrameHost()->BeginFrameSubscription(std::move(subscriber));
|
||||||
|
@ -685,12 +700,6 @@ gfx::Rect OffScreenRenderWidgetHostView::GetBoundsInRootWindow() {
|
||||||
return gfx::Rect(size_);
|
return gfx::Rect(size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffScreenRenderWidgetHostView::LockCompositingSurface() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void OffScreenRenderWidgetHostView::UnlockCompositingSurface() {
|
|
||||||
}
|
|
||||||
|
|
||||||
void OffScreenRenderWidgetHostView::ImeCompositionRangeChanged(
|
void OffScreenRenderWidgetHostView::ImeCompositionRangeChanged(
|
||||||
const gfx::Range &, const std::vector<gfx::Rect>&) {
|
const gfx::Range &, const std::vector<gfx::Rect>&) {
|
||||||
}
|
}
|
||||||
|
@ -752,6 +761,40 @@ void OffScreenRenderWidgetHostView::SetBeginFrameSource(
|
||||||
|
|
||||||
#endif // !defined(OS_MACOSX)
|
#endif // !defined(OS_MACOSX)
|
||||||
|
|
||||||
|
bool OffScreenRenderWidgetHostView::TransformPointToLocalCoordSpace(
|
||||||
|
const gfx::Point& point,
|
||||||
|
const cc::SurfaceId& original_surface,
|
||||||
|
gfx::Point* transformed_point) {
|
||||||
|
// Transformations use physical pixels rather than DIP, so conversion
|
||||||
|
// is necessary.
|
||||||
|
gfx::Point point_in_pixels =
|
||||||
|
gfx::ConvertPointToPixel(scale_factor_, point);
|
||||||
|
if (!GetDelegatedFrameHost()->TransformPointToLocalCoordSpace(
|
||||||
|
point_in_pixels, original_surface, transformed_point)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*transformed_point =
|
||||||
|
gfx::ConvertPointToDIP(scale_factor_, *transformed_point);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OffScreenRenderWidgetHostView::TransformPointToCoordSpaceForView(
|
||||||
|
const gfx::Point& point,
|
||||||
|
RenderWidgetHostViewBase* target_view,
|
||||||
|
gfx::Point* transformed_point) {
|
||||||
|
if (target_view == this) {
|
||||||
|
*transformed_point = point;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In TransformPointToLocalCoordSpace() there is a Point-to-Pixel conversion,
|
||||||
|
// but it is not necessary here because the final target view is responsible
|
||||||
|
// for converting before computing the final transform.
|
||||||
|
return GetDelegatedFrameHost()->TransformPointToCoordSpaceForView(
|
||||||
|
point, target_view, transformed_point);
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<cc::SoftwareOutputDevice>
|
std::unique_ptr<cc::SoftwareOutputDevice>
|
||||||
OffScreenRenderWidgetHostView::CreateSoftwareOutputDevice(
|
OffScreenRenderWidgetHostView::CreateSoftwareOutputDevice(
|
||||||
ui::Compositor* compositor) {
|
ui::Compositor* compositor) {
|
||||||
|
@ -894,15 +937,20 @@ void OffScreenRenderWidgetHostView::ResizeRootLayer() {
|
||||||
GetCompositor()->SetScaleAndSize(scale_factor_, size_in_pixels);
|
GetCompositor()->SetScaleAndSize(scale_factor_, size_in_pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffScreenRenderWidgetHostView::OnWindowResize() {
|
cc::FrameSinkId OffScreenRenderWidgetHostView::AllocateFrameSinkId(
|
||||||
// In offscreen mode call RenderWidgetHostView's SetSize explicitly
|
bool is_guest_view_hack) {
|
||||||
auto size = native_window_->GetSize();
|
// GuestViews have two RenderWidgetHostViews and so we need to make sure
|
||||||
SetSize(size);
|
// we don't have FrameSinkId collisions.
|
||||||
}
|
// The FrameSinkId generated here must be unique with FrameSinkId allocated
|
||||||
|
// in ContextFactoryPrivate.
|
||||||
void OffScreenRenderWidgetHostView::OnWindowClosed() {
|
content::ImageTransportFactory* factory =
|
||||||
native_window_->RemoveObserver(this);
|
content::ImageTransportFactory::GetInstance();
|
||||||
native_window_ = nullptr;
|
return is_guest_view_hack
|
||||||
|
? factory->GetContextFactoryPrivate()->AllocateFrameSinkId()
|
||||||
|
: cc::FrameSinkId(base::checked_cast<uint32_t>(
|
||||||
|
render_widget_host_->GetProcess()->GetID()),
|
||||||
|
base::checked_cast<uint32_t>(
|
||||||
|
render_widget_host_->GetRoutingID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -69,6 +69,7 @@ class OffScreenRenderWidgetHostView
|
||||||
OffScreenRenderWidgetHostView(bool transparent,
|
OffScreenRenderWidgetHostView(bool transparent,
|
||||||
const OnPaintCallback& callback,
|
const OnPaintCallback& callback,
|
||||||
content::RenderWidgetHost* render_widget_host,
|
content::RenderWidgetHost* render_widget_host,
|
||||||
|
bool is_guest_view_hack,
|
||||||
NativeWindow* native_window);
|
NativeWindow* native_window);
|
||||||
~OffScreenRenderWidgetHostView() override;
|
~OffScreenRenderWidgetHostView() override;
|
||||||
|
|
||||||
|
@ -126,23 +127,20 @@ class OffScreenRenderWidgetHostView
|
||||||
#endif
|
#endif
|
||||||
void SelectionBoundsChanged(const ViewHostMsg_SelectionBounds_Params &)
|
void SelectionBoundsChanged(const ViewHostMsg_SelectionBounds_Params &)
|
||||||
override;
|
override;
|
||||||
void CopyFromCompositingSurface(const gfx::Rect &,
|
void CopyFromSurface(
|
||||||
const gfx::Size &,
|
const gfx::Rect& src_subrect,
|
||||||
const content::ReadbackRequestCallback &,
|
const gfx::Size& dst_size,
|
||||||
const SkColorType) override;
|
const content::ReadbackRequestCallback& callback,
|
||||||
void CopyFromCompositingSurfaceToVideoFrame(
|
const SkColorType color_type) override;
|
||||||
const gfx::Rect &,
|
void CopyFromSurfaceToVideoFrame(
|
||||||
const scoped_refptr<media::VideoFrame> &,
|
const gfx::Rect& src_subrect,
|
||||||
const base::Callback<void(const gfx::Rect &, bool),
|
scoped_refptr<media::VideoFrame> target,
|
||||||
base::internal::CopyMode::Copyable> &) override;
|
const base::Callback<void(const gfx::Rect&, bool)>& callback) override;
|
||||||
bool CanCopyToVideoFrame(void) const override;
|
|
||||||
void BeginFrameSubscription(
|
void BeginFrameSubscription(
|
||||||
std::unique_ptr<content::RenderWidgetHostViewFrameSubscriber>) override;
|
std::unique_ptr<content::RenderWidgetHostViewFrameSubscriber>) override;
|
||||||
void EndFrameSubscription() override;
|
void EndFrameSubscription() override;
|
||||||
bool HasAcceleratedSurface(const gfx::Size &) override;
|
bool HasAcceleratedSurface(const gfx::Size &) override;
|
||||||
gfx::Rect GetBoundsInRootWindow(void) override;
|
gfx::Rect GetBoundsInRootWindow(void) override;
|
||||||
void LockCompositingSurface(void) override;
|
|
||||||
void UnlockCompositingSurface(void) override;
|
|
||||||
void ImeCompositionRangeChanged(
|
void ImeCompositionRangeChanged(
|
||||||
const gfx::Range &, const std::vector<gfx::Rect>&) override;
|
const gfx::Range &, const std::vector<gfx::Rect>&) override;
|
||||||
gfx::Size GetPhysicalBackingSize() const override;
|
gfx::Size GetPhysicalBackingSize() const override;
|
||||||
|
@ -166,6 +164,15 @@ class OffScreenRenderWidgetHostView
|
||||||
void SetBeginFrameSource(cc::BeginFrameSource* source) override;
|
void SetBeginFrameSource(cc::BeginFrameSource* source) override;
|
||||||
#endif // !defined(OS_MACOSX)
|
#endif // !defined(OS_MACOSX)
|
||||||
|
|
||||||
|
bool TransformPointToLocalCoordSpace(
|
||||||
|
const gfx::Point& point,
|
||||||
|
const cc::SurfaceId& original_surface,
|
||||||
|
gfx::Point* transformed_point) override;
|
||||||
|
bool TransformPointToCoordSpaceForView(
|
||||||
|
const gfx::Point& point,
|
||||||
|
RenderWidgetHostViewBase* target_view,
|
||||||
|
gfx::Point* transformed_point) override;
|
||||||
|
|
||||||
// ui::CompositorDelegate:
|
// ui::CompositorDelegate:
|
||||||
std::unique_ptr<cc::SoftwareOutputDevice> CreateSoftwareOutputDevice(
|
std::unique_ptr<cc::SoftwareOutputDevice> CreateSoftwareOutputDevice(
|
||||||
ui::Compositor* compositor) override;
|
ui::Compositor* compositor) override;
|
||||||
|
@ -182,7 +189,7 @@ class OffScreenRenderWidgetHostView
|
||||||
base::TimeDelta vsync_period);
|
base::TimeDelta vsync_period);
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
void CreatePlatformWidget();
|
void CreatePlatformWidget(bool is_guest_view_hack);
|
||||||
void DestroyPlatformWidget();
|
void DestroyPlatformWidget();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -210,6 +217,8 @@ class OffScreenRenderWidgetHostView
|
||||||
void SetupFrameRate(bool force);
|
void SetupFrameRate(bool force);
|
||||||
void ResizeRootLayer();
|
void ResizeRootLayer();
|
||||||
|
|
||||||
|
cc::FrameSinkId AllocateFrameSinkId(bool is_guest_view_hack);
|
||||||
|
|
||||||
// Weak ptrs.
|
// Weak ptrs.
|
||||||
content::RenderWidgetHostImpl* render_widget_host_;
|
content::RenderWidgetHostImpl* render_widget_host_;
|
||||||
NativeWindow* native_window_;
|
NativeWindow* native_window_;
|
||||||
|
@ -236,6 +245,10 @@ class OffScreenRenderWidgetHostView
|
||||||
std::unique_ptr<AtomCopyFrameGenerator> copy_frame_generator_;
|
std::unique_ptr<AtomCopyFrameGenerator> copy_frame_generator_;
|
||||||
std::unique_ptr<AtomBeginFrameTimer> begin_frame_timer_;
|
std::unique_ptr<AtomBeginFrameTimer> begin_frame_timer_;
|
||||||
|
|
||||||
|
// Provides |source_id| for BeginFrameArgs that we create.
|
||||||
|
cc::StubBeginFrameSource begin_frame_source_;
|
||||||
|
uint64_t begin_frame_number_ = cc::BeginFrameArgs::kStartingFrameNumber;
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
CALayer* background_layer_;
|
CALayer* background_layer_;
|
||||||
std::unique_ptr<content::BrowserCompositorMac> browser_compositor_;
|
std::unique_ptr<content::BrowserCompositorMac> browser_compositor_;
|
||||||
|
|
|
@ -121,10 +121,12 @@ void OffScreenRenderWidgetHostView::SelectionChanged(
|
||||||
RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
|
RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffScreenRenderWidgetHostView::CreatePlatformWidget() {
|
void OffScreenRenderWidgetHostView::CreatePlatformWidget(
|
||||||
|
bool is_guest_view_hack) {
|
||||||
mac_helper_ = new MacHelper(this);
|
mac_helper_ = new MacHelper(this);
|
||||||
browser_compositor_.reset(new content::BrowserCompositorMac(
|
browser_compositor_.reset(new content::BrowserCompositorMac(
|
||||||
mac_helper_, mac_helper_, render_widget_host_->is_hidden(), true));
|
mac_helper_, mac_helper_, render_widget_host_->is_hidden(), true,
|
||||||
|
AllocateFrameSinkId(is_guest_view_hack)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffScreenRenderWidgetHostView::DestroyPlatformWidget() {
|
void OffScreenRenderWidgetHostView::DestroyPlatformWidget() {
|
||||||
|
|
|
@ -79,7 +79,8 @@ content::RenderWidgetHostViewBase*
|
||||||
content::RenderWidgetHost* render_widget_host, bool is_guest_view_hack) {
|
content::RenderWidgetHost* render_widget_host, bool is_guest_view_hack) {
|
||||||
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
|
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
|
||||||
view_ = new OffScreenRenderWidgetHostView(
|
view_ = new OffScreenRenderWidgetHostView(
|
||||||
transparent_, callback_, render_widget_host, relay->window.get());
|
transparent_, callback_, render_widget_host,
|
||||||
|
is_guest_view_hack, relay->window.get());
|
||||||
return view_;
|
return view_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +89,7 @@ content::RenderWidgetHostViewBase*
|
||||||
content::RenderWidgetHost* render_widget_host) {
|
content::RenderWidgetHost* render_widget_host) {
|
||||||
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
|
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
|
||||||
view_ = new OffScreenRenderWidgetHostView(
|
view_ = new OffScreenRenderWidgetHostView(
|
||||||
transparent_, callback_, render_widget_host, relay->window.get());
|
transparent_, callback_, render_widget_host, false, relay->window.get());
|
||||||
return view_;
|
return view_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
auto cert_db = net::CertDatabase::GetInstance();
|
auto cert_db = net::CertDatabase::GetInstance();
|
||||||
// This forces Chromium to reload the certificate since it might be trusted
|
// This forces Chromium to reload the certificate since it might be trusted
|
||||||
// now.
|
// now.
|
||||||
cert_db->NotifyObserversCertDBChanged(cert_.get());
|
cert_db->NotifyObserversCertDBChanged();
|
||||||
|
|
||||||
callback_.Run();
|
callback_.Run();
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ BOOL AddToTrustedRootStore(const PCCERT_CONTEXT cert_context,
|
||||||
if (result) {
|
if (result) {
|
||||||
// force Chromium to reload it's database for this certificate
|
// force Chromium to reload it's database for this certificate
|
||||||
auto cert_db = net::CertDatabase::GetInstance();
|
auto cert_db = net::CertDatabase::GetInstance();
|
||||||
cert_db->NotifyObserversCertDBChanged(cert.get());
|
cert_db->NotifyObserversCertDBChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
CertCloseStore(root_cert_store, CERT_CLOSE_STORE_FORCE_FLAG);
|
CertCloseStore(root_cert_store, CERT_CLOSE_STORE_FORCE_FLAG);
|
||||||
|
|
|
@ -41,7 +41,7 @@ class GtkMessageBox : public NativeWindowObserver {
|
||||||
const gfx::ImageSkia& icon)
|
const gfx::ImageSkia& icon)
|
||||||
: cancel_id_(cancel_id),
|
: cancel_id_(cancel_id),
|
||||||
checkbox_checked_(false),
|
checkbox_checked_(false),
|
||||||
parent_(static_cast<NativeWindowViews*>(parent_window)) {
|
parent_(static_cast<NativeWindow*>(parent_window)) {
|
||||||
// Create dialog.
|
// Create dialog.
|
||||||
dialog_ = gtk_message_dialog_new(
|
dialog_ = gtk_message_dialog_new(
|
||||||
nullptr, // parent
|
nullptr, // parent
|
||||||
|
@ -94,7 +94,7 @@ class GtkMessageBox : public NativeWindowObserver {
|
||||||
// Parent window.
|
// Parent window.
|
||||||
if (parent_) {
|
if (parent_) {
|
||||||
parent_->AddObserver(this);
|
parent_->AddObserver(this);
|
||||||
parent_->SetEnabled(false);
|
static_cast<NativeWindowViews*>(parent_)->SetEnabled(false);
|
||||||
libgtkui::SetGtkTransientForAura(dialog_, parent_->GetNativeWindow());
|
libgtkui::SetGtkTransientForAura(dialog_, parent_->GetNativeWindow());
|
||||||
gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE);
|
gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE);
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ class GtkMessageBox : public NativeWindowObserver {
|
||||||
gtk_widget_destroy(dialog_);
|
gtk_widget_destroy(dialog_);
|
||||||
if (parent_) {
|
if (parent_) {
|
||||||
parent_->RemoveObserver(this);
|
parent_->RemoveObserver(this);
|
||||||
parent_->SetEnabled(true);
|
static_cast<NativeWindowViews*>(parent_)->SetEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ class GtkMessageBox : public NativeWindowObserver {
|
||||||
|
|
||||||
bool checkbox_checked_;
|
bool checkbox_checked_;
|
||||||
|
|
||||||
NativeWindowViews* parent_;
|
NativeWindow* parent_;
|
||||||
GtkWidget* dialog_;
|
GtkWidget* dialog_;
|
||||||
MessageBoxCallback callback_;
|
MessageBoxCallback callback_;
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,10 @@
|
||||||
// This conflicts with mate::Converter,
|
// This conflicts with mate::Converter,
|
||||||
#undef True
|
#undef True
|
||||||
#undef False
|
#undef False
|
||||||
// and V8.
|
// and V8,
|
||||||
#undef None
|
#undef None
|
||||||
|
// and url_request_status.h,
|
||||||
|
#undef Status
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
|
@ -36,7 +36,7 @@ SubmenuButton::SubmenuButton(const base::string16& title,
|
||||||
|
|
||||||
if (GetUnderlinePosition(title, &accelerator_, &underline_start_,
|
if (GetUnderlinePosition(title, &accelerator_, &underline_start_,
|
||||||
&underline_end_))
|
&underline_end_))
|
||||||
gfx::Canvas::SizeStringInt(GetText(), GetFontList(), &text_width_,
|
gfx::Canvas::SizeStringInt(GetText(), gfx::FontList(), &text_width_,
|
||||||
&text_height_, 0, 0);
|
&text_height_, 0, 0);
|
||||||
|
|
||||||
SetInkDropMode(InkDropMode::ON);
|
SetInkDropMode(InkDropMode::ON);
|
||||||
|
@ -107,8 +107,8 @@ bool SubmenuButton::GetUnderlinePosition(const base::string16& text,
|
||||||
void SubmenuButton::GetCharacterPosition(
|
void SubmenuButton::GetCharacterPosition(
|
||||||
const base::string16& text, int index, int* pos) {
|
const base::string16& text, int index, int* pos) {
|
||||||
int height = 0;
|
int height = 0;
|
||||||
gfx::Canvas::SizeStringInt(text.substr(0, index), GetFontList(), pos, &height,
|
gfx::Canvas::SizeStringInt(text.substr(0, index), gfx::FontList(), pos,
|
||||||
0, 0);
|
&height, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -33,9 +33,8 @@ void CreateResponseHeadersDictionary(const net::HttpResponseHeaders* headers,
|
||||||
while (headers->EnumerateHeaderLines(&iter, &header_name, &header_value)) {
|
while (headers->EnumerateHeaderLines(&iter, &header_name, &header_value)) {
|
||||||
base::Value* existing_value = nullptr;
|
base::Value* existing_value = nullptr;
|
||||||
if (result->Get(header_name, &existing_value)) {
|
if (result->Get(header_name, &existing_value)) {
|
||||||
base::StringValue* existing_string_value =
|
std::string src = existing_value->GetString();
|
||||||
static_cast<base::StringValue*>(existing_value);
|
result->SetString(header_name, src + ", " + header_value);
|
||||||
existing_string_value->GetString()->append(", ").append(header_value);
|
|
||||||
} else {
|
} else {
|
||||||
result->SetString(header_name, header_value);
|
result->SetString(header_name, header_value);
|
||||||
}
|
}
|
||||||
|
@ -131,7 +130,7 @@ void PdfViewerHandler::GetDefaultZoom(const base::ListValue* args) {
|
||||||
double zoom_level = host_zoom_map->GetDefaultZoomLevel();
|
double zoom_level = host_zoom_map->GetDefaultZoomLevel();
|
||||||
ResolveJavascriptCallback(
|
ResolveJavascriptCallback(
|
||||||
*callback_id,
|
*callback_id,
|
||||||
base::FundamentalValue(content::ZoomLevelToZoomFactor(zoom_level)));
|
base::Value(content::ZoomLevelToZoomFactor(zoom_level)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdfViewerHandler::GetInitialZoom(const base::ListValue* args) {
|
void PdfViewerHandler::GetInitialZoom(const base::ListValue* args) {
|
||||||
|
@ -145,7 +144,7 @@ void PdfViewerHandler::GetInitialZoom(const base::ListValue* args) {
|
||||||
content::HostZoomMap::GetZoomLevel(web_ui()->GetWebContents());
|
content::HostZoomMap::GetZoomLevel(web_ui()->GetWebContents());
|
||||||
ResolveJavascriptCallback(
|
ResolveJavascriptCallback(
|
||||||
*callback_id,
|
*callback_id,
|
||||||
base::FundamentalValue(content::ZoomLevelToZoomFactor(zoom_level)));
|
base::Value(content::ZoomLevelToZoomFactor(zoom_level)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdfViewerHandler::SetZoom(const base::ListValue* args) {
|
void PdfViewerHandler::SetZoom(const base::ListValue* args) {
|
||||||
|
@ -159,7 +158,7 @@ void PdfViewerHandler::SetZoom(const base::ListValue* args) {
|
||||||
|
|
||||||
content::HostZoomMap::SetZoomLevel(web_ui()->GetWebContents(),
|
content::HostZoomMap::SetZoomLevel(web_ui()->GetWebContents(),
|
||||||
zoom_level);
|
zoom_level);
|
||||||
ResolveJavascriptCallback(*callback_id, base::FundamentalValue(zoom_level));
|
ResolveJavascriptCallback(*callback_id, base::Value(zoom_level));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdfViewerHandler::GetStrings(const base::ListValue* args) {
|
void PdfViewerHandler::GetStrings(const base::ListValue* args) {
|
||||||
|
@ -204,7 +203,7 @@ void PdfViewerHandler::OnZoomLevelChanged(
|
||||||
if (change.host == kPdfViewerUIHost) {
|
if (change.host == kPdfViewerUIHost) {
|
||||||
CallJavascriptFunction(
|
CallJavascriptFunction(
|
||||||
"cr.webUIListenerCallback", base::StringValue("onZoomLevelChanged"),
|
"cr.webUIListenerCallback", base::StringValue("onZoomLevelChanged"),
|
||||||
base::FundamentalValue(
|
base::Value(
|
||||||
content::ZoomLevelToZoomFactor(change.zoom_level)));
|
content::ZoomLevelToZoomFactor(change.zoom_level)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,8 @@ class PdfViewerUI::ResourceRequester
|
||||||
content::ResourceDispatcherHostImpl::Get()->InitializeURLRequest(
|
content::ResourceDispatcherHostImpl::Get()->InitializeURLRequest(
|
||||||
request.get(), content::Referrer(url, blink::WebReferrerPolicyDefault),
|
request.get(), content::Referrer(url, blink::WebReferrerPolicyDefault),
|
||||||
false, // download.
|
false, // download.
|
||||||
render_process_id, render_view_id, render_frame_id, resource_context);
|
render_process_id, render_view_id, render_frame_id,
|
||||||
|
content::PREVIEWS_OFF, resource_context);
|
||||||
|
|
||||||
content::ResourceRequestInfoImpl* info =
|
content::ResourceRequestInfoImpl* info =
|
||||||
content::ResourceRequestInfoImpl::ForRequest(request.get());
|
content::ResourceRequestInfoImpl::ForRequest(request.get());
|
||||||
|
@ -202,7 +203,8 @@ PdfViewerUI::PdfViewerUI(content::BrowserContext* browser_context,
|
||||||
content::WebContentsObserver(web_ui->GetWebContents()),
|
content::WebContentsObserver(web_ui->GetWebContents()),
|
||||||
src_(src) {
|
src_(src) {
|
||||||
pdf_handler_ = new PdfViewerHandler(src);
|
pdf_handler_ = new PdfViewerHandler(src);
|
||||||
web_ui->AddMessageHandler(pdf_handler_);
|
web_ui->AddMessageHandler(
|
||||||
|
std::unique_ptr<content::WebUIMessageHandler>(pdf_handler_));
|
||||||
content::URLDataSource::Add(browser_context, new BundledDataSource);
|
content::URLDataSource::Add(browser_context, new BundledDataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,17 +6,17 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "atom_natives.h" // NOLINT: This file is generated with coffee2c.
|
|
||||||
|
|
||||||
#include "atom/common/asar/archive.h"
|
#include "atom/common/asar/archive.h"
|
||||||
#include "atom/common/native_mate_converters/callback.h"
|
#include "atom/common/native_mate_converters/callback.h"
|
||||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||||
#include "atom/common/node_includes.h"
|
|
||||||
#include "native_mate/arguments.h"
|
#include "native_mate/arguments.h"
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
#include "native_mate/object_template_builder.h"
|
#include "native_mate/object_template_builder.h"
|
||||||
#include "native_mate/wrappable.h"
|
#include "native_mate/wrappable.h"
|
||||||
|
|
||||||
|
#include "atom/common/node_includes.h"
|
||||||
|
#include "atom_natives.h" // NOLINT: This file is generated with js2c.
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class Archive : public mate::Wrappable<Archive> {
|
class Archive : public mate::Wrappable<Archive> {
|
||||||
|
@ -130,7 +130,7 @@ class Archive : public mate::Wrappable<Archive> {
|
||||||
void InitAsarSupport(v8::Isolate* isolate,
|
void InitAsarSupport(v8::Isolate* isolate,
|
||||||
v8::Local<v8::Value> process,
|
v8::Local<v8::Value> process,
|
||||||
v8::Local<v8::Value> require) {
|
v8::Local<v8::Value> require) {
|
||||||
// Evaluate asar_init.coffee.
|
// Evaluate asar_init.js.
|
||||||
const char* asar_init_native = reinterpret_cast<const char*>(
|
const char* asar_init_native = reinterpret_cast<const char*>(
|
||||||
static_cast<const unsigned char*>(node::asar_init_data));
|
static_cast<const unsigned char*>(node::asar_init_data));
|
||||||
v8::Local<v8::Script> asar_init = v8::Script::Compile(v8::String::NewFromUtf8(
|
v8::Local<v8::Script> asar_init = v8::Script::Compile(v8::String::NewFromUtf8(
|
||||||
|
|
|
@ -181,7 +181,7 @@ bool Archive::Init() {
|
||||||
std::string error;
|
std::string error;
|
||||||
base::JSONReader reader;
|
base::JSONReader reader;
|
||||||
std::unique_ptr<base::Value> value(reader.ReadToValue(header));
|
std::unique_ptr<base::Value> value(reader.ReadToValue(header));
|
||||||
if (!value || !value->IsType(base::Value::TYPE_DICTIONARY)) {
|
if (!value || !value->IsType(base::Value::Type::DICTIONARY)) {
|
||||||
LOG(ERROR) << "Failed to parse header: " << error;
|
LOG(ERROR) << "Failed to parse header: " << error;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -269,8 +269,9 @@ bool Archive::Realpath(const base::FilePath& path, base::FilePath* realpath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Archive::CopyFileOut(const base::FilePath& path, base::FilePath* out) {
|
bool Archive::CopyFileOut(const base::FilePath& path, base::FilePath* out) {
|
||||||
if (external_files_.contains(path)) {
|
auto it = external_files_.find(path.value());
|
||||||
*out = external_files_.get(path)->path();
|
if (it != external_files_.end()) {
|
||||||
|
*out = it->second->path();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,7 +297,7 @@ bool Archive::CopyFileOut(const base::FilePath& path, base::FilePath* out) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*out = temp_file->path();
|
*out = temp_file->path();
|
||||||
external_files_.set(path, std::move(temp_file));
|
external_files_[path.value()] = std::move(temp_file);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
#define ATOM_COMMON_ASAR_ARCHIVE_H_
|
#define ATOM_COMMON_ASAR_ARCHIVE_H_
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/containers/scoped_ptr_hash_map.h"
|
|
||||||
#include "base/files/file.h"
|
#include "base/files/file.h"
|
||||||
#include "base/files/file_path.h"
|
#include "base/files/file_path.h"
|
||||||
|
|
||||||
|
@ -75,8 +75,8 @@ class Archive {
|
||||||
std::unique_ptr<base::DictionaryValue> header_;
|
std::unique_ptr<base::DictionaryValue> header_;
|
||||||
|
|
||||||
// Cached external temporary files.
|
// Cached external temporary files.
|
||||||
base::ScopedPtrHashMap<base::FilePath, std::unique_ptr<ScopedTemporaryFile>>
|
std::unordered_map<base::FilePath::StringType,
|
||||||
external_files_;
|
std::unique_ptr<ScopedTemporaryFile>> external_files_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(Archive);
|
DISALLOW_COPY_AND_ASSIGN(Archive);
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#ifndef ATOM_COMMON_CHROME_VERSION_H_
|
#ifndef ATOM_COMMON_CHROME_VERSION_H_
|
||||||
#define ATOM_COMMON_CHROME_VERSION_H_
|
#define ATOM_COMMON_CHROME_VERSION_H_
|
||||||
|
|
||||||
#define CHROME_VERSION_STRING "56.0.2924.87"
|
#define CHROME_VERSION_STRING "58.0.3029.110"
|
||||||
#define CHROME_VERSION "v" CHROME_VERSION_STRING
|
#define CHROME_VERSION "v" CHROME_VERSION_STRING
|
||||||
|
|
||||||
#endif // ATOM_COMMON_CHROME_VERSION_H_
|
#endif // ATOM_COMMON_CHROME_VERSION_H_
|
||||||
|
|
|
@ -31,4 +31,3 @@ namespace IPC {
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
#include "atom/common/common_message_generator.h"
|
#include "atom/common/common_message_generator.h"
|
||||||
} // namespace IPC
|
} // namespace IPC
|
||||||
|
|
||||||
|
|
|
@ -9,4 +9,5 @@
|
||||||
#include "chrome/common/tts_messages.h"
|
#include "chrome/common/tts_messages.h"
|
||||||
#include "chrome/common/widevine_cdm_messages.h"
|
#include "chrome/common/widevine_cdm_messages.h"
|
||||||
#include "chrome/common/chrome_utility_messages.h"
|
#include "chrome/common/chrome_utility_messages.h"
|
||||||
|
#include "chrome/common/chrome_utility_printing_messages.h"
|
||||||
#include "components/pdf/common/pdf_messages.h"
|
#include "components/pdf/common/pdf_messages.h"
|
||||||
|
|
|
@ -43,11 +43,16 @@ void CrashReporterMac::InitBreakpad(const std::string& product_name,
|
||||||
base::FilePath handler_path =
|
base::FilePath handler_path =
|
||||||
framework_bundle_path.Append("Resources").Append("crashpad_handler");
|
framework_bundle_path.Append("Resources").Append("crashpad_handler");
|
||||||
|
|
||||||
|
std::vector<std::string> args = {
|
||||||
|
"--no-rate-limit",
|
||||||
|
"--no-upload-gzip", // not all servers accept gzip
|
||||||
|
};
|
||||||
|
|
||||||
crashpad::CrashpadClient crashpad_client;
|
crashpad::CrashpadClient crashpad_client;
|
||||||
crashpad_client.StartHandler(handler_path, crashes_dir, crashes_dir,
|
crashpad_client.StartHandler(handler_path, crashes_dir, crashes_dir,
|
||||||
submit_url,
|
submit_url,
|
||||||
StringMap(),
|
StringMap(),
|
||||||
std::vector<std::string>(),
|
args,
|
||||||
true,
|
true,
|
||||||
false);
|
false);
|
||||||
} // @autoreleasepool
|
} // @autoreleasepool
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
#include "content/public/browser/native_web_keyboard_event.h"
|
#include "content/public/browser/native_web_keyboard_event.h"
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
#include "third_party/WebKit/public/platform/WebInputEvent.h"
|
#include "third_party/WebKit/public/platform/WebInputEvent.h"
|
||||||
#include "third_party/WebKit/public/web/WebCache.h"
|
#include "third_party/WebKit/public/platform/WebMouseEvent.h"
|
||||||
|
#include "third_party/WebKit/public/platform/WebMouseWheelEvent.h"
|
||||||
#include "third_party/WebKit/public/web/WebDeviceEmulationParams.h"
|
#include "third_party/WebKit/public/web/WebDeviceEmulationParams.h"
|
||||||
#include "third_party/WebKit/public/web/WebFindOptions.h"
|
#include "third_party/WebKit/public/web/WebFindOptions.h"
|
||||||
#include "ui/base/clipboard/clipboard.h"
|
#include "ui/base/clipboard/clipboard.h"
|
||||||
|
@ -149,12 +150,14 @@ bool Converter<blink::WebInputEvent>::FromV8(
|
||||||
mate::Dictionary dict;
|
mate::Dictionary dict;
|
||||||
if (!ConvertFromV8(isolate, val, &dict))
|
if (!ConvertFromV8(isolate, val, &dict))
|
||||||
return false;
|
return false;
|
||||||
if (!dict.Get("type", &out->type))
|
blink::WebInputEvent::Type type;
|
||||||
|
if (!dict.Get("type", &type))
|
||||||
return false;
|
return false;
|
||||||
|
out->setType(type);
|
||||||
std::vector<blink::WebInputEvent::Modifiers> modifiers;
|
std::vector<blink::WebInputEvent::Modifiers> modifiers;
|
||||||
if (dict.Get("modifiers", &modifiers))
|
if (dict.Get("modifiers", &modifiers))
|
||||||
out->modifiers = VectorToBitArray(modifiers);
|
out->setModifiers(VectorToBitArray(modifiers));
|
||||||
out->timeStampSeconds = base::Time::Now().ToDoubleT();
|
out->setTimeStampSeconds(base::Time::Now().ToDoubleT());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,19 +178,19 @@ bool Converter<blink::WebKeyboardEvent>::FromV8(
|
||||||
ui::KeyboardCode keyCode = atom::KeyboardCodeFromStr(str, &shifted);
|
ui::KeyboardCode keyCode = atom::KeyboardCodeFromStr(str, &shifted);
|
||||||
out->windowsKeyCode = keyCode;
|
out->windowsKeyCode = keyCode;
|
||||||
if (shifted)
|
if (shifted)
|
||||||
out->modifiers |= blink::WebInputEvent::ShiftKey;
|
out->setModifiers(out->modifiers() | blink::WebInputEvent::ShiftKey);
|
||||||
|
|
||||||
ui::DomCode domCode = ui::UsLayoutKeyboardCodeToDomCode(keyCode);
|
ui::DomCode domCode = ui::UsLayoutKeyboardCodeToDomCode(keyCode);
|
||||||
out->domCode = static_cast<int>(domCode);
|
out->domCode = static_cast<int>(domCode);
|
||||||
|
|
||||||
ui::DomKey domKey;
|
ui::DomKey domKey;
|
||||||
ui::KeyboardCode dummy_code;
|
ui::KeyboardCode dummy_code;
|
||||||
int flags = atom::WebEventModifiersToEventFlags(out->modifiers);
|
int flags = atom::WebEventModifiersToEventFlags(out->modifiers());
|
||||||
if (ui::DomCodeToUsLayoutDomKey(domCode, flags, &domKey, &dummy_code))
|
if (ui::DomCodeToUsLayoutDomKey(domCode, flags, &domKey, &dummy_code))
|
||||||
out->domKey = static_cast<int>(domKey);
|
out->domKey = static_cast<int>(domKey);
|
||||||
|
|
||||||
if ((out->type == blink::WebInputEvent::Char ||
|
if ((out->type() == blink::WebInputEvent::Char ||
|
||||||
out->type == blink::WebInputEvent::RawKeyDown)) {
|
out->type() == blink::WebInputEvent::RawKeyDown)) {
|
||||||
// Make sure to not read beyond the buffer in case some bad code doesn't
|
// Make sure to not read beyond the buffer in case some bad code doesn't
|
||||||
// NULL-terminate it (this is called from plugins).
|
// NULL-terminate it (this is called from plugins).
|
||||||
size_t text_length_cap = blink::WebKeyboardEvent::textLengthCap;
|
size_t text_length_cap = blink::WebKeyboardEvent::textLengthCap;
|
||||||
|
@ -219,20 +222,20 @@ v8::Local<v8::Value> Converter<content::NativeWebKeyboardEvent>::ToV8(
|
||||||
v8::Isolate* isolate, const content::NativeWebKeyboardEvent& in) {
|
v8::Isolate* isolate, const content::NativeWebKeyboardEvent& in) {
|
||||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||||
|
|
||||||
if (in.type == blink::WebInputEvent::Type::RawKeyDown)
|
if (in.type() == blink::WebInputEvent::Type::RawKeyDown)
|
||||||
dict.Set("type", "keyDown");
|
dict.Set("type", "keyDown");
|
||||||
else if (in.type == blink::WebInputEvent::Type::KeyUp)
|
else if (in.type() == blink::WebInputEvent::Type::KeyUp)
|
||||||
dict.Set("type", "keyUp");
|
dict.Set("type", "keyUp");
|
||||||
dict.Set("key", ui::KeycodeConverter::DomKeyToKeyString(in.domKey));
|
dict.Set("key", ui::KeycodeConverter::DomKeyToKeyString(in.domKey));
|
||||||
dict.Set("code", ui::KeycodeConverter::DomCodeToCodeString(
|
dict.Set("code", ui::KeycodeConverter::DomCodeToCodeString(
|
||||||
static_cast<ui::DomCode>(in.domCode)));
|
static_cast<ui::DomCode>(in.domCode)));
|
||||||
|
|
||||||
using Modifiers = blink::WebInputEvent::Modifiers;
|
using Modifiers = blink::WebInputEvent::Modifiers;
|
||||||
dict.Set("isAutoRepeat", (in.modifiers & Modifiers::IsAutoRepeat) != 0);
|
dict.Set("isAutoRepeat", (in.modifiers() & Modifiers::IsAutoRepeat) != 0);
|
||||||
dict.Set("shift", (in.modifiers & Modifiers::ShiftKey) != 0);
|
dict.Set("shift", (in.modifiers() & Modifiers::ShiftKey) != 0);
|
||||||
dict.Set("control", (in.modifiers & Modifiers::ControlKey) != 0);
|
dict.Set("control", (in.modifiers() & Modifiers::ControlKey) != 0);
|
||||||
dict.Set("alt", (in.modifiers & Modifiers::AltKey) != 0);
|
dict.Set("alt", (in.modifiers() & Modifiers::AltKey) != 0);
|
||||||
dict.Set("meta", (in.modifiers & Modifiers::MetaKey) != 0);
|
dict.Set("meta", (in.modifiers() & Modifiers::MetaKey) != 0);
|
||||||
|
|
||||||
return dict.GetHandle();
|
return dict.GetHandle();
|
||||||
}
|
}
|
||||||
|
@ -277,7 +280,7 @@ bool Converter<blink::WebMouseWheelEvent>::FromV8(
|
||||||
bool can_scroll = true;
|
bool can_scroll = true;
|
||||||
if (dict.Get("canScroll", &can_scroll) && !can_scroll) {
|
if (dict.Get("canScroll", &can_scroll) && !can_scroll) {
|
||||||
out->hasPreciseScrollingDeltas = false;
|
out->hasPreciseScrollingDeltas = false;
|
||||||
out->modifiers &= ~blink::WebInputEvent::ControlKey;
|
out->setModifiers(out->modifiers() & ~blink::WebInputEvent::ControlKey);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
|
@ -444,7 +447,7 @@ v8::Local<v8::Value> Converter<blink::WebCache::ResourceTypeStat>::ToV8(
|
||||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||||
dict.Set("count", static_cast<uint32_t>(stat.count));
|
dict.Set("count", static_cast<uint32_t>(stat.count));
|
||||||
dict.Set("size", static_cast<double>(stat.size));
|
dict.Set("size", static_cast<double>(stat.size));
|
||||||
dict.Set("liveSize", static_cast<double>(stat.liveSize));
|
dict.Set("liveSize", static_cast<double>(stat.decodedSize));
|
||||||
return dict.GetHandle();
|
return dict.GetHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#define ATOM_COMMON_NATIVE_MATE_CONVERTERS_BLINK_CONVERTER_H_
|
#define ATOM_COMMON_NATIVE_MATE_CONVERTERS_BLINK_CONVERTER_H_
|
||||||
|
|
||||||
#include "native_mate/converter.h"
|
#include "native_mate/converter.h"
|
||||||
#include "third_party/WebKit/public/web/WebCache.h"
|
#include "third_party/WebKit/public/platform/WebCache.h"
|
||||||
#include "third_party/WebKit/public/web/WebContextMenuData.h"
|
#include "third_party/WebKit/public/web/WebContextMenuData.h"
|
||||||
|
|
||||||
namespace blink {
|
namespace blink {
|
||||||
|
|
|
@ -167,42 +167,42 @@ base::Value* V8ValueConverter::FromV8Value(
|
||||||
v8::Local<v8::Value> V8ValueConverter::ToV8ValueImpl(
|
v8::Local<v8::Value> V8ValueConverter::ToV8ValueImpl(
|
||||||
v8::Isolate* isolate, const base::Value* value) const {
|
v8::Isolate* isolate, const base::Value* value) const {
|
||||||
switch (value->GetType()) {
|
switch (value->GetType()) {
|
||||||
case base::Value::TYPE_NULL:
|
case base::Value::Type::NONE:
|
||||||
return v8::Null(isolate);
|
return v8::Null(isolate);
|
||||||
|
|
||||||
case base::Value::TYPE_BOOLEAN: {
|
case base::Value::Type::BOOLEAN: {
|
||||||
bool val = false;
|
bool val = false;
|
||||||
value->GetAsBoolean(&val);
|
value->GetAsBoolean(&val);
|
||||||
return v8::Boolean::New(isolate, val);
|
return v8::Boolean::New(isolate, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
case base::Value::TYPE_INTEGER: {
|
case base::Value::Type::INTEGER: {
|
||||||
int val = 0;
|
int val = 0;
|
||||||
value->GetAsInteger(&val);
|
value->GetAsInteger(&val);
|
||||||
return v8::Integer::New(isolate, val);
|
return v8::Integer::New(isolate, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
case base::Value::TYPE_DOUBLE: {
|
case base::Value::Type::DOUBLE: {
|
||||||
double val = 0.0;
|
double val = 0.0;
|
||||||
value->GetAsDouble(&val);
|
value->GetAsDouble(&val);
|
||||||
return v8::Number::New(isolate, val);
|
return v8::Number::New(isolate, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
case base::Value::TYPE_STRING: {
|
case base::Value::Type::STRING: {
|
||||||
std::string val;
|
std::string val;
|
||||||
value->GetAsString(&val);
|
value->GetAsString(&val);
|
||||||
return v8::String::NewFromUtf8(
|
return v8::String::NewFromUtf8(
|
||||||
isolate, val.c_str(), v8::String::kNormalString, val.length());
|
isolate, val.c_str(), v8::String::kNormalString, val.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
case base::Value::TYPE_LIST:
|
case base::Value::Type::LIST:
|
||||||
return ToV8Array(isolate, static_cast<const base::ListValue*>(value));
|
return ToV8Array(isolate, static_cast<const base::ListValue*>(value));
|
||||||
|
|
||||||
case base::Value::TYPE_DICTIONARY:
|
case base::Value::Type::DICTIONARY:
|
||||||
return ToV8Object(isolate,
|
return ToV8Object(isolate,
|
||||||
static_cast<const base::DictionaryValue*>(value));
|
static_cast<const base::DictionaryValue*>(value));
|
||||||
|
|
||||||
case base::Value::TYPE_BINARY:
|
case base::Value::Type::BINARY:
|
||||||
return ToArrayBuffer(isolate,
|
return ToArrayBuffer(isolate,
|
||||||
static_cast<const base::BinaryValue*>(value));
|
static_cast<const base::BinaryValue*>(value));
|
||||||
|
|
||||||
|
@ -314,13 +314,13 @@ base::Value* V8ValueConverter::FromV8ValueImpl(
|
||||||
return base::Value::CreateNullValue().release();
|
return base::Value::CreateNullValue().release();
|
||||||
|
|
||||||
if (val->IsBoolean())
|
if (val->IsBoolean())
|
||||||
return new base::FundamentalValue(val->ToBoolean()->Value());
|
return new base::Value(val->ToBoolean()->Value());
|
||||||
|
|
||||||
if (val->IsInt32())
|
if (val->IsInt32())
|
||||||
return new base::FundamentalValue(val->ToInt32()->Value());
|
return new base::Value(val->ToInt32()->Value());
|
||||||
|
|
||||||
if (val->IsNumber())
|
if (val->IsNumber())
|
||||||
return new base::FundamentalValue(val->ToNumber()->Value());
|
return new base::Value(val->ToNumber()->Value());
|
||||||
|
|
||||||
if (val->IsString()) {
|
if (val->IsString()) {
|
||||||
v8::String::Utf8Value utf8(val->ToString());
|
v8::String::Utf8Value utf8(val->ToString());
|
||||||
|
@ -490,7 +490,7 @@ base::Value* V8ValueConverter::FromV8Object(
|
||||||
// there *is* a "windowId" property, but since it should be an int, code
|
// there *is* a "windowId" property, but since it should be an int, code
|
||||||
// on the browser which doesn't additionally check for null will fail.
|
// on the browser which doesn't additionally check for null will fail.
|
||||||
// We can avoid all bugs related to this by stripping null.
|
// We can avoid all bugs related to this by stripping null.
|
||||||
if (strip_null_from_objects_ && child->IsType(base::Value::TYPE_NULL))
|
if (strip_null_from_objects_ && child->IsType(base::Value::Type::NONE))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()),
|
result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()),
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
#include "v8/include/v8.h"
|
#include "v8/include/v8.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
class BinaryValue;
|
|
||||||
class DictionaryValue;
|
class DictionaryValue;
|
||||||
class ListValue;
|
class ListValue;
|
||||||
class Value;
|
class Value;
|
||||||
|
using BinaryValue = Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
|
@ -15,7 +15,7 @@ bool Converter<base::DictionaryValue>::FromV8(v8::Isolate* isolate,
|
||||||
std::unique_ptr<atom::V8ValueConverter> converter(new atom::V8ValueConverter);
|
std::unique_ptr<atom::V8ValueConverter> converter(new atom::V8ValueConverter);
|
||||||
std::unique_ptr<base::Value> value(converter->FromV8Value(
|
std::unique_ptr<base::Value> value(converter->FromV8Value(
|
||||||
val, isolate->GetCurrentContext()));
|
val, isolate->GetCurrentContext()));
|
||||||
if (value && value->IsType(base::Value::TYPE_DICTIONARY)) {
|
if (value && value->IsType(base::Value::Type::DICTIONARY)) {
|
||||||
out->Swap(static_cast<base::DictionaryValue*>(value.get()));
|
out->Swap(static_cast<base::DictionaryValue*>(value.get()));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -36,7 +36,7 @@ bool Converter<base::ListValue>::FromV8(v8::Isolate* isolate,
|
||||||
std::unique_ptr<atom::V8ValueConverter> converter(new atom::V8ValueConverter);
|
std::unique_ptr<atom::V8ValueConverter> converter(new atom::V8ValueConverter);
|
||||||
std::unique_ptr<base::Value> value(converter->FromV8Value(
|
std::unique_ptr<base::Value> value(converter->FromV8Value(
|
||||||
val, isolate->GetCurrentContext()));
|
val, isolate->GetCurrentContext()));
|
||||||
if (value->IsType(base::Value::TYPE_LIST)) {
|
if (value->IsType(base::Value::Type::LIST)) {
|
||||||
out->Swap(static_cast<base::ListValue*>(value.get()));
|
out->Swap(static_cast<base::ListValue*>(value.get()));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
|
||||||
#define U_I18N_IMPLEMENTATION
|
#define U_I18N_IMPLEMENTATION
|
||||||
|
#define U_COMMON_IMPLEMENTATION
|
||||||
|
#define U_COMBINED_IMPLEMENTATION
|
||||||
|
|
||||||
#include "third_party/icu/source/common/unicode/ubidi.h"
|
#include "third_party/icu/source/common/unicode/ubidi.h"
|
||||||
#include "third_party/icu/source/common/unicode/uchar.h"
|
#include "third_party/icu/source/common/unicode/uchar.h"
|
||||||
|
@ -15,6 +17,7 @@
|
||||||
#include "third_party/icu/source/common/unicode/unorm.h"
|
#include "third_party/icu/source/common/unicode/unorm.h"
|
||||||
#include "third_party/icu/source/common/unicode/urename.h"
|
#include "third_party/icu/source/common/unicode/urename.h"
|
||||||
#include "third_party/icu/source/common/unicode/ustring.h"
|
#include "third_party/icu/source/common/unicode/ustring.h"
|
||||||
|
#include "third_party/icu/source/i18n/unicode/dtitvfmt.h"
|
||||||
#include "third_party/icu/source/i18n/unicode/measfmt.h"
|
#include "third_party/icu/source/i18n/unicode/measfmt.h"
|
||||||
#include "third_party/icu/source/i18n/unicode/translit.h"
|
#include "third_party/icu/source/i18n/unicode/translit.h"
|
||||||
#include "third_party/icu/source/i18n/unicode/ucsdet.h"
|
#include "third_party/icu/source/i18n/unicode/ucsdet.h"
|
||||||
|
@ -22,6 +25,7 @@
|
||||||
#include "third_party/icu/source/i18n/unicode/uregex.h"
|
#include "third_party/icu/source/i18n/unicode/uregex.h"
|
||||||
#include "third_party/icu/source/i18n/unicode/uspoof.h"
|
#include "third_party/icu/source/i18n/unicode/uspoof.h"
|
||||||
#include "third_party/icu/source/i18n/unicode/usearch.h"
|
#include "third_party/icu/source/i18n/unicode/usearch.h"
|
||||||
|
#include "util-inl.h"
|
||||||
#include "v8-profiler.h"
|
#include "v8-profiler.h"
|
||||||
#include "v8-inspector.h"
|
#include "v8-inspector.h"
|
||||||
|
|
||||||
|
@ -35,6 +39,18 @@ int close(int fd) {
|
||||||
return _close(fd);
|
return _close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* ArrayBufferCalloc(size_t length) {
|
||||||
|
return UncheckedCalloc(length);
|
||||||
|
}
|
||||||
|
|
||||||
|
void* ArrayBufferMalloc(size_t length) {
|
||||||
|
return UncheckedMalloc(length);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArrayBufferFree(void* data, size_t length) {
|
||||||
|
return ::free(data);
|
||||||
|
}
|
||||||
|
|
||||||
void ReferenceSymbols() {
|
void ReferenceSymbols() {
|
||||||
// Following symbols are used by electron.exe but got stripped by compiler,
|
// Following symbols are used by electron.exe but got stripped by compiler,
|
||||||
// by using the symbols we can force compiler to keep the objects in node.dll,
|
// by using the symbols we can force compiler to keep the objects in node.dll,
|
||||||
|
@ -60,6 +76,9 @@ void ReferenceSymbols() {
|
||||||
UMeasureFormatWidth width = UMEASFMT_WIDTH_WIDE;
|
UMeasureFormatWidth width = UMEASFMT_WIDTH_WIDE;
|
||||||
UErrorCode status = U_ZERO_ERROR;
|
UErrorCode status = U_ZERO_ERROR;
|
||||||
icu::MeasureFormat format(icu::Locale::getRoot(), width, status);
|
icu::MeasureFormat format(icu::Locale::getRoot(), width, status);
|
||||||
|
icu::DateInterval internal(0, 0);
|
||||||
|
icu::DateIntervalFormat::createInstance(UnicodeString(),
|
||||||
|
icu::Locale::getRoot(), status);
|
||||||
reinterpret_cast<icu::Transliterator*>(nullptr)->clone();
|
reinterpret_cast<icu::Transliterator*>(nullptr)->clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,12 @@ namespace node {
|
||||||
__declspec(dllexport) int open_osfhandle(intptr_t osfhandle, int flags);
|
__declspec(dllexport) int open_osfhandle(intptr_t osfhandle, int flags);
|
||||||
__declspec(dllexport) int close(int fd);
|
__declspec(dllexport) int close(int fd);
|
||||||
|
|
||||||
|
// Memory allocation functions from Node's module, used by ArrayBuffer allocator
|
||||||
|
// to make sure memories are allocated and freed with the same allocator.
|
||||||
|
__declspec(dllexport) void* ArrayBufferCalloc(size_t length);
|
||||||
|
__declspec(dllexport) void* ArrayBufferMalloc(size_t length);
|
||||||
|
__declspec(dllexport) void ArrayBufferFree(void* data, size_t length);
|
||||||
|
|
||||||
// A trick to force referencing symbols.
|
// A trick to force referencing symbols.
|
||||||
__declspec(dllexport) void ReferenceSymbols();
|
__declspec(dllexport) void ReferenceSymbols();
|
||||||
|
|
||||||
|
|
|
@ -51,13 +51,13 @@ SpellCheckClient::SpellCheckClient(const std::string& language,
|
||||||
|
|
||||||
SpellCheckClient::~SpellCheckClient() {}
|
SpellCheckClient::~SpellCheckClient() {}
|
||||||
|
|
||||||
void SpellCheckClient::spellCheck(
|
void SpellCheckClient::checkSpelling(
|
||||||
const blink::WebString& text,
|
const blink::WebString& text,
|
||||||
int& misspelling_start,
|
int& misspelling_start,
|
||||||
int& misspelling_len,
|
int& misspelling_len,
|
||||||
blink::WebVector<blink::WebString>* optional_suggestions) {
|
blink::WebVector<blink::WebString>* optional_suggestions) {
|
||||||
std::vector<blink::WebTextCheckingResult> results;
|
std::vector<blink::WebTextCheckingResult> results;
|
||||||
SpellCheckText(base::string16(text), true, &results);
|
SpellCheckText(text.utf16(), true, &results);
|
||||||
if (results.size() == 1) {
|
if (results.size() == 1) {
|
||||||
misspelling_start = results[0].location;
|
misspelling_start = results[0].location;
|
||||||
misspelling_len = results[0].length;
|
misspelling_len = results[0].length;
|
||||||
|
@ -66,10 +66,8 @@ void SpellCheckClient::spellCheck(
|
||||||
|
|
||||||
void SpellCheckClient::requestCheckingOfText(
|
void SpellCheckClient::requestCheckingOfText(
|
||||||
const blink::WebString& textToCheck,
|
const blink::WebString& textToCheck,
|
||||||
const blink::WebVector<uint32_t>& markersInText,
|
|
||||||
const blink::WebVector<unsigned>& markerOffsets,
|
|
||||||
blink::WebTextCheckingCompletion* completionCallback) {
|
blink::WebTextCheckingCompletion* completionCallback) {
|
||||||
base::string16 text(textToCheck);
|
base::string16 text(textToCheck.utf16());
|
||||||
if (text.empty() || !HasWordCharacters(text, 0)) {
|
if (text.empty() || !HasWordCharacters(text, 0)) {
|
||||||
completionCallback->didCancelCheckingText();
|
completionCallback->didCancelCheckingText();
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -13,6 +13,10 @@
|
||||||
#include "native_mate/scoped_persistent.h"
|
#include "native_mate/scoped_persistent.h"
|
||||||
#include "third_party/WebKit/public/web/WebSpellCheckClient.h"
|
#include "third_party/WebKit/public/web/WebSpellCheckClient.h"
|
||||||
|
|
||||||
|
namespace blink {
|
||||||
|
struct WebTextCheckingResult;
|
||||||
|
}
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace api {
|
namespace api {
|
||||||
|
@ -27,15 +31,13 @@ class SpellCheckClient : public blink::WebSpellCheckClient {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// blink::WebSpellCheckClient:
|
// blink::WebSpellCheckClient:
|
||||||
void spellCheck(
|
void checkSpelling(
|
||||||
const blink::WebString& text,
|
const blink::WebString& text,
|
||||||
int& misspelledOffset,
|
int& misspelledOffset,
|
||||||
int& misspelledLength,
|
int& misspelledLength,
|
||||||
blink::WebVector<blink::WebString>* optionalSuggestions) override;
|
blink::WebVector<blink::WebString>* optionalSuggestions) override;
|
||||||
void requestCheckingOfText(
|
void requestCheckingOfText(
|
||||||
const blink::WebString& textToCheck,
|
const blink::WebString& textToCheck,
|
||||||
const blink::WebVector<uint32_t>& markersInText,
|
|
||||||
const blink::WebVector<unsigned>& markerOffsets,
|
|
||||||
blink::WebTextCheckingCompletion* completionCallback) override;
|
blink::WebTextCheckingCompletion* completionCallback) override;
|
||||||
void showSpellingUI(bool show) override;
|
void showSpellingUI(bool show) override;
|
||||||
bool isShowingSpellingUI() override;
|
bool isShowingSpellingUI() override;
|
||||||
|
|
|
@ -16,15 +16,15 @@
|
||||||
#include "content/public/renderer/render_view.h"
|
#include "content/public/renderer/render_view.h"
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
#include "native_mate/object_template_builder.h"
|
#include "native_mate/object_template_builder.h"
|
||||||
#include "third_party/WebKit/public/web/WebCache.h"
|
#include "third_party/WebKit/public/platform/WebCache.h"
|
||||||
#include "third_party/WebKit/public/web/WebDocument.h"
|
#include "third_party/WebKit/public/web/WebDocument.h"
|
||||||
#include "third_party/WebKit/public/web/WebFrameWidget.h"
|
#include "third_party/WebKit/public/web/WebFrameWidget.h"
|
||||||
#include "third_party/WebKit/public/web/WebInputMethodController.h"
|
#include "third_party/WebKit/public/web/WebInputMethodController.h"
|
||||||
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
||||||
#include "third_party/WebKit/public/web/WebScriptExecutionCallback.h"
|
#include "third_party/WebKit/public/web/WebScriptExecutionCallback.h"
|
||||||
#include "third_party/WebKit/public/web/WebScriptSource.h"
|
#include "third_party/WebKit/public/web/WebScriptSource.h"
|
||||||
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
|
|
||||||
#include "third_party/WebKit/public/web/WebView.h"
|
#include "third_party/WebKit/public/web/WebView.h"
|
||||||
|
#include "third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h"
|
||||||
|
|
||||||
#include "atom/common/node_includes.h"
|
#include "atom/common/node_includes.h"
|
||||||
|
|
||||||
|
@ -110,7 +110,8 @@ void WebFrame::SetLayoutZoomLevelLimits(double min_level, double max_level) {
|
||||||
v8::Local<v8::Value> WebFrame::RegisterEmbedderCustomElement(
|
v8::Local<v8::Value> WebFrame::RegisterEmbedderCustomElement(
|
||||||
const base::string16& name, v8::Local<v8::Object> options) {
|
const base::string16& name, v8::Local<v8::Object> options) {
|
||||||
blink::WebExceptionCode c = 0;
|
blink::WebExceptionCode c = 0;
|
||||||
return web_frame_->document().registerEmbedderCustomElement(name, options, c);
|
return web_frame_->document().registerEmbedderCustomElement(
|
||||||
|
blink::WebString::fromUTF16(name), options, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebFrame::RegisterElementResizeCallback(
|
void WebFrame::RegisterElementResizeCallback(
|
||||||
|
@ -145,15 +146,14 @@ void WebFrame::SetSpellCheckProvider(mate::Arguments* args,
|
||||||
|
|
||||||
void WebFrame::RegisterURLSchemeAsSecure(const std::string& scheme) {
|
void WebFrame::RegisterURLSchemeAsSecure(const std::string& scheme) {
|
||||||
// TODO(pfrazee): Remove 2.0
|
// TODO(pfrazee): Remove 2.0
|
||||||
// Register scheme to secure list (https, wss, data).
|
blink::SchemeRegistry::registerURLSchemeAsSecure(
|
||||||
blink::WebSecurityPolicy::registerURLSchemeAsSecure(
|
WTF::String::fromUTF8(scheme.data(), scheme.length()));
|
||||||
blink::WebString::fromUTF8(scheme));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebFrame::RegisterURLSchemeAsBypassingCSP(const std::string& scheme) {
|
void WebFrame::RegisterURLSchemeAsBypassingCSP(const std::string& scheme) {
|
||||||
// Register scheme to bypass pages's Content Security Policy.
|
// Register scheme to bypass pages's Content Security Policy.
|
||||||
blink::WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy(
|
blink::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(
|
||||||
blink::WebString::fromUTF8(scheme));
|
WTF::String::fromUTF8(scheme.data(), scheme.length()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebFrame::RegisterURLSchemeAsPrivileged(const std::string& scheme,
|
void WebFrame::RegisterURLSchemeAsPrivileged(const std::string& scheme,
|
||||||
|
@ -175,32 +175,36 @@ void WebFrame::RegisterURLSchemeAsPrivileged(const std::string& scheme,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Register scheme to privileged list (https, wss, data, chrome-extension)
|
// Register scheme to privileged list (https, wss, data, chrome-extension)
|
||||||
blink::WebString privileged_scheme(blink::WebString::fromUTF8(scheme));
|
WTF::String privileged_scheme(
|
||||||
|
WTF::String::fromUTF8(scheme.data(), scheme.length()));
|
||||||
if (secure) {
|
if (secure) {
|
||||||
// TODO(pfrazee): Remove 2.0
|
// TODO(pfrazee): Remove 2.0
|
||||||
blink::WebSecurityPolicy::registerURLSchemeAsSecure(privileged_scheme);
|
blink::SchemeRegistry::registerURLSchemeAsSecure(privileged_scheme);
|
||||||
}
|
}
|
||||||
if (bypassCSP) {
|
if (bypassCSP) {
|
||||||
blink::WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy(
|
blink::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(
|
||||||
privileged_scheme);
|
privileged_scheme);
|
||||||
}
|
}
|
||||||
if (allowServiceWorkers) {
|
if (allowServiceWorkers) {
|
||||||
blink::WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers(
|
blink::SchemeRegistry::registerURLSchemeAsAllowingServiceWorkers(
|
||||||
privileged_scheme);
|
privileged_scheme);
|
||||||
}
|
}
|
||||||
if (supportFetchAPI) {
|
if (supportFetchAPI) {
|
||||||
blink::WebSecurityPolicy::registerURLSchemeAsSupportingFetchAPI(
|
blink::SchemeRegistry::registerURLSchemeAsSupportingFetchAPI(
|
||||||
privileged_scheme);
|
privileged_scheme);
|
||||||
}
|
}
|
||||||
if (corsEnabled) {
|
if (corsEnabled) {
|
||||||
blink::WebSecurityPolicy::registerURLSchemeAsCORSEnabled(privileged_scheme);
|
blink::SchemeRegistry::registerURLSchemeAsCORSEnabled(privileged_scheme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebFrame::InsertText(const std::string& text) {
|
void WebFrame::InsertText(const std::string& text) {
|
||||||
web_frame_->frameWidget()
|
web_frame_->frameWidget()
|
||||||
->getActiveWebInputMethodController()
|
->getActiveWebInputMethodController()
|
||||||
->commitText(blink::WebString::fromUTF8(text), 0);
|
->commitText(blink::WebString::fromUTF8(text),
|
||||||
|
blink::WebVector<blink::WebCompositionUnderline>(),
|
||||||
|
blink::WebRange(),
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebFrame::InsertCSS(const std::string& css) {
|
void WebFrame::InsertCSS(const std::string& css) {
|
||||||
|
@ -216,7 +220,7 @@ void WebFrame::ExecuteJavaScript(const base::string16& code,
|
||||||
std::unique_ptr<blink::WebScriptExecutionCallback> callback(
|
std::unique_ptr<blink::WebScriptExecutionCallback> callback(
|
||||||
new ScriptExecutionCallback(completion_callback));
|
new ScriptExecutionCallback(completion_callback));
|
||||||
web_frame_->requestExecuteScriptAndReturnValue(
|
web_frame_->requestExecuteScriptAndReturnValue(
|
||||||
blink::WebScriptSource(code),
|
blink::WebScriptSource(blink::WebString::fromUTF16(code)),
|
||||||
has_user_gesture,
|
has_user_gesture,
|
||||||
callback.release());
|
callback.release());
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "atom/renderer/guest_view_container.h"
|
#include "atom/renderer/guest_view_container.h"
|
||||||
#include "native_mate/handle.h"
|
#include "native_mate/handle.h"
|
||||||
#include "native_mate/wrappable.h"
|
#include "native_mate/wrappable.h"
|
||||||
#include "third_party/WebKit/public/web/WebCache.h"
|
#include "third_party/WebKit/public/platform/WebCache.h"
|
||||||
|
|
||||||
namespace blink {
|
namespace blink {
|
||||||
class WebLocalFrame;
|
class WebLocalFrame;
|
||||||
|
|
|
@ -24,7 +24,6 @@ void AtomRenderFrameObserver::DidClearWindowObject() {
|
||||||
|
|
||||||
void AtomRenderFrameObserver::DidCreateScriptContext(
|
void AtomRenderFrameObserver::DidCreateScriptContext(
|
||||||
v8::Handle<v8::Context> context,
|
v8::Handle<v8::Context> context,
|
||||||
int extension_group,
|
|
||||||
int world_id) {
|
int world_id) {
|
||||||
if (ShouldNotifyClient(world_id))
|
if (ShouldNotifyClient(world_id))
|
||||||
renderer_client_->DidCreateScriptContext(context, render_frame_);
|
renderer_client_->DidCreateScriptContext(context, render_frame_);
|
||||||
|
@ -62,8 +61,7 @@ void AtomRenderFrameObserver::CreateIsolatedWorldContext() {
|
||||||
|
|
||||||
// Create initial script context in isolated world
|
// Create initial script context in isolated world
|
||||||
blink::WebScriptSource source("void 0");
|
blink::WebScriptSource source("void 0");
|
||||||
frame->executeScriptInIsolatedWorld(
|
frame->executeScriptInIsolatedWorld(World::ISOLATED_WORLD, &source, 1);
|
||||||
World::ISOLATED_WORLD, &source, 1, ExtensionGroup::MAIN_GROUP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AtomRenderFrameObserver::IsMainWorld(int world_id) {
|
bool AtomRenderFrameObserver::IsMainWorld(int world_id) {
|
||||||
|
|
|
@ -17,10 +17,6 @@ enum World {
|
||||||
ISOLATED_WORLD = 999
|
ISOLATED_WORLD = 999
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ExtensionGroup {
|
|
||||||
MAIN_GROUP = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
// Helper class to forward the messages to the client.
|
// Helper class to forward the messages to the client.
|
||||||
class AtomRenderFrameObserver : public content::RenderFrameObserver {
|
class AtomRenderFrameObserver : public content::RenderFrameObserver {
|
||||||
public:
|
public:
|
||||||
|
@ -30,7 +26,6 @@ class AtomRenderFrameObserver : public content::RenderFrameObserver {
|
||||||
// content::RenderFrameObserver:
|
// content::RenderFrameObserver:
|
||||||
void DidClearWindowObject() override;
|
void DidClearWindowObject() override;
|
||||||
void DidCreateScriptContext(v8::Handle<v8::Context> context,
|
void DidCreateScriptContext(v8::Handle<v8::Context> context,
|
||||||
int extension_group,
|
|
||||||
int world_id) override;
|
int world_id) override;
|
||||||
void WillReleaseScriptContext(v8::Local<v8::Context> context,
|
void WillReleaseScriptContext(v8::Local<v8::Context> context,
|
||||||
int world_id) override;
|
int world_id) override;
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "atom_natives.h" // NOLINT: This file is generated with js2c
|
|
||||||
|
|
||||||
#include "atom/common/api/atom_bindings.h"
|
#include "atom/common/api/atom_bindings.h"
|
||||||
#include "atom/common/api/event_emitter_caller.h"
|
#include "atom/common/api/event_emitter_caller.h"
|
||||||
#include "atom/common/asar/asar_util.h"
|
#include "atom/common/asar/asar_util.h"
|
||||||
|
@ -27,6 +25,7 @@
|
||||||
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
||||||
|
|
||||||
#include "atom/common/node_includes.h"
|
#include "atom/common/node_includes.h"
|
||||||
|
#include "atom_natives.h" // NOLINT: This file is generated with js2c
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
@ -172,8 +171,7 @@ void AtomRendererClient::WillDestroyWorkerContextOnWorkerThread(
|
||||||
v8::Local<v8::Context> AtomRendererClient::GetContext(
|
v8::Local<v8::Context> AtomRendererClient::GetContext(
|
||||||
blink::WebFrame* frame, v8::Isolate* isolate) {
|
blink::WebFrame* frame, v8::Isolate* isolate) {
|
||||||
if (isolated_world())
|
if (isolated_world())
|
||||||
return frame->worldScriptContext(
|
return frame->worldScriptContext(isolate, World::ISOLATED_WORLD);
|
||||||
isolate, World::ISOLATED_WORLD, ExtensionGroup::MAIN_GROUP);
|
|
||||||
else
|
else
|
||||||
return frame->mainWorldScriptContext();
|
return frame->mainWorldScriptContext();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,11 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "atom_natives.h" // NOLINT: This file is generated with js2c
|
|
||||||
|
|
||||||
#include "atom/common/api/api_messages.h"
|
#include "atom/common/api/api_messages.h"
|
||||||
#include "atom/common/api/atom_bindings.h"
|
#include "atom/common/api/atom_bindings.h"
|
||||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||||
#include "atom/common/native_mate_converters/v8_value_converter.h"
|
#include "atom/common/native_mate_converters/v8_value_converter.h"
|
||||||
#include "atom/common/native_mate_converters/value_converter.h"
|
#include "atom/common/native_mate_converters/value_converter.h"
|
||||||
#include "atom/common/node_includes.h"
|
|
||||||
#include "atom/common/options_switches.h"
|
#include "atom/common/options_switches.h"
|
||||||
#include "atom/renderer/api/atom_api_renderer_ipc.h"
|
#include "atom/renderer/api/atom_api_renderer_ipc.h"
|
||||||
#include "atom/renderer/atom_render_view_observer.h"
|
#include "atom/renderer/atom_render_view_observer.h"
|
||||||
|
@ -31,6 +28,9 @@
|
||||||
#include "third_party/WebKit/public/web/WebScriptSource.h"
|
#include "third_party/WebKit/public/web/WebScriptSource.h"
|
||||||
#include "third_party/WebKit/public/web/WebView.h"
|
#include "third_party/WebKit/public/web/WebView.h"
|
||||||
|
|
||||||
|
#include "atom/common/node_includes.h"
|
||||||
|
#include "atom_natives.h" // NOLINT: This file is generated with js2c
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "third_party/WebKit/public/web/WebPluginParams.h"
|
#include "third_party/WebKit/public/web/WebPluginParams.h"
|
||||||
#include "third_party/WebKit/public/web/WebScriptSource.h"
|
#include "third_party/WebKit/public/web/WebScriptSource.h"
|
||||||
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
|
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
|
||||||
|
#include "third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h"
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
#include "base/mac/mac_util.h"
|
#include "base/mac/mac_util.h"
|
||||||
|
@ -85,6 +86,13 @@ void RendererClientBase::RenderThreadStarted() {
|
||||||
blink::WebCustomElement::addEmbedderCustomElementName("webview");
|
blink::WebCustomElement::addEmbedderCustomElementName("webview");
|
||||||
blink::WebCustomElement::addEmbedderCustomElementName("browserplugin");
|
blink::WebCustomElement::addEmbedderCustomElementName("browserplugin");
|
||||||
|
|
||||||
|
// Parse --secure-schemes=scheme1,scheme2
|
||||||
|
std::vector<std::string> secure_schemes_list =
|
||||||
|
ParseSchemesCLISwitch(switches::kSecureSchemes);
|
||||||
|
for (const std::string& scheme : secure_schemes_list)
|
||||||
|
blink::SchemeRegistry::registerURLSchemeAsSecure(
|
||||||
|
WTF::String::fromUTF8(scheme.data(), scheme.length()));
|
||||||
|
|
||||||
preferences_manager_.reset(new PreferencesManager);
|
preferences_manager_.reset(new PreferencesManager);
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
|
@ -126,13 +134,6 @@ void RendererClientBase::RenderFrameCreated(
|
||||||
// Allow access to file scheme from pdf viewer.
|
// Allow access to file scheme from pdf viewer.
|
||||||
blink::WebSecurityPolicy::addOriginAccessWhitelistEntry(
|
blink::WebSecurityPolicy::addOriginAccessWhitelistEntry(
|
||||||
GURL(kPdfViewerUIOrigin), "file", "", true);
|
GURL(kPdfViewerUIOrigin), "file", "", true);
|
||||||
|
|
||||||
// Parse --secure-schemes=scheme1,scheme2
|
|
||||||
std::vector<std::string> secure_schemes_list =
|
|
||||||
ParseSchemesCLISwitch(switches::kSecureSchemes);
|
|
||||||
for (const std::string& secure_scheme : secure_schemes_list)
|
|
||||||
blink::WebSecurityPolicy::registerURLSchemeAsSecure(
|
|
||||||
blink::WebString::fromUTF8(secure_scheme));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RendererClientBase::RenderViewCreated(content::RenderView* render_view) {
|
void RendererClientBase::RenderViewCreated(content::RenderView* render_view) {
|
||||||
|
|
|
@ -92,12 +92,12 @@ CertificateManagerModel::CertificateManagerModel(
|
||||||
CertificateManagerModel::~CertificateManagerModel() {
|
CertificateManagerModel::~CertificateManagerModel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int CertificateManagerModel::ImportFromPKCS12(net::CryptoModule* module,
|
int CertificateManagerModel::ImportFromPKCS12(PK11SlotInfo* slot_info,
|
||||||
const std::string& data,
|
const std::string& data,
|
||||||
const base::string16& password,
|
const base::string16& password,
|
||||||
bool is_extractable,
|
bool is_extractable,
|
||||||
net::CertificateList* imported_certs) {
|
net::CertificateList* imported_certs) {
|
||||||
return cert_db_->ImportFromPKCS12(module, data, password,
|
return cert_db_->ImportFromPKCS12(slot_info, data, password,
|
||||||
is_extractable, imported_certs);
|
is_extractable, imported_certs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ class CertificateManagerModel {
|
||||||
// |data|, using the given |password|. If |is_extractable| is false,
|
// |data|, using the given |password|. If |is_extractable| is false,
|
||||||
// mark the private key as unextractable from the module.
|
// mark the private key as unextractable from the module.
|
||||||
// Returns a net error code on failure.
|
// Returns a net error code on failure.
|
||||||
int ImportFromPKCS12(net::CryptoModule* module,
|
int ImportFromPKCS12(PK11SlotInfo* slot_info,
|
||||||
const std::string& data,
|
const std::string& data,
|
||||||
const base::string16& password,
|
const base::string16& password,
|
||||||
bool is_extractable,
|
bool is_extractable,
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
using base::PlatformThreadRef;
|
||||||
|
|
||||||
#include "base/hash.h"
|
#include "base/hash.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/strings/string_number_conversions.h"
|
#include "base/strings/string_number_conversions.h"
|
||||||
|
|
|
@ -18,10 +18,9 @@
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "base/memory/ptr_util.h"
|
#include "base/memory/ptr_util.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
|
||||||
#include "base/threading/thread_task_runner_handle.h"
|
#include "base/threading/thread_task_runner_handle.h"
|
||||||
#include "chrome/common/chrome_utility_messages.h"
|
#include "chrome/common/chrome_utility_messages.h"
|
||||||
#include "chrome/common/print_messages.h"
|
#include "chrome/common/chrome_utility_printing_messages.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "content/public/browser/child_process_data.h"
|
#include "content/public/browser/child_process_data.h"
|
||||||
#include "content/public/browser/utility_process_host.h"
|
#include "content/public/browser/utility_process_host.h"
|
||||||
|
@ -30,13 +29,13 @@
|
||||||
#include "printing/pdf_render_settings.h"
|
#include "printing/pdf_render_settings.h"
|
||||||
#include "ui/base/l10n/l10n_util.h"
|
#include "ui/base/l10n/l10n_util.h"
|
||||||
|
|
||||||
|
using content::BrowserThread;
|
||||||
|
|
||||||
namespace printing {
|
namespace printing {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using content::BrowserThread;
|
class PdfConverterImpl;
|
||||||
|
|
||||||
class PdfToEmfConverterImpl;
|
|
||||||
|
|
||||||
// Allows to delete temporary directory after all temporary files created inside
|
// Allows to delete temporary directory after all temporary files created inside
|
||||||
// are closed. Windows cannot delete directory with opened files. Directory is
|
// are closed. Windows cannot delete directory with opened files. Directory is
|
||||||
|
@ -59,8 +58,8 @@ class RefCountedTempDir
|
||||||
DISALLOW_COPY_AND_ASSIGN(RefCountedTempDir);
|
DISALLOW_COPY_AND_ASSIGN(RefCountedTempDir);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::unique_ptr<base::File, BrowserThread::DeleteOnFileThread>
|
using ScopedTempFile =
|
||||||
ScopedTempFile;
|
std::unique_ptr<base::File, BrowserThread::DeleteOnFileThread>;
|
||||||
|
|
||||||
// Wrapper for Emf to keep only file handle in memory, and load actual data only
|
// Wrapper for Emf to keep only file handle in memory, and load actual data only
|
||||||
// on playback. Emf::InitFromFile() can play metafile directly from disk, but it
|
// on playback. Emf::InitFromFile() can play metafile directly from disk, but it
|
||||||
|
@ -74,21 +73,39 @@ class LazyEmf : public MetafilePlayer {
|
||||||
}
|
}
|
||||||
~LazyEmf() override { Close(); }
|
~LazyEmf() override { Close(); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// MetafilePlayer:
|
||||||
bool SafePlayback(HDC hdc) const override;
|
bool SafePlayback(HDC hdc) const override;
|
||||||
bool GetDataAsVector(std::vector<char>* buffer) const override;
|
|
||||||
bool SaveTo(base::File* file) const override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
void Close() const;
|
void Close() const;
|
||||||
bool LoadEmf(Emf* emf) const;
|
bool LoadEmf(Emf* emf) const;
|
||||||
|
|
||||||
|
private:
|
||||||
mutable scoped_refptr<RefCountedTempDir> temp_dir_;
|
mutable scoped_refptr<RefCountedTempDir> temp_dir_;
|
||||||
mutable ScopedTempFile file_; // Mutable because of consts in base class.
|
mutable ScopedTempFile file_; // Mutable because of consts in base class.
|
||||||
|
|
||||||
|
bool GetDataAsVector(std::vector<char>* buffer) const override;
|
||||||
|
bool SaveTo(base::File* file) const override;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(LazyEmf);
|
DISALLOW_COPY_AND_ASSIGN(LazyEmf);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Converts PDF into EMF.
|
// Postscript metafile subclass to override SafePlayback.
|
||||||
|
class PostScriptMetaFile : public LazyEmf {
|
||||||
|
public:
|
||||||
|
PostScriptMetaFile(const scoped_refptr<RefCountedTempDir>& temp_dir,
|
||||||
|
ScopedTempFile file)
|
||||||
|
: LazyEmf(temp_dir, std::move(file)) {}
|
||||||
|
~PostScriptMetaFile() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// MetafilePlayer:
|
||||||
|
bool SafePlayback(HDC hdc) const override;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(PostScriptMetaFile);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Class for converting PDF to another format for printing (Emf, Postscript).
|
||||||
// Class uses 3 threads: UI, IO and FILE.
|
// Class uses 3 threads: UI, IO and FILE.
|
||||||
// Internal workflow is following:
|
// Internal workflow is following:
|
||||||
// 1. Create instance on the UI thread. (files_, settings_,)
|
// 1. Create instance on the UI thread. (files_, settings_,)
|
||||||
|
@ -101,36 +118,33 @@ class LazyEmf : public MetafilePlayer {
|
||||||
//
|
//
|
||||||
// All these steps work sequentially, so no data should be accessed
|
// All these steps work sequentially, so no data should be accessed
|
||||||
// simultaneously by several threads.
|
// simultaneously by several threads.
|
||||||
class PdfToEmfUtilityProcessHostClient
|
class PdfConverterUtilityProcessHostClient
|
||||||
: public content::UtilityProcessHostClient {
|
: public content::UtilityProcessHostClient {
|
||||||
public:
|
public:
|
||||||
PdfToEmfUtilityProcessHostClient(
|
PdfConverterUtilityProcessHostClient(
|
||||||
base::WeakPtr<PdfToEmfConverterImpl> converter,
|
base::WeakPtr<PdfConverterImpl> converter,
|
||||||
const PdfRenderSettings& settings);
|
const PdfRenderSettings& settings);
|
||||||
|
|
||||||
void Start(const scoped_refptr<base::RefCountedMemory>& data,
|
void Start(const scoped_refptr<base::RefCountedMemory>& data,
|
||||||
bool print_text_with_gdi,
|
const PdfConverter::StartCallback& start_callback);
|
||||||
const PdfToEmfConverter::StartCallback& start_callback);
|
|
||||||
|
|
||||||
void GetPage(int page_number,
|
void GetPage(int page_number,
|
||||||
const PdfToEmfConverter::GetPageCallback& get_page_callback);
|
const PdfConverter::GetPageCallback& get_page_callback);
|
||||||
|
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
|
// UtilityProcessHostClient implementation.
|
||||||
|
void OnProcessCrashed(int exit_code) override;
|
||||||
|
void OnProcessLaunchFailed(int exit_code) override;
|
||||||
|
|
||||||
// Needs to be public to handle ChromeUtilityHostMsg_PreCacheFontCharacters
|
// Needs to be public to handle ChromeUtilityHostMsg_PreCacheFontCharacters
|
||||||
// sync message replies.
|
// sync message replies.
|
||||||
bool Send(IPC::Message* msg);
|
bool Send(IPC::Message* msg);
|
||||||
|
|
||||||
// UtilityProcessHostClient implementation.
|
protected:
|
||||||
void OnProcessCrashed(int exit_code) override;
|
|
||||||
void OnProcessLaunchFailed(int exit_code) override;
|
|
||||||
bool OnMessageReceived(const IPC::Message& message) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
class GetPageCallbackData {
|
class GetPageCallbackData {
|
||||||
public:
|
public:
|
||||||
GetPageCallbackData(int page_number,
|
GetPageCallbackData(int page_number, PdfConverter::GetPageCallback callback)
|
||||||
PdfToEmfConverter::GetPageCallback callback)
|
|
||||||
: page_number_(page_number), callback_(callback) {}
|
: page_number_(page_number), callback_(callback) {}
|
||||||
|
|
||||||
GetPageCallbackData(GetPageCallbackData&& other) {
|
GetPageCallbackData(GetPageCallbackData&& other) {
|
||||||
|
@ -140,45 +154,62 @@ class PdfToEmfUtilityProcessHostClient
|
||||||
GetPageCallbackData& operator=(GetPageCallbackData&& rhs) {
|
GetPageCallbackData& operator=(GetPageCallbackData&& rhs) {
|
||||||
page_number_ = rhs.page_number_;
|
page_number_ = rhs.page_number_;
|
||||||
callback_ = rhs.callback_;
|
callback_ = rhs.callback_;
|
||||||
emf_ = std::move(rhs.emf_);
|
file_ = std::move(rhs.file_);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
int page_number() const { return page_number_; }
|
int page_number() const { return page_number_; }
|
||||||
const PdfToEmfConverter::GetPageCallback& callback() const {
|
const PdfConverter::GetPageCallback& callback() const { return callback_; }
|
||||||
return callback_;
|
ScopedTempFile TakeFile() { return std::move(file_); }
|
||||||
}
|
void set_file(ScopedTempFile file) { file_ = std::move(file); }
|
||||||
ScopedTempFile TakeEmf() { return std::move(emf_); }
|
|
||||||
void set_emf(ScopedTempFile emf) { emf_ = std::move(emf); }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int page_number_;
|
int page_number_;
|
||||||
PdfToEmfConverter::GetPageCallback callback_;
|
|
||||||
ScopedTempFile emf_;
|
PdfConverter::GetPageCallback callback_;
|
||||||
|
ScopedTempFile file_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(GetPageCallbackData);
|
DISALLOW_COPY_AND_ASSIGN(GetPageCallbackData);
|
||||||
};
|
};
|
||||||
|
|
||||||
~PdfToEmfUtilityProcessHostClient() override;
|
~PdfConverterUtilityProcessHostClient() override;
|
||||||
|
|
||||||
// Message handlers.
|
bool OnMessageReceived(const IPC::Message& message) override;
|
||||||
|
|
||||||
|
// Helper functions: must be overridden by subclasses
|
||||||
|
// Set the process name
|
||||||
|
virtual base::string16 GetName() const;
|
||||||
|
// Create a metafileplayer subclass file from a temporary file.
|
||||||
|
virtual std::unique_ptr<MetafilePlayer> GetFileFromTemp(
|
||||||
|
std::unique_ptr<base::File, content::BrowserThread::DeleteOnFileThread>
|
||||||
|
temp_file);
|
||||||
|
// Send the messages to Start, GetPage, and Stop.
|
||||||
|
virtual void SendStartMessage(IPC::PlatformFileForTransit transit);
|
||||||
|
virtual void SendGetPageMessage(int page_number,
|
||||||
|
IPC::PlatformFileForTransit transit);
|
||||||
|
virtual void SendStopMessage();
|
||||||
|
|
||||||
|
// Message handlers:
|
||||||
void OnPageCount(int page_count);
|
void OnPageCount(int page_count);
|
||||||
void OnPageDone(bool success, float scale_factor);
|
void OnPageDone(bool success, float scale_factor);
|
||||||
|
|
||||||
|
void OnFailed();
|
||||||
|
void OnTempPdfReady(ScopedTempFile pdf);
|
||||||
|
void OnTempFileReady(GetPageCallbackData* callback_data,
|
||||||
|
ScopedTempFile temp_file);
|
||||||
|
|
||||||
|
// Additional message handler needed for Pdf to Emf
|
||||||
void OnPreCacheFontCharacters(const LOGFONT& log_font,
|
void OnPreCacheFontCharacters(const LOGFONT& log_font,
|
||||||
const base::string16& characters);
|
const base::string16& characters);
|
||||||
|
|
||||||
void OnFailed();
|
|
||||||
void OnTempPdfReady(bool print_text_with_gdi, ScopedTempFile pdf);
|
|
||||||
void OnTempEmfReady(GetPageCallbackData* callback_data, ScopedTempFile emf);
|
|
||||||
|
|
||||||
scoped_refptr<RefCountedTempDir> temp_dir_;
|
scoped_refptr<RefCountedTempDir> temp_dir_;
|
||||||
|
|
||||||
// Used to suppress callbacks after PdfToEmfConverterImpl is deleted.
|
// Used to suppress callbacks after PdfConverter is deleted.
|
||||||
base::WeakPtr<PdfToEmfConverterImpl> converter_;
|
base::WeakPtr<PdfConverterImpl> converter_;
|
||||||
PdfRenderSettings settings_;
|
PdfRenderSettings settings_;
|
||||||
|
|
||||||
// Document loaded callback.
|
// Document loaded callback.
|
||||||
PdfToEmfConverter::StartCallback start_callback_;
|
PdfConverter::StartCallback start_callback_;
|
||||||
|
|
||||||
// Process host for IPC.
|
// Process host for IPC.
|
||||||
base::WeakPtr<content::UtilityProcessHost> utility_process_host_;
|
base::WeakPtr<content::UtilityProcessHost> utility_process_host_;
|
||||||
|
@ -186,22 +217,37 @@ class PdfToEmfUtilityProcessHostClient
|
||||||
// Queue of callbacks for GetPage() requests. Utility process should reply
|
// Queue of callbacks for GetPage() requests. Utility process should reply
|
||||||
// with PageDone in the same order as requests were received.
|
// with PageDone in the same order as requests were received.
|
||||||
// Use containers that keeps element pointers valid after push() and pop().
|
// Use containers that keeps element pointers valid after push() and pop().
|
||||||
typedef std::queue<GetPageCallbackData> GetPageCallbacks;
|
using GetPageCallbacks = std::queue<GetPageCallbackData>;
|
||||||
GetPageCallbacks get_page_callbacks_;
|
GetPageCallbacks get_page_callbacks_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(PdfToEmfUtilityProcessHostClient);
|
DISALLOW_COPY_AND_ASSIGN(PdfConverterUtilityProcessHostClient);
|
||||||
};
|
};
|
||||||
|
|
||||||
class PdfToEmfConverterImpl : public PdfToEmfConverter {
|
std::unique_ptr<MetafilePlayer>
|
||||||
public:
|
PdfConverterUtilityProcessHostClient::GetFileFromTemp(
|
||||||
PdfToEmfConverterImpl();
|
std::unique_ptr<base::File, content::BrowserThread::DeleteOnFileThread>
|
||||||
|
temp_file) {
|
||||||
|
if (settings_.mode == PdfRenderSettings::Mode::POSTSCRIPT_LEVEL2 ||
|
||||||
|
settings_.mode == PdfRenderSettings::Mode::POSTSCRIPT_LEVEL3) {
|
||||||
|
return base::MakeUnique<PostScriptMetaFile>(temp_dir_,
|
||||||
|
std::move(temp_file));
|
||||||
|
}
|
||||||
|
return base::MakeUnique<LazyEmf>(temp_dir_, std::move(temp_file));
|
||||||
|
}
|
||||||
|
|
||||||
~PdfToEmfConverterImpl() override;
|
class PdfConverterImpl : public PdfConverter {
|
||||||
|
public:
|
||||||
|
PdfConverterImpl();
|
||||||
|
|
||||||
|
~PdfConverterImpl() override;
|
||||||
|
|
||||||
|
base::WeakPtr<PdfConverterImpl> GetWeakPtr() {
|
||||||
|
return weak_ptr_factory_.GetWeakPtr();
|
||||||
|
}
|
||||||
|
|
||||||
void Start(const scoped_refptr<base::RefCountedMemory>& data,
|
void Start(const scoped_refptr<base::RefCountedMemory>& data,
|
||||||
const PdfRenderSettings& conversion_settings,
|
const PdfRenderSettings& conversion_settings,
|
||||||
bool print_text_with_gdi,
|
const StartCallback& start_callback);
|
||||||
const StartCallback& start_callback) override;
|
|
||||||
|
|
||||||
void GetPage(int page_number,
|
void GetPage(int page_number,
|
||||||
const GetPageCallback& get_page_callback) override;
|
const GetPageCallback& get_page_callback) override;
|
||||||
|
@ -209,11 +255,17 @@ class PdfToEmfConverterImpl : public PdfToEmfConverter {
|
||||||
// Helps to cancel callbacks if this object is destroyed.
|
// Helps to cancel callbacks if this object is destroyed.
|
||||||
void RunCallback(const base::Closure& callback);
|
void RunCallback(const base::Closure& callback);
|
||||||
|
|
||||||
private:
|
void Start(
|
||||||
scoped_refptr<PdfToEmfUtilityProcessHostClient> utility_client_;
|
const scoped_refptr<PdfConverterUtilityProcessHostClient>& utility_client,
|
||||||
base::WeakPtrFactory<PdfToEmfConverterImpl> weak_ptr_factory_;
|
const scoped_refptr<base::RefCountedMemory>& data,
|
||||||
|
const StartCallback& start_callback);
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(PdfToEmfConverterImpl);
|
private:
|
||||||
|
scoped_refptr<PdfConverterUtilityProcessHostClient> utility_client_;
|
||||||
|
|
||||||
|
base::WeakPtrFactory<PdfConverterImpl> weak_ptr_factory_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(PdfConverterImpl);
|
||||||
};
|
};
|
||||||
|
|
||||||
ScopedTempFile CreateTempFile(scoped_refptr<RefCountedTempDir>* temp_dir) {
|
ScopedTempFile CreateTempFile(scoped_refptr<RefCountedTempDir>* temp_dir) {
|
||||||
|
@ -260,10 +312,10 @@ ScopedTempFile CreateTempPdfFile(
|
||||||
bool LazyEmf::SafePlayback(HDC hdc) const {
|
bool LazyEmf::SafePlayback(HDC hdc) const {
|
||||||
Emf emf;
|
Emf emf;
|
||||||
bool result = LoadEmf(&emf) && emf.SafePlayback(hdc);
|
bool result = LoadEmf(&emf) && emf.SafePlayback(hdc);
|
||||||
// TODO(vitalybuka): Fix destruction of metafiles. For some reasons
|
// TODO(thestig): Fix destruction of metafiles. For some reasons
|
||||||
// instances of Emf are not deleted. crbug.com/411683
|
// instances of Emf are not deleted. https://crbug.com/260806
|
||||||
// It's known that the Emf going to be played just once to a printer. So just
|
// It's known that the Emf going to be played just once to a printer. So just
|
||||||
// release file here.
|
// release |file_| here.
|
||||||
Close();
|
Close();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -280,7 +332,7 @@ bool LazyEmf::SaveTo(base::File* file) const {
|
||||||
|
|
||||||
void LazyEmf::Close() const {
|
void LazyEmf::Close() const {
|
||||||
file_.reset();
|
file_.reset();
|
||||||
temp_dir_ = NULL;
|
temp_dir_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LazyEmf::LoadEmf(Emf* emf) const {
|
bool LazyEmf::LoadEmf(Emf* emf) const {
|
||||||
|
@ -294,24 +346,55 @@ bool LazyEmf::LoadEmf(Emf* emf) const {
|
||||||
return emf->InitFromData(data.data(), data.size());
|
return emf->InitFromData(data.data(), data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
PdfToEmfUtilityProcessHostClient::PdfToEmfUtilityProcessHostClient(
|
PostScriptMetaFile::~PostScriptMetaFile() {
|
||||||
base::WeakPtr<PdfToEmfConverterImpl> converter,
|
}
|
||||||
|
|
||||||
|
bool PostScriptMetaFile::SafePlayback(HDC hdc) const {
|
||||||
|
// TODO(thestig): Fix destruction of metafiles. For some reasons
|
||||||
|
// instances of Emf are not deleted. https://crbug.com/260806
|
||||||
|
// It's known that the Emf going to be played just once to a printer. So just
|
||||||
|
// release |file_| before returning.
|
||||||
|
Emf emf;
|
||||||
|
if (!LoadEmf(&emf)) {
|
||||||
|
Close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// Ensure enumerator destruction before calling Close() below.
|
||||||
|
Emf::Enumerator emf_enum(emf, nullptr, nullptr);
|
||||||
|
for (const Emf::Record& record : emf_enum) {
|
||||||
|
auto* emf_record = record.record();
|
||||||
|
if (emf_record->iType != EMR_GDICOMMENT)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
const EMRGDICOMMENT* comment =
|
||||||
|
reinterpret_cast<const EMRGDICOMMENT*>(emf_record);
|
||||||
|
const char* data = reinterpret_cast<const char*>(comment->Data);
|
||||||
|
const uint16_t* ptr = reinterpret_cast<const uint16_t*>(data);
|
||||||
|
int ret = ExtEscape(hdc, PASSTHROUGH, 2 + *ptr, data, 0, nullptr);
|
||||||
|
DCHECK_EQ(*ptr, ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PdfConverterUtilityProcessHostClient::PdfConverterUtilityProcessHostClient(
|
||||||
|
base::WeakPtr<PdfConverterImpl> converter,
|
||||||
const PdfRenderSettings& settings)
|
const PdfRenderSettings& settings)
|
||||||
: converter_(converter), settings_(settings) {
|
: converter_(converter), settings_(settings) {}
|
||||||
}
|
|
||||||
|
|
||||||
PdfToEmfUtilityProcessHostClient::~PdfToEmfUtilityProcessHostClient() {
|
PdfConverterUtilityProcessHostClient::~PdfConverterUtilityProcessHostClient() {}
|
||||||
}
|
|
||||||
|
|
||||||
void PdfToEmfUtilityProcessHostClient::Start(
|
void PdfConverterUtilityProcessHostClient::Start(
|
||||||
const scoped_refptr<base::RefCountedMemory>& data,
|
const scoped_refptr<base::RefCountedMemory>& data,
|
||||||
bool print_text_with_gdi,
|
const PdfConverter::StartCallback& start_callback) {
|
||||||
const PdfToEmfConverter::StartCallback& start_callback) {
|
|
||||||
if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
|
if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
|
||||||
BrowserThread::PostTask(
|
BrowserThread::PostTask(
|
||||||
BrowserThread::IO, FROM_HERE,
|
BrowserThread::IO, FROM_HERE,
|
||||||
base::Bind(&PdfToEmfUtilityProcessHostClient::Start, this, data,
|
base::Bind(&PdfConverterUtilityProcessHostClient::Start, this, data,
|
||||||
print_text_with_gdi, start_callback));
|
start_callback));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,50 +407,41 @@ void PdfToEmfUtilityProcessHostClient::Start(
|
||||||
utility_process_host_ = content::UtilityProcessHost::Create(
|
utility_process_host_ = content::UtilityProcessHost::Create(
|
||||||
this, base::ThreadTaskRunnerHandle::Get())
|
this, base::ThreadTaskRunnerHandle::Get())
|
||||||
->AsWeakPtr();
|
->AsWeakPtr();
|
||||||
utility_process_host_->SetName(base::ASCIIToUTF16(
|
utility_process_host_->SetName(GetName());
|
||||||
"IDS_UTILITY_PROCESS_EMF_CONVERTOR_NAME"));
|
|
||||||
|
|
||||||
BrowserThread::PostTaskAndReplyWithResult(
|
BrowserThread::PostTaskAndReplyWithResult(
|
||||||
BrowserThread::FILE, FROM_HERE,
|
BrowserThread::FILE, FROM_HERE,
|
||||||
base::Bind(&CreateTempPdfFile, data, &temp_dir_),
|
base::Bind(&CreateTempPdfFile, data, &temp_dir_),
|
||||||
base::Bind(&PdfToEmfUtilityProcessHostClient::OnTempPdfReady, this,
|
base::Bind(&PdfConverterUtilityProcessHostClient::OnTempPdfReady, this));
|
||||||
print_text_with_gdi));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdfToEmfUtilityProcessHostClient::OnTempPdfReady(bool print_text_with_gdi,
|
void PdfConverterUtilityProcessHostClient::OnTempPdfReady(ScopedTempFile pdf) {
|
||||||
ScopedTempFile pdf) {
|
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||||
if (!utility_process_host_ || !pdf)
|
if (!utility_process_host_ || !pdf)
|
||||||
return OnFailed();
|
return OnFailed();
|
||||||
// Should reply with OnPageCount().
|
// Should reply with OnPageCount().
|
||||||
Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles(
|
SendStartMessage(
|
||||||
IPC::GetPlatformFileForTransit(pdf->GetPlatformFile(), false), settings_,
|
IPC::GetPlatformFileForTransit(pdf->GetPlatformFile(), false));
|
||||||
print_text_with_gdi));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdfToEmfUtilityProcessHostClient::OnPageCount(int page_count) {
|
void PdfConverterUtilityProcessHostClient::OnPageCount(int page_count) {
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||||
if (start_callback_.is_null())
|
if (start_callback_.is_null())
|
||||||
return OnFailed();
|
return OnFailed();
|
||||||
BrowserThread::PostTask(BrowserThread::UI,
|
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
||||||
FROM_HERE,
|
base::Bind(&PdfConverterImpl::RunCallback, converter_,
|
||||||
base::Bind(&PdfToEmfConverterImpl::RunCallback,
|
|
||||||
converter_,
|
|
||||||
base::Bind(start_callback_, page_count)));
|
base::Bind(start_callback_, page_count)));
|
||||||
start_callback_.Reset();
|
start_callback_.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdfToEmfUtilityProcessHostClient::GetPage(
|
void PdfConverterUtilityProcessHostClient::GetPage(
|
||||||
int page_number,
|
int page_number,
|
||||||
const PdfToEmfConverter::GetPageCallback& get_page_callback) {
|
const PdfConverter::GetPageCallback& get_page_callback) {
|
||||||
if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
|
if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
|
||||||
BrowserThread::PostTask(
|
BrowserThread::PostTask(
|
||||||
BrowserThread::IO,
|
BrowserThread::IO, FROM_HERE,
|
||||||
FROM_HERE,
|
base::Bind(&PdfConverterUtilityProcessHostClient::GetPage, this,
|
||||||
base::Bind(&PdfToEmfUtilityProcessHostClient::GetPage,
|
page_number, get_page_callback));
|
||||||
this,
|
|
||||||
page_number,
|
|
||||||
get_page_callback));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,55 +452,84 @@ void PdfToEmfUtilityProcessHostClient::GetPage(
|
||||||
return OnFailed();
|
return OnFailed();
|
||||||
|
|
||||||
BrowserThread::PostTaskAndReplyWithResult(
|
BrowserThread::PostTaskAndReplyWithResult(
|
||||||
BrowserThread::FILE,
|
BrowserThread::FILE, FROM_HERE, base::Bind(&CreateTempFile, &temp_dir_),
|
||||||
FROM_HERE,
|
base::Bind(&PdfConverterUtilityProcessHostClient::OnTempFileReady, this,
|
||||||
base::Bind(&CreateTempFile, &temp_dir_),
|
|
||||||
base::Bind(&PdfToEmfUtilityProcessHostClient::OnTempEmfReady,
|
|
||||||
this,
|
|
||||||
&get_page_callbacks_.back()));
|
&get_page_callbacks_.back()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdfToEmfUtilityProcessHostClient::OnTempEmfReady(
|
void PdfConverterUtilityProcessHostClient::OnTempFileReady(
|
||||||
GetPageCallbackData* callback_data,
|
GetPageCallbackData* callback_data,
|
||||||
ScopedTempFile emf) {
|
ScopedTempFile temp_file) {
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||||
if (!utility_process_host_ || !emf)
|
if (!utility_process_host_ || !temp_file)
|
||||||
return OnFailed();
|
return OnFailed();
|
||||||
IPC::PlatformFileForTransit transit =
|
IPC::PlatformFileForTransit transit =
|
||||||
IPC::GetPlatformFileForTransit(emf->GetPlatformFile(), false);
|
IPC::GetPlatformFileForTransit(temp_file->GetPlatformFile(), false);
|
||||||
callback_data->set_emf(std::move(emf));
|
callback_data->set_file(std::move(temp_file));
|
||||||
// Should reply with OnPageDone().
|
// Should reply with OnPageDone().
|
||||||
Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles_GetPage(
|
SendGetPageMessage(callback_data->page_number(), transit);
|
||||||
callback_data->page_number(), transit));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdfToEmfUtilityProcessHostClient::OnPageDone(bool success,
|
void PdfConverterUtilityProcessHostClient::OnPageDone(bool success,
|
||||||
float scale_factor) {
|
float scale_factor) {
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||||
if (get_page_callbacks_.empty())
|
if (get_page_callbacks_.empty())
|
||||||
return OnFailed();
|
return OnFailed();
|
||||||
GetPageCallbackData& data = get_page_callbacks_.front();
|
GetPageCallbackData& data = get_page_callbacks_.front();
|
||||||
std::unique_ptr<MetafilePlayer> emf;
|
std::unique_ptr<MetafilePlayer> file;
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
ScopedTempFile temp_emf = data.TakeEmf();
|
ScopedTempFile temp_file = data.TakeFile();
|
||||||
if (!temp_emf) // Unexpected message from utility process.
|
if (!temp_file) // Unexpected message from utility process.
|
||||||
return OnFailed();
|
return OnFailed();
|
||||||
emf = base::MakeUnique<LazyEmf>(temp_dir_, std::move(temp_emf));
|
file = GetFileFromTemp(std::move(temp_file));
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserThread::PostTask(BrowserThread::UI,
|
BrowserThread::PostTask(
|
||||||
FROM_HERE,
|
BrowserThread::UI, FROM_HERE,
|
||||||
base::Bind(&PdfToEmfConverterImpl::RunCallback,
|
base::Bind(&PdfConverterImpl::RunCallback, converter_,
|
||||||
converter_,
|
base::Bind(data.callback(), data.page_number(), scale_factor,
|
||||||
base::Bind(data.callback(),
|
base::Passed(&file))));
|
||||||
data.page_number(),
|
|
||||||
scale_factor,
|
|
||||||
base::Passed(&emf))));
|
|
||||||
get_page_callbacks_.pop();
|
get_page_callbacks_.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdfToEmfUtilityProcessHostClient::OnPreCacheFontCharacters(
|
void PdfConverterUtilityProcessHostClient::Stop() {
|
||||||
|
if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
|
||||||
|
BrowserThread::PostTask(
|
||||||
|
BrowserThread::IO, FROM_HERE,
|
||||||
|
base::Bind(&PdfConverterUtilityProcessHostClient::Stop, this));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SendStopMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PdfConverterUtilityProcessHostClient::OnProcessCrashed(int exit_code) {
|
||||||
|
OnFailed();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PdfConverterUtilityProcessHostClient::OnProcessLaunchFailed(
|
||||||
|
int exit_code) {
|
||||||
|
OnFailed();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PdfConverterUtilityProcessHostClient::Send(IPC::Message* msg) {
|
||||||
|
if (utility_process_host_)
|
||||||
|
return utility_process_host_->Send(msg);
|
||||||
|
delete msg;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PdfConverterUtilityProcessHostClient::OnFailed() {
|
||||||
|
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||||
|
if (!start_callback_.is_null())
|
||||||
|
OnPageCount(0);
|
||||||
|
while (!get_page_callbacks_.empty())
|
||||||
|
OnPageDone(false, 0.0f);
|
||||||
|
utility_process_host_.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PdfConverterUtilityProcessHostClient::OnPreCacheFontCharacters(
|
||||||
const LOGFONT& font,
|
const LOGFONT& font,
|
||||||
const base::string16& str) {
|
const base::string16& str) {
|
||||||
// TODO(scottmg): pdf/ppapi still require the renderer to be able to precache
|
// TODO(scottmg): pdf/ppapi still require the renderer to be able to precache
|
||||||
|
@ -458,29 +561,10 @@ void PdfToEmfUtilityProcessHostClient::OnPreCacheFontCharacters(
|
||||||
DeleteEnhMetaFile(metafile);
|
DeleteEnhMetaFile(metafile);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdfToEmfUtilityProcessHostClient::Stop() {
|
bool PdfConverterUtilityProcessHostClient::OnMessageReceived(
|
||||||
if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
|
|
||||||
BrowserThread::PostTask(
|
|
||||||
BrowserThread::IO,
|
|
||||||
FROM_HERE,
|
|
||||||
base::Bind(&PdfToEmfUtilityProcessHostClient::Stop, this));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles_Stop());
|
|
||||||
}
|
|
||||||
|
|
||||||
void PdfToEmfUtilityProcessHostClient::OnProcessCrashed(int exit_code) {
|
|
||||||
OnFailed();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PdfToEmfUtilityProcessHostClient::OnProcessLaunchFailed(int exit_code) {
|
|
||||||
OnFailed();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PdfToEmfUtilityProcessHostClient::OnMessageReceived(
|
|
||||||
const IPC::Message& message) {
|
const IPC::Message& message) {
|
||||||
bool handled = true;
|
bool handled = true;
|
||||||
IPC_BEGIN_MESSAGE_MAP(PdfToEmfUtilityProcessHostClient, message)
|
IPC_BEGIN_MESSAGE_MAP(PdfConverterUtilityProcessHostClient, message)
|
||||||
IPC_MESSAGE_HANDLER(
|
IPC_MESSAGE_HANDLER(
|
||||||
ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageCount, OnPageCount)
|
ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageCount, OnPageCount)
|
||||||
IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageDone,
|
IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageDone,
|
||||||
|
@ -492,59 +576,69 @@ bool PdfToEmfUtilityProcessHostClient::OnMessageReceived(
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PdfToEmfUtilityProcessHostClient::Send(IPC::Message* msg) {
|
base::string16 PdfConverterUtilityProcessHostClient::GetName() const {
|
||||||
if (utility_process_host_)
|
return L"ChromeUtilityProcessPDFConvertor";
|
||||||
return utility_process_host_->Send(msg);
|
|
||||||
delete msg;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdfToEmfUtilityProcessHostClient::OnFailed() {
|
void PdfConverterUtilityProcessHostClient::SendGetPageMessage(
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
int page_number,
|
||||||
if (!start_callback_.is_null())
|
IPC::PlatformFileForTransit transit) {
|
||||||
OnPageCount(0);
|
Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles_GetPage(page_number,
|
||||||
while (!get_page_callbacks_.empty())
|
transit));
|
||||||
OnPageDone(false, 0.0f);
|
|
||||||
utility_process_host_.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PdfToEmfConverterImpl::PdfToEmfConverterImpl() : weak_ptr_factory_(this) {
|
void PdfConverterUtilityProcessHostClient::SendStartMessage(
|
||||||
|
IPC::PlatformFileForTransit transit) {
|
||||||
|
Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles(transit, settings_));
|
||||||
}
|
}
|
||||||
|
|
||||||
PdfToEmfConverterImpl::~PdfToEmfConverterImpl() {
|
void PdfConverterUtilityProcessHostClient::SendStopMessage() {
|
||||||
|
Send(new ChromeUtilityMsg_RenderPDFPagesToMetafiles_Stop());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pdf Converter Impl and subclasses
|
||||||
|
PdfConverterImpl::PdfConverterImpl() : weak_ptr_factory_(this) {}
|
||||||
|
|
||||||
|
PdfConverterImpl::~PdfConverterImpl() {
|
||||||
if (utility_client_.get())
|
if (utility_client_.get())
|
||||||
utility_client_->Stop();
|
utility_client_->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdfToEmfConverterImpl::Start(
|
void PdfConverterImpl::Start(
|
||||||
const scoped_refptr<base::RefCountedMemory>& data,
|
const scoped_refptr<PdfConverterUtilityProcessHostClient>& utility_client,
|
||||||
const PdfRenderSettings& conversion_settings,
|
const scoped_refptr<base::RefCountedMemory>& data,
|
||||||
bool print_text_with_gdi,
|
const StartCallback& start_callback) {
|
||||||
const StartCallback& start_callback) {
|
DCHECK(!utility_client_);
|
||||||
DCHECK(!utility_client_.get());
|
utility_client_ = utility_client;
|
||||||
utility_client_ = new PdfToEmfUtilityProcessHostClient(
|
utility_client_->Start(data, start_callback);
|
||||||
weak_ptr_factory_.GetWeakPtr(), conversion_settings);
|
|
||||||
utility_client_->Start(data, print_text_with_gdi, start_callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdfToEmfConverterImpl::GetPage(int page_number,
|
void PdfConverterImpl::GetPage(int page_number,
|
||||||
const GetPageCallback& get_page_callback) {
|
const GetPageCallback& get_page_callback) {
|
||||||
utility_client_->GetPage(page_number, get_page_callback);
|
utility_client_->GetPage(page_number, get_page_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PdfToEmfConverterImpl::RunCallback(const base::Closure& callback) {
|
void PdfConverterImpl::RunCallback(const base::Closure& callback) {
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||||
callback.Run();
|
callback.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
PdfToEmfConverter::~PdfToEmfConverter() {
|
PdfConverter::~PdfConverter() {}
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
std::unique_ptr<PdfToEmfConverter> PdfToEmfConverter::CreateDefault() {
|
std::unique_ptr<PdfConverter> PdfConverter::StartPdfConverter(
|
||||||
return std::unique_ptr<PdfToEmfConverter>(new PdfToEmfConverterImpl());
|
const scoped_refptr<base::RefCountedMemory>& data,
|
||||||
|
const PdfRenderSettings& conversion_settings,
|
||||||
|
const StartCallback& start_callback) {
|
||||||
|
std::unique_ptr<PdfConverterImpl> converter =
|
||||||
|
base::MakeUnique<PdfConverterImpl>();
|
||||||
|
converter->Start(
|
||||||
|
new PdfConverterUtilityProcessHostClient(converter->GetWeakPtr(),
|
||||||
|
conversion_settings),
|
||||||
|
data, start_callback);
|
||||||
|
return std::move(converter);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace printing
|
} // namespace printing
|
||||||
|
|
|
@ -15,24 +15,21 @@ namespace printing {
|
||||||
class MetafilePlayer;
|
class MetafilePlayer;
|
||||||
struct PdfRenderSettings;
|
struct PdfRenderSettings;
|
||||||
|
|
||||||
class PdfToEmfConverter {
|
class PdfConverter {
|
||||||
public:
|
public:
|
||||||
typedef base::Callback<void(int page_count)> StartCallback;
|
using StartCallback = base::Callback<void(int page_count)>;
|
||||||
typedef base::Callback<void(int page_number,
|
using GetPageCallback =
|
||||||
float scale_factor,
|
base::Callback<void(int page_number,
|
||||||
std::unique_ptr<MetafilePlayer> emf)>
|
float scale_factor,
|
||||||
GetPageCallback;
|
std::unique_ptr<MetafilePlayer> file)>;
|
||||||
|
virtual ~PdfConverter();
|
||||||
virtual ~PdfToEmfConverter();
|
|
||||||
|
|
||||||
static std::unique_ptr<PdfToEmfConverter> CreateDefault();
|
|
||||||
|
|
||||||
// Starts conversion of PDF provided as |data|. Calls |start_callback|
|
// Starts conversion of PDF provided as |data|. Calls |start_callback|
|
||||||
// with positive |page_count|. |page_count| is 0 if initialization failed.
|
// with positive |page_count|. |page_count| is 0 if initialization failed.
|
||||||
virtual void Start(const scoped_refptr<base::RefCountedMemory>& data,
|
static std::unique_ptr<PdfConverter> StartPdfConverter(
|
||||||
const PdfRenderSettings& conversion_settings,
|
const scoped_refptr<base::RefCountedMemory>& data,
|
||||||
bool print_text_with_gdi,
|
const PdfRenderSettings& conversion_settings,
|
||||||
const StartCallback& start_callback) = 0;
|
const StartCallback& start_callback);
|
||||||
|
|
||||||
// Requests conversion of the page. |page_number| is 0-base page number in
|
// Requests conversion of the page. |page_number| is 0-base page number in
|
||||||
// PDF provided in Start() call.
|
// PDF provided in Start() call.
|
||||||
|
@ -41,7 +38,6 @@ class PdfToEmfConverter {
|
||||||
virtual void GetPage(int page_number,
|
virtual void GetPage(int page_number,
|
||||||
const GetPageCallback& get_page_callback) = 0;
|
const GetPageCallback& get_page_callback) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace printing
|
} // namespace printing
|
||||||
|
|
||||||
#endif // CHROME_BROWSER_PRINTING_PDF_TO_EMF_CONVERTER_H_
|
#endif // CHROME_BROWSER_PRINTING_PDF_TO_EMF_CONVERTER_H_
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "base/message_loop/message_loop.h"
|
#include "base/message_loop/message_loop.h"
|
||||||
#include "base/run_loop.h"
|
#include "base/run_loop.h"
|
||||||
#include "base/single_thread_task_runner.h"
|
#include "base/single_thread_task_runner.h"
|
||||||
|
#include "base/threading/sequenced_worker_pool.h"
|
||||||
#include "base/threading/thread_restrictions.h"
|
#include "base/threading/thread_restrictions.h"
|
||||||
#include "base/threading/thread_task_runner_handle.h"
|
#include "base/threading/thread_task_runner_handle.h"
|
||||||
#include "base/threading/worker_pool.h"
|
#include "base/threading/worker_pool.h"
|
||||||
|
@ -222,27 +223,23 @@ PrintedDocument* PrintJob::document() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
|
class PrintJob::PdfConversionState {
|
||||||
class PrintJob::PdfToEmfState {
|
|
||||||
public:
|
public:
|
||||||
PdfToEmfState(const gfx::Size& page_size, const gfx::Rect& content_area)
|
PdfConversionState(gfx::Size page_size, gfx::Rect content_area)
|
||||||
: page_count_(0),
|
: page_count_(0),
|
||||||
current_page_(0),
|
current_page_(0),
|
||||||
pages_in_progress_(0),
|
pages_in_progress_(0),
|
||||||
page_size_(page_size),
|
page_size_(page_size),
|
||||||
content_area_(content_area),
|
content_area_(content_area) {}
|
||||||
converter_(PdfToEmfConverter::CreateDefault()) {}
|
|
||||||
|
|
||||||
void Start(const scoped_refptr<base::RefCountedMemory>& data,
|
void Start(const scoped_refptr<base::RefCountedMemory>& data,
|
||||||
const PdfRenderSettings& conversion_settings,
|
const PdfRenderSettings& conversion_settings,
|
||||||
bool print_text_with_gdi,
|
const PdfConverter::StartCallback& start_callback) {
|
||||||
const PdfToEmfConverter::StartCallback& start_callback) {
|
converter_ = PdfConverter::StartPdfConverter(
|
||||||
converter_->Start(data, conversion_settings, print_text_with_gdi,
|
data, conversion_settings, start_callback);
|
||||||
start_callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetMorePages(
|
void GetMorePages(const PdfConverter::GetPageCallback& get_page_callback) {
|
||||||
const PdfToEmfConverter::GetPageCallback& get_page_callback) {
|
|
||||||
const int kMaxNumberOfTempFilesPerDocument = 3;
|
const int kMaxNumberOfTempFilesPerDocument = 3;
|
||||||
while (pages_in_progress_ < kMaxNumberOfTempFilesPerDocument &&
|
while (pages_in_progress_ < kMaxNumberOfTempFilesPerDocument &&
|
||||||
current_page_ < page_count_) {
|
current_page_ < page_count_) {
|
||||||
|
@ -251,8 +248,7 @@ class PrintJob::PdfToEmfState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnPageProcessed(
|
void OnPageProcessed(const PdfConverter::GetPageCallback& get_page_callback) {
|
||||||
const PdfToEmfConverter::GetPageCallback& get_page_callback) {
|
|
||||||
--pages_in_progress_;
|
--pages_in_progress_;
|
||||||
GetMorePages(get_page_callback);
|
GetMorePages(get_page_callback);
|
||||||
// Release converter if we don't need this any more.
|
// Release converter if we don't need this any more.
|
||||||
|
@ -270,7 +266,7 @@ class PrintJob::PdfToEmfState {
|
||||||
int pages_in_progress_;
|
int pages_in_progress_;
|
||||||
gfx::Size page_size_;
|
gfx::Size page_size_;
|
||||||
gfx::Rect content_area_;
|
gfx::Rect content_area_;
|
||||||
std::unique_ptr<PdfToEmfConverter> converter_;
|
std::unique_ptr<PdfConverter> converter_;
|
||||||
};
|
};
|
||||||
|
|
||||||
void PrintJob::AppendPrintedPage(int page_number) {
|
void PrintJob::AppendPrintedPage(int page_number) {
|
||||||
|
@ -282,46 +278,67 @@ void PrintJob::StartPdfToEmfConversion(
|
||||||
const gfx::Size& page_size,
|
const gfx::Size& page_size,
|
||||||
const gfx::Rect& content_area,
|
const gfx::Rect& content_area,
|
||||||
bool print_text_with_gdi) {
|
bool print_text_with_gdi) {
|
||||||
DCHECK(!pdf_to_emf_state_);
|
DCHECK(!pdf_conversion_state_);
|
||||||
pdf_to_emf_state_ = base::MakeUnique<PdfToEmfState>(page_size, content_area);
|
pdf_conversion_state_ =
|
||||||
|
base::MakeUnique<PdfConversionState>(page_size, content_area);
|
||||||
const int kPrinterDpi = settings().dpi();
|
const int kPrinterDpi = settings().dpi();
|
||||||
pdf_to_emf_state_->Start(
|
PdfRenderSettings settings(
|
||||||
bytes, PdfRenderSettings(content_area, kPrinterDpi, true),
|
content_area, gfx::Point(0, 0), kPrinterDpi, /*autorotate=*/true,
|
||||||
print_text_with_gdi, base::Bind(&PrintJob::OnPdfToEmfStarted, this));
|
print_text_with_gdi ? PdfRenderSettings::Mode::GDI_TEXT
|
||||||
|
: PdfRenderSettings::Mode::NORMAL);
|
||||||
|
pdf_conversion_state_->Start(
|
||||||
|
bytes, settings, base::Bind(&PrintJob::OnPdfConversionStarted, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintJob::OnPdfToEmfStarted(int page_count) {
|
void PrintJob::OnPdfConversionStarted(int page_count) {
|
||||||
if (page_count <= 0) {
|
if (page_count <= 0) {
|
||||||
pdf_to_emf_state_.reset();
|
pdf_conversion_state_.reset();
|
||||||
Cancel();
|
Cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pdf_to_emf_state_->set_page_count(page_count);
|
pdf_conversion_state_->set_page_count(page_count);
|
||||||
pdf_to_emf_state_->GetMorePages(
|
pdf_conversion_state_->GetMorePages(
|
||||||
base::Bind(&PrintJob::OnPdfToEmfPageConverted, this));
|
base::Bind(&PrintJob::OnPdfPageConverted, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintJob::OnPdfToEmfPageConverted(int page_number,
|
void PrintJob::OnPdfPageConverted(int page_number,
|
||||||
float scale_factor,
|
float scale_factor,
|
||||||
std::unique_ptr<MetafilePlayer> emf) {
|
std::unique_ptr<MetafilePlayer> metafile) {
|
||||||
DCHECK(pdf_to_emf_state_);
|
DCHECK(pdf_conversion_state_);
|
||||||
if (!document_.get() || !emf || page_number < 0 ||
|
if (!document_.get() || !metafile || page_number < 0 ||
|
||||||
static_cast<size_t>(page_number) >= pdf_page_mapping_.size()) {
|
static_cast<size_t>(page_number) >= pdf_page_mapping_.size()) {
|
||||||
pdf_to_emf_state_.reset();
|
pdf_conversion_state_.reset();
|
||||||
Cancel();
|
Cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the rendered document. It will send notifications to the listener.
|
// Update the rendered document. It will send notifications to the listener.
|
||||||
document_->SetPage(pdf_page_mapping_[page_number], std::move(emf),
|
document_->SetPage(pdf_page_mapping_[page_number], std::move(metafile),
|
||||||
scale_factor, pdf_to_emf_state_->page_size(),
|
scale_factor, pdf_conversion_state_->page_size(),
|
||||||
pdf_to_emf_state_->content_area());
|
pdf_conversion_state_->content_area());
|
||||||
|
|
||||||
pdf_to_emf_state_->GetMorePages(
|
pdf_conversion_state_->GetMorePages(
|
||||||
base::Bind(&PrintJob::OnPdfToEmfPageConverted, this));
|
base::Bind(&PrintJob::OnPdfPageConverted, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // OS_WIN
|
void PrintJob::StartPdfToPostScriptConversion(
|
||||||
|
const scoped_refptr<base::RefCountedMemory>& bytes,
|
||||||
|
const gfx::Rect& content_area,
|
||||||
|
const gfx::Point& physical_offsets,
|
||||||
|
bool ps_level2) {
|
||||||
|
DCHECK(!pdf_conversion_state_);
|
||||||
|
pdf_conversion_state_ = base::MakeUnique<PdfConversionState>(
|
||||||
|
gfx::Size(), gfx::Rect());
|
||||||
|
const int kPrinterDpi = settings().dpi();
|
||||||
|
PdfRenderSettings settings(
|
||||||
|
content_area, physical_offsets, kPrinterDpi, true /* autorotate? */,
|
||||||
|
ps_level2 ? PdfRenderSettings::Mode::POSTSCRIPT_LEVEL2
|
||||||
|
: PdfRenderSettings::Mode::POSTSCRIPT_LEVEL3);
|
||||||
|
pdf_conversion_state_->Start(
|
||||||
|
bytes, settings, base::Bind(&PrintJob::OnPdfConversionStarted, this));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // defined(OS_WIN)
|
||||||
|
|
||||||
void PrintJob::UpdatePrintedDocument(PrintedDocument* new_document) {
|
void PrintJob::UpdatePrintedDocument(PrintedDocument* new_document) {
|
||||||
if (document_.get() == new_document)
|
if (document_.get() == new_document)
|
||||||
|
@ -372,8 +389,10 @@ void PrintJob::OnNotifyPrintJobEvent(const JobEventDetails& event_details) {
|
||||||
}
|
}
|
||||||
case JobEventDetails::PAGE_DONE:
|
case JobEventDetails::PAGE_DONE:
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
pdf_to_emf_state_->OnPageProcessed(
|
if (pdf_conversion_state_) {
|
||||||
base::Bind(&PrintJob::OnPdfToEmfPageConverted, this));
|
pdf_conversion_state_->OnPageProcessed(
|
||||||
|
base::Bind(&PrintJob::OnPdfPageConverted, this));
|
||||||
|
}
|
||||||
#endif // defined(OS_WIN)
|
#endif // defined(OS_WIN)
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
|
|
|
@ -100,6 +100,12 @@ class PrintJob : public PrintJobWorkerOwner,
|
||||||
const gfx::Size& page_size,
|
const gfx::Size& page_size,
|
||||||
const gfx::Rect& content_area,
|
const gfx::Rect& content_area,
|
||||||
bool print_text_with_gdi);
|
bool print_text_with_gdi);
|
||||||
|
|
||||||
|
void StartPdfToPostScriptConversion(
|
||||||
|
const scoped_refptr<base::RefCountedMemory>& bytes,
|
||||||
|
const gfx::Rect& content_area,
|
||||||
|
const gfx::Point& physical_offset,
|
||||||
|
bool ps_level2);
|
||||||
#endif // defined(OS_WIN)
|
#endif // defined(OS_WIN)
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -126,10 +132,10 @@ class PrintJob : public PrintJobWorkerOwner,
|
||||||
void HoldUntilStopIsCalled();
|
void HoldUntilStopIsCalled();
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
void OnPdfToEmfStarted(int page_count);
|
void OnPdfConversionStarted(int page_count);
|
||||||
void OnPdfToEmfPageConverted(int page_number,
|
void OnPdfPageConverted(int page_number,
|
||||||
float scale_factor,
|
float scale_factor,
|
||||||
std::unique_ptr<MetafilePlayer> emf);
|
std::unique_ptr<MetafilePlayer> emf);
|
||||||
#endif // defined(OS_WIN)
|
#endif // defined(OS_WIN)
|
||||||
|
|
||||||
content::NotificationRegistrar registrar_;
|
content::NotificationRegistrar registrar_;
|
||||||
|
@ -157,8 +163,8 @@ class PrintJob : public PrintJobWorkerOwner,
|
||||||
bool is_canceling_;
|
bool is_canceling_;
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
class PdfToEmfState;
|
class PdfConversionState;
|
||||||
std::unique_ptr<PdfToEmfState> pdf_to_emf_state_;
|
std::unique_ptr<PdfConversionState> pdf_conversion_state_;
|
||||||
std::vector<int> pdf_page_mapping_;
|
std::vector<int> pdf_page_mapping_;
|
||||||
#endif // defined(OS_WIN)
|
#endif // defined(OS_WIN)
|
||||||
|
|
||||||
|
|
|
@ -49,25 +49,34 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <memory>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "atom/common/atom_command_line.h"
|
#include "atom/common/atom_command_line.h"
|
||||||
|
|
||||||
#include "base/base_paths.h"
|
#include "base/base_paths.h"
|
||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
#include "base/command_line.h"
|
#include "base/command_line.h"
|
||||||
|
#include "base/files/file_descriptor_watcher_posix.h"
|
||||||
#include "base/files/file_path.h"
|
#include "base/files/file_path.h"
|
||||||
#include "base/files/file_util.h"
|
#include "base/files/file_util.h"
|
||||||
#include "base/location.h"
|
#include "base/location.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
|
#include "base/macros.h"
|
||||||
|
#include "base/memory/ptr_util.h"
|
||||||
|
#include "base/memory/ref_counted.h"
|
||||||
#include "base/message_loop/message_loop.h"
|
#include "base/message_loop/message_loop.h"
|
||||||
|
#include "base/metrics/histogram_macros.h"
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
#include "base/posix/eintr_wrapper.h"
|
#include "base/posix/eintr_wrapper.h"
|
||||||
#include "base/posix/safe_strerror.h"
|
#include "base/posix/safe_strerror.h"
|
||||||
#include "base/rand_util.h"
|
#include "base/rand_util.h"
|
||||||
#include "base/sequenced_task_runner_helpers.h"
|
#include "base/sequenced_task_runner_helpers.h"
|
||||||
#include "base/single_thread_task_runner.h"
|
#include "base/single_thread_task_runner.h"
|
||||||
#include "base/stl_util.h"
|
#include "base/single_thread_task_runner.h"
|
||||||
#include "base/strings/string_number_conversions.h"
|
#include "base/strings/string_number_conversions.h"
|
||||||
#include "base/strings/string_split.h"
|
#include "base/strings/string_split.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
|
@ -78,6 +87,7 @@
|
||||||
#include "base/threading/thread_task_runner_handle.h"
|
#include "base/threading/thread_task_runner_handle.h"
|
||||||
#include "base/time/time.h"
|
#include "base/time/time.h"
|
||||||
#include "base/timer/timer.h"
|
#include "base/timer/timer.h"
|
||||||
|
#include "build/build_config.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "net/base/network_interfaces.h"
|
#include "net/base/network_interfaces.h"
|
||||||
#include "ui/base/l10n/l10n_util.h"
|
#include "ui/base/l10n/l10n_util.h"
|
||||||
|
@ -222,9 +232,8 @@ int SetupSocketOnly() {
|
||||||
int sock = socket(PF_UNIX, SOCK_STREAM, 0);
|
int sock = socket(PF_UNIX, SOCK_STREAM, 0);
|
||||||
PCHECK(sock >= 0) << "socket() failed";
|
PCHECK(sock >= 0) << "socket() failed";
|
||||||
|
|
||||||
int rv = base::SetNonBlocking(sock);
|
DCHECK(base::SetNonBlocking(sock)) << "Failed to make non-blocking socket.";
|
||||||
DCHECK_EQ(0, rv) << "Failed to make non-blocking socket.";
|
int rv = SetCloseOnExec(sock);
|
||||||
rv = SetCloseOnExec(sock);
|
|
||||||
DCHECK_EQ(0, rv) << "Failed to set CLOEXEC on socket.";
|
DCHECK_EQ(0, rv) << "Failed to set CLOEXEC on socket.";
|
||||||
|
|
||||||
return sock;
|
return sock;
|
||||||
|
@ -305,7 +314,6 @@ bool ParseLockPath(const base::FilePath& path,
|
||||||
bool DisplayProfileInUseError(const base::FilePath& lock_path,
|
bool DisplayProfileInUseError(const base::FilePath& lock_path,
|
||||||
const std::string& hostname,
|
const std::string& hostname,
|
||||||
int pid) {
|
int pid) {
|
||||||
// TODO: yolo
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,44 +463,38 @@ bool ReplaceOldSingletonLock(const base::FilePath& symlink_content,
|
||||||
// This class sets up a listener on the singleton socket and handles parsing
|
// This class sets up a listener on the singleton socket and handles parsing
|
||||||
// messages that come in on the singleton socket.
|
// messages that come in on the singleton socket.
|
||||||
class ProcessSingleton::LinuxWatcher
|
class ProcessSingleton::LinuxWatcher
|
||||||
: public base::MessageLoopForIO::Watcher,
|
: public base::RefCountedThreadSafe<ProcessSingleton::LinuxWatcher,
|
||||||
public base::MessageLoop::DestructionObserver,
|
|
||||||
public base::RefCountedThreadSafe<ProcessSingleton::LinuxWatcher,
|
|
||||||
BrowserThread::DeleteOnIOThread> {
|
BrowserThread::DeleteOnIOThread> {
|
||||||
public:
|
public:
|
||||||
// A helper class to read message from an established socket.
|
// A helper class to read message from an established socket.
|
||||||
class SocketReader : public base::MessageLoopForIO::Watcher {
|
class SocketReader {
|
||||||
public:
|
public:
|
||||||
SocketReader(ProcessSingleton::LinuxWatcher* parent,
|
SocketReader(ProcessSingleton::LinuxWatcher* parent,
|
||||||
base::MessageLoop* ui_message_loop,
|
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
|
||||||
int fd)
|
int fd)
|
||||||
: parent_(parent),
|
: parent_(parent),
|
||||||
ui_message_loop_(ui_message_loop),
|
ui_task_runner_(ui_task_runner),
|
||||||
fd_(fd),
|
fd_(fd),
|
||||||
bytes_read_(0) {
|
bytes_read_(0) {
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||||
// Wait for reads.
|
// Wait for reads.
|
||||||
base::MessageLoopForIO::current()->WatchFileDescriptor(
|
fd_watch_controller_ = base::FileDescriptorWatcher::WatchReadable(
|
||||||
fd, true, base::MessageLoopForIO::WATCH_READ, &fd_reader_, this);
|
fd, base::Bind(&SocketReader::OnSocketCanReadWithoutBlocking,
|
||||||
|
base::Unretained(this)));
|
||||||
// If we haven't completed in a reasonable amount of time, give up.
|
// If we haven't completed in a reasonable amount of time, give up.
|
||||||
timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kTimeoutInSeconds),
|
timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kTimeoutInSeconds),
|
||||||
this, &SocketReader::CleanupAndDeleteSelf);
|
this, &SocketReader::CleanupAndDeleteSelf);
|
||||||
}
|
}
|
||||||
|
|
||||||
~SocketReader() override { CloseSocket(fd_); }
|
~SocketReader() { CloseSocket(fd_); }
|
||||||
|
|
||||||
// MessageLoopForIO::Watcher impl.
|
|
||||||
void OnFileCanReadWithoutBlocking(int fd) override;
|
|
||||||
void OnFileCanWriteWithoutBlocking(int fd) override {
|
|
||||||
// SocketReader only watches for accept (read) events.
|
|
||||||
NOTREACHED();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finish handling the incoming message by optionally sending back an ACK
|
// Finish handling the incoming message by optionally sending back an ACK
|
||||||
// message and removing this SocketReader.
|
// message and removing this SocketReader.
|
||||||
void FinishWithACK(const char *message, size_t length);
|
void FinishWithACK(const char *message, size_t length);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void OnSocketCanReadWithoutBlocking();
|
||||||
|
|
||||||
void CleanupAndDeleteSelf() {
|
void CleanupAndDeleteSelf() {
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||||
|
|
||||||
|
@ -500,13 +502,15 @@ class ProcessSingleton::LinuxWatcher
|
||||||
// We're deleted beyond this point.
|
// We're deleted beyond this point.
|
||||||
}
|
}
|
||||||
|
|
||||||
base::MessageLoopForIO::FileDescriptorWatcher fd_reader_;
|
// Controls watching |fd_|.
|
||||||
|
std::unique_ptr<base::FileDescriptorWatcher::Controller>
|
||||||
|
fd_watch_controller_;
|
||||||
|
|
||||||
// The ProcessSingleton::LinuxWatcher that owns us.
|
// The ProcessSingleton::LinuxWatcher that owns us.
|
||||||
ProcessSingleton::LinuxWatcher* const parent_;
|
ProcessSingleton::LinuxWatcher* const parent_;
|
||||||
|
|
||||||
// A reference to the UI message loop.
|
// A reference to the UI task runner.
|
||||||
base::MessageLoop* const ui_message_loop_;
|
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
|
||||||
|
|
||||||
// The file descriptor we're reading.
|
// The file descriptor we're reading.
|
||||||
const int fd_;
|
const int fd_;
|
||||||
|
@ -525,9 +529,7 @@ class ProcessSingleton::LinuxWatcher
|
||||||
|
|
||||||
// We expect to only be constructed on the UI thread.
|
// We expect to only be constructed on the UI thread.
|
||||||
explicit LinuxWatcher(ProcessSingleton* parent)
|
explicit LinuxWatcher(ProcessSingleton* parent)
|
||||||
: ui_message_loop_(base::MessageLoop::current()),
|
: ui_task_runner_(base::ThreadTaskRunnerHandle::Get()), parent_(parent) {}
|
||||||
parent_(parent) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start listening for connections on the socket. This method should be
|
// Start listening for connections on the socket. This method should be
|
||||||
// called from the IO thread.
|
// called from the IO thread.
|
||||||
|
@ -540,79 +542,63 @@ class ProcessSingleton::LinuxWatcher
|
||||||
const std::vector<std::string>& argv,
|
const std::vector<std::string>& argv,
|
||||||
SocketReader* reader);
|
SocketReader* reader);
|
||||||
|
|
||||||
// MessageLoopForIO::Watcher impl. These run on the IO thread.
|
|
||||||
void OnFileCanReadWithoutBlocking(int fd) override;
|
|
||||||
void OnFileCanWriteWithoutBlocking(int fd) override {
|
|
||||||
// ProcessSingleton only watches for accept (read) events.
|
|
||||||
NOTREACHED();
|
|
||||||
}
|
|
||||||
|
|
||||||
// MessageLoop::DestructionObserver
|
|
||||||
void WillDestroyCurrentMessageLoop() override {
|
|
||||||
fd_watcher_.StopWatchingFileDescriptor();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>;
|
friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>;
|
||||||
friend class base::DeleteHelper<ProcessSingleton::LinuxWatcher>;
|
friend class base::DeleteHelper<ProcessSingleton::LinuxWatcher>;
|
||||||
|
|
||||||
~LinuxWatcher() override {
|
~LinuxWatcher() {
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||||
STLDeleteElements(&readers_);
|
|
||||||
|
|
||||||
base::MessageLoopForIO* ml = base::MessageLoopForIO::current();
|
|
||||||
ml->RemoveDestructionObserver(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OnSocketCanReadWithoutBlocking(int socket);
|
||||||
|
|
||||||
// Removes and deletes the SocketReader.
|
// Removes and deletes the SocketReader.
|
||||||
void RemoveSocketReader(SocketReader* reader);
|
void RemoveSocketReader(SocketReader* reader);
|
||||||
|
|
||||||
base::MessageLoopForIO::FileDescriptorWatcher fd_watcher_;
|
std::unique_ptr<base::FileDescriptorWatcher::Controller> socket_watcher_;
|
||||||
|
|
||||||
// A reference to the UI message loop (i.e., the message loop we were
|
// A reference to the UI message loop (i.e., the message loop we were
|
||||||
// constructed on).
|
// constructed on).
|
||||||
base::MessageLoop* ui_message_loop_;
|
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
|
||||||
|
|
||||||
// The ProcessSingleton that owns us.
|
// The ProcessSingleton that owns us.
|
||||||
ProcessSingleton* const parent_;
|
ProcessSingleton* const parent_;
|
||||||
|
|
||||||
std::set<SocketReader*> readers_;
|
std::set<std::unique_ptr<SocketReader>> readers_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(LinuxWatcher);
|
DISALLOW_COPY_AND_ASSIGN(LinuxWatcher);
|
||||||
};
|
};
|
||||||
|
|
||||||
void ProcessSingleton::LinuxWatcher::OnFileCanReadWithoutBlocking(int fd) {
|
void ProcessSingleton::LinuxWatcher::OnSocketCanReadWithoutBlocking(
|
||||||
|
int socket) {
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||||
// Accepting incoming client.
|
// Accepting incoming client.
|
||||||
sockaddr_un from;
|
sockaddr_un from;
|
||||||
socklen_t from_len = sizeof(from);
|
socklen_t from_len = sizeof(from);
|
||||||
int connection_socket = HANDLE_EINTR(accept(
|
int connection_socket = HANDLE_EINTR(
|
||||||
fd, reinterpret_cast<sockaddr*>(&from), &from_len));
|
accept(socket, reinterpret_cast<sockaddr*>(&from), &from_len));
|
||||||
if (-1 == connection_socket) {
|
if (-1 == connection_socket) {
|
||||||
PLOG(ERROR) << "accept() failed";
|
PLOG(ERROR) << "accept() failed";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int rv = base::SetNonBlocking(connection_socket);
|
DCHECK(base::SetNonBlocking(connection_socket))
|
||||||
DCHECK_EQ(0, rv) << "Failed to make non-blocking socket.";
|
<< "Failed to make non-blocking socket.";
|
||||||
SocketReader* reader = new SocketReader(this,
|
readers_.insert(
|
||||||
ui_message_loop_,
|
base::MakeUnique<SocketReader>(this, ui_task_runner_, connection_socket));
|
||||||
connection_socket);
|
|
||||||
readers_.insert(reader);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessSingleton::LinuxWatcher::StartListening(int socket) {
|
void ProcessSingleton::LinuxWatcher::StartListening(int socket) {
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||||
// Watch for client connections on this socket.
|
// Watch for client connections on this socket.
|
||||||
base::MessageLoopForIO* ml = base::MessageLoopForIO::current();
|
socket_watcher_ = base::FileDescriptorWatcher::WatchReadable(
|
||||||
ml->AddDestructionObserver(this);
|
socket, base::Bind(&LinuxWatcher::OnSocketCanReadWithoutBlocking,
|
||||||
ml->WatchFileDescriptor(socket, true, base::MessageLoopForIO::WATCH_READ,
|
base::Unretained(this), socket));
|
||||||
&fd_watcher_, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessSingleton::LinuxWatcher::HandleMessage(
|
void ProcessSingleton::LinuxWatcher::HandleMessage(
|
||||||
const std::string& current_dir, const std::vector<std::string>& argv,
|
const std::string& current_dir, const std::vector<std::string>& argv,
|
||||||
SocketReader* reader) {
|
SocketReader* reader) {
|
||||||
DCHECK(ui_message_loop_ == base::MessageLoop::current());
|
DCHECK(ui_task_runner_->BelongsToCurrentThread());
|
||||||
DCHECK(reader);
|
DCHECK(reader);
|
||||||
|
|
||||||
if (parent_->notification_callback_.Run(argv,
|
if (parent_->notification_callback_.Run(argv,
|
||||||
|
@ -632,25 +618,27 @@ void ProcessSingleton::LinuxWatcher::HandleMessage(
|
||||||
void ProcessSingleton::LinuxWatcher::RemoveSocketReader(SocketReader* reader) {
|
void ProcessSingleton::LinuxWatcher::RemoveSocketReader(SocketReader* reader) {
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||||
DCHECK(reader);
|
DCHECK(reader);
|
||||||
readers_.erase(reader);
|
auto it = std::find_if(readers_.begin(), readers_.end(),
|
||||||
delete reader;
|
[reader](const std::unique_ptr<SocketReader>& ptr) {
|
||||||
|
return ptr.get() == reader;
|
||||||
|
});
|
||||||
|
readers_.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// ProcessSingleton::LinuxWatcher::SocketReader
|
// ProcessSingleton::LinuxWatcher::SocketReader
|
||||||
//
|
//
|
||||||
|
|
||||||
void ProcessSingleton::LinuxWatcher::SocketReader::OnFileCanReadWithoutBlocking(
|
void ProcessSingleton::LinuxWatcher::SocketReader::
|
||||||
int fd) {
|
OnSocketCanReadWithoutBlocking() {
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||||
DCHECK_EQ(fd, fd_);
|
|
||||||
while (bytes_read_ < sizeof(buf_)) {
|
while (bytes_read_ < sizeof(buf_)) {
|
||||||
ssize_t rv = HANDLE_EINTR(
|
ssize_t rv =
|
||||||
read(fd, buf_ + bytes_read_, sizeof(buf_) - bytes_read_));
|
HANDLE_EINTR(read(fd_, buf_ + bytes_read_, sizeof(buf_) - bytes_read_));
|
||||||
if (rv < 0) {
|
if (rv < 0) {
|
||||||
if (errno != EAGAIN && errno != EWOULDBLOCK) {
|
if (errno != EAGAIN && errno != EWOULDBLOCK) {
|
||||||
PLOG(ERROR) << "read() failed";
|
PLOG(ERROR) << "read() failed";
|
||||||
CloseSocket(fd);
|
CloseSocket(fd_);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
// It would block, so we just return and continue to watch for the next
|
// It would block, so we just return and continue to watch for the next
|
||||||
|
@ -696,10 +684,10 @@ void ProcessSingleton::LinuxWatcher::SocketReader::OnFileCanReadWithoutBlocking(
|
||||||
tokens.erase(tokens.begin());
|
tokens.erase(tokens.begin());
|
||||||
|
|
||||||
// Return to the UI thread to handle opening a new browser tab.
|
// Return to the UI thread to handle opening a new browser tab.
|
||||||
ui_message_loop_->task_runner()->PostTask(
|
ui_task_runner_->PostTask(
|
||||||
FROM_HERE, base::Bind(&ProcessSingleton::LinuxWatcher::HandleMessage,
|
FROM_HERE, base::Bind(&ProcessSingleton::LinuxWatcher::HandleMessage,
|
||||||
parent_, current_dir, tokens, this));
|
parent_, current_dir, tokens, this));
|
||||||
fd_reader_.StopWatchingFileDescriptor();
|
fd_watch_controller_.reset();
|
||||||
|
|
||||||
// LinuxWatcher::HandleMessage() is in charge of destroying this SocketReader
|
// LinuxWatcher::HandleMessage() is in charge of destroying this SocketReader
|
||||||
// object by invoking SocketReader::FinishWithACK().
|
// object by invoking SocketReader::FinishWithACK().
|
||||||
|
@ -731,7 +719,8 @@ ProcessSingleton::ProcessSingleton(
|
||||||
const base::FilePath& user_data_dir,
|
const base::FilePath& user_data_dir,
|
||||||
const NotificationCallback& notification_callback)
|
const NotificationCallback& notification_callback)
|
||||||
: notification_callback_(notification_callback),
|
: notification_callback_(notification_callback),
|
||||||
current_pid_(base::GetCurrentProcId()) {
|
current_pid_(base::GetCurrentProcId()),
|
||||||
|
watcher_(new LinuxWatcher(this)) {
|
||||||
// The user_data_dir may have not been created yet.
|
// The user_data_dir may have not been created yet.
|
||||||
base::CreateDirectoryAndGetError(user_data_dir, nullptr);
|
base::CreateDirectoryAndGetError(user_data_dir, nullptr);
|
||||||
|
|
||||||
|
@ -897,12 +886,26 @@ ProcessSingleton::NotifyOtherProcessWithTimeoutOrCreate(
|
||||||
const base::CommandLine& command_line,
|
const base::CommandLine& command_line,
|
||||||
int retry_attempts,
|
int retry_attempts,
|
||||||
const base::TimeDelta& timeout) {
|
const base::TimeDelta& timeout) {
|
||||||
|
const base::TimeTicks begin_ticks = base::TimeTicks::Now();
|
||||||
NotifyResult result = NotifyOtherProcessWithTimeout(
|
NotifyResult result = NotifyOtherProcessWithTimeout(
|
||||||
command_line, retry_attempts, timeout, true);
|
command_line, retry_attempts, timeout, true);
|
||||||
if (result != PROCESS_NONE)
|
if (result != PROCESS_NONE) {
|
||||||
|
if (result == PROCESS_NOTIFIED) {
|
||||||
|
UMA_HISTOGRAM_MEDIUM_TIMES("Chrome.ProcessSingleton.TimeToNotify",
|
||||||
|
base::TimeTicks::Now() - begin_ticks);
|
||||||
|
} else {
|
||||||
|
UMA_HISTOGRAM_MEDIUM_TIMES("Chrome.ProcessSingleton.TimeToFailure",
|
||||||
|
base::TimeTicks::Now() - begin_ticks);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
if (Create())
|
}
|
||||||
|
|
||||||
|
if (Create()) {
|
||||||
|
UMA_HISTOGRAM_MEDIUM_TIMES("Chrome.ProcessSingleton.TimeToCreate",
|
||||||
|
base::TimeTicks::Now() - begin_ticks);
|
||||||
return PROCESS_NONE;
|
return PROCESS_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
// If the Create() failed, try again to notify. (It could be that another
|
// If the Create() failed, try again to notify. (It could be that another
|
||||||
// instance was starting at the same time and managed to grab the lock before
|
// instance was starting at the same time and managed to grab the lock before
|
||||||
// we did.)
|
// we did.)
|
||||||
|
@ -910,6 +913,15 @@ ProcessSingleton::NotifyOtherProcessWithTimeoutOrCreate(
|
||||||
// aren't going to try to take over the lock ourselves.
|
// aren't going to try to take over the lock ourselves.
|
||||||
result = NotifyOtherProcessWithTimeout(
|
result = NotifyOtherProcessWithTimeout(
|
||||||
command_line, retry_attempts, timeout, false);
|
command_line, retry_attempts, timeout, false);
|
||||||
|
|
||||||
|
if (result == PROCESS_NOTIFIED) {
|
||||||
|
UMA_HISTOGRAM_MEDIUM_TIMES("Chrome.ProcessSingleton.TimeToNotify",
|
||||||
|
base::TimeTicks::Now() - begin_ticks);
|
||||||
|
} else {
|
||||||
|
UMA_HISTOGRAM_MEDIUM_TIMES("Chrome.ProcessSingleton.TimeToFailure",
|
||||||
|
base::TimeTicks::Now() - begin_ticks);
|
||||||
|
}
|
||||||
|
|
||||||
if (result != PROCESS_NONE)
|
if (result != PROCESS_NONE)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
@ -1019,15 +1031,13 @@ bool ProcessSingleton::Create() {
|
||||||
if (listen(sock, 5) < 0)
|
if (listen(sock, 5) < 0)
|
||||||
NOTREACHED() << "listen failed: " << base::safe_strerror(errno);
|
NOTREACHED() << "listen failed: " << base::safe_strerror(errno);
|
||||||
|
|
||||||
// In Electron the ProcessSingleton is created earlier than the IO
|
DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::IO));
|
||||||
// thread gets created, so we have to postpone the call until message
|
BrowserThread::PostTask(
|
||||||
// loop is up an running.
|
BrowserThread::IO,
|
||||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner =
|
|
||||||
base::ThreadTaskRunnerHandle::Get();
|
|
||||||
task_runner->PostTask(
|
|
||||||
FROM_HERE,
|
FROM_HERE,
|
||||||
base::Bind(&ProcessSingleton::StartListening,
|
base::Bind(&ProcessSingleton::LinuxWatcher::StartListening,
|
||||||
base::Unretained(this), sock));
|
watcher_,
|
||||||
|
sock));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1038,17 +1048,6 @@ void ProcessSingleton::Cleanup() {
|
||||||
UnlinkPath(lock_path_);
|
UnlinkPath(lock_path_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProcessSingleton::StartListening(int sock) {
|
|
||||||
watcher_ = new LinuxWatcher(this);
|
|
||||||
DCHECK(BrowserThread::IsMessageLoopValid(BrowserThread::IO));
|
|
||||||
BrowserThread::PostTask(
|
|
||||||
BrowserThread::IO,
|
|
||||||
FROM_HERE,
|
|
||||||
base::Bind(&ProcessSingleton::LinuxWatcher::StartListening,
|
|
||||||
watcher_.get(),
|
|
||||||
sock));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProcessSingleton::IsSameChromeInstance(pid_t pid) {
|
bool ProcessSingleton::IsSameChromeInstance(pid_t pid) {
|
||||||
pid_t cur_pid = current_pid_;
|
pid_t cur_pid = current_pid_;
|
||||||
while (pid != cur_pid) {
|
while (pid != cur_pid) {
|
||||||
|
|
111
chromium_src/chrome/common/chrome_utility_printing_messages.h
Normal file
111
chromium_src/chrome/common/chrome_utility_printing_messages.h
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
// Copyright 2014 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.
|
||||||
|
|
||||||
|
// Multiply-included message file, so no include guard.
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "base/strings/string16.h"
|
||||||
|
#include "build/build_config.h"
|
||||||
|
#include "ipc/ipc_message_macros.h"
|
||||||
|
#include "ipc/ipc_param_traits.h"
|
||||||
|
#include "ipc/ipc_platform_file.h"
|
||||||
|
#include "printing/backend/print_backend.h"
|
||||||
|
#include "printing/features/features.h"
|
||||||
|
#include "printing/page_range.h"
|
||||||
|
#include "printing/pdf_render_settings.h"
|
||||||
|
#include "printing/pwg_raster_settings.h"
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define IPC_MESSAGE_START ChromeUtilityPrintingMsgStart
|
||||||
|
|
||||||
|
IPC_ENUM_TRAITS_MAX_VALUE(printing::PdfRenderSettings::Mode,
|
||||||
|
printing::PdfRenderSettings::Mode::LAST)
|
||||||
|
|
||||||
|
IPC_STRUCT_TRAITS_BEGIN(printing::PdfRenderSettings)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(area)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(offsets)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(dpi)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(autorotate)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(mode)
|
||||||
|
IPC_STRUCT_TRAITS_END()
|
||||||
|
|
||||||
|
IPC_STRUCT_TRAITS_BEGIN(printing::PrinterCapsAndDefaults)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(printer_capabilities)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(caps_mime_type)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(printer_defaults)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(defaults_mime_type)
|
||||||
|
IPC_STRUCT_TRAITS_END()
|
||||||
|
|
||||||
|
IPC_ENUM_TRAITS_MAX_VALUE(printing::ColorModel, printing::PROCESSCOLORMODEL_RGB)
|
||||||
|
|
||||||
|
IPC_STRUCT_TRAITS_BEGIN(printing::PrinterSemanticCapsAndDefaults::Paper)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(display_name)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(vendor_id)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(size_um)
|
||||||
|
IPC_STRUCT_TRAITS_END()
|
||||||
|
|
||||||
|
IPC_STRUCT_TRAITS_BEGIN(printing::PrinterSemanticCapsAndDefaults)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(collate_capable)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(collate_default)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(copies_capable)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(duplex_capable)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(duplex_default)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(color_changeable)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(color_default)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(color_model)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(bw_model)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(papers)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(default_paper)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(dpis)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(default_dpi)
|
||||||
|
IPC_STRUCT_TRAITS_END()
|
||||||
|
|
||||||
|
IPC_ENUM_TRAITS_MAX_VALUE(printing::PwgRasterTransformType,
|
||||||
|
printing::TRANSFORM_TYPE_LAST)
|
||||||
|
|
||||||
|
IPC_STRUCT_TRAITS_BEGIN(printing::PwgRasterSettings)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(odd_page_transform)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(rotate_all_pages)
|
||||||
|
IPC_STRUCT_TRAITS_MEMBER(reverse_page_order)
|
||||||
|
IPC_STRUCT_TRAITS_END()
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
// Reply when the utility process loaded PDF. |page_count| is 0, if loading
|
||||||
|
// failed.
|
||||||
|
IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageCount,
|
||||||
|
int /* page_count */)
|
||||||
|
|
||||||
|
// Reply when the utility process rendered the PDF page.
|
||||||
|
IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageDone,
|
||||||
|
bool /* success */,
|
||||||
|
float /* scale_factor */)
|
||||||
|
|
||||||
|
// Request that the given font characters be loaded by the browser so it's
|
||||||
|
// cached by the OS. Please see
|
||||||
|
// PdfToEmfUtilityProcessHostClient::OnPreCacheFontCharacters for details.
|
||||||
|
IPC_SYNC_MESSAGE_CONTROL2_0(ChromeUtilityHostMsg_PreCacheFontCharacters,
|
||||||
|
LOGFONT /* font_data */,
|
||||||
|
base::string16 /* characters */)
|
||||||
|
|
||||||
|
// Tell the utility process to start rendering the given PDF into a metafile.
|
||||||
|
// Utility process would be alive until
|
||||||
|
// ChromeUtilityMsg_RenderPDFPagesToMetafiles_Stop message.
|
||||||
|
IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_RenderPDFPagesToMetafiles,
|
||||||
|
IPC::PlatformFileForTransit /* input_file */,
|
||||||
|
printing::PdfRenderSettings /* settings */)
|
||||||
|
|
||||||
|
// Requests conversion of the next page.
|
||||||
|
IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_RenderPDFPagesToMetafiles_GetPage,
|
||||||
|
int /* page_number */,
|
||||||
|
IPC::PlatformFileForTransit /* output_file */)
|
||||||
|
|
||||||
|
// Requests utility process to stop conversion and exit.
|
||||||
|
IPC_MESSAGE_CONTROL0(ChromeUtilityMsg_RenderPDFPagesToMetafiles_Stop)
|
||||||
|
|
||||||
|
#endif // OS_WIN
|
|
@ -74,6 +74,9 @@ struct PrintMsg_PrintPages_Params {
|
||||||
|
|
||||||
IPC_ENUM_TRAITS_MAX_VALUE(printing::MarginType,
|
IPC_ENUM_TRAITS_MAX_VALUE(printing::MarginType,
|
||||||
printing::MARGIN_TYPE_LAST)
|
printing::MARGIN_TYPE_LAST)
|
||||||
|
IPC_ENUM_TRAITS_MIN_MAX_VALUE(printing::DuplexMode,
|
||||||
|
printing::UNKNOWN_DUPLEX_MODE,
|
||||||
|
printing::SHORT_EDGE)
|
||||||
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebPrintScalingOption,
|
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebPrintScalingOption,
|
||||||
blink::WebPrintScalingOptionLast)
|
blink::WebPrintScalingOptionLast)
|
||||||
|
|
||||||
|
@ -310,39 +313,3 @@ IPC_MESSAGE_ROUTED1(PrintHostMsg_MetafileReadyForPrinting,
|
||||||
IPC_MESSAGE_ROUTED2(PrintHostMsg_PrintPreviewFailed,
|
IPC_MESSAGE_ROUTED2(PrintHostMsg_PrintPreviewFailed,
|
||||||
int /* document cookie */,
|
int /* document cookie */,
|
||||||
int /* request_id */);
|
int /* request_id */);
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
|
||||||
// Tell the utility process to start rendering the given PDF into a metafile.
|
|
||||||
// Utility process would be alive until
|
|
||||||
// ChromeUtilityMsg_RenderPDFPagesToMetafiles_Stop message.
|
|
||||||
IPC_MESSAGE_CONTROL3(ChromeUtilityMsg_RenderPDFPagesToMetafiles,
|
|
||||||
IPC::PlatformFileForTransit /* input_file */,
|
|
||||||
printing::PdfRenderSettings /* settings */,
|
|
||||||
bool /* print_text_with_gdi */)
|
|
||||||
|
|
||||||
// Requests conversion of the next page.
|
|
||||||
IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_RenderPDFPagesToMetafiles_GetPage,
|
|
||||||
int /* page_number */,
|
|
||||||
IPC::PlatformFileForTransit /* output_file */)
|
|
||||||
|
|
||||||
// Requests utility process to stop conversion and exit.
|
|
||||||
IPC_MESSAGE_CONTROL0(ChromeUtilityMsg_RenderPDFPagesToMetafiles_Stop)
|
|
||||||
|
|
||||||
// Reply when the utility process loaded PDF. |page_count| is 0, if loading
|
|
||||||
// failed.
|
|
||||||
IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageCount,
|
|
||||||
int /* page_count */)
|
|
||||||
|
|
||||||
// Reply when the utility process rendered the PDF page.
|
|
||||||
IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageDone,
|
|
||||||
bool /* success */,
|
|
||||||
float /* scale_factor */)
|
|
||||||
|
|
||||||
// Request that the given font characters be loaded by the browser so it's
|
|
||||||
// cached by the OS. Please see
|
|
||||||
// PdfToEmfUtilityProcessHostClient::OnPreCacheFontCharacters for details.
|
|
||||||
IPC_SYNC_MESSAGE_CONTROL2_0(ChromeUtilityHostMsg_PreCacheFontCharacters,
|
|
||||||
LOGFONT /* font_data */,
|
|
||||||
base::string16 /* characters */)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -66,11 +66,11 @@ class ExternalClearKeyProperties : public KeySystemProperties {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case media::EmeInitDataType::CENC:
|
case media::EmeInitDataType::CENC:
|
||||||
#if defined(USE_PROPRIETARY_CODECS)
|
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif // defined(USE_PROPRIETARY_CODECS)
|
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||||
|
|
||||||
case media::EmeInitDataType::UNKNOWN:
|
case media::EmeInitDataType::UNKNOWN:
|
||||||
return false;
|
return false;
|
||||||
|
@ -80,7 +80,7 @@ class ExternalClearKeyProperties : public KeySystemProperties {
|
||||||
}
|
}
|
||||||
|
|
||||||
SupportedCodecs GetSupportedCodecs() const override {
|
SupportedCodecs GetSupportedCodecs() const override {
|
||||||
#if defined(USE_PROPRIETARY_CODECS)
|
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||||
return media::EME_CODEC_MP4_ALL | media::EME_CODEC_WEBM_ALL;
|
return media::EME_CODEC_MP4_ALL | media::EME_CODEC_WEBM_ALL;
|
||||||
#else
|
#else
|
||||||
return media::EME_CODEC_WEBM_ALL;
|
return media::EME_CODEC_WEBM_ALL;
|
||||||
|
@ -224,21 +224,21 @@ static void AddPepperBasedWidevine(
|
||||||
// as those may offer a higher level of protection.
|
// as those may offer a higher level of protection.
|
||||||
supported_codecs |= media::EME_CODEC_WEBM_OPUS;
|
supported_codecs |= media::EME_CODEC_WEBM_OPUS;
|
||||||
supported_codecs |= media::EME_CODEC_WEBM_VORBIS;
|
supported_codecs |= media::EME_CODEC_WEBM_VORBIS;
|
||||||
#if defined(USE_PROPRIETARY_CODECS)
|
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||||
supported_codecs |= media::EME_CODEC_MP4_AAC;
|
supported_codecs |= media::EME_CODEC_MP4_AAC;
|
||||||
#endif // defined(USE_PROPRIETARY_CODECS)
|
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||||
|
|
||||||
for (size_t i = 0; i < codecs.size(); ++i) {
|
for (size_t i = 0; i < codecs.size(); ++i) {
|
||||||
if (codecs[i] == kCdmSupportedCodecVp8)
|
if (codecs[i] == kCdmSupportedCodecVp8)
|
||||||
supported_codecs |= media::EME_CODEC_WEBM_VP8;
|
supported_codecs |= media::EME_CODEC_WEBM_VP8;
|
||||||
if (codecs[i] == kCdmSupportedCodecVp9)
|
if (codecs[i] == kCdmSupportedCodecVp9)
|
||||||
supported_codecs |= media::EME_CODEC_WEBM_VP9;
|
supported_codecs |= media::EME_CODEC_WEBM_VP9;
|
||||||
#if defined(USE_PROPRIETARY_CODECS)
|
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||||
if (codecs[i] == kCdmSupportedCodecAvc1)
|
if (codecs[i] == kCdmSupportedCodecAvc1)
|
||||||
supported_codecs |= media::EME_CODEC_MP4_AVC1;
|
supported_codecs |= media::EME_CODEC_MP4_AVC1;
|
||||||
if (codecs[i] == kCdmSupportedCodecVp9)
|
if (codecs[i] == kCdmSupportedCodecVp9)
|
||||||
supported_codecs |= media::EME_CODEC_MP4_VP9;
|
supported_codecs |= media::EME_CODEC_MP4_VP9;
|
||||||
#endif // defined(USE_PROPRIETARY_CODECS)
|
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||||
}
|
}
|
||||||
|
|
||||||
using Robustness = cdm::WidevineKeySystemProperties::Robustness;
|
using Robustness = cdm::WidevineKeySystemProperties::Robustness;
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
#include "ppapi/proxy/serialized_structs.h"
|
#include "ppapi/proxy/serialized_structs.h"
|
||||||
|
|
||||||
#if defined(OS_LINUX) || defined(OS_OPENBSD)
|
#if defined(OS_LINUX) || defined(OS_OPENBSD)
|
||||||
#include "content/public/common/child_process_sandbox_support_linux.h"
|
#include "content/public/child/child_process_sandbox_support_linux.h"
|
||||||
|
#include "content/public/common/common_sandbox_support_linux.h"
|
||||||
#elif defined(OS_WIN)
|
#elif defined(OS_WIN)
|
||||||
#include "third_party/skia/include/ports/SkFontMgr.h"
|
#include "third_party/skia/include/ports/SkFontMgr.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -8,7 +8,8 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/lazy_instance.h"
|
#include "base/lazy_instance.h"
|
||||||
#include "base/metrics/histogram.h"
|
#include "base/macros.h"
|
||||||
|
#include "base/metrics/histogram_macros.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
#include "content/public/renderer/pepper_plugin_instance.h"
|
#include "content/public/renderer/pepper_plugin_instance.h"
|
||||||
#include "content/public/renderer/render_thread.h"
|
#include "content/public/renderer/render_thread.h"
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include "base/json/json_writer.h"
|
#include "base/json/json_writer.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/message_loop/message_loop.h"
|
#include "base/message_loop/message_loop.h"
|
||||||
#include "base/metrics/histogram.h"
|
#include "base/metrics/histogram_macros.h"
|
||||||
#include "base/process/process_handle.h"
|
#include "base/process/process_handle.h"
|
||||||
#include "base/strings/string_number_conversions.h"
|
#include "base/strings/string_number_conversions.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
|
@ -32,6 +32,7 @@
|
||||||
#include "third_party/WebKit/public/web/WebDocument.h"
|
#include "third_party/WebKit/public/web/WebDocument.h"
|
||||||
#include "third_party/WebKit/public/web/WebElement.h"
|
#include "third_party/WebKit/public/web/WebElement.h"
|
||||||
#include "third_party/WebKit/public/web/WebFrameClient.h"
|
#include "third_party/WebKit/public/web/WebFrameClient.h"
|
||||||
|
#include "third_party/WebKit/public/web/WebFrameWidget.h"
|
||||||
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
||||||
#include "third_party/WebKit/public/web/WebPlugin.h"
|
#include "third_party/WebKit/public/web/WebPlugin.h"
|
||||||
#include "third_party/WebKit/public/web/WebPluginDocument.h"
|
#include "third_party/WebKit/public/web/WebPluginDocument.h"
|
||||||
|
@ -484,12 +485,9 @@ void PrepareFrameAndViewForPrint::ResizeForPrinting() {
|
||||||
|
|
||||||
// Backup size and offset if it's a local frame.
|
// Backup size and offset if it's a local frame.
|
||||||
blink::WebView* web_view = frame_.view();
|
blink::WebView* web_view = frame_.view();
|
||||||
// Backup size and offset.
|
|
||||||
if (blink::WebFrame* web_frame = web_view->mainFrame())
|
|
||||||
prev_scroll_offset_ = web_frame->scrollOffset();
|
|
||||||
if (blink::WebFrame* web_frame = web_view->mainFrame()) {
|
if (blink::WebFrame* web_frame = web_view->mainFrame()) {
|
||||||
if (web_frame->isWebLocalFrame())
|
if (web_frame->isWebLocalFrame())
|
||||||
prev_scroll_offset_ = web_frame->scrollOffset();
|
prev_scroll_offset_ = web_frame->getScrollOffset();
|
||||||
}
|
}
|
||||||
prev_view_size_ = web_view->size();
|
prev_view_size_ = web_view->size();
|
||||||
|
|
||||||
|
@ -535,8 +533,10 @@ void PrepareFrameAndViewForPrint::CopySelection(
|
||||||
blink::WebView::create(this, blink::WebPageVisibilityStateVisible);
|
blink::WebView::create(this, blink::WebPageVisibilityStateVisible);
|
||||||
owns_web_view_ = true;
|
owns_web_view_ = true;
|
||||||
content::RenderView::ApplyWebPreferences(prefs, web_view);
|
content::RenderView::ApplyWebPreferences(prefs, web_view);
|
||||||
web_view->setMainFrame(
|
blink::WebLocalFrame* main_frame = blink::WebLocalFrame::create(
|
||||||
blink::WebLocalFrame::create(blink::WebTreeScopeType::Document, this));
|
blink::WebTreeScopeType::Document, this, nullptr, nullptr);
|
||||||
|
web_view->setMainFrame(main_frame);
|
||||||
|
blink::WebFrameWidget::create(this, web_view, main_frame);
|
||||||
frame_.Reset(web_view->mainFrame()->toWebLocalFrame());
|
frame_.Reset(web_view->mainFrame()->toWebLocalFrame());
|
||||||
node_to_print_.reset();
|
node_to_print_.reset();
|
||||||
|
|
||||||
|
@ -565,7 +565,8 @@ blink::WebLocalFrame* PrepareFrameAndViewForPrint::createChildFrame(
|
||||||
const blink::WebString& unique_name,
|
const blink::WebString& unique_name,
|
||||||
blink::WebSandboxFlags sandbox_flags,
|
blink::WebSandboxFlags sandbox_flags,
|
||||||
const blink::WebFrameOwnerProperties& frame_owner_properties) {
|
const blink::WebFrameOwnerProperties& frame_owner_properties) {
|
||||||
blink::WebLocalFrame* frame = blink::WebLocalFrame::create(scope, this);
|
blink::WebLocalFrame* frame = blink::WebLocalFrame::create(
|
||||||
|
scope, this, nullptr, nullptr);
|
||||||
parent->appendChild(frame);
|
parent->appendChild(frame);
|
||||||
return frame;
|
return frame;
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,12 +126,12 @@ void PrintWebViewHelper::PrintPageInternal(
|
||||||
&content_area);
|
&content_area);
|
||||||
gfx::Rect canvas_area = content_area;
|
gfx::Rect canvas_area = content_area;
|
||||||
|
|
||||||
SkCanvas* canvas = metafile->GetVectorCanvasForNewPage(
|
cc::PaintCanvas* canvas =
|
||||||
page_size, canvas_area, scale_factor);
|
metafile->GetVectorCanvasForNewPage(page_size, canvas_area, scale_factor);
|
||||||
if (!canvas)
|
if (!canvas)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile);
|
MetafileSkiaWrapper::SetMetafileOnCanvas(canvas, metafile);
|
||||||
|
|
||||||
RenderPageContent(frame, params.page_number, canvas_area, content_area,
|
RenderPageContent(frame, params.page_number, canvas_area, content_area,
|
||||||
scale_factor, canvas);
|
scale_factor, canvas);
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include "printing/page_size_margins.h"
|
#include "printing/page_size_margins.h"
|
||||||
#include "third_party/WebKit/public/platform/WebCanvas.h"
|
#include "third_party/WebKit/public/platform/WebCanvas.h"
|
||||||
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
||||||
#include "third_party/skia/include/core/SkCanvas.h"
|
|
||||||
|
|
||||||
namespace printing {
|
namespace printing {
|
||||||
|
|
||||||
|
@ -112,13 +111,13 @@ void PrintWebViewHelper::RenderPage(const PrintMsg_Print_Params& params,
|
||||||
gfx::Rect canvas_area = content_area;
|
gfx::Rect canvas_area = content_area;
|
||||||
|
|
||||||
{
|
{
|
||||||
SkCanvas* canvas = metafile->GetVectorCanvasForNewPage(
|
cc::PaintCanvas* canvas = metafile->GetVectorCanvasForNewPage(
|
||||||
*page_size, canvas_area, scale_factor);
|
*page_size, canvas_area, scale_factor);
|
||||||
if (!canvas)
|
if (!canvas)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile);
|
MetafileSkiaWrapper::SetMetafileOnCanvas(canvas, metafile);
|
||||||
skia::SetIsPreviewMetafile(*canvas, is_preview);
|
cc::SetIsPreviewMetafile(canvas, is_preview);
|
||||||
RenderPageContent(frame, page_number, canvas_area, content_area,
|
RenderPageContent(frame, page_number, canvas_area, content_area,
|
||||||
scale_factor, static_cast<blink::WebCanvas*>(canvas));
|
scale_factor, static_cast<blink::WebCanvas*>(canvas));
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include "printing/page_size_margins.h"
|
#include "printing/page_size_margins.h"
|
||||||
#include "printing/pdf_metafile_skia.h"
|
#include "printing/pdf_metafile_skia.h"
|
||||||
#include "printing/units.h"
|
#include "printing/units.h"
|
||||||
#include "skia/ext/platform_device.h"
|
|
||||||
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -161,12 +160,12 @@ void PrintWebViewHelper::PrintPageInternal(
|
||||||
frame->getPrintPageShrink(params.page_number);
|
frame->getPrintPageShrink(params.page_number);
|
||||||
float scale_factor = css_scale_factor * webkit_page_shrink_factor;
|
float scale_factor = css_scale_factor * webkit_page_shrink_factor;
|
||||||
|
|
||||||
SkCanvas* canvas = metafile->GetVectorCanvasForNewPage(
|
cc::PaintCanvas* canvas =
|
||||||
page_size, canvas_area, scale_factor);
|
metafile->GetVectorCanvasForNewPage(page_size, canvas_area, scale_factor);
|
||||||
if (!canvas)
|
if (!canvas)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MetafileSkiaWrapper::SetMetafileOnCanvas(*canvas, metafile);
|
MetafileSkiaWrapper::SetMetafileOnCanvas(canvas, metafile);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (params.params.display_header_footer) {
|
if (params.params.display_header_footer) {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "base/lazy_instance.h"
|
#include "base/lazy_instance.h"
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
#include "base/scoped_native_library.h"
|
#include "base/scoped_native_library.h"
|
||||||
|
#include "chrome/common/chrome_utility_printing_messages.h"
|
||||||
#include "chrome/common/print_messages.h"
|
#include "chrome/common/print_messages.h"
|
||||||
#include "content/public/utility/utility_thread.h"
|
#include "content/public/utility/utility_thread.h"
|
||||||
#include "pdf/pdf.h"
|
#include "pdf/pdf.h"
|
||||||
|
@ -59,13 +60,25 @@ bool PrintingHandlerWin::OnMessageReceived(const IPC::Message& message) {
|
||||||
|
|
||||||
void PrintingHandlerWin::OnRenderPDFPagesToMetafile(
|
void PrintingHandlerWin::OnRenderPDFPagesToMetafile(
|
||||||
IPC::PlatformFileForTransit pdf_transit,
|
IPC::PlatformFileForTransit pdf_transit,
|
||||||
const PdfRenderSettings& settings,
|
const PdfRenderSettings& settings) {
|
||||||
bool print_text_with_gdi) {
|
|
||||||
pdf_rendering_settings_ = settings;
|
pdf_rendering_settings_ = settings;
|
||||||
chrome_pdf::SetPDFUseGDIPrinting(print_text_with_gdi);
|
chrome_pdf::SetPDFUseGDIPrinting(pdf_rendering_settings_.mode ==
|
||||||
|
PdfRenderSettings::Mode::GDI_TEXT);
|
||||||
|
int postscript_level;
|
||||||
|
switch (pdf_rendering_settings_.mode) {
|
||||||
|
case PdfRenderSettings::Mode::POSTSCRIPT_LEVEL2:
|
||||||
|
postscript_level = 2;
|
||||||
|
break;
|
||||||
|
case PdfRenderSettings::Mode::POSTSCRIPT_LEVEL3:
|
||||||
|
postscript_level = 3;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
postscript_level = 0; // Not using postscript.
|
||||||
|
}
|
||||||
|
chrome_pdf::SetPDFPostscriptPrintingLevel(postscript_level);
|
||||||
|
|
||||||
base::File pdf_file = IPC::PlatformFileForTransitToFile(pdf_transit);
|
base::File pdf_file = IPC::PlatformFileForTransitToFile(pdf_transit);
|
||||||
int page_count = LoadPDF(std::move(pdf_file));
|
int page_count = LoadPDF(std::move(pdf_file));
|
||||||
//int page_count = 1;
|
|
||||||
Send(
|
Send(
|
||||||
new ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageCount(page_count));
|
new ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageCount(page_count));
|
||||||
}
|
}
|
||||||
|
@ -75,8 +88,12 @@ void PrintingHandlerWin::OnRenderPDFPagesToMetafileGetPage(
|
||||||
IPC::PlatformFileForTransit output_file) {
|
IPC::PlatformFileForTransit output_file) {
|
||||||
base::File emf_file = IPC::PlatformFileForTransitToFile(output_file);
|
base::File emf_file = IPC::PlatformFileForTransitToFile(output_file);
|
||||||
float scale_factor = 1.0f;
|
float scale_factor = 1.0f;
|
||||||
bool success =
|
bool postscript = pdf_rendering_settings_.mode ==
|
||||||
RenderPdfPageToMetafile(page_number, std::move(emf_file), &scale_factor);
|
PdfRenderSettings::Mode::POSTSCRIPT_LEVEL2 ||
|
||||||
|
pdf_rendering_settings_.mode ==
|
||||||
|
PdfRenderSettings::Mode::POSTSCRIPT_LEVEL3;
|
||||||
|
bool success = RenderPdfPageToMetafile(page_number, std::move(emf_file),
|
||||||
|
&scale_factor, postscript);
|
||||||
Send(new ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageDone(
|
Send(new ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_PageDone(
|
||||||
success, scale_factor));
|
success, scale_factor));
|
||||||
}
|
}
|
||||||
|
@ -105,7 +122,8 @@ int PrintingHandlerWin::LoadPDF(base::File pdf_file) {
|
||||||
|
|
||||||
bool PrintingHandlerWin::RenderPdfPageToMetafile(int page_number,
|
bool PrintingHandlerWin::RenderPdfPageToMetafile(int page_number,
|
||||||
base::File output_file,
|
base::File output_file,
|
||||||
float* scale_factor) {
|
float* scale_factor,
|
||||||
|
bool postscript) {
|
||||||
Emf metafile;
|
Emf metafile;
|
||||||
metafile.Init();
|
metafile.Init();
|
||||||
|
|
||||||
|
@ -116,18 +134,30 @@ bool PrintingHandlerWin::RenderPdfPageToMetafile(int page_number,
|
||||||
// original coordinates and we'll be able to print in full resolution.
|
// original coordinates and we'll be able to print in full resolution.
|
||||||
// Before playback we'll need to counter the scaling up that will happen
|
// Before playback we'll need to counter the scaling up that will happen
|
||||||
// in the service (print_system_win.cc).
|
// in the service (print_system_win.cc).
|
||||||
*scale_factor = gfx::CalculatePageScale(
|
//
|
||||||
metafile.context(), pdf_rendering_settings_.area.right(),
|
// The postscript driver does not use the metafile size since it outputs
|
||||||
pdf_rendering_settings_.area.bottom());
|
// postscript rather than a metafile. Instead it uses the printable area
|
||||||
gfx::ScaleDC(metafile.context(), *scale_factor);
|
// sent to RenderPDFPageToDC to determine the area to render. Therefore,
|
||||||
|
// don't scale the DC to match the metafile, and send the printer physical
|
||||||
|
// offsets to the driver.
|
||||||
|
if (!postscript) {
|
||||||
|
*scale_factor = gfx::CalculatePageScale(
|
||||||
|
metafile.context(), pdf_rendering_settings_.area.right(),
|
||||||
|
pdf_rendering_settings_.area.bottom());
|
||||||
|
gfx::ScaleDC(metafile.context(), *scale_factor);
|
||||||
|
}
|
||||||
|
|
||||||
// The underlying metafile is of type Emf and ignores the arguments passed
|
// The underlying metafile is of type Emf and ignores the arguments passed
|
||||||
// to StartPage.
|
// to StartPage.
|
||||||
metafile.StartPage(gfx::Size(), gfx::Rect(), 1);
|
metafile.StartPage(gfx::Size(), gfx::Rect(), 1);
|
||||||
|
int offset_x = postscript ? pdf_rendering_settings_.offsets.x() : 0;
|
||||||
|
int offset_y = postscript ? pdf_rendering_settings_.offsets.y() : 0;
|
||||||
|
|
||||||
if (!chrome_pdf::RenderPDFPageToDC(
|
if (!chrome_pdf::RenderPDFPageToDC(
|
||||||
&pdf_data_.front(), pdf_data_.size(), page_number, metafile.context(),
|
&pdf_data_.front(), pdf_data_.size(), page_number, metafile.context(),
|
||||||
pdf_rendering_settings_.dpi, pdf_rendering_settings_.area.x(),
|
pdf_rendering_settings_.dpi,
|
||||||
pdf_rendering_settings_.area.y(),
|
pdf_rendering_settings_.area.x() - offset_x,
|
||||||
|
pdf_rendering_settings_.area.y() - offset_y,
|
||||||
pdf_rendering_settings_.area.width(),
|
pdf_rendering_settings_.area.width(),
|
||||||
pdf_rendering_settings_.area.height(), true, false, true, true,
|
pdf_rendering_settings_.area.height(), true, false, true, true,
|
||||||
pdf_rendering_settings_.autorotate)) {
|
pdf_rendering_settings_.autorotate)) {
|
||||||
|
@ -138,4 +168,4 @@ bool PrintingHandlerWin::RenderPdfPageToMetafile(int page_number,
|
||||||
return metafile.SaveTo(&output_file);
|
return metafile.SaveTo(&output_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // printing
|
} // namespace printing
|
||||||
|
|
|
@ -29,8 +29,7 @@ class PrintingHandlerWin : public UtilityMessageHandler {
|
||||||
private:
|
private:
|
||||||
// IPC message handlers.
|
// IPC message handlers.
|
||||||
void OnRenderPDFPagesToMetafile(IPC::PlatformFileForTransit pdf_transit,
|
void OnRenderPDFPagesToMetafile(IPC::PlatformFileForTransit pdf_transit,
|
||||||
const PdfRenderSettings& settings,
|
const PdfRenderSettings& settings);
|
||||||
bool print_text_with_gdi);
|
|
||||||
void OnRenderPDFPagesToMetafileGetPage(
|
void OnRenderPDFPagesToMetafileGetPage(
|
||||||
int page_number,
|
int page_number,
|
||||||
IPC::PlatformFileForTransit output_file);
|
IPC::PlatformFileForTransit output_file);
|
||||||
|
@ -39,7 +38,8 @@ class PrintingHandlerWin : public UtilityMessageHandler {
|
||||||
int LoadPDF(base::File pdf_file);
|
int LoadPDF(base::File pdf_file);
|
||||||
bool RenderPdfPageToMetafile(int page_number,
|
bool RenderPdfPageToMetafile(int page_number,
|
||||||
base::File output_file,
|
base::File output_file,
|
||||||
float* scale_factor);
|
float* scale_factor,
|
||||||
|
bool postscript);
|
||||||
|
|
||||||
std::vector<char> pdf_data_;
|
std::vector<char> pdf_data_;
|
||||||
PdfRenderSettings pdf_rendering_settings_;
|
PdfRenderSettings pdf_rendering_settings_;
|
||||||
|
|
|
@ -47,7 +47,7 @@ int32_t PepperPDFHost::OnHostMsgDidStartLoading(
|
||||||
if (!render_frame)
|
if (!render_frame)
|
||||||
return PP_ERROR_FAILED;
|
return PP_ERROR_FAILED;
|
||||||
|
|
||||||
render_frame->DidStartLoading();
|
render_frame->PluginDidStartLoading();
|
||||||
return PP_OK;
|
return PP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ int32_t PepperPDFHost::OnHostMsgDidStopLoading(
|
||||||
if (!render_frame)
|
if (!render_frame)
|
||||||
return PP_ERROR_FAILED;
|
return PP_ERROR_FAILED;
|
||||||
|
|
||||||
render_frame->DidStopLoading();
|
render_frame->PluginDidStopLoading();
|
||||||
return PP_OK;
|
return PP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,9 @@ const int StreamListenSocket::kSocketError = -1;
|
||||||
StreamListenSocket::StreamListenSocket(SocketDescriptor s,
|
StreamListenSocket::StreamListenSocket(SocketDescriptor s,
|
||||||
StreamListenSocket::Delegate* del)
|
StreamListenSocket::Delegate* del)
|
||||||
: socket_delegate_(del),
|
: socket_delegate_(del),
|
||||||
|
#if defined(OS_POSIX)
|
||||||
|
watcher_(FROM_HERE),
|
||||||
|
#endif
|
||||||
socket_(s),
|
socket_(s),
|
||||||
reads_paused_(false),
|
reads_paused_(false),
|
||||||
has_pending_reads_(false) {
|
has_pending_reads_(false) {
|
||||||
|
|
|
@ -240,6 +240,7 @@
|
||||||
4302, # (atldlgs.h) 'type cast': truncation from 'LPCTSTR' to 'WORD'
|
4302, # (atldlgs.h) 'type cast': truncation from 'LPCTSTR' to 'WORD'
|
||||||
4458, # (atldlgs.h) declaration of 'dwCommonButtons' hides class member
|
4458, # (atldlgs.h) declaration of 'dwCommonButtons' hides class member
|
||||||
4503, # decorated name length exceeded, name was truncated
|
4503, # decorated name length exceeded, name was truncated
|
||||||
|
4714, # (atomicstring.h) function marked as __forceinline not inlined
|
||||||
4800, # (v8.h) forcing value to bool 'true' or 'false'
|
4800, # (v8.h) forcing value to bool 'true' or 'false'
|
||||||
4819, # The file contains a character that cannot be represented in the current code page
|
4819, # The file contains a character that cannot be represented in the current code page
|
||||||
4838, # (atlgdi.h) conversion from 'int' to 'UINT' requires a narrowing conversion
|
4838, # (atlgdi.h) conversion from 'int' to 'UINT' requires a narrowing conversion
|
||||||
|
|
|
@ -237,9 +237,6 @@
|
||||||
'USING_V8_SHARED',
|
'USING_V8_SHARED',
|
||||||
'USING_V8_PLATFORM_SHARED',
|
'USING_V8_PLATFORM_SHARED',
|
||||||
'USING_V8_BASE_SHARED',
|
'USING_V8_BASE_SHARED',
|
||||||
# Remove this after enable_plugins becomes a feature flag.
|
|
||||||
'ENABLE_PLUGINS',
|
|
||||||
'USE_PROPRIETARY_CODECS',
|
|
||||||
],
|
],
|
||||||
'sources': [
|
'sources': [
|
||||||
'<@(lib_sources)',
|
'<@(lib_sources)',
|
||||||
|
|
|
@ -63,6 +63,7 @@ def main():
|
||||||
create_chrome_version_h()
|
create_chrome_version_h()
|
||||||
touch_config_gypi()
|
touch_config_gypi()
|
||||||
run_update(defines, args.msvs)
|
run_update(defines, args.msvs)
|
||||||
|
create_node_headers()
|
||||||
update_electron_modules('spec', args.target_arch)
|
update_electron_modules('spec', args.target_arch)
|
||||||
|
|
||||||
|
|
||||||
|
@ -176,17 +177,21 @@ def update_node_modules(dirname, env=None):
|
||||||
if os.environ.has_key('CI'):
|
if os.environ.has_key('CI'):
|
||||||
try:
|
try:
|
||||||
execute_stdout(args, env)
|
execute_stdout(args, env)
|
||||||
|
execute_stdout([NPM, 'rebuild'], env)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
execute_stdout(args, env)
|
execute_stdout(args, env)
|
||||||
|
execute_stdout([NPM, 'rebuild'], env)
|
||||||
|
|
||||||
|
|
||||||
def update_electron_modules(dirname, target_arch):
|
def update_electron_modules(dirname, target_arch):
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
|
version = get_electron_version()
|
||||||
env['npm_config_arch'] = target_arch
|
env['npm_config_arch'] = target_arch
|
||||||
env['npm_config_target'] = get_electron_version()
|
env['npm_config_target'] = version
|
||||||
env['npm_config_disturl'] = 'https://atom.io/download/electron'
|
env['npm_config_nodedir'] = os.path.join(SOURCE_ROOT, 'dist',
|
||||||
|
'node-{0}'.format(version))
|
||||||
update_node_modules(dirname, env)
|
update_node_modules(dirname, env)
|
||||||
|
|
||||||
|
|
||||||
|
@ -260,5 +265,11 @@ def run_update(defines, msvs):
|
||||||
execute_stdout(args)
|
execute_stdout(args)
|
||||||
|
|
||||||
|
|
||||||
|
def create_node_headers():
|
||||||
|
execute_stdout([sys.executable,
|
||||||
|
os.path.join(SOURCE_ROOT, 'script', 'create-node-headers.py'),
|
||||||
|
'--version', get_electron_version()])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
|
104
script/create-node-headers.py
Executable file
104
script/create-node-headers.py
Executable file
|
@ -0,0 +1,104 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import sys
|
||||||
|
import tarfile
|
||||||
|
|
||||||
|
from lib.util import safe_mkdir, scoped_cwd
|
||||||
|
|
||||||
|
|
||||||
|
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||||
|
DIST_DIR = os.path.join(SOURCE_ROOT, 'dist')
|
||||||
|
NODE_DIR = os.path.join(SOURCE_ROOT, 'vendor', 'node')
|
||||||
|
OUT_DIR = os.path.join(SOURCE_ROOT, 'out', 'R')
|
||||||
|
|
||||||
|
HEADERS_SUFFIX = [
|
||||||
|
'.h',
|
||||||
|
'.gypi',
|
||||||
|
]
|
||||||
|
HEADERS_DIRS = [
|
||||||
|
'src',
|
||||||
|
'deps/http_parser',
|
||||||
|
'deps/zlib',
|
||||||
|
'deps/uv',
|
||||||
|
'deps/npm',
|
||||||
|
'deps/mdb_v8',
|
||||||
|
]
|
||||||
|
HEADERS_FILES = [
|
||||||
|
'common.gypi',
|
||||||
|
'config.gypi',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
safe_mkdir(DIST_DIR)
|
||||||
|
|
||||||
|
args = parse_args()
|
||||||
|
node_headers_dir = os.path.join(DIST_DIR, 'node-{0}'.format(args.version))
|
||||||
|
iojs_headers_dir = os.path.join(DIST_DIR, 'iojs-{0}'.format(args.version))
|
||||||
|
iojs2_headers_dir = os.path.join(DIST_DIR,
|
||||||
|
'iojs-{0}-headers'.format(args.version))
|
||||||
|
|
||||||
|
copy_headers(node_headers_dir)
|
||||||
|
create_header_tarball(node_headers_dir)
|
||||||
|
copy_headers(iojs_headers_dir)
|
||||||
|
create_header_tarball(iojs_headers_dir)
|
||||||
|
copy_headers(iojs2_headers_dir)
|
||||||
|
create_header_tarball(iojs2_headers_dir)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args():
|
||||||
|
parser = argparse.ArgumentParser(description='create node header tarballs')
|
||||||
|
parser.add_argument('-v', '--version', help='Specify the version',
|
||||||
|
required=True)
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def copy_headers(dist_headers_dir):
|
||||||
|
safe_mkdir(dist_headers_dir)
|
||||||
|
|
||||||
|
# Copy standard node headers from node. repository.
|
||||||
|
for include_path in HEADERS_DIRS:
|
||||||
|
abs_path = os.path.join(NODE_DIR, include_path)
|
||||||
|
for dirpath, _, filenames in os.walk(abs_path):
|
||||||
|
for filename in filenames:
|
||||||
|
extension = os.path.splitext(filename)[1]
|
||||||
|
if extension not in HEADERS_SUFFIX:
|
||||||
|
continue
|
||||||
|
copy_source_file(os.path.join(dirpath, filename), NODE_DIR,
|
||||||
|
dist_headers_dir)
|
||||||
|
for other_file in HEADERS_FILES:
|
||||||
|
copy_source_file(os.path.join(NODE_DIR, other_file), NODE_DIR,
|
||||||
|
dist_headers_dir)
|
||||||
|
|
||||||
|
# Copy V8 headers from chromium's repository.
|
||||||
|
src = os.path.join(SOURCE_ROOT, 'vendor', 'brightray', 'vendor', 'download',
|
||||||
|
'libchromiumcontent', 'src')
|
||||||
|
for dirpath, _, filenames in os.walk(os.path.join(src, 'v8')):
|
||||||
|
for filename in filenames:
|
||||||
|
extension = os.path.splitext(filename)[1]
|
||||||
|
if extension not in HEADERS_SUFFIX:
|
||||||
|
continue
|
||||||
|
copy_source_file(os.path.join(dirpath, filename), src,
|
||||||
|
os.path.join(dist_headers_dir, 'deps'))
|
||||||
|
|
||||||
|
|
||||||
|
def create_header_tarball(dist_headers_dir):
|
||||||
|
target = dist_headers_dir + '.tar.gz'
|
||||||
|
with scoped_cwd(DIST_DIR):
|
||||||
|
tarball = tarfile.open(name=target, mode='w:gz')
|
||||||
|
tarball.add(os.path.relpath(dist_headers_dir))
|
||||||
|
tarball.close()
|
||||||
|
|
||||||
|
|
||||||
|
def copy_source_file(source, start, destination):
|
||||||
|
relative = os.path.relpath(source, start=start)
|
||||||
|
final_destination = os.path.join(destination, relative)
|
||||||
|
safe_mkdir(os.path.dirname(final_destination))
|
||||||
|
shutil.copy2(source, final_destination)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main())
|
|
@ -9,7 +9,7 @@ import sys
|
||||||
BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \
|
BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \
|
||||||
'https://s3.amazonaws.com/github-janky-artifacts/libchromiumcontent'
|
'https://s3.amazonaws.com/github-janky-artifacts/libchromiumcontent'
|
||||||
LIBCHROMIUMCONTENT_COMMIT = os.getenv('LIBCHROMIUMCONTENT_COMMIT') or \
|
LIBCHROMIUMCONTENT_COMMIT = os.getenv('LIBCHROMIUMCONTENT_COMMIT') or \
|
||||||
'4a0e32606e52c12c50c2e3a0973d015d8cdff494'
|
'44a803957cb27610c38f7e859016ac257959aeb5'
|
||||||
|
|
||||||
PLATFORM = {
|
PLATFORM = {
|
||||||
'cygwin': 'win32',
|
'cygwin': 'win32',
|
||||||
|
|
|
@ -5,50 +5,17 @@ import glob
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
import tarfile
|
|
||||||
|
|
||||||
from lib.config import PLATFORM, get_target_arch, s3_config
|
from lib.config import PLATFORM, get_target_arch, s3_config
|
||||||
from lib.util import execute, safe_mkdir, scoped_cwd, s3put
|
from lib.util import safe_mkdir, scoped_cwd, s3put
|
||||||
|
|
||||||
|
|
||||||
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||||
DIST_DIR = os.path.join(SOURCE_ROOT, 'dist')
|
DIST_DIR = os.path.join(SOURCE_ROOT, 'dist')
|
||||||
NODE_DIR = os.path.join(SOURCE_ROOT, 'vendor', 'node')
|
|
||||||
OUT_DIR = os.path.join(SOURCE_ROOT, 'out', 'R')
|
OUT_DIR = os.path.join(SOURCE_ROOT, 'out', 'R')
|
||||||
|
|
||||||
HEADERS_SUFFIX = [
|
|
||||||
'.h',
|
|
||||||
'.gypi',
|
|
||||||
]
|
|
||||||
HEADERS_DIRS = [
|
|
||||||
'src',
|
|
||||||
'deps/http_parser',
|
|
||||||
'deps/zlib',
|
|
||||||
'deps/uv',
|
|
||||||
'deps/npm',
|
|
||||||
'deps/mdb_v8',
|
|
||||||
]
|
|
||||||
HEADERS_FILES = [
|
|
||||||
'common.gypi',
|
|
||||||
'config.gypi',
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
safe_mkdir(DIST_DIR)
|
|
||||||
|
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
node_headers_dir = os.path.join(DIST_DIR, 'node-{0}'.format(args.version))
|
|
||||||
iojs_headers_dir = os.path.join(DIST_DIR, 'iojs-{0}'.format(args.version))
|
|
||||||
iojs2_headers_dir = os.path.join(DIST_DIR,
|
|
||||||
'iojs-{0}-headers'.format(args.version))
|
|
||||||
|
|
||||||
copy_headers(node_headers_dir)
|
|
||||||
create_header_tarball(node_headers_dir)
|
|
||||||
copy_headers(iojs_headers_dir)
|
|
||||||
create_header_tarball(iojs_headers_dir)
|
|
||||||
copy_headers(iojs2_headers_dir)
|
|
||||||
create_header_tarball(iojs2_headers_dir)
|
|
||||||
|
|
||||||
# Upload node's headers to S3.
|
# Upload node's headers to S3.
|
||||||
bucket, access_key, secret_key = s3_config()
|
bucket, access_key, secret_key = s3_config()
|
||||||
|
@ -62,50 +29,6 @@ def parse_args():
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def copy_headers(dist_headers_dir):
|
|
||||||
safe_mkdir(dist_headers_dir)
|
|
||||||
|
|
||||||
# Copy standard node headers from node. repository.
|
|
||||||
for include_path in HEADERS_DIRS:
|
|
||||||
abs_path = os.path.join(NODE_DIR, include_path)
|
|
||||||
for dirpath, _, filenames in os.walk(abs_path):
|
|
||||||
for filename in filenames:
|
|
||||||
extension = os.path.splitext(filename)[1]
|
|
||||||
if extension not in HEADERS_SUFFIX:
|
|
||||||
continue
|
|
||||||
copy_source_file(os.path.join(dirpath, filename), NODE_DIR,
|
|
||||||
dist_headers_dir)
|
|
||||||
for other_file in HEADERS_FILES:
|
|
||||||
copy_source_file(os.path.join(NODE_DIR, other_file), NODE_DIR,
|
|
||||||
dist_headers_dir)
|
|
||||||
|
|
||||||
# Copy V8 headers from chromium's repository.
|
|
||||||
src = os.path.join(SOURCE_ROOT, 'vendor', 'brightray', 'vendor', 'download',
|
|
||||||
'libchromiumcontent', 'src')
|
|
||||||
for dirpath, _, filenames in os.walk(os.path.join(src, 'v8')):
|
|
||||||
for filename in filenames:
|
|
||||||
extension = os.path.splitext(filename)[1]
|
|
||||||
if extension not in HEADERS_SUFFIX:
|
|
||||||
continue
|
|
||||||
copy_source_file(os.path.join(dirpath, filename), src,
|
|
||||||
os.path.join(dist_headers_dir, 'deps'))
|
|
||||||
|
|
||||||
|
|
||||||
def create_header_tarball(dist_headers_dir):
|
|
||||||
target = dist_headers_dir + '.tar.gz'
|
|
||||||
with scoped_cwd(DIST_DIR):
|
|
||||||
tarball = tarfile.open(name=target, mode='w:gz')
|
|
||||||
tarball.add(os.path.relpath(dist_headers_dir))
|
|
||||||
tarball.close()
|
|
||||||
|
|
||||||
|
|
||||||
def copy_source_file(source, start, destination):
|
|
||||||
relative = os.path.relpath(source, start=start)
|
|
||||||
final_destination = os.path.join(destination, relative)
|
|
||||||
safe_mkdir(os.path.dirname(final_destination))
|
|
||||||
shutil.copy2(source, final_destination)
|
|
||||||
|
|
||||||
|
|
||||||
def upload_node(bucket, access_key, secret_key, version):
|
def upload_node(bucket, access_key, secret_key, version):
|
||||||
with scoped_cwd(DIST_DIR):
|
with scoped_cwd(DIST_DIR):
|
||||||
s3put(bucket, access_key, secret_key, DIST_DIR,
|
s3put(bucket, access_key, secret_key, DIST_DIR,
|
||||||
|
|
|
@ -102,6 +102,7 @@ def main():
|
||||||
run_python_script('upload-windows-pdb.py')
|
run_python_script('upload-windows-pdb.py')
|
||||||
|
|
||||||
# Upload node headers.
|
# Upload node headers.
|
||||||
|
run_python_script('create-node-headers.py', '-v', args.version)
|
||||||
run_python_script('upload-node-headers.py', '-v', args.version)
|
run_python_script('upload-node-headers.py', '-v', args.version)
|
||||||
|
|
||||||
|
|
||||||
|
|
2
vendor/brightray
vendored
2
vendor/brightray
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 909c49265493bd095c27cefd999567be2107899a
|
Subproject commit 3d9ebb549990d50ab67b705b8ff16433a3dbc546
|
2
vendor/crashpad
vendored
2
vendor/crashpad
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit eeac857dfb5b255c899c8763d62654863b4c8890
|
Subproject commit 2871326543ea0e01488f034bb660bf5a39f55c0c
|
2
vendor/node
vendored
2
vendor/node
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 3fe90cfcf54dd946980e59daf550a7cdb2317c8f
|
Subproject commit df227c3a5db7aa8eab64c86f54588c6cd2d6c623
|
Loading…
Reference in a new issue