Merge remote-tracking branch 'origin/master' into renaesop_master
This commit is contained in:
commit
84a9b6a42d
336 changed files with 16704 additions and 2418 deletions
9
.gitignore
vendored
9
.gitignore
vendored
|
@ -5,7 +5,7 @@
|
|||
/dist/
|
||||
/external_binaries/
|
||||
/out/
|
||||
/vendor/brightray/vendor/download/
|
||||
/vendor/download/
|
||||
/vendor/debian_wheezy_amd64-sysroot/
|
||||
/vendor/debian_wheezy_arm-sysroot/
|
||||
/vendor/debian_wheezy_i386-sysroot/
|
||||
|
@ -27,3 +27,10 @@ node_modules/
|
|||
*.vcxproj.filters
|
||||
*.sln
|
||||
*.log
|
||||
/brightray/brightray.opensdf
|
||||
/brightray/brightray.sdf
|
||||
/brightray/brightray.sln
|
||||
/brightray/brightray.vcxproj*
|
||||
/brightray/brightray.suo
|
||||
/brightray/brightray.v12.suo
|
||||
/brightray/brightray.xcodeproj/
|
||||
|
|
9
.gitmodules
vendored
9
.gitmodules
vendored
|
@ -1,6 +1,3 @@
|
|||
[submodule "vendor/brightray"]
|
||||
path = vendor/brightray
|
||||
url = https://github.com/electron/brightray.git
|
||||
[submodule "vendor/node"]
|
||||
path = vendor/node
|
||||
url = https://github.com/electron/node.git
|
||||
|
@ -25,3 +22,9 @@
|
|||
[submodule "vendor/pdf_viewer"]
|
||||
path = vendor/pdf_viewer
|
||||
url = https://github.com/electron/pdf-viewer.git
|
||||
[submodule "vendor/gyp"]
|
||||
path = vendor/gyp
|
||||
url = https://github.com/electron/gyp
|
||||
[submodule "vendor/libchromiumcontent"]
|
||||
path = vendor/libchromiumcontent
|
||||
url = https://github.com/electron/libchromiumcontent
|
||||
|
|
|
@ -58,6 +58,7 @@ contains documents describing how to build and contribute to Electron.
|
|||
- [Ukrainian](https://github.com/electron/electron/tree/master/docs-translations/uk-UA)
|
||||
- [Russian](https://github.com/electron/electron/tree/master/docs-translations/ru-RU)
|
||||
- [French](https://github.com/electron/electron/tree/master/docs-translations/fr-FR)
|
||||
- [Indonesian](https://github.com/electron/electron/tree/master/docs-translations/id)
|
||||
|
||||
## Quick Start
|
||||
|
||||
|
|
|
@ -93,9 +93,9 @@ content::PepperPluginInfo CreateWidevineCdmInfo(const base::FilePath& path,
|
|||
std::vector<std::string> codecs;
|
||||
codecs.push_back(kCdmSupportedCodecVp8);
|
||||
codecs.push_back(kCdmSupportedCodecVp9);
|
||||
#if defined(USE_PROPRIETARY_CODECS)
|
||||
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||
codecs.push_back(kCdmSupportedCodecAvc1);
|
||||
#endif // defined(USE_PROPRIETARY_CODECS)
|
||||
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
|
||||
std::string codec_string = base::JoinString(
|
||||
codecs, std::string(1, kCdmSupportedCodecsValueDelimiter));
|
||||
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);
|
||||
}
|
||||
|
||||
void AtomContentClient::AddAdditionalSchemes(
|
||||
std::vector<url::SchemeWithType>* standard_schemes,
|
||||
std::vector<url::SchemeWithType>* referrer_schemes,
|
||||
std::vector<std::string>* savable_schemes) {
|
||||
standard_schemes->push_back({"chrome-extension", url::SCHEME_WITHOUT_PORT});
|
||||
void AtomContentClient::AddAdditionalSchemes(Schemes* schemes) {
|
||||
schemes->standard_schemes.push_back("chrome-extension");
|
||||
|
||||
std::vector<std::string> splited;
|
||||
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(
|
||||
|
@ -214,25 +222,4 @@ void AtomContentClient::AddPepperPlugins(
|
|||
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
|
||||
|
|
|
@ -23,17 +23,9 @@ class AtomContentClient : public brightray::ContentClient {
|
|||
std::string GetProduct() const override;
|
||||
std::string GetUserAgent() const override;
|
||||
base::string16 GetLocalizedString(int message_id) const override;
|
||||
void AddAdditionalSchemes(
|
||||
std::vector<url::SchemeWithType>* standard_schemes,
|
||||
std::vector<url::SchemeWithType>* referrer_schemes,
|
||||
std::vector<std::string>* savable_schemes) override;
|
||||
void AddAdditionalSchemes(Schemes* schemes) override;
|
||||
void AddPepperPlugins(
|
||||
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:
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomContentClient);
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include "atom/app/uv_task_runner.h"
|
||||
#include "atom/browser/javascript_environment.h"
|
||||
#include "atom/browser/node_debugger.h"
|
||||
#include "atom/common/api/atom_bindings.h"
|
||||
#include "atom/common/crash_reporter/crash_reporter.h"
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
|
@ -51,11 +50,6 @@ int NodeMain(int argc, char *argv[]) {
|
|||
&isolate_data, gin_env.context(), argc, argv,
|
||||
exec_argc, exec_argv);
|
||||
|
||||
// Start our custom debugger implementation.
|
||||
NodeDebugger node_debugger(gin_env.isolate());
|
||||
if (node_debugger.IsRunning())
|
||||
env->AssignToContext(v8::Debug::GetDebugContext(gin_env.isolate()));
|
||||
|
||||
mate::Dictionary process(gin_env.isolate(), env->process_object());
|
||||
#if defined(OS_WIN)
|
||||
process.SetMethod("log", &AtomBindings::Log);
|
||||
|
|
|
@ -464,8 +464,8 @@ int ImportIntoCertStore(
|
|||
|
||||
if (!cert_path.empty()) {
|
||||
if (base::ReadFileToString(base::FilePath(cert_path), &file_data)) {
|
||||
auto module = model->cert_db()->GetPublicModule();
|
||||
rv = model->ImportFromPKCS12(module,
|
||||
auto module = model->cert_db()->GetPrivateSlot();
|
||||
rv = model->ImportFromPKCS12(module.get(),
|
||||
file_data,
|
||||
password,
|
||||
true,
|
||||
|
|
|
@ -62,6 +62,10 @@ struct Converter<net::CookieStore::ChangeCause> {
|
|||
switch (val) {
|
||||
case net::CookieStore::ChangeCause::INSERTED:
|
||||
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");
|
||||
case net::CookieStore::ChangeCause::OVERWRITE:
|
||||
return mate::StringToV8(isolate, "overwrite");
|
||||
|
@ -228,8 +232,8 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
|||
GetCookieStore(getter)->SetCookieWithDetailsAsync(
|
||||
GURL(url), name, value, domain, path, creation_time,
|
||||
expiration_time, last_access_time, secure, http_only,
|
||||
net::CookieSameSite::DEFAULT_MODE, false,
|
||||
net::COOKIE_PRIORITY_DEFAULT, base::Bind(OnSetCookie, callback));
|
||||
net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT,
|
||||
base::Bind(OnSetCookie, callback));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include "atom/browser/api/atom_api_desktop_capturer.h"
|
||||
|
||||
using base::PlatformThreadRef;
|
||||
|
||||
#include "atom/common/api/atom_api_native_image.h"
|
||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
|
|
|
@ -50,20 +50,25 @@ void RegisterStandardSchemes(const std::vector<std::string>& schemes,
|
|||
mate::Arguments* args) {
|
||||
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();
|
||||
for (const std::string& scheme : schemes) {
|
||||
url::AddStandardScheme(scheme.c_str(), url::SCHEME_WITHOUT_PORT);
|
||||
if (secure) {
|
||||
url::AddSecureScheme(scheme.c_str());
|
||||
}
|
||||
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(
|
||||
atom::switches::kStandardSchemes, base::JoinString(schemes, ","));
|
||||
|
||||
mate::Dictionary opts;
|
||||
bool secure = false;
|
||||
if (args->GetNext(&opts) && opts.Get("secure", &secure) && secure) {
|
||||
// add switches to register as secure
|
||||
if (secure) {
|
||||
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
|
||||
atom::switches::kSecureSchemes, base::JoinString(schemes, ","));
|
||||
}
|
||||
|
|
|
@ -432,7 +432,8 @@ void DownloadIdCallback(content::DownloadManager* download_manager,
|
|||
last_modified, offset, length, std::string(),
|
||||
content::DownloadItem::INTERRUPTED,
|
||||
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
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include "atom/browser/atom_browser_client.h"
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
#include "atom/browser/atom_javascript_dialog_manager.h"
|
||||
#include "atom/browser/child_web_contents_tracker.h"
|
||||
#include "atom/browser/lib/bluetooth_chooser.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/net/atom_network_delegate.h"
|
||||
|
@ -39,6 +41,7 @@
|
|||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/process/process_handle.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "base/values.h"
|
||||
|
@ -49,6 +52,7 @@
|
|||
#include "chrome/browser/ssl/security_state_tab_helper.h"
|
||||
#include "content/browser/frame_host/navigation_entry_impl.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_view_base.h"
|
||||
#include "content/browser/web_contents/web_contents_impl.h"
|
||||
#include "content/common/view_messages.h"
|
||||
#include "content/public/browser/favicon_status.h"
|
||||
|
@ -78,6 +82,7 @@
|
|||
#include "third_party/WebKit/public/platform/WebInputEvent.h"
|
||||
#include "third_party/WebKit/public/web/WebFindOptions.h"
|
||||
#include "ui/display/screen.h"
|
||||
#include "ui/events/base_event_utils.h"
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
#include "ui/aura/window.h"
|
||||
|
@ -332,6 +337,9 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
|
|||
else if (options.Get("offscreen", &b) && b)
|
||||
type_ = OFF_SCREEN;
|
||||
|
||||
// Init embedder earlier
|
||||
options.Get("embedder", &embedder_);
|
||||
|
||||
// Whether to enable DevTools.
|
||||
options.Get("devTools", &enable_devtools_);
|
||||
|
||||
|
@ -356,7 +364,18 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
|
|||
session->browser_context(), site_instance);
|
||||
guest_delegate_.reset(new WebViewGuestDelegate);
|
||||
params.guest_delegate = guest_delegate_.get();
|
||||
web_contents = content::WebContents::Create(params);
|
||||
|
||||
if (embedder_ && embedder_->IsOffScreen()) {
|
||||
auto* view = new OffScreenWebContentsView(false,
|
||||
base::Bind(&WebContents::OnPaint, base::Unretained(this)));
|
||||
params.view = view;
|
||||
params.delegate_view = view;
|
||||
|
||||
web_contents = content::WebContents::Create(params);
|
||||
view->SetWebContents(web_contents);
|
||||
} else {
|
||||
web_contents = content::WebContents::Create(params);
|
||||
}
|
||||
} else if (IsOffScreen()) {
|
||||
bool transparent = false;
|
||||
options.Get("transparent", &transparent);
|
||||
|
@ -406,7 +425,7 @@ void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
|
|||
guest_delegate_->Initialize(this);
|
||||
|
||||
NativeWindow* owner_window = nullptr;
|
||||
if (options.Get("embedder", &embedder_) && embedder_) {
|
||||
if (embedder_) {
|
||||
// New WebContents's owner_window is the embedder's owner_window.
|
||||
auto relay =
|
||||
NativeWindowRelay::FromWebContents(embedder_->web_contents());
|
||||
|
@ -502,6 +521,7 @@ void WebContents::AddNewContents(content::WebContents* source,
|
|||
const gfx::Rect& initial_rect,
|
||||
bool user_gesture,
|
||||
bool* was_blocked) {
|
||||
new ChildWebContentsTracker(new_contents);
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
auto api_web_contents = CreateFrom(isolate(), new_contents);
|
||||
|
@ -585,8 +605,8 @@ bool WebContents::PreHandleKeyboardEvent(
|
|||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event,
|
||||
bool* is_keyboard_shortcut) {
|
||||
if (event.type == blink::WebInputEvent::Type::RawKeyDown
|
||||
|| event.type == blink::WebInputEvent::Type::KeyUp)
|
||||
if (event.type() == blink::WebInputEvent::Type::RawKeyDown ||
|
||||
event.type() == blink::WebInputEvent::Type::KeyUp)
|
||||
return Emit("before-input-event", event);
|
||||
else
|
||||
return false;
|
||||
|
@ -698,6 +718,15 @@ std::unique_ptr<content::BluetoothChooser> WebContents::RunBluetoothChooser(
|
|||
return std::move(bluetooth_chooser);
|
||||
}
|
||||
|
||||
content::JavaScriptDialogManager*
|
||||
WebContents::GetJavaScriptDialogManager(
|
||||
content::WebContents* source) {
|
||||
if (!dialog_manager_)
|
||||
dialog_manager_.reset(new AtomJavaScriptDialogManager(this));
|
||||
|
||||
return dialog_manager_.get();
|
||||
}
|
||||
|
||||
void WebContents::BeforeUnloadFired(const base::TimeTicks& proceed_time) {
|
||||
// Do nothing, we override this method just to avoid compilation error since
|
||||
// there are two virtual functions named BeforeUnloadFired.
|
||||
|
@ -890,6 +919,15 @@ void WebContents::Observe(int type,
|
|||
}
|
||||
}
|
||||
|
||||
void WebContents::BeforeUnloadDialogCancelled() {
|
||||
if (deferred_load_url_.id) {
|
||||
auto& controller = web_contents()->GetController();
|
||||
if (!controller.GetPendingEntry()) {
|
||||
deferred_load_url_.id = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WebContents::DevToolsReloadPage() {
|
||||
Emit("devtools-reload-page");
|
||||
}
|
||||
|
@ -906,7 +944,7 @@ void WebContents::DevToolsOpened() {
|
|||
devtools_web_contents_.Reset(isolate(), handle.ToV8());
|
||||
|
||||
// Set inspected tabID.
|
||||
base::FundamentalValue tab_id(ID());
|
||||
base::Value tab_id(ID());
|
||||
managed_web_contents()->CallClientFunction(
|
||||
"DevToolsAPI.setInspectedTabId", &tab_id, nullptr, nullptr);
|
||||
|
||||
|
@ -979,7 +1017,7 @@ void WebContents::NavigationEntryCommitted(
|
|||
|
||||
int64_t WebContents::GetID() const {
|
||||
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;
|
||||
return rv;
|
||||
}
|
||||
|
@ -988,6 +1026,11 @@ int WebContents::GetProcessID() const {
|
|||
return web_contents()->GetRenderProcessHost()->GetID();
|
||||
}
|
||||
|
||||
base::ProcessId WebContents::GetOSProcessID() const {
|
||||
auto process_handle = web_contents()->GetRenderProcessHost()->GetHandle();
|
||||
return base::GetProcId(process_handle);
|
||||
}
|
||||
|
||||
WebContents::Type WebContents::GetType() const {
|
||||
return type_;
|
||||
}
|
||||
|
@ -1345,7 +1388,7 @@ void WebContents::SelectAll() {
|
|||
}
|
||||
|
||||
void WebContents::Unselect() {
|
||||
web_contents()->Unselect();
|
||||
web_contents()->CollapseSelection();
|
||||
}
|
||||
|
||||
void WebContents::Replace(const base::string16& word) {
|
||||
|
@ -1420,30 +1463,31 @@ bool WebContents::SendIPCMessage(bool all_frames,
|
|||
|
||||
void WebContents::SendInputEvent(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> input_event) {
|
||||
const auto view = web_contents()->GetRenderWidgetHostView();
|
||||
const auto view = static_cast<content::RenderWidgetHostViewBase*>(
|
||||
web_contents()->GetRenderWidgetHostView());
|
||||
if (!view)
|
||||
return;
|
||||
const auto host = view->GetRenderWidgetHost();
|
||||
if (!host)
|
||||
return;
|
||||
|
||||
int type = mate::GetWebInputEventType(isolate, input_event);
|
||||
if (blink::WebInputEvent::isMouseEventType(type)) {
|
||||
blink::WebMouseEvent mouse_event;
|
||||
if (mate::ConvertFromV8(isolate, input_event, &mouse_event)) {
|
||||
host->ForwardMouseEvent(mouse_event);
|
||||
view->ProcessMouseEvent(mouse_event, ui::LatencyInfo());
|
||||
return;
|
||||
}
|
||||
} 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)) {
|
||||
host->ForwardKeyboardEvent(keyboard_event);
|
||||
view->ProcessKeyboardEvent(keyboard_event);
|
||||
return;
|
||||
}
|
||||
} else if (type == blink::WebInputEvent::MouseWheel) {
|
||||
blink::WebMouseWheelEvent mouse_wheel_event;
|
||||
if (mate::ConvertFromV8(isolate, input_event, &mouse_wheel_event)) {
|
||||
host->ForwardWheelEvent(mouse_wheel_event);
|
||||
view->ProcessMouseWheelEvent(mouse_wheel_event, ui::LatencyInfo());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1525,8 +1569,7 @@ void WebContents::CapturePage(mate::Arguments* args) {
|
|||
}
|
||||
|
||||
const auto view = web_contents()->GetRenderWidgetHostView();
|
||||
const auto host = view ? view->GetRenderWidgetHost() : nullptr;
|
||||
if (!view || !host) {
|
||||
if (!view) {
|
||||
callback.Run(gfx::Image());
|
||||
return;
|
||||
}
|
||||
|
@ -1546,10 +1589,10 @@ void WebContents::CapturePage(mate::Arguments* args) {
|
|||
if (scale > 1.0f)
|
||||
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
|
||||
|
||||
host->CopyFromBackingStore(gfx::Rect(rect.origin(), view_size),
|
||||
bitmap_size,
|
||||
base::Bind(&OnCapturePageDone, callback),
|
||||
kBGRA_8888_SkColorType);
|
||||
view->CopyFromSurface(gfx::Rect(rect.origin(), view_size),
|
||||
bitmap_size,
|
||||
base::Bind(&OnCapturePageDone, callback),
|
||||
kBGRA_8888_SkColorType);
|
||||
}
|
||||
|
||||
void WebContents::OnCursorChange(const content::WebCursor& cursor) {
|
||||
|
@ -1581,9 +1624,7 @@ bool WebContents::IsOffScreen() const {
|
|||
}
|
||||
|
||||
void WebContents::OnPaint(const gfx::Rect& dirty_rect, const SkBitmap& bitmap) {
|
||||
mate::Handle<NativeImage> image =
|
||||
NativeImage::Create(isolate(), gfx::Image::CreateFrom1xBitmap(bitmap));
|
||||
Emit("paint", dirty_rect, image);
|
||||
Emit("paint", dirty_rect, gfx::Image::CreateFrom1xBitmap(bitmap));
|
||||
}
|
||||
|
||||
void WebContents::StartPainting() {
|
||||
|
@ -1647,6 +1688,18 @@ void WebContents::Invalidate() {
|
|||
}
|
||||
}
|
||||
|
||||
gfx::Size WebContents::GetSizeForNewRenderView(
|
||||
content::WebContents* wc) const {
|
||||
if (IsOffScreen() && wc == web_contents()) {
|
||||
auto relay = NativeWindowRelay::FromWebContents(web_contents());
|
||||
if (relay) {
|
||||
return relay->window->GetSize();
|
||||
}
|
||||
}
|
||||
|
||||
return gfx::Size();
|
||||
}
|
||||
|
||||
void WebContents::SetZoomLevel(double level) {
|
||||
zoom_controller_->SetZoomLevel(level);
|
||||
}
|
||||
|
@ -1747,6 +1800,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
|||
.MakeDestroyable()
|
||||
.SetMethod("getId", &WebContents::GetID)
|
||||
.SetMethod("getProcessId", &WebContents::GetProcessID)
|
||||
.SetMethod("getOSProcessId", &WebContents::GetOSProcessID)
|
||||
.SetMethod("equal", &WebContents::Equal)
|
||||
.SetMethod("_loadURL", &WebContents::LoadURL)
|
||||
.SetMethod("downloadURL", &WebContents::DownloadURL)
|
||||
|
|
|
@ -42,6 +42,7 @@ namespace atom {
|
|||
|
||||
struct SetSizeParams;
|
||||
class AtomBrowserContext;
|
||||
class AtomJavaScriptDialogManager;
|
||||
class WebContentsZoomController;
|
||||
class WebViewGuestDelegate;
|
||||
|
||||
|
@ -83,6 +84,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
|
||||
int64_t GetID() const;
|
||||
int GetProcessID() const;
|
||||
base::ProcessId GetOSProcessID() const;
|
||||
Type GetType() const;
|
||||
bool Equal(const WebContents* web_contents) const;
|
||||
void LoadURL(const GURL& url, const mate::Dictionary& options);
|
||||
|
@ -185,6 +187,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
void SetFrameRate(int frame_rate);
|
||||
int GetFrameRate() const;
|
||||
void Invalidate();
|
||||
gfx::Size GetSizeForNewRenderView(content::WebContents*) const override;
|
||||
|
||||
// Methods for zoom handling.
|
||||
void SetZoomLevel(double level);
|
||||
|
@ -298,6 +301,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
std::unique_ptr<content::BluetoothChooser> RunBluetoothChooser(
|
||||
content::RenderFrameHost* frame,
|
||||
const content::BluetoothChooser::EventHandler& handler) override;
|
||||
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
|
||||
content::WebContents* source) override;
|
||||
|
||||
// content::WebContentsObserver:
|
||||
void BeforeUnloadFired(const base::TimeTicks& proceed_time) override;
|
||||
|
@ -342,6 +347,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
void Observe(int type,
|
||||
const content::NotificationSource& source,
|
||||
const content::NotificationDetails& details) override;
|
||||
void BeforeUnloadDialogCancelled() override;
|
||||
|
||||
// brightray::InspectableWebContentsDelegate:
|
||||
void DevToolsReloadPage() override;
|
||||
|
@ -389,6 +395,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
v8::Global<v8::Value> devtools_web_contents_;
|
||||
v8::Global<v8::Value> debugger_;
|
||||
|
||||
std::unique_ptr<AtomJavaScriptDialogManager> dialog_manager_;
|
||||
std::unique_ptr<WebViewGuestDelegate> guest_delegate_;
|
||||
|
||||
// The host webcontents that may contain this webcontents.
|
||||
|
|
|
@ -24,6 +24,7 @@ FrameSubscriber::FrameSubscriber(v8::Isolate* isolate,
|
|||
view_(view),
|
||||
callback_(callback),
|
||||
only_dirty_(only_dirty),
|
||||
source_id_for_copy_request_(base::UnguessableToken::Create()),
|
||||
weak_factory_(this) {
|
||||
}
|
||||
|
||||
|
@ -32,8 +33,7 @@ bool FrameSubscriber::ShouldCaptureFrame(
|
|||
base::TimeTicks present_time,
|
||||
scoped_refptr<media::VideoFrame>* storage,
|
||||
DeliverFrameCallback* callback) {
|
||||
const auto host = view_ ? view_->GetRenderWidgetHost() : nullptr;
|
||||
if (!view_ || !host)
|
||||
if (!view_)
|
||||
return false;
|
||||
|
||||
if (dirty_rect.IsEmpty())
|
||||
|
@ -54,7 +54,7 @@ bool FrameSubscriber::ShouldCaptureFrame(
|
|||
|
||||
rect = gfx::Rect(rect.origin(), bitmap_size);
|
||||
|
||||
host->CopyFromBackingStore(
|
||||
view_->CopyFromSurface(
|
||||
rect,
|
||||
rect.size(),
|
||||
base::Bind(&FrameSubscriber::OnFrameDelivered,
|
||||
|
@ -64,6 +64,10 @@ bool FrameSubscriber::ShouldCaptureFrame(
|
|||
return false;
|
||||
}
|
||||
|
||||
const base::UnguessableToken& FrameSubscriber::GetSourceIdForCopyRequest() {
|
||||
return source_id_for_copy_request_;
|
||||
}
|
||||
|
||||
void FrameSubscriber::OnFrameDelivered(const FrameCaptureCallback& callback,
|
||||
const gfx::Rect& damage_rect,
|
||||
const SkBitmap& bitmap,
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
#include "base/callback.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/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 "ui/gfx/geometry/size.h"
|
||||
#include "v8/include/v8.h"
|
||||
|
@ -32,6 +32,7 @@ class FrameSubscriber : public content::RenderWidgetHostViewFrameSubscriber {
|
|||
base::TimeTicks present_time,
|
||||
scoped_refptr<media::VideoFrame>* storage,
|
||||
DeliverFrameCallback* callback) override;
|
||||
const base::UnguessableToken& GetSourceIdForCopyRequest() override;
|
||||
|
||||
private:
|
||||
void OnFrameDelivered(const FrameCaptureCallback& callback,
|
||||
|
@ -44,6 +45,8 @@ class FrameSubscriber : public content::RenderWidgetHostViewFrameSubscriber {
|
|||
FrameCaptureCallback callback_;
|
||||
bool only_dirty_;
|
||||
|
||||
base::UnguessableToken source_id_for_copy_request_;
|
||||
|
||||
base::WeakPtrFactory<FrameSubscriber> weak_factory_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(FrameSubscriber);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "atom/browser/atom_quota_permission_context.h"
|
||||
#include "atom/browser/atom_resource_dispatcher_host_delegate.h"
|
||||
#include "atom/browser/atom_speech_recognition_manager_delegate.h"
|
||||
#include "atom/browser/child_web_contents_tracker.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/web_contents_permission_helper.h"
|
||||
#include "atom/browser/web_contents_preferences.h"
|
||||
|
@ -87,17 +88,31 @@ content::WebContents* AtomBrowserClient::GetWebContentsFromProcessID(
|
|||
}
|
||||
|
||||
bool AtomBrowserClient::ShouldCreateNewSiteInstance(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
content::BrowserContext* browser_context,
|
||||
content::SiteInstance* current_instance,
|
||||
const GURL& url) {
|
||||
|
||||
if (url.SchemeIs(url::kJavaScriptScheme))
|
||||
// "javacript:" scheme should always use same SiteInstance
|
||||
return false;
|
||||
|
||||
if (!IsRendererSandboxed(current_instance->GetProcess()->GetID()))
|
||||
// non-sandboxed renderers should always create a new SiteInstance
|
||||
return true;
|
||||
int process_id = current_instance->GetProcess()->GetID();
|
||||
if (!IsRendererSandboxed(process_id)) {
|
||||
if (!RendererUsesNativeWindowOpen(process_id)) {
|
||||
// non-sandboxed renderers without native window.open should always create
|
||||
// a new SiteInstance
|
||||
return true;
|
||||
}
|
||||
auto web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
if (!ChildWebContentsTracker::IsChildWebContents(web_contents)) {
|
||||
// Root WebContents should always create new process to make sure
|
||||
// native addons are loaded correctly after reload / navigation.
|
||||
// (Non-root WebContents opened by window.open() should try to
|
||||
// reuse process to allow synchronous cross-window scripting.)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Create new a SiteInstance if navigating to a different site.
|
||||
auto src_url = current_instance->GetSiteURL();
|
||||
|
@ -109,19 +124,27 @@ bool AtomBrowserClient::ShouldCreateNewSiteInstance(
|
|||
content::SiteInstance::GetSiteForURL(browser_context, url) != src_url;
|
||||
}
|
||||
|
||||
void AtomBrowserClient::AddSandboxedRendererId(int process_id) {
|
||||
base::AutoLock auto_lock(sandboxed_renderers_lock_);
|
||||
sandboxed_renderers_.insert(process_id);
|
||||
void AtomBrowserClient::AddProcessPreferences(
|
||||
int process_id, AtomBrowserClient::ProcessPreferences prefs) {
|
||||
base::AutoLock auto_lock(process_preferences_lock_);
|
||||
process_preferences_[process_id] = prefs;
|
||||
}
|
||||
|
||||
void AtomBrowserClient::RemoveSandboxedRendererId(int process_id) {
|
||||
base::AutoLock auto_lock(sandboxed_renderers_lock_);
|
||||
sandboxed_renderers_.erase(process_id);
|
||||
void AtomBrowserClient::RemoveProcessPreferences(int process_id) {
|
||||
base::AutoLock auto_lock(process_preferences_lock_);
|
||||
process_preferences_.erase(process_id);
|
||||
}
|
||||
|
||||
bool AtomBrowserClient::IsRendererSandboxed(int process_id) {
|
||||
base::AutoLock auto_lock(sandboxed_renderers_lock_);
|
||||
return sandboxed_renderers_.count(process_id);
|
||||
base::AutoLock auto_lock(process_preferences_lock_);
|
||||
auto it = process_preferences_.find(process_id);
|
||||
return it != process_preferences_.end() && it->second.sandbox;
|
||||
}
|
||||
|
||||
bool AtomBrowserClient::RendererUsesNativeWindowOpen(int process_id) {
|
||||
base::AutoLock auto_lock(process_preferences_lock_);
|
||||
auto it = process_preferences_.find(process_id);
|
||||
return it != process_preferences_.end() && it->second.native_window_open;
|
||||
}
|
||||
|
||||
void AtomBrowserClient::RenderProcessWillLaunch(
|
||||
|
@ -133,11 +156,13 @@ void AtomBrowserClient::RenderProcessWillLaunch(
|
|||
new WidevineCdmMessageFilter(process_id, host->GetBrowserContext()));
|
||||
|
||||
content::WebContents* web_contents = GetWebContentsFromProcessID(process_id);
|
||||
if (WebContentsPreferences::IsSandboxed(web_contents)) {
|
||||
AddSandboxedRendererId(host->GetID());
|
||||
// ensure the sandboxed renderer id is removed later
|
||||
host->AddObserver(this);
|
||||
}
|
||||
ProcessPreferences process_prefs;
|
||||
process_prefs.sandbox = WebContentsPreferences::IsSandboxed(web_contents);
|
||||
process_prefs.native_window_open
|
||||
= WebContentsPreferences::UsesNativeWindowOpen(web_contents);
|
||||
AddProcessPreferences(host->GetID(), process_prefs);
|
||||
// ensure the ProcessPreferences is removed later
|
||||
host->AddObserver(this);
|
||||
}
|
||||
|
||||
content::SpeechRecognitionManagerDelegate*
|
||||
|
@ -182,7 +207,8 @@ void AtomBrowserClient::OverrideSiteInstanceForNavigation(
|
|||
return;
|
||||
}
|
||||
|
||||
if (!ShouldCreateNewSiteInstance(browser_context, current_instance, url))
|
||||
if (!ShouldCreateNewSiteInstance(render_frame_host, browser_context,
|
||||
current_instance, url))
|
||||
return;
|
||||
|
||||
scoped_refptr<content::SiteInstance> site_instance =
|
||||
|
@ -296,27 +322,27 @@ void AtomBrowserClient::ResourceDispatcherHostCreated() {
|
|||
}
|
||||
|
||||
bool AtomBrowserClient::CanCreateWindow(
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
const GURL& opener_url,
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
WindowContainerType container_type,
|
||||
content::mojom::WindowContainerType container_type,
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::WebWindowFeatures& features,
|
||||
const blink::mojom::WindowFeatures& features,
|
||||
const std::vector<std::string>& additional_features,
|
||||
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
|
||||
bool user_gesture,
|
||||
bool opener_suppressed,
|
||||
content::ResourceContext* context,
|
||||
int render_process_id,
|
||||
int opener_render_view_id,
|
||||
int opener_render_frame_id,
|
||||
bool* no_javascript_access) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
|
||||
|
||||
if (IsRendererSandboxed(render_process_id)) {
|
||||
if (IsRendererSandboxed(opener_render_process_id)
|
||||
|| RendererUsesNativeWindowOpen(opener_render_process_id)) {
|
||||
*no_javascript_access = false;
|
||||
return true;
|
||||
}
|
||||
|
@ -330,7 +356,7 @@ bool AtomBrowserClient::CanCreateWindow(
|
|||
disposition,
|
||||
additional_features,
|
||||
body,
|
||||
render_process_id,
|
||||
opener_render_process_id,
|
||||
opener_render_frame_id));
|
||||
}
|
||||
|
||||
|
@ -381,7 +407,7 @@ void AtomBrowserClient::RenderProcessHostDestroyed(
|
|||
break;
|
||||
}
|
||||
}
|
||||
RemoveSandboxedRendererId(process_id);
|
||||
RemoveProcessPreferences(process_id);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -80,23 +80,22 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
|||
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
|
||||
void ResourceDispatcherHostCreated() override;
|
||||
bool CanCreateWindow(
|
||||
int opener_render_process_id,
|
||||
int opener_render_frame_id,
|
||||
const GURL& opener_url,
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
WindowContainerType container_type,
|
||||
content::mojom::WindowContainerType container_type,
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::WebWindowFeatures& features,
|
||||
const blink::mojom::WindowFeatures& features,
|
||||
const std::vector<std::string>& additional_features,
|
||||
const scoped_refptr<content::ResourceRequestBodyImpl>& body,
|
||||
bool user_gesture,
|
||||
bool opener_suppressed,
|
||||
content::ResourceContext* context,
|
||||
int render_process_id,
|
||||
int opener_render_view_id,
|
||||
int opener_render_frame_id,
|
||||
bool* no_javascript_access) override;
|
||||
void GetAdditionalAllowedSchemesForFileSystem(
|
||||
std::vector<std::string>* schemes) override;
|
||||
|
@ -112,19 +111,24 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
|||
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
||||
|
||||
private:
|
||||
bool ShouldCreateNewSiteInstance(content::BrowserContext* browser_context,
|
||||
bool ShouldCreateNewSiteInstance(content::RenderFrameHost* render_frame_host,
|
||||
content::BrowserContext* browser_context,
|
||||
content::SiteInstance* current_instance,
|
||||
const GURL& dest_url);
|
||||
// Add/remove a process id to `sandboxed_renderers_`.
|
||||
void AddSandboxedRendererId(int process_id);
|
||||
void RemoveSandboxedRendererId(int process_id);
|
||||
struct ProcessPreferences {
|
||||
bool sandbox;
|
||||
bool native_window_open;
|
||||
};
|
||||
void AddProcessPreferences(int process_id, ProcessPreferences prefs);
|
||||
void RemoveProcessPreferences(int process_id);
|
||||
bool IsRendererSandboxed(int process_id);
|
||||
bool RendererUsesNativeWindowOpen(int process_id);
|
||||
|
||||
// pending_render_process => current_render_process.
|
||||
std::map<int, int> pending_processes_;
|
||||
// Set that contains the process ids of all sandboxed renderers
|
||||
std::set<int> sandboxed_renderers_;
|
||||
base::Lock sandboxed_renderers_lock_;
|
||||
|
||||
std::map<int, ProcessPreferences> process_preferences_;
|
||||
base::Lock process_preferences_lock_;
|
||||
|
||||
std::unique_ptr<AtomResourceDispatcherHostDelegate>
|
||||
resource_dispatcher_host_delegate_;
|
||||
|
|
|
@ -129,17 +129,14 @@ void AtomBrowserMainParts::PostEarlyInitialization() {
|
|||
|
||||
node_bindings_->Initialize();
|
||||
|
||||
// Support the "--debug" switch.
|
||||
node_debugger_.reset(new NodeDebugger(js_env_->isolate()));
|
||||
|
||||
// Create the global environment.
|
||||
node::Environment* env =
|
||||
node_bindings_->CreateEnvironment(js_env_->context());
|
||||
node_env_.reset(new NodeEnvironment(env));
|
||||
|
||||
// Make sure node can get correct environment when debugging.
|
||||
if (node_debugger_->IsRunning())
|
||||
env->AssignToContext(v8::Debug::GetDebugContext(js_env_->isolate()));
|
||||
// Enable support for v8 inspector
|
||||
node_debugger_.reset(new NodeDebugger(env));
|
||||
node_debugger_->Start();
|
||||
|
||||
// Add Electron extended APIs.
|
||||
atom_bindings_->BindTo(js_env_->isolate(), env->process_object());
|
||||
|
|
|
@ -7,33 +7,37 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/api/atom_api_web_contents.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/ui/message_box.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "ui/gfx/image/image_skia.h"
|
||||
|
||||
using content::JavaScriptMessageType;
|
||||
using content::JavaScriptDialogType;
|
||||
|
||||
namespace atom {
|
||||
|
||||
AtomJavaScriptDialogManager::AtomJavaScriptDialogManager(
|
||||
api::WebContents* api_web_contents)
|
||||
: api_web_contents_(api_web_contents) {}
|
||||
|
||||
void AtomJavaScriptDialogManager::RunJavaScriptDialog(
|
||||
content::WebContents* web_contents,
|
||||
const GURL& origin_url,
|
||||
JavaScriptMessageType message_type,
|
||||
JavaScriptDialogType dialog_type,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
const DialogClosedCallback& callback,
|
||||
bool* did_suppress_message) {
|
||||
|
||||
if (message_type != JavaScriptMessageType::JAVASCRIPT_MESSAGE_TYPE_ALERT &&
|
||||
message_type != JavaScriptMessageType::JAVASCRIPT_MESSAGE_TYPE_CONFIRM) {
|
||||
if (dialog_type != JavaScriptDialogType::JAVASCRIPT_DIALOG_TYPE_ALERT &&
|
||||
dialog_type != JavaScriptDialogType::JAVASCRIPT_DIALOG_TYPE_CONFIRM) {
|
||||
callback.Run(false, base::string16());
|
||||
return;
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
@ -49,13 +53,13 @@ void AtomJavaScriptDialogManager::RunBeforeUnloadDialog(
|
|||
content::WebContents* web_contents,
|
||||
bool is_reload,
|
||||
const DialogClosedCallback& callback) {
|
||||
// FIXME(zcbenz): the |message_text| is removed, figure out what should we do.
|
||||
callback.Run(false, base::ASCIIToUTF16("This should not be displayed"));
|
||||
bool default_prevented = api_web_contents_->Emit("will-prevent-unload");
|
||||
callback.Run(default_prevented, base::string16());
|
||||
return;
|
||||
}
|
||||
|
||||
void AtomJavaScriptDialogManager::CancelDialogs(
|
||||
content::WebContents* web_contents,
|
||||
bool suppress_callbacks,
|
||||
bool reset_state) {
|
||||
}
|
||||
|
||||
|
|
|
@ -11,13 +11,19 @@
|
|||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
class WebContents;
|
||||
}
|
||||
|
||||
class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
|
||||
public:
|
||||
explicit AtomJavaScriptDialogManager(api::WebContents* api_web_contents);
|
||||
|
||||
// content::JavaScriptDialogManager implementations.
|
||||
void RunJavaScriptDialog(
|
||||
content::WebContents* web_contents,
|
||||
const GURL& origin_url,
|
||||
content::JavaScriptMessageType javascript_message_type,
|
||||
content::JavaScriptDialogType dialog_type,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
const DialogClosedCallback& callback,
|
||||
|
@ -27,13 +33,13 @@ class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
|
|||
bool is_reload,
|
||||
const DialogClosedCallback& callback) override;
|
||||
void CancelDialogs(content::WebContents* web_contents,
|
||||
bool suppress_callbacks,
|
||||
bool reset_state) override;
|
||||
|
||||
private:
|
||||
static void OnMessageBoxCallback(const DialogClosedCallback& callback,
|
||||
int code,
|
||||
bool checkbox_checked);
|
||||
api::WebContents* api_web_contents_;
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -131,7 +131,7 @@ int AtomPermissionManager::RequestPermissions(
|
|||
|
||||
auto web_contents =
|
||||
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));
|
||||
|
||||
for (size_t i = 0; i < permissions.size(); ++i) {
|
||||
|
@ -187,12 +187,6 @@ blink::mojom::PermissionStatus AtomPermissionManager::GetPermissionStatus(
|
|||
return blink::mojom::PermissionStatus::GRANTED;
|
||||
}
|
||||
|
||||
void AtomPermissionManager::RegisterPermissionUsage(
|
||||
content::PermissionType permission,
|
||||
const GURL& requesting_origin,
|
||||
const GURL& embedding_origin) {
|
||||
}
|
||||
|
||||
int AtomPermissionManager::SubscribePermissionStatusChange(
|
||||
content::PermissionType permission,
|
||||
const GURL& requesting_origin,
|
||||
|
|
|
@ -66,9 +66,6 @@ class AtomPermissionManager : public content::PermissionManager {
|
|||
content::PermissionType permission,
|
||||
const GURL& requesting_origin,
|
||||
const GURL& embedding_origin) override;
|
||||
void RegisterPermissionUsage(content::PermissionType permission,
|
||||
const GURL& requesting_origin,
|
||||
const GURL& embedding_origin) override;
|
||||
int SubscribePermissionStatusChange(
|
||||
content::PermissionType permission,
|
||||
const GURL& requesting_origin,
|
||||
|
@ -79,7 +76,7 @@ class AtomPermissionManager : public content::PermissionManager {
|
|||
|
||||
private:
|
||||
class PendingRequest;
|
||||
using PendingRequestsMap = IDMap<PendingRequest, IDMapOwnPointer>;
|
||||
using PendingRequestsMap = IDMap<std::unique_ptr<PendingRequest>>;
|
||||
|
||||
RequestHandler request_handler_;
|
||||
|
||||
|
|
33
atom/browser/child_web_contents_tracker.cc
Normal file
33
atom/browser/child_web_contents_tracker.cc
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) 2017 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "atom/browser/child_web_contents_tracker.h"
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
std::unordered_set<content::WebContents*> g_child_web_contents;
|
||||
|
||||
} // namespace
|
||||
|
||||
ChildWebContentsTracker::ChildWebContentsTracker(
|
||||
content::WebContents* web_contents)
|
||||
: content::WebContentsObserver(web_contents) {
|
||||
g_child_web_contents.insert(web_contents);
|
||||
}
|
||||
|
||||
bool ChildWebContentsTracker::IsChildWebContents(
|
||||
content::WebContents* web_contents) {
|
||||
return g_child_web_contents.find(web_contents) != g_child_web_contents.end();
|
||||
}
|
||||
|
||||
void ChildWebContentsTracker::WebContentsDestroyed() {
|
||||
g_child_web_contents.erase(web_contents());
|
||||
delete this;
|
||||
}
|
||||
|
||||
} // namespace atom
|
25
atom/browser/child_web_contents_tracker.h
Normal file
25
atom/browser/child_web_contents_tracker.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
// Copyright (c) 2017 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ATOM_BROWSER_CHILD_WEB_CONTENTS_TRACKER_H_
|
||||
#define ATOM_BROWSER_CHILD_WEB_CONTENTS_TRACKER_H_
|
||||
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
// ChildWebContentsTracker tracks child WebContents
|
||||
// created by native `window.open()`
|
||||
class ChildWebContentsTracker : public content::WebContentsObserver {
|
||||
public:
|
||||
explicit ChildWebContentsTracker(content::WebContents* web_contents);
|
||||
static bool IsChildWebContents(content::WebContents* web_contents);
|
||||
|
||||
protected:
|
||||
void WebContentsDestroyed() override;
|
||||
};
|
||||
|
||||
} // namespace atom
|
||||
|
||||
#endif // ATOM_BROWSER_CHILD_WEB_CONTENTS_TRACKER_H_
|
|
@ -9,7 +9,6 @@
|
|||
#include <vector>
|
||||
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/atom_javascript_dialog_manager.h"
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/ui/file_dialog.h"
|
||||
#include "atom/browser/web_dialog_helper.h"
|
||||
|
@ -230,15 +229,6 @@ bool CommonWebContentsDelegate::CanOverscrollContent() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
content::JavaScriptDialogManager*
|
||||
CommonWebContentsDelegate::GetJavaScriptDialogManager(
|
||||
content::WebContents* source) {
|
||||
if (!dialog_manager_)
|
||||
dialog_manager_.reset(new AtomJavaScriptDialogManager);
|
||||
|
||||
return dialog_manager_.get();
|
||||
}
|
||||
|
||||
content::ColorChooser* CommonWebContentsDelegate::OpenColorChooser(
|
||||
content::WebContents* web_contents,
|
||||
SkColor color,
|
||||
|
@ -494,9 +484,9 @@ void CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated(
|
|||
int request_id,
|
||||
const std::string& file_system_path,
|
||||
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::FundamentalValue total_work_value(total_work);
|
||||
base::Value total_work_value(total_work);
|
||||
web_contents_->CallClientFunction("DevToolsAPI.indexingTotalWorkCalculated",
|
||||
&request_id_value,
|
||||
&file_system_path_value,
|
||||
|
@ -507,9 +497,9 @@ void CommonWebContentsDelegate::OnDevToolsIndexingWorked(
|
|||
int request_id,
|
||||
const std::string& file_system_path,
|
||||
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::FundamentalValue worked_value(worked);
|
||||
base::Value worked_value(worked);
|
||||
web_contents_->CallClientFunction("DevToolsAPI.indexingWorked",
|
||||
&request_id_value,
|
||||
&file_system_path_value,
|
||||
|
@ -520,7 +510,7 @@ void CommonWebContentsDelegate::OnDevToolsIndexingDone(
|
|||
int request_id,
|
||||
const std::string& file_system_path) {
|
||||
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);
|
||||
web_contents_->CallClientFunction("DevToolsAPI.indexingDone",
|
||||
&request_id_value,
|
||||
|
@ -536,7 +526,7 @@ void CommonWebContentsDelegate::OnDevToolsSearchCompleted(
|
|||
for (const auto& file_path : file_paths) {
|
||||
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);
|
||||
web_contents_->CallClientFunction("DevToolsAPI.searchCompleted",
|
||||
&request_id_value,
|
||||
|
|
|
@ -20,7 +20,6 @@ using brightray::DevToolsFileSystemIndexer;
|
|||
namespace atom {
|
||||
|
||||
class AtomBrowserContext;
|
||||
class AtomJavaScriptDialogManager;
|
||||
class NativeWindow;
|
||||
class WebDialogHelper;
|
||||
|
||||
|
@ -62,8 +61,6 @@ class CommonWebContentsDelegate
|
|||
content::WebContents* source,
|
||||
const content::OpenURLParams& params) override;
|
||||
bool CanOverscrollContent() const override;
|
||||
content::JavaScriptDialogManager* GetJavaScriptDialogManager(
|
||||
content::WebContents* source) override;
|
||||
content::ColorChooser* OpenColorChooser(
|
||||
content::WebContents* web_contents,
|
||||
SkColor color,
|
||||
|
@ -147,7 +144,6 @@ class CommonWebContentsDelegate
|
|||
bool native_fullscreen_;
|
||||
|
||||
std::unique_ptr<WebDialogHelper> web_dialog_helper_;
|
||||
std::unique_ptr<AtomJavaScriptDialogManager> dialog_manager_;
|
||||
scoped_refptr<DevToolsFileSystemIndexer> devtools_file_system_indexer_;
|
||||
|
||||
// Make sure BrowserContext is alwasys destroyed after WebContents.
|
||||
|
|
|
@ -20,7 +20,7 @@ void CommonWebContentsDelegate::HandleKeyboardEvent(
|
|||
content::WebContents* source,
|
||||
const content::NativeWebKeyboardEvent& event) {
|
||||
if (event.skip_in_browser ||
|
||||
event.type == content::NativeWebKeyboardEvent::Char)
|
||||
event.type() == content::NativeWebKeyboardEvent::Char)
|
||||
return;
|
||||
|
||||
// Escape exits tabbed fullscreen mode.
|
||||
|
|
|
@ -8,16 +8,45 @@
|
|||
|
||||
#include "base/command_line.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "gin/array_buffer.h"
|
||||
#include "gin/v8_initializer.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "atom/node/osfhandle.h"
|
||||
#endif
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
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()
|
||||
: initialized_(Initialize()),
|
||||
isolate_holder_(base::ThreadTaskRunnerHandle::Get()),
|
||||
isolate_(isolate_holder_.isolate()),
|
||||
isolate_scope_(isolate_),
|
||||
locker_(isolate_),
|
||||
|
@ -44,7 +73,7 @@ bool JavascriptEnvironment::Initialize() {
|
|||
|
||||
gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
|
||||
gin::IsolateHolder::kStableV8Extras,
|
||||
gin::ArrayBufferAllocator::SharedInstance());
|
||||
&allocator_);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,14 @@ class Environment;
|
|||
|
||||
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.
|
||||
class JavascriptEnvironment {
|
||||
public:
|
||||
|
@ -31,6 +39,7 @@ class JavascriptEnvironment {
|
|||
bool Initialize();
|
||||
|
||||
bool initialized_;
|
||||
ArrayBufferAllocator allocator_;
|
||||
gin::IsolateHolder isolate_holder_;
|
||||
v8::Isolate* isolate_;
|
||||
v8::Isolate::Scope isolate_scope_;
|
||||
|
|
|
@ -15,12 +15,12 @@ LayeredResourceHandler::LayeredResourceHandler(
|
|||
|
||||
LayeredResourceHandler::~LayeredResourceHandler() {}
|
||||
|
||||
bool LayeredResourceHandler::OnResponseStarted(
|
||||
void LayeredResourceHandler::OnResponseStarted(
|
||||
content::ResourceResponse* response,
|
||||
bool* defer) {
|
||||
std::unique_ptr<content::ResourceController> controller) {
|
||||
if (delegate_)
|
||||
delegate_->OnResponseStarted(response);
|
||||
return next_handler_->OnResponseStarted(response, defer);
|
||||
next_handler_->OnResponseStarted(response, std::move(controller));
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -26,8 +26,9 @@ class LayeredResourceHandler : public content::LayeredResourceHandler {
|
|||
~LayeredResourceHandler() override;
|
||||
|
||||
// content::LayeredResourceHandler:
|
||||
bool OnResponseStarted(content::ResourceResponse* response,
|
||||
bool* defer) override;
|
||||
void OnResponseStarted(
|
||||
content::ResourceResponse* response,
|
||||
std::unique_ptr<content::ResourceController> controller) override;
|
||||
|
||||
private:
|
||||
Delegate* delegate_;
|
||||
|
|
|
@ -147,6 +147,7 @@ class NativeWindow : public base::SupportsUserData,
|
|||
virtual void SetMenu(AtomMenuModel* menu);
|
||||
virtual void SetParentWindow(NativeWindow* parent);
|
||||
virtual void SetBrowserView(NativeBrowserView* browser_view) = 0;
|
||||
virtual gfx::NativeView GetNativeView() = 0;
|
||||
virtual gfx::NativeWindow GetNativeWindow() = 0;
|
||||
virtual gfx::AcceleratedWidget GetAcceleratedWidget() = 0;
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ class NativeWindowMac : public NativeWindow,
|
|||
void SetContentProtection(bool enable) override;
|
||||
void SetBrowserView(NativeBrowserView* browser_view) override;
|
||||
void SetParentWindow(NativeWindow* parent) override;
|
||||
gfx::NativeView GetNativeView() override;
|
||||
gfx::NativeWindow GetNativeWindow() override;
|
||||
gfx::AcceleratedWidget GetAcceleratedWidget() override;
|
||||
void SetProgressBar(double progress, const ProgressState state) override;
|
||||
|
|
|
@ -1314,6 +1314,10 @@ void NativeWindowMac::SetParentWindow(NativeWindow* parent) {
|
|||
[parent->GetNativeWindow() addChildWindow:window_ ordered:NSWindowAbove];
|
||||
}
|
||||
|
||||
gfx::NativeView NativeWindowMac::GetNativeView() {
|
||||
return inspectable_web_contents()->GetView()->GetNativeView();
|
||||
}
|
||||
|
||||
gfx::NativeWindow NativeWindowMac::GetNativeWindow() {
|
||||
return window_;
|
||||
}
|
||||
|
@ -1458,7 +1462,7 @@ void NativeWindowMac::SetEscapeTouchBarItem(const mate::PersistentDictionary& it
|
|||
}
|
||||
|
||||
void NativeWindowMac::OnInputEvent(const blink::WebInputEvent& event) {
|
||||
switch (event.type) {
|
||||
switch (event.type()) {
|
||||
case blink::WebInputEvent::GestureScrollBegin:
|
||||
case blink::WebInputEvent::GestureScrollUpdate:
|
||||
case blink::WebInputEvent::GestureScrollEnd:
|
||||
|
|
|
@ -86,7 +86,7 @@ bool IsAltKey(const content::NativeWebKeyboardEvent& event) {
|
|||
|
||||
bool IsAltModifier(const content::NativeWebKeyboardEvent& event) {
|
||||
typedef content::NativeWebKeyboardEvent::Modifiers Modifiers;
|
||||
int modifiers = event.modifiers;
|
||||
int modifiers = event.modifiers();
|
||||
modifiers &= ~Modifiers::NumLockOn;
|
||||
modifiers &= ~Modifiers::CapsLockOn;
|
||||
return (modifiers == Modifiers::AltKey) ||
|
||||
|
@ -767,13 +767,14 @@ void NativeWindowViews::SetBackgroundColor(const std::string& color_name) {
|
|||
}
|
||||
|
||||
void NativeWindowViews::SetHasShadow(bool has_shadow) {
|
||||
wm::SetShadowType(
|
||||
wm::SetShadowElevation(
|
||||
GetNativeWindow(),
|
||||
has_shadow ? wm::SHADOW_TYPE_RECTANGULAR : wm::SHADOW_TYPE_NONE);
|
||||
has_shadow ? wm::ShadowElevation::MEDIUM : wm::ShadowElevation::NONE);
|
||||
}
|
||||
|
||||
bool NativeWindowViews::HasShadow() {
|
||||
return wm::GetShadowType(GetNativeWindow()) != wm::SHADOW_TYPE_NONE;
|
||||
return GetNativeWindow()->GetProperty(wm::kShadowElevationKey)
|
||||
!= wm::ShadowElevation::NONE;
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetIgnoreMouseEvents(bool ignore) {
|
||||
|
@ -923,6 +924,10 @@ void NativeWindowViews::SetParentWindow(NativeWindow* parent) {
|
|||
#endif
|
||||
}
|
||||
|
||||
gfx::NativeView NativeWindowViews::GetNativeView() {
|
||||
return window_->GetNativeView();
|
||||
}
|
||||
|
||||
gfx::NativeWindow NativeWindowViews::GetNativeWindow() {
|
||||
return window_->GetNativeWindow();
|
||||
}
|
||||
|
@ -1234,10 +1239,10 @@ void NativeWindowViews::HandleKeyboardEvent(
|
|||
// Show accelerator when "Alt" is pressed.
|
||||
if (menu_bar_visible_ && IsAltKey(event))
|
||||
menu_bar_->SetAcceleratorVisibility(
|
||||
event.type == blink::WebInputEvent::RawKeyDown);
|
||||
event.type() == blink::WebInputEvent::RawKeyDown);
|
||||
|
||||
// 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)) {
|
||||
if (!menu_bar_visible_ &&
|
||||
(menu_bar_->GetAcceleratorIndex(event.windowsKeyCode) != -1))
|
||||
|
@ -1250,10 +1255,10 @@ void NativeWindowViews::HandleKeyboardEvent(
|
|||
return;
|
||||
|
||||
// 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:
|
||||
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_) {
|
||||
// When a single Alt is released right after a Alt is pressed:
|
||||
menu_bar_alt_pressed_ = false;
|
||||
|
|
|
@ -106,6 +106,7 @@ class NativeWindowViews : public NativeWindow,
|
|||
void SetMenu(AtomMenuModel* menu_model) override;
|
||||
void SetBrowserView(NativeBrowserView* browser_view) override;
|
||||
void SetParentWindow(NativeWindow* parent) override;
|
||||
gfx::NativeView GetNativeView() override;
|
||||
gfx::NativeWindow GetNativeWindow() override;
|
||||
void SetOverlayIcon(const gfx::Image& overlay,
|
||||
const std::string& description) override;
|
||||
|
|
|
@ -50,15 +50,16 @@ bool AtomURLRequestJobFactory::InterceptProtocol(
|
|||
return false;
|
||||
ProtocolHandler* original_protocol_handler = protocol_handler_map_[scheme];
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
protocol_handler_map_[scheme] =
|
||||
original_protocols_.take_and_erase(scheme).release();
|
||||
protocol_handler_map_[scheme] = it->second.release();
|
||||
original_protocols_.erase(it);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -78,7 +79,9 @@ bool AtomURLRequestJobFactory::HasProtocolHandler(
|
|||
}
|
||||
|
||||
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(
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/scoped_ptr_hash_map.h"
|
||||
#include "net/url_request/url_request_job_factory.h"
|
||||
|
||||
namespace atom {
|
||||
|
@ -64,7 +64,7 @@ class AtomURLRequestJobFactory : public net::URLRequestJobFactory {
|
|||
ProtocolHandlerMap protocol_handler_map_;
|
||||
|
||||
// Map that stores the original protocols of schemes.
|
||||
using OriginalProtocolsMap = base::ScopedPtrHashMap<
|
||||
using OriginalProtocolsMap = std::unordered_map<
|
||||
std::string, std::unique_ptr<ProtocolHandler>>;
|
||||
// Can only be accessed in IO thread.
|
||||
OriginalProtocolsMap original_protocols_;
|
||||
|
|
|
@ -59,11 +59,11 @@ void AskForOptions(v8::Isolate* isolate,
|
|||
}
|
||||
|
||||
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);
|
||||
if (dict->GetInteger("error", error))
|
||||
return true;
|
||||
} else if (value->IsType(base::Value::TYPE_INTEGER)) {
|
||||
} else if (value->IsType(base::Value::Type::INTEGER)) {
|
||||
if (value->GetAsInteger(error))
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "content/public/browser/browser_thread.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/http/http_response_headers.h"
|
||||
#include "net/http/http_status_code.h"
|
||||
#include "net/url_request/url_request_context_getter.h"
|
||||
#include "net/url_request/url_request_job.h"
|
||||
#include "v8/include/v8.h"
|
||||
|
@ -82,6 +83,9 @@ class JsAsker : public RequestJob {
|
|||
base::Bind(&JsAsker::OnResponse,
|
||||
weak_factory_.GetWeakPtr())));
|
||||
}
|
||||
|
||||
int GetResponseCode() const override { return net::HTTP_OK; }
|
||||
|
||||
void GetResponseInfo(net::HttpResponseInfo* info) override {
|
||||
info->headers = new net::HttpResponseHeaders("");
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "atom/common/atom_constants.h"
|
||||
#include "base/threading/sequenced_worker_pool.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -18,10 +19,10 @@ URLRequestAsyncAsarJob::URLRequestAsyncAsarJob(
|
|||
|
||||
void URLRequestAsyncAsarJob::StartAsync(std::unique_ptr<base::Value> options) {
|
||||
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(
|
||||
"path", &file_path);
|
||||
} else if (options->IsType(base::Value::TYPE_STRING)) {
|
||||
} else if (options->IsType(base::Value::Type::STRING)) {
|
||||
options->GetAsString(&file_path);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,13 +34,13 @@ URLRequestBufferJob::URLRequestBufferJob(
|
|||
|
||||
void URLRequestBufferJob::StartAsync(std::unique_ptr<base::Value> options) {
|
||||
const base::BinaryValue* binary = nullptr;
|
||||
if (options->IsType(base::Value::TYPE_DICTIONARY)) {
|
||||
if (options->IsType(base::Value::Type::DICTIONARY)) {
|
||||
base::DictionaryValue* dict =
|
||||
static_cast<base::DictionaryValue*>(options.get());
|
||||
dict->GetString("mimeType", &mime_type_);
|
||||
dict->GetString("charset", &charset_);
|
||||
dict->GetBinary("data", &binary);
|
||||
} else if (options->IsType(base::Value::TYPE_BINARY)) {
|
||||
} else if (options->IsType(base::Value::Type::BINARY)) {
|
||||
options->GetAsBinary(&binary);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ void URLRequestBufferJob::StartAsync(std::unique_ptr<base::Value> options) {
|
|||
}
|
||||
|
||||
void URLRequestBufferJob::GetResponseInfo(net::HttpResponseInfo* info) {
|
||||
std::string status("HTTP/1.1 ");
|
||||
std::string status("HTTP/1.1 200 OK");
|
||||
status.append(base::IntToString(status_code_));
|
||||
status.append(" ");
|
||||
status.append(net::GetHttpReasonPhrase(status_code_));
|
||||
|
|
|
@ -9,14 +9,18 @@
|
|||
|
||||
#include "atom/browser/api/atom_api_session.h"
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "base/guid.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "brightray/browser/url_request_context_getter.h"
|
||||
#include "content/browser/streams/stream_context.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "net/base/io_buffer.h"
|
||||
#include "net/base/net_errors.h"
|
||||
#include "net/http/http_response_headers.h"
|
||||
#include "net/url_request/url_fetcher.h"
|
||||
#include "net/url_request/url_fetcher_response_writer.h"
|
||||
#include "url/url_constants.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
|
@ -62,7 +66,8 @@ class ResponsePiper : public net::URLFetcherResponseWriter {
|
|||
job_->HeadersCompleted();
|
||||
first_write_ = false;
|
||||
}
|
||||
return job_->DataAvailable(buffer, num_bytes, callback);
|
||||
job_->stream()->AddData(buffer->data(), num_bytes);
|
||||
return num_bytes;
|
||||
}
|
||||
int Finish(int net_error, const net::CompletionCallback& callback) override {
|
||||
return net::OK;
|
||||
|
@ -77,12 +82,11 @@ class ResponsePiper : public net::URLFetcherResponseWriter {
|
|||
|
||||
} // namespace
|
||||
|
||||
URLRequestFetchJob::URLRequestFetchJob(
|
||||
net::URLRequest* request, net::NetworkDelegate* network_delegate)
|
||||
URLRequestFetchJob::URLRequestFetchJob(net::URLRequest* request,
|
||||
net::NetworkDelegate* network_delegate)
|
||||
: JsAsker<net::URLRequestJob>(request, network_delegate),
|
||||
pending_buffer_size_(0),
|
||||
write_num_bytes_(0) {
|
||||
}
|
||||
total_bytes_read_(0) {}
|
||||
|
||||
void URLRequestFetchJob::BeforeStartInUI(
|
||||
v8::Isolate* isolate, v8::Local<v8::Value> value) {
|
||||
|
@ -112,7 +116,7 @@ void URLRequestFetchJob::BeforeStartInUI(
|
|||
}
|
||||
|
||||
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(
|
||||
net::URLRequestStatus::FAILED, net::ERR_NOT_IMPLEMENTED));
|
||||
return;
|
||||
|
@ -169,7 +173,22 @@ void URLRequestFetchJob::StartAsync(std::unique_ptr<base::Value> options) {
|
|||
fetcher_->SetExtraRequestHeaders(
|
||||
request()->extra_request_headers().ToString());
|
||||
|
||||
fetcher_->Start();
|
||||
// Create readable stream for URLFetcher response.
|
||||
content::StreamContext* stream_context =
|
||||
static_cast<brightray::URLRequestContextGetter*>(request_context_getter())
|
||||
->stream_context();
|
||||
|
||||
if (stream_context) {
|
||||
GURL stream_url(std::string(url::kBlobScheme) + ":" +
|
||||
formated_url.GetOrigin().spec() + base::GenerateGUID());
|
||||
stream_ =
|
||||
new content::Stream(stream_context->registry(), nullptr, stream_url);
|
||||
stream_->SetReadObserver(this);
|
||||
fetcher_->Start();
|
||||
} else {
|
||||
NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::CANCELED,
|
||||
net::ERR_ABORTED));
|
||||
}
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::HeadersCompleted() {
|
||||
|
@ -178,53 +197,55 @@ void URLRequestFetchJob::HeadersCompleted() {
|
|||
NotifyHeadersComplete();
|
||||
}
|
||||
|
||||
int URLRequestFetchJob::DataAvailable(net::IOBuffer* buffer,
|
||||
int num_bytes,
|
||||
const net::CompletionCallback& callback) {
|
||||
// When pending_buffer_ is empty, there's no ReadRawData() operation waiting
|
||||
// for IO completion, we have to save the parameters until the request is
|
||||
// ready to read data.
|
||||
if (!pending_buffer_.get()) {
|
||||
write_buffer_ = buffer;
|
||||
write_num_bytes_ = num_bytes;
|
||||
write_callback_ = callback;
|
||||
return net::ERR_IO_PENDING;
|
||||
}
|
||||
|
||||
// Write data to the pending buffer and clear them after the writing.
|
||||
int bytes_read = BufferCopy(buffer, num_bytes,
|
||||
pending_buffer_.get(), pending_buffer_size_);
|
||||
ClearPendingBuffer();
|
||||
ReadRawDataComplete(bytes_read);
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::Kill() {
|
||||
JsAsker<URLRequestJob>::Kill();
|
||||
ClearStream();
|
||||
fetcher_.reset();
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::OnDataAvailable(content::Stream* stream) {
|
||||
if (!pending_buffer_.get())
|
||||
return;
|
||||
|
||||
int result = 0;
|
||||
auto state = stream_->ReadRawData(pending_buffer_.get(), pending_buffer_size_,
|
||||
&result);
|
||||
if (state == content::Stream::STREAM_ABORTED)
|
||||
result = net::ERR_CONNECTION_RESET;
|
||||
|
||||
// Clear the buffers before notifying the read is complete, so that it is
|
||||
// safe for the observer to read.
|
||||
pending_buffer_ = nullptr;
|
||||
pending_buffer_size_ = 0;
|
||||
|
||||
if (result > 0)
|
||||
total_bytes_read_ += result;
|
||||
ReadRawDataComplete(result);
|
||||
}
|
||||
|
||||
int URLRequestFetchJob::ReadRawData(net::IOBuffer* dest, int dest_size) {
|
||||
if (GetResponseCode() == 204) {
|
||||
request()->set_received_response_content_length(prefilter_bytes_read());
|
||||
return net::OK;
|
||||
}
|
||||
|
||||
// When write_buffer_ is empty, there is no data valable yet, we have to save
|
||||
// the dest buffer util DataAvailable.
|
||||
if (!write_buffer_.get()) {
|
||||
pending_buffer_ = dest;
|
||||
pending_buffer_size_ = dest_size;
|
||||
return net::ERR_IO_PENDING;
|
||||
int bytes_read = 0;
|
||||
switch (stream_->ReadRawData(dest, dest_size, &bytes_read)) {
|
||||
case content::Stream::STREAM_HAS_DATA:
|
||||
total_bytes_read_ += bytes_read;
|
||||
return bytes_read;
|
||||
case content::Stream::STREAM_COMPLETE:
|
||||
return stream_->GetStatus();
|
||||
case content::Stream::STREAM_EMPTY:
|
||||
pending_buffer_ = dest;
|
||||
pending_buffer_size_ = dest_size;
|
||||
return net::ERR_IO_PENDING;
|
||||
case content::Stream::STREAM_ABORTED:
|
||||
// Handle this as connection reset.
|
||||
return net::ERR_CONNECTION_RESET;
|
||||
}
|
||||
|
||||
// Read from the write buffer and clear them after reading.
|
||||
int bytes_read = BufferCopy(write_buffer_.get(), write_num_bytes_,
|
||||
dest, dest_size);
|
||||
net::CompletionCallback write_callback = write_callback_;
|
||||
ClearWriteBuffer();
|
||||
write_callback.Run(bytes_read);
|
||||
return bytes_read;
|
||||
NOTREACHED();
|
||||
return net::ERR_FAILED;
|
||||
}
|
||||
|
||||
bool URLRequestFetchJob::GetMimeType(std::string* mime_type) const {
|
||||
|
@ -246,11 +267,18 @@ int URLRequestFetchJob::GetResponseCode() const {
|
|||
return response_info_->headers->response_code();
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::OnURLFetchComplete(const net::URLFetcher* source) {
|
||||
ClearPendingBuffer();
|
||||
ClearWriteBuffer();
|
||||
int64_t URLRequestFetchJob::GetTotalReceivedBytes() const {
|
||||
int64_t total_received_bytes = 0;
|
||||
if (response_info_)
|
||||
total_received_bytes = response_info_->headers->raw_headers().size();
|
||||
if (stream_.get())
|
||||
total_received_bytes += total_bytes_read_;
|
||||
return total_received_bytes;
|
||||
}
|
||||
|
||||
if (fetcher_->GetStatus().is_success()) {
|
||||
void URLRequestFetchJob::OnURLFetchComplete(const net::URLFetcher* source) {
|
||||
auto status = fetcher_->GetStatus();
|
||||
if (status.is_success()) {
|
||||
if (!response_info_) {
|
||||
// Since we notify header completion only after first write there will be
|
||||
// no response object constructed for http respones with no content 204.
|
||||
|
@ -258,28 +286,16 @@ void URLRequestFetchJob::OnURLFetchComplete(const net::URLFetcher* source) {
|
|||
HeadersCompleted();
|
||||
return;
|
||||
}
|
||||
ReadRawDataComplete(0);
|
||||
stream_->Finalize(0);
|
||||
} else {
|
||||
NotifyStartError(fetcher_->GetStatus());
|
||||
stream_->Finalize(status.error());
|
||||
NotifyStartError(status);
|
||||
}
|
||||
}
|
||||
|
||||
int URLRequestFetchJob::BufferCopy(net::IOBuffer* source, int num_bytes,
|
||||
net::IOBuffer* target, int target_size) {
|
||||
int bytes_written = std::min(num_bytes, target_size);
|
||||
memcpy(target->data(), source->data(), bytes_written);
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::ClearPendingBuffer() {
|
||||
pending_buffer_ = nullptr;
|
||||
pending_buffer_size_ = 0;
|
||||
}
|
||||
|
||||
void URLRequestFetchJob::ClearWriteBuffer() {
|
||||
write_buffer_ = nullptr;
|
||||
write_num_bytes_ = 0;
|
||||
write_callback_.Reset();
|
||||
void URLRequestFetchJob::ClearStream() {
|
||||
stream_->RemoveReadObserver(this);
|
||||
stream_ = nullptr;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -9,21 +9,23 @@
|
|||
|
||||
#include "atom/browser/net/js_asker.h"
|
||||
#include "browser/url_request_context_getter.h"
|
||||
#include "content/browser/streams/stream.h"
|
||||
#include "content/browser/streams/stream_read_observer.h"
|
||||
#include "net/url_request/url_fetcher_delegate.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
class URLRequestFetchJob : public JsAsker<net::URLRequestJob>,
|
||||
public net::URLFetcherDelegate,
|
||||
public brightray::URLRequestContextGetter::Delegate {
|
||||
public brightray::URLRequestContextGetter::Delegate,
|
||||
public content::StreamReadObserver {
|
||||
public:
|
||||
URLRequestFetchJob(net::URLRequest*, net::NetworkDelegate*);
|
||||
|
||||
// Called by response writer.
|
||||
void HeadersCompleted();
|
||||
int DataAvailable(net::IOBuffer* buffer,
|
||||
int num_bytes,
|
||||
const net::CompletionCallback& callback);
|
||||
|
||||
content::Stream* stream() const { return stream_.get(); }
|
||||
|
||||
protected:
|
||||
// JsAsker:
|
||||
|
@ -36,28 +38,26 @@ class URLRequestFetchJob : public JsAsker<net::URLRequestJob>,
|
|||
bool GetMimeType(std::string* mime_type) const override;
|
||||
void GetResponseInfo(net::HttpResponseInfo* info) override;
|
||||
int GetResponseCode() const override;
|
||||
int64_t GetTotalReceivedBytes() const override;
|
||||
|
||||
// net::URLFetcherDelegate:
|
||||
void OnURLFetchComplete(const net::URLFetcher* source) override;
|
||||
|
||||
// content::StreamReadObserver:
|
||||
void OnDataAvailable(content::Stream* stream) override;
|
||||
|
||||
private:
|
||||
int BufferCopy(net::IOBuffer* source, int num_bytes,
|
||||
net::IOBuffer* target, int target_size);
|
||||
void ClearPendingBuffer();
|
||||
void ClearWriteBuffer();
|
||||
void ClearStream();
|
||||
|
||||
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
|
||||
std::unique_ptr<net::URLFetcher> fetcher_;
|
||||
std::unique_ptr<net::HttpResponseInfo> response_info_;
|
||||
scoped_refptr<content::Stream> stream_;
|
||||
|
||||
// Saved arguments passed to ReadRawData.
|
||||
scoped_refptr<net::IOBuffer> pending_buffer_;
|
||||
int pending_buffer_size_;
|
||||
|
||||
// Saved arguments passed to DataAvailable.
|
||||
scoped_refptr<net::IOBuffer> write_buffer_;
|
||||
int write_num_bytes_;
|
||||
net::CompletionCallback write_callback_;
|
||||
int total_bytes_read_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(URLRequestFetchJob);
|
||||
};
|
||||
|
|
|
@ -17,13 +17,13 @@ URLRequestStringJob::URLRequestStringJob(
|
|||
}
|
||||
|
||||
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 =
|
||||
static_cast<base::DictionaryValue*>(options.get());
|
||||
dict->GetString("mimeType", &mime_type_);
|
||||
dict->GetString("charset", &charset_);
|
||||
dict->GetString("data", &data_);
|
||||
} else if (options->IsType(base::Value::TYPE_STRING)) {
|
||||
} else if (options->IsType(base::Value::Type::STRING)) {
|
||||
options->GetAsString(&data_);
|
||||
}
|
||||
net::URLRequestSimpleJob::Start();
|
||||
|
|
|
@ -4,202 +4,47 @@
|
|||
|
||||
#include "atom/browser/node_debugger.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "net/test/embedded_test_server/tcp_listen_socket.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "libplatform/libplatform.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
// NodeDebugger is stored in Isolate's data, slots 0, 1, 3 have already been
|
||||
// taken by gin, blink and node, using 2 is a safe option for now.
|
||||
const int kIsolateSlot = 2;
|
||||
|
||||
const char* kContentLength = "Content-Length";
|
||||
|
||||
} // namespace
|
||||
|
||||
NodeDebugger::NodeDebugger(v8::Isolate* isolate)
|
||||
: isolate_(isolate),
|
||||
thread_("NodeDebugger"),
|
||||
content_length_(-1),
|
||||
weak_factory_(this) {
|
||||
bool use_debug_agent = false;
|
||||
int port = 5858;
|
||||
|
||||
std::string port_str;
|
||||
base::CommandLine* cmd = base::CommandLine::ForCurrentProcess();
|
||||
if (cmd->HasSwitch("debug")) {
|
||||
use_debug_agent = true;
|
||||
port_str = cmd->GetSwitchValueASCII("debug");
|
||||
} else if (cmd->HasSwitch("debug-brk")) {
|
||||
use_debug_agent = true;
|
||||
port_str = cmd->GetSwitchValueASCII("debug-brk");
|
||||
}
|
||||
|
||||
if (use_debug_agent) {
|
||||
if (!port_str.empty())
|
||||
base::StringToInt(port_str, &port);
|
||||
|
||||
isolate_->SetData(kIsolateSlot, this);
|
||||
v8::Debug::SetMessageHandler(isolate_, DebugMessageHandler);
|
||||
|
||||
weak_up_ui_handle_.data = this;
|
||||
uv_async_init(uv_default_loop(), &weak_up_ui_handle_, ProcessMessageInUI);
|
||||
|
||||
// Start a new IO thread.
|
||||
base::Thread::Options options;
|
||||
options.message_loop_type = base::MessageLoop::TYPE_IO;
|
||||
if (!thread_.StartWithOptions(options)) {
|
||||
LOG(ERROR) << "Unable to start debugger thread";
|
||||
return;
|
||||
}
|
||||
|
||||
// Start the server in new IO thread.
|
||||
thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&NodeDebugger::StartServer, weak_factory_.GetWeakPtr(),
|
||||
port));
|
||||
}
|
||||
NodeDebugger::NodeDebugger(node::Environment* env) : env_(env) {
|
||||
}
|
||||
|
||||
NodeDebugger::~NodeDebugger() {
|
||||
thread_.Stop();
|
||||
}
|
||||
|
||||
bool NodeDebugger::IsRunning() const {
|
||||
return thread_.IsRunning();
|
||||
}
|
||||
|
||||
void NodeDebugger::StartServer(int port) {
|
||||
server_ = net::test_server::TCPListenSocket::CreateAndListen(
|
||||
"127.0.0.1", port, this);
|
||||
if (!server_) {
|
||||
LOG(ERROR) << "Cannot start debugger server";
|
||||
void NodeDebugger::Start() {
|
||||
auto inspector = env_->inspector_agent();
|
||||
if (inspector == nullptr)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void NodeDebugger::CloseSession() {
|
||||
accepted_socket_.reset();
|
||||
}
|
||||
|
||||
void NodeDebugger::OnMessage(const std::string& message) {
|
||||
if (message.find("\"type\":\"request\",\"command\":\"disconnect\"}") !=
|
||||
std::string::npos)
|
||||
CloseSession();
|
||||
|
||||
base::string16 message16 = base::UTF8ToUTF16(message);
|
||||
v8::Debug::SendCommand(
|
||||
isolate_,
|
||||
reinterpret_cast<const uint16_t*>(message16.data()), message16.size());
|
||||
|
||||
uv_async_send(&weak_up_ui_handle_);
|
||||
}
|
||||
|
||||
void NodeDebugger::SendMessage(const std::string& message) {
|
||||
if (accepted_socket_) {
|
||||
std::string header = base::StringPrintf(
|
||||
"%s: %d\r\n\r\n", kContentLength, static_cast<int>(message.size()));
|
||||
accepted_socket_->Send(header);
|
||||
accepted_socket_->Send(message);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeDebugger::SendConnectMessage() {
|
||||
accepted_socket_->Send(base::StringPrintf(
|
||||
"Type: connect\r\n"
|
||||
"V8-Version: %s\r\n"
|
||||
"Protocol-Version: 1\r\n"
|
||||
"Embedding-Host: %s\r\n"
|
||||
"%s: 0\r\n",
|
||||
v8::V8::GetVersion(), ATOM_PRODUCT_NAME, kContentLength), true);
|
||||
}
|
||||
|
||||
// static
|
||||
void NodeDebugger::ProcessMessageInUI(uv_async_t* handle) {
|
||||
NodeDebugger* self = static_cast<NodeDebugger*>(handle->data);
|
||||
v8::Debug::ProcessDebugMessages(self->isolate_);
|
||||
}
|
||||
|
||||
// static
|
||||
void NodeDebugger::DebugMessageHandler(const v8::Debug::Message& message) {
|
||||
NodeDebugger* self = static_cast<NodeDebugger*>(
|
||||
message.GetIsolate()->GetData(kIsolateSlot));
|
||||
|
||||
if (self) {
|
||||
std::string message8(*v8::String::Utf8Value(message.GetJSON()));
|
||||
self->thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&NodeDebugger::SendMessage, self->weak_factory_.GetWeakPtr(),
|
||||
message8));
|
||||
}
|
||||
}
|
||||
|
||||
void NodeDebugger::DidAccept(
|
||||
net::test_server::StreamListenSocket* server,
|
||||
std::unique_ptr<net::test_server::StreamListenSocket> socket) {
|
||||
// Only accept one session.
|
||||
if (accepted_socket_) {
|
||||
socket->Send(std::string("Remote debugging session already active"), true);
|
||||
return;
|
||||
node::DebugOptions options;
|
||||
for (auto& arg : base::CommandLine::ForCurrentProcess()->argv()) {
|
||||
#if defined(OS_WIN)
|
||||
options.ParseOption(base::UTF16ToUTF8(arg));
|
||||
#else
|
||||
options.ParseOption(arg);
|
||||
#endif
|
||||
}
|
||||
|
||||
accepted_socket_ = std::move(socket);
|
||||
SendConnectMessage();
|
||||
}
|
||||
if (options.inspector_enabled()) {
|
||||
// Use custom platform since the gin platform does not work correctly
|
||||
// with node's inspector agent
|
||||
platform_.reset(v8::platform::CreateDefaultPlatform());
|
||||
|
||||
void NodeDebugger::DidRead(net::test_server::StreamListenSocket* socket,
|
||||
const char* data,
|
||||
int len) {
|
||||
buffer_.append(data, len);
|
||||
|
||||
do {
|
||||
if (buffer_.empty())
|
||||
return;
|
||||
|
||||
// Read the "Content-Length" header.
|
||||
if (content_length_ < 0) {
|
||||
size_t pos = buffer_.find("\r\n\r\n");
|
||||
if (pos == std::string::npos)
|
||||
return;
|
||||
|
||||
// We can be sure that the header is "Content-Length: xxx\r\n".
|
||||
std::string content_length = buffer_.substr(16, pos - 16);
|
||||
if (!base::StringToInt(content_length, &content_length_)) {
|
||||
DidClose(accepted_socket_.get());
|
||||
return;
|
||||
}
|
||||
|
||||
// Strip header from buffer.
|
||||
buffer_ = buffer_.substr(pos + 4);
|
||||
// Set process._debugWaitConnect if --inspect-brk was specified to stop
|
||||
// the debugger on the first line
|
||||
if (options.wait_for_connect()) {
|
||||
mate::Dictionary process(env_->isolate(), env_->process_object());
|
||||
process.Set("_debugWaitConnect", true);
|
||||
}
|
||||
|
||||
// Read the message.
|
||||
if (buffer_.size() >= static_cast<size_t>(content_length_)) {
|
||||
std::string message = buffer_.substr(0, content_length_);
|
||||
buffer_ = buffer_.substr(content_length_);
|
||||
|
||||
OnMessage(message);
|
||||
|
||||
// Get ready for next message.
|
||||
content_length_ = -1;
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
|
||||
void NodeDebugger::DidClose(net::test_server::StreamListenSocket* socket) {
|
||||
// If we lost the connection, then simulate a disconnect msg:
|
||||
OnMessage("{\"seq\":1,\"type\":\"request\",\"command\":\"disconnect\"}");
|
||||
inspector->Start(platform_.get(), nullptr, options);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -6,56 +6,22 @@
|
|||
#define ATOM_BROWSER_NODE_DEBUGGER_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/threading/thread.h"
|
||||
#include "net/test/embedded_test_server/stream_listen_socket.h"
|
||||
#include "v8/include/v8-debug.h"
|
||||
#include "vendor/node/deps/uv/include/uv.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
// Add support for node's "--debug" switch.
|
||||
class NodeDebugger : public net::test_server::StreamListenSocket::Delegate {
|
||||
// Add support for node's "--inspect" switch.
|
||||
class NodeDebugger {
|
||||
public:
|
||||
explicit NodeDebugger(v8::Isolate* isolate);
|
||||
virtual ~NodeDebugger();
|
||||
explicit NodeDebugger(node::Environment* env);
|
||||
~NodeDebugger();
|
||||
|
||||
bool IsRunning() const;
|
||||
void Start();
|
||||
|
||||
private:
|
||||
void StartServer(int port);
|
||||
void CloseSession();
|
||||
void OnMessage(const std::string& message);
|
||||
void SendMessage(const std::string& message);
|
||||
void SendConnectMessage();
|
||||
|
||||
static void ProcessMessageInUI(uv_async_t* handle);
|
||||
|
||||
static void DebugMessageHandler(const v8::Debug::Message& message);
|
||||
|
||||
// net::test_server::StreamListenSocket::Delegate:
|
||||
void DidAccept(
|
||||
net::test_server::StreamListenSocket* server,
|
||||
std::unique_ptr<net::test_server::StreamListenSocket> socket) override;
|
||||
void DidRead(net::test_server::StreamListenSocket* socket,
|
||||
const char* data,
|
||||
int len) override;
|
||||
void DidClose(net::test_server::StreamListenSocket* socket) override;
|
||||
|
||||
v8::Isolate* isolate_;
|
||||
|
||||
uv_async_t weak_up_ui_handle_;
|
||||
|
||||
base::Thread thread_;
|
||||
std::unique_ptr<net::test_server::StreamListenSocket> server_;
|
||||
std::unique_ptr<net::test_server::StreamListenSocket> accepted_socket_;
|
||||
|
||||
std::string buffer_;
|
||||
int content_length_;
|
||||
|
||||
base::WeakPtrFactory<NodeDebugger> weak_factory_;
|
||||
node::Environment* env_;
|
||||
std::unique_ptr<v8::Platform> platform_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NodeDebugger);
|
||||
};
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
|
||||
#include "atom/browser/osr/osr_output_device.h"
|
||||
|
||||
#include "third_party/skia/include/core/SkDevice.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
#include "third_party/skia/include/core/SkRect.h"
|
||||
#include "third_party/skia/src/core/SkDevice.h"
|
||||
#include "ui/gfx/skia_util.h"
|
||||
|
||||
namespace atom {
|
||||
|
@ -36,8 +38,11 @@ void OffScreenOutputDevice::Resize(
|
|||
return;
|
||||
}
|
||||
|
||||
if (transparent_)
|
||||
bitmap_->eraseARGB(0, 0, 0, 0);
|
||||
if (transparent_) {
|
||||
bitmap_->eraseColor(SK_ColorTRANSPARENT);
|
||||
} else {
|
||||
bitmap_->eraseColor(SK_ColorWHITE);
|
||||
}
|
||||
|
||||
canvas_.reset(new SkCanvas(*bitmap_));
|
||||
}
|
||||
|
@ -47,6 +52,17 @@ SkCanvas* OffScreenOutputDevice::BeginPaint(const gfx::Rect& damage_rect) {
|
|||
DCHECK(bitmap_.get());
|
||||
|
||||
damage_rect_ = damage_rect;
|
||||
SkIRect damage = SkIRect::MakeXYWH(
|
||||
damage_rect_.x(),
|
||||
damage_rect_.y(),
|
||||
damage_rect_.width(),
|
||||
damage_rect_.height());
|
||||
|
||||
if (transparent_) {
|
||||
bitmap_->erase(SK_ColorTRANSPARENT, damage);
|
||||
} else {
|
||||
bitmap_->erase(SK_ColorWHITE, damage);
|
||||
}
|
||||
|
||||
return canvas_.get();
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -5,6 +5,7 @@
|
|||
#ifndef ATOM_BROWSER_OSR_OSR_RENDER_WIDGET_HOST_VIEW_H_
|
||||
#define ATOM_BROWSER_OSR_OSR_RENDER_WIDGET_HOST_VIEW_H_
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -20,10 +21,13 @@
|
|||
#include "base/time/time.h"
|
||||
#include "cc/output/compositor_frame.h"
|
||||
#include "cc/scheduler/begin_frame_source.h"
|
||||
#include "content/browser/frame_host/render_widget_host_view_guest.h"
|
||||
#include "content/browser/renderer_host/delegated_frame_host.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||
#include "content/browser/renderer_host/render_widget_host_view_base.h"
|
||||
#include "content/browser/renderer_host/resize_lock.h"
|
||||
#include "content/browser/web_contents/web_contents_view.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "third_party/WebKit/public/platform/WebVector.h"
|
||||
#include "ui/base/ime/text_input_client.h"
|
||||
#include "ui/compositor/compositor.h"
|
||||
|
@ -69,6 +73,7 @@ class OffScreenRenderWidgetHostView
|
|||
OffScreenRenderWidgetHostView(bool transparent,
|
||||
const OnPaintCallback& callback,
|
||||
content::RenderWidgetHost* render_widget_host,
|
||||
OffScreenRenderWidgetHostView* parent_host_view,
|
||||
NativeWindow* native_window);
|
||||
~OffScreenRenderWidgetHostView() override;
|
||||
|
||||
|
@ -126,28 +131,33 @@ class OffScreenRenderWidgetHostView
|
|||
#endif
|
||||
void SelectionBoundsChanged(const ViewHostMsg_SelectionBounds_Params &)
|
||||
override;
|
||||
void CopyFromCompositingSurface(const gfx::Rect &,
|
||||
const gfx::Size &,
|
||||
const content::ReadbackRequestCallback &,
|
||||
const SkColorType) override;
|
||||
void CopyFromCompositingSurfaceToVideoFrame(
|
||||
const gfx::Rect &,
|
||||
const scoped_refptr<media::VideoFrame> &,
|
||||
const base::Callback<void(const gfx::Rect &, bool),
|
||||
base::internal::CopyMode::Copyable> &) override;
|
||||
bool CanCopyToVideoFrame(void) const override;
|
||||
void CopyFromSurface(
|
||||
const gfx::Rect& src_subrect,
|
||||
const gfx::Size& dst_size,
|
||||
const content::ReadbackRequestCallback& callback,
|
||||
const SkColorType color_type) override;
|
||||
void CopyFromSurfaceToVideoFrame(
|
||||
const gfx::Rect& src_subrect,
|
||||
scoped_refptr<media::VideoFrame> target,
|
||||
const base::Callback<void(const gfx::Rect&, bool)>& callback) override;
|
||||
void BeginFrameSubscription(
|
||||
std::unique_ptr<content::RenderWidgetHostViewFrameSubscriber>) override;
|
||||
void EndFrameSubscription() override;
|
||||
void InitAsGuest(
|
||||
content::RenderWidgetHostView*,
|
||||
content::RenderWidgetHostViewGuest*) override;
|
||||
bool HasAcceleratedSurface(const gfx::Size &) override;
|
||||
gfx::Rect GetBoundsInRootWindow(void) override;
|
||||
void LockCompositingSurface(void) override;
|
||||
void UnlockCompositingSurface(void) override;
|
||||
void ImeCompositionRangeChanged(
|
||||
const gfx::Range &, const std::vector<gfx::Rect>&) override;
|
||||
gfx::Size GetPhysicalBackingSize() const override;
|
||||
gfx::Size GetRequestedRendererSize() const override;
|
||||
|
||||
content::RenderWidgetHostViewBase* CreateViewForWidget(
|
||||
content::RenderWidgetHost*,
|
||||
content::RenderWidgetHost*,
|
||||
content::WebContentsView*) override;
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
// content::DelegatedFrameHostClient:
|
||||
int DelegatedFrameHostGetGpuMemoryBufferClientId(void) const;
|
||||
|
@ -166,6 +176,15 @@ class OffScreenRenderWidgetHostView
|
|||
void SetBeginFrameSource(cc::BeginFrameSource* source) override;
|
||||
#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:
|
||||
std::unique_ptr<cc::SoftwareOutputDevice> CreateSoftwareOutputDevice(
|
||||
ui::Compositor* compositor) override;
|
||||
|
@ -182,11 +201,36 @@ class OffScreenRenderWidgetHostView
|
|||
base::TimeDelta vsync_period);
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
void CreatePlatformWidget();
|
||||
void CreatePlatformWidget(bool is_guest_view_hack);
|
||||
void DestroyPlatformWidget();
|
||||
#endif
|
||||
|
||||
void CancelWidget();
|
||||
void AddGuestHostView(OffScreenRenderWidgetHostView* guest_host);
|
||||
void RemoveGuestHostView(OffScreenRenderWidgetHostView* guest_host);
|
||||
|
||||
void RegisterGuestViewFrameSwappedCallback(
|
||||
content::RenderWidgetHostViewGuest* guest_host_view);
|
||||
void OnGuestViewFrameSwapped(
|
||||
content::RenderWidgetHostViewGuest* guest_host_view);
|
||||
|
||||
void OnPaint(const gfx::Rect& damage_rect, const SkBitmap& bitmap);
|
||||
void OnPopupPaint(const gfx::Rect& damage_rect, const SkBitmap& bitmap);
|
||||
|
||||
bool IsPopupWidget() const {
|
||||
return popup_type_ != blink::WebPopupTypeNone;
|
||||
}
|
||||
|
||||
void HoldResize();
|
||||
void ReleaseResize();
|
||||
void WasResized();
|
||||
|
||||
void ProcessKeyboardEvent(
|
||||
const content::NativeWebKeyboardEvent& event) override;
|
||||
void ProcessMouseEvent(const blink::WebMouseEvent& event,
|
||||
const ui::LatencyInfo& latency) override;
|
||||
void ProcessMouseWheelEvent(const blink::WebMouseWheelEvent& event,
|
||||
const ui::LatencyInfo& latency) override;
|
||||
|
||||
void SetPainting(bool painting);
|
||||
bool IsPainting() const;
|
||||
|
@ -199,6 +243,7 @@ class OffScreenRenderWidgetHostView
|
|||
content::DelegatedFrameHost* GetDelegatedFrameHost() const;
|
||||
|
||||
void Invalidate();
|
||||
void InvalidateBounds(const gfx::Rect&);
|
||||
|
||||
content::RenderWidgetHostImpl* render_widget_host() const
|
||||
{ return render_widget_host_; }
|
||||
|
@ -206,29 +251,53 @@ class OffScreenRenderWidgetHostView
|
|||
gfx::Size size() const { return size_; }
|
||||
float scale_factor() const { return scale_factor_; }
|
||||
|
||||
void set_popup_host_view(OffScreenRenderWidgetHostView* popup_view) {
|
||||
popup_host_view_ = popup_view;
|
||||
}
|
||||
|
||||
void set_child_host_view(OffScreenRenderWidgetHostView* child_view) {
|
||||
child_host_view_ = child_view;
|
||||
}
|
||||
|
||||
private:
|
||||
void SetupFrameRate(bool force);
|
||||
void ResizeRootLayer();
|
||||
|
||||
cc::FrameSinkId AllocateFrameSinkId(bool is_guest_view_hack);
|
||||
|
||||
// Weak ptrs.
|
||||
content::RenderWidgetHostImpl* render_widget_host_;
|
||||
|
||||
OffScreenRenderWidgetHostView* parent_host_view_;
|
||||
OffScreenRenderWidgetHostView* popup_host_view_;
|
||||
std::unique_ptr<SkBitmap> popup_bitmap_;
|
||||
OffScreenRenderWidgetHostView* child_host_view_;
|
||||
std::set<OffScreenRenderWidgetHostView*> guest_host_views_;
|
||||
|
||||
NativeWindow* native_window_;
|
||||
OffScreenOutputDevice* software_output_device_;
|
||||
|
||||
const bool transparent_;
|
||||
OnPaintCallback callback_;
|
||||
OnPaintCallback parent_callback_;
|
||||
|
||||
int frame_rate_;
|
||||
int frame_rate_threshold_ms_;
|
||||
int frame_rate_threshold_us_;
|
||||
|
||||
base::Time last_time_;
|
||||
|
||||
float scale_factor_;
|
||||
bool is_showing_;
|
||||
gfx::Vector2dF last_scroll_offset_;
|
||||
gfx::Size size_;
|
||||
bool painting_;
|
||||
|
||||
bool is_showing_;
|
||||
bool is_destroyed_;
|
||||
gfx::Rect popup_position_;
|
||||
|
||||
bool hold_resize_;
|
||||
bool pending_resize_;
|
||||
|
||||
std::unique_ptr<ui::Layer> root_layer_;
|
||||
std::unique_ptr<ui::Compositor> compositor_;
|
||||
std::unique_ptr<content::DelegatedFrameHost> delegated_frame_host_;
|
||||
|
@ -236,6 +305,10 @@ class OffScreenRenderWidgetHostView
|
|||
std::unique_ptr<AtomCopyFrameGenerator> copy_frame_generator_;
|
||||
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)
|
||||
CALayer* background_layer_;
|
||||
std::unique_ptr<content::BrowserCompositorMac> browser_compositor_;
|
||||
|
|
|
@ -121,10 +121,12 @@ void OffScreenRenderWidgetHostView::SelectionChanged(
|
|||
RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
|
||||
}
|
||||
|
||||
void OffScreenRenderWidgetHostView::CreatePlatformWidget() {
|
||||
void OffScreenRenderWidgetHostView::CreatePlatformWidget(
|
||||
bool is_guest_view_hack) {
|
||||
mac_helper_ = new MacHelper(this);
|
||||
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() {
|
||||
|
|
|
@ -4,7 +4,11 @@
|
|||
|
||||
#include "atom/browser/osr/osr_web_contents_view.h"
|
||||
|
||||
#include "atom/common/api/api_messages.h"
|
||||
#include "content/browser/web_contents/web_contents_impl.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "third_party/WebKit/public/platform/WebScreenInfo.h"
|
||||
#include "ui/display/screen.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -27,19 +31,33 @@ OffScreenWebContentsView::~OffScreenWebContentsView() {
|
|||
void OffScreenWebContentsView::SetWebContents(
|
||||
content::WebContents* web_contents) {
|
||||
web_contents_ = web_contents;
|
||||
|
||||
RenderViewCreated(web_contents_->GetRenderViewHost());
|
||||
}
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
gfx::NativeView OffScreenWebContentsView::GetNativeView() const {
|
||||
return gfx::NativeView();
|
||||
if (!web_contents_) return gfx::NativeView();
|
||||
|
||||
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
|
||||
if (!relay) return gfx::NativeView();
|
||||
return relay->window->GetNativeView();
|
||||
}
|
||||
|
||||
gfx::NativeView OffScreenWebContentsView::GetContentNativeView() const {
|
||||
return gfx::NativeView();
|
||||
if (!web_contents_) return gfx::NativeView();
|
||||
|
||||
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
|
||||
if (!relay) return gfx::NativeView();
|
||||
return relay->window->GetNativeView();
|
||||
}
|
||||
|
||||
gfx::NativeWindow OffScreenWebContentsView::GetTopLevelNativeWindow() const {
|
||||
return gfx::NativeWindow();
|
||||
if (!web_contents_) return gfx::NativeWindow();
|
||||
|
||||
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
|
||||
if (!relay) return gfx::NativeWindow();
|
||||
return relay->window->GetNativeWindow();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -67,7 +85,7 @@ content::DropData* OffScreenWebContentsView::GetDropData() const {
|
|||
}
|
||||
|
||||
gfx::Rect OffScreenWebContentsView::GetViewBounds() const {
|
||||
return view_ ? view_->GetViewBounds() : gfx::Rect();
|
||||
return GetView() ? GetView()->GetViewBounds() : gfx::Rect();
|
||||
}
|
||||
|
||||
void OffScreenWebContentsView::CreateView(const gfx::Size& initial_size,
|
||||
|
@ -77,19 +95,40 @@ void OffScreenWebContentsView::CreateView(const gfx::Size& initial_size,
|
|||
content::RenderWidgetHostViewBase*
|
||||
OffScreenWebContentsView::CreateViewForWidget(
|
||||
content::RenderWidgetHost* render_widget_host, bool is_guest_view_hack) {
|
||||
if (render_widget_host->GetView()) {
|
||||
return static_cast<content::RenderWidgetHostViewBase*>(
|
||||
render_widget_host->GetView());
|
||||
}
|
||||
|
||||
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
|
||||
view_ = new OffScreenRenderWidgetHostView(
|
||||
transparent_, callback_, render_widget_host, relay->window.get());
|
||||
return view_;
|
||||
return new OffScreenRenderWidgetHostView(
|
||||
transparent_,
|
||||
callback_,
|
||||
render_widget_host,
|
||||
nullptr,
|
||||
relay->window.get());
|
||||
}
|
||||
|
||||
content::RenderWidgetHostViewBase*
|
||||
OffScreenWebContentsView::CreateViewForPopupWidget(
|
||||
content::RenderWidgetHost* render_widget_host) {
|
||||
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
|
||||
view_ = new OffScreenRenderWidgetHostView(
|
||||
transparent_, callback_, render_widget_host, relay->window.get());
|
||||
return view_;
|
||||
|
||||
content::WebContentsImpl *web_contents_impl =
|
||||
static_cast<content::WebContentsImpl*>(web_contents_);
|
||||
|
||||
OffScreenRenderWidgetHostView *view =
|
||||
static_cast<OffScreenRenderWidgetHostView*>(
|
||||
web_contents_impl->GetOuterWebContents()
|
||||
? web_contents_impl->GetOuterWebContents()->GetRenderWidgetHostView()
|
||||
: web_contents_impl->GetRenderWidgetHostView());
|
||||
|
||||
return new OffScreenRenderWidgetHostView(
|
||||
transparent_,
|
||||
callback_,
|
||||
render_widget_host,
|
||||
view,
|
||||
relay->window.get());
|
||||
}
|
||||
|
||||
void OffScreenWebContentsView::SetPageTitle(const base::string16& title) {
|
||||
|
@ -97,8 +136,12 @@ void OffScreenWebContentsView::SetPageTitle(const base::string16& title) {
|
|||
|
||||
void OffScreenWebContentsView::RenderViewCreated(
|
||||
content::RenderViewHost* host) {
|
||||
if (view_)
|
||||
view_->InstallTransparency();
|
||||
if (GetView())
|
||||
GetView()->InstallTransparency();
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
host->Send(new AtomViewMsg_Offscreen(host->GetRoutingID()));
|
||||
#endif
|
||||
}
|
||||
|
||||
void OffScreenWebContentsView::RenderViewSwappedIn(
|
||||
|
@ -110,14 +153,22 @@ void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled) {
|
|||
|
||||
void OffScreenWebContentsView::GetScreenInfo(
|
||||
content::ScreenInfo* screen_info) const {
|
||||
screen_info->rect = gfx::Rect(view_->size());
|
||||
screen_info->available_rect = gfx::Rect(view_->size());
|
||||
screen_info->depth = 24;
|
||||
screen_info->depth_per_component = 8;
|
||||
screen_info->device_scale_factor = view_->scale_factor();
|
||||
screen_info->orientation_angle = 0;
|
||||
screen_info->device_scale_factor = 1.0;
|
||||
screen_info->orientation_type =
|
||||
content::SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY;
|
||||
|
||||
if (GetView()) {
|
||||
screen_info->rect = gfx::Rect(GetView()->size());
|
||||
screen_info->available_rect = gfx::Rect(GetView()->size());
|
||||
} else {
|
||||
const display::Display display =
|
||||
display::Screen::GetScreen()->GetPrimaryDisplay();
|
||||
screen_info->rect = display.bounds();
|
||||
screen_info->available_rect = display.work_area();
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
|
@ -151,4 +202,12 @@ void OffScreenWebContentsView::UpdateDragCursor(
|
|||
blink::WebDragOperation operation) {
|
||||
}
|
||||
|
||||
OffScreenRenderWidgetHostView* OffScreenWebContentsView::GetView() const {
|
||||
if (web_contents_) {
|
||||
return static_cast<OffScreenRenderWidgetHostView*>(
|
||||
web_contents_->GetRenderViewHost()->GetWidget()->GetView());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -75,11 +75,12 @@ class OffScreenWebContentsView : public content::WebContentsView,
|
|||
void PlatformDestroy();
|
||||
#endif
|
||||
|
||||
OffScreenRenderWidgetHostView* GetView() const;
|
||||
|
||||
const bool transparent_;
|
||||
OnPaintCallback callback_;
|
||||
|
||||
// Weak refs.
|
||||
OffScreenRenderWidgetHostView* view_;
|
||||
content::WebContents* web_contents_;
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
<key>CFBundleIconFile</key>
|
||||
<string>electron.icns</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.6.8</string>
|
||||
<string>1.7.1</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.6.8</string>
|
||||
<string>1.7.1</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.developer-tools</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
|
|
|
@ -56,8 +56,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,6,8,0
|
||||
PRODUCTVERSION 1,6,8,0
|
||||
FILEVERSION 1,7,1,0
|
||||
PRODUCTVERSION 1,7,1,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -74,12 +74,12 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "GitHub, Inc."
|
||||
VALUE "FileDescription", "Electron"
|
||||
VALUE "FileVersion", "1.6.8"
|
||||
VALUE "FileVersion", "1.7.1"
|
||||
VALUE "InternalName", "electron.exe"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved."
|
||||
VALUE "OriginalFilename", "electron.exe"
|
||||
VALUE "ProductName", "Electron"
|
||||
VALUE "ProductVersion", "1.6.8"
|
||||
VALUE "ProductVersion", "1.7.1"
|
||||
VALUE "SquirrelAwareVersion", "1"
|
||||
END
|
||||
END
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
auto cert_db = net::CertDatabase::GetInstance();
|
||||
// This forces Chromium to reload the certificate since it might be trusted
|
||||
// now.
|
||||
cert_db->NotifyObserversCertDBChanged(cert_.get());
|
||||
cert_db->NotifyObserversCertDBChanged();
|
||||
|
||||
callback_.Run();
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ BOOL AddToTrustedRootStore(const PCCERT_CONTEXT cert_context,
|
|||
if (result) {
|
||||
// force Chromium to reload it's database for this certificate
|
||||
auto cert_db = net::CertDatabase::GetInstance();
|
||||
cert_db->NotifyObserversCertDBChanged(cert.get());
|
||||
cert_db->NotifyObserversCertDBChanged();
|
||||
}
|
||||
|
||||
CertCloseStore(root_cert_store, CERT_CLOSE_STORE_FORCE_FLAG);
|
||||
|
|
|
@ -41,7 +41,7 @@ class GtkMessageBox : public NativeWindowObserver {
|
|||
const gfx::ImageSkia& icon)
|
||||
: cancel_id_(cancel_id),
|
||||
checkbox_checked_(false),
|
||||
parent_(static_cast<NativeWindowViews*>(parent_window)) {
|
||||
parent_(static_cast<NativeWindow*>(parent_window)) {
|
||||
// Create dialog.
|
||||
dialog_ = gtk_message_dialog_new(
|
||||
nullptr, // parent
|
||||
|
@ -94,7 +94,7 @@ class GtkMessageBox : public NativeWindowObserver {
|
|||
// Parent window.
|
||||
if (parent_) {
|
||||
parent_->AddObserver(this);
|
||||
parent_->SetEnabled(false);
|
||||
static_cast<NativeWindowViews*>(parent_)->SetEnabled(false);
|
||||
libgtkui::SetGtkTransientForAura(dialog_, parent_->GetNativeWindow());
|
||||
gtk_window_set_modal(GTK_WINDOW(dialog_), TRUE);
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ class GtkMessageBox : public NativeWindowObserver {
|
|||
gtk_widget_destroy(dialog_);
|
||||
if (parent_) {
|
||||
parent_->RemoveObserver(this);
|
||||
parent_->SetEnabled(true);
|
||||
static_cast<NativeWindowViews*>(parent_)->SetEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ class GtkMessageBox : public NativeWindowObserver {
|
|||
|
||||
bool checkbox_checked_;
|
||||
|
||||
NativeWindowViews* parent_;
|
||||
NativeWindow* parent_;
|
||||
GtkWidget* dialog_;
|
||||
MessageBoxCallback callback_;
|
||||
|
||||
|
|
|
@ -9,8 +9,10 @@
|
|||
// This conflicts with mate::Converter,
|
||||
#undef True
|
||||
#undef False
|
||||
// and V8.
|
||||
// and V8,
|
||||
#undef None
|
||||
// and url_request_status.h,
|
||||
#undef Status
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <glib-object.h>
|
||||
|
|
|
@ -36,7 +36,7 @@ SubmenuButton::SubmenuButton(const base::string16& title,
|
|||
|
||||
if (GetUnderlinePosition(title, &accelerator_, &underline_start_,
|
||||
&underline_end_))
|
||||
gfx::Canvas::SizeStringInt(GetText(), GetFontList(), &text_width_,
|
||||
gfx::Canvas::SizeStringInt(GetText(), gfx::FontList(), &text_width_,
|
||||
&text_height_, 0, 0);
|
||||
|
||||
SetInkDropMode(InkDropMode::ON);
|
||||
|
@ -107,8 +107,8 @@ bool SubmenuButton::GetUnderlinePosition(const base::string16& text,
|
|||
void SubmenuButton::GetCharacterPosition(
|
||||
const base::string16& text, int index, int* pos) {
|
||||
int height = 0;
|
||||
gfx::Canvas::SizeStringInt(text.substr(0, index), GetFontList(), pos, &height,
|
||||
0, 0);
|
||||
gfx::Canvas::SizeStringInt(text.substr(0, index), gfx::FontList(), pos,
|
||||
&height, 0, 0);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -33,9 +33,8 @@ void CreateResponseHeadersDictionary(const net::HttpResponseHeaders* headers,
|
|||
while (headers->EnumerateHeaderLines(&iter, &header_name, &header_value)) {
|
||||
base::Value* existing_value = nullptr;
|
||||
if (result->Get(header_name, &existing_value)) {
|
||||
base::StringValue* existing_string_value =
|
||||
static_cast<base::StringValue*>(existing_value);
|
||||
existing_string_value->GetString()->append(", ").append(header_value);
|
||||
std::string src = existing_value->GetString();
|
||||
result->SetString(header_name, src + ", " + header_value);
|
||||
} else {
|
||||
result->SetString(header_name, header_value);
|
||||
}
|
||||
|
@ -131,7 +130,7 @@ void PdfViewerHandler::GetDefaultZoom(const base::ListValue* args) {
|
|||
double zoom_level = host_zoom_map->GetDefaultZoomLevel();
|
||||
ResolveJavascriptCallback(
|
||||
*callback_id,
|
||||
base::FundamentalValue(content::ZoomLevelToZoomFactor(zoom_level)));
|
||||
base::Value(content::ZoomLevelToZoomFactor(zoom_level)));
|
||||
}
|
||||
|
||||
void PdfViewerHandler::GetInitialZoom(const base::ListValue* args) {
|
||||
|
@ -145,7 +144,7 @@ void PdfViewerHandler::GetInitialZoom(const base::ListValue* args) {
|
|||
content::HostZoomMap::GetZoomLevel(web_ui()->GetWebContents());
|
||||
ResolveJavascriptCallback(
|
||||
*callback_id,
|
||||
base::FundamentalValue(content::ZoomLevelToZoomFactor(zoom_level)));
|
||||
base::Value(content::ZoomLevelToZoomFactor(zoom_level)));
|
||||
}
|
||||
|
||||
void PdfViewerHandler::SetZoom(const base::ListValue* args) {
|
||||
|
@ -159,7 +158,7 @@ void PdfViewerHandler::SetZoom(const base::ListValue* args) {
|
|||
|
||||
content::HostZoomMap::SetZoomLevel(web_ui()->GetWebContents(),
|
||||
zoom_level);
|
||||
ResolveJavascriptCallback(*callback_id, base::FundamentalValue(zoom_level));
|
||||
ResolveJavascriptCallback(*callback_id, base::Value(zoom_level));
|
||||
}
|
||||
|
||||
void PdfViewerHandler::GetStrings(const base::ListValue* args) {
|
||||
|
@ -204,7 +203,7 @@ void PdfViewerHandler::OnZoomLevelChanged(
|
|||
if (change.host == kPdfViewerUIHost) {
|
||||
CallJavascriptFunction(
|
||||
"cr.webUIListenerCallback", base::StringValue("onZoomLevelChanged"),
|
||||
base::FundamentalValue(
|
||||
base::Value(
|
||||
content::ZoomLevelToZoomFactor(change.zoom_level)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,7 +134,8 @@ class PdfViewerUI::ResourceRequester
|
|||
content::ResourceDispatcherHostImpl::Get()->InitializeURLRequest(
|
||||
request.get(), content::Referrer(url, blink::WebReferrerPolicyDefault),
|
||||
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::ForRequest(request.get());
|
||||
|
@ -202,7 +203,8 @@ PdfViewerUI::PdfViewerUI(content::BrowserContext* browser_context,
|
|||
content::WebContentsObserver(web_ui->GetWebContents()),
|
||||
src_(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);
|
||||
}
|
||||
|
||||
|
|
|
@ -106,6 +106,8 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
|
|||
// integration.
|
||||
if (IsSandboxed(web_contents))
|
||||
command_line->AppendSwitch(switches::kEnableSandbox);
|
||||
if (web_preferences.GetBoolean("nativeWindowOpen", &b) && b)
|
||||
command_line->AppendSwitch(switches::kNativeWindowOpen);
|
||||
|
||||
// The preload script.
|
||||
base::FilePath::StringType preload;
|
||||
|
@ -212,6 +214,22 @@ bool WebContentsPreferences::IsSandboxed(content::WebContents* web_contents) {
|
|||
return sandboxed;
|
||||
}
|
||||
|
||||
bool WebContentsPreferences::UsesNativeWindowOpen(
|
||||
content::WebContents* web_contents) {
|
||||
WebContentsPreferences* self;
|
||||
if (!web_contents)
|
||||
return false;
|
||||
|
||||
self = FromWebContents(web_contents);
|
||||
if (!self)
|
||||
return false;
|
||||
|
||||
base::DictionaryValue& web_preferences = self->web_preferences_;
|
||||
bool use = false;
|
||||
web_preferences.GetBoolean("nativeWindowOpen", &use);
|
||||
return use;
|
||||
}
|
||||
|
||||
// static
|
||||
void WebContentsPreferences::OverrideWebkitPrefs(
|
||||
content::WebContents* web_contents, content::WebPreferences* prefs) {
|
||||
|
|
|
@ -38,6 +38,7 @@ class WebContentsPreferences
|
|||
content::WebContents* web_contents, base::CommandLine* command_line);
|
||||
|
||||
static bool IsSandboxed(content::WebContents* web_contents);
|
||||
static bool UsesNativeWindowOpen(content::WebContents* web_contents);
|
||||
|
||||
// Modify the WebPreferences according to |web_contents|'s preferences.
|
||||
static void OverrideWebkitPrefs(
|
||||
|
|
|
@ -35,6 +35,8 @@ IPC_MESSAGE_ROUTED3(AtomViewMsg_Message,
|
|||
base::string16 /* channel */,
|
||||
base::ListValue /* arguments */)
|
||||
|
||||
IPC_MESSAGE_ROUTED0(AtomViewMsg_Offscreen)
|
||||
|
||||
// Sent by the renderer when the draggable regions are updated.
|
||||
IPC_MESSAGE_ROUTED1(AtomViewHostMsg_UpdateDraggableRegions,
|
||||
std::vector<atom::DraggableRegion> /* regions */)
|
||||
|
|
|
@ -6,17 +6,17 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
#include "atom_natives.h" // NOLINT: This file is generated with coffee2c.
|
||||
|
||||
#include "atom/common/asar/archive.h"
|
||||
#include "atom/common/native_mate_converters/callback.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/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "atom_natives.h" // NOLINT: This file is generated with js2c.
|
||||
|
||||
namespace {
|
||||
|
||||
class Archive : public mate::Wrappable<Archive> {
|
||||
|
@ -130,7 +130,7 @@ class Archive : public mate::Wrappable<Archive> {
|
|||
void InitAsarSupport(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> process,
|
||||
v8::Local<v8::Value> require) {
|
||||
// Evaluate asar_init.coffee.
|
||||
// Evaluate asar_init.js.
|
||||
const char* asar_init_native = reinterpret_cast<const char*>(
|
||||
static_cast<const unsigned char*>(node::asar_init_data));
|
||||
v8::Local<v8::Script> asar_init = v8::Script::Compile(v8::String::NewFromUtf8(
|
||||
|
|
|
@ -202,6 +202,11 @@ void Noop(char*, void*) {
|
|||
NativeImage::NativeImage(v8::Isolate* isolate, const gfx::Image& image)
|
||||
: image_(image) {
|
||||
Init(isolate);
|
||||
if (image_.HasRepresentation(gfx::Image::kImageRepSkia)) {
|
||||
isolate->AdjustAmountOfExternalAllocatedMemory(
|
||||
image_.ToImageSkia()->bitmap()->computeSize64());
|
||||
}
|
||||
MarkHighMemoryUsage();
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
@ -212,10 +217,20 @@ NativeImage::NativeImage(v8::Isolate* isolate, const base::FilePath& hicon_path)
|
|||
ReadImageSkiaFromICO(&image_skia, GetHICON(256));
|
||||
image_ = gfx::Image(image_skia);
|
||||
Init(isolate);
|
||||
if (image_.HasRepresentation(gfx::Image::kImageRepSkia)) {
|
||||
isolate->AdjustAmountOfExternalAllocatedMemory(
|
||||
image_.ToImageSkia()->bitmap()->computeSize64());
|
||||
}
|
||||
MarkHighMemoryUsage();
|
||||
}
|
||||
#endif
|
||||
|
||||
NativeImage::~NativeImage() {}
|
||||
NativeImage::~NativeImage() {
|
||||
if (image_.HasRepresentation(gfx::Image::kImageRepSkia)) {
|
||||
isolate()->AdjustAmountOfExternalAllocatedMemory(
|
||||
- image_.ToImageSkia()->bitmap()->computeSize64());
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
HICON NativeImage::GetHICON(int size) {
|
||||
|
|
|
@ -181,7 +181,7 @@ bool Archive::Init() {
|
|||
std::string error;
|
||||
base::JSONReader reader;
|
||||
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;
|
||||
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) {
|
||||
if (external_files_.contains(path)) {
|
||||
*out = external_files_.get(path)->path();
|
||||
auto it = external_files_.find(path.value());
|
||||
if (it != external_files_.end()) {
|
||||
*out = it->second->path();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -296,7 +297,7 @@ bool Archive::CopyFileOut(const base::FilePath& path, base::FilePath* out) {
|
|||
#endif
|
||||
|
||||
*out = temp_file->path();
|
||||
external_files_.set(path, std::move(temp_file));
|
||||
external_files_[path.value()] = std::move(temp_file);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
#define ATOM_COMMON_ASAR_ARCHIVE_H_
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/scoped_ptr_hash_map.h"
|
||||
#include "base/files/file.h"
|
||||
#include "base/files/file_path.h"
|
||||
|
||||
|
@ -75,8 +75,8 @@ class Archive {
|
|||
std::unique_ptr<base::DictionaryValue> header_;
|
||||
|
||||
// Cached external temporary files.
|
||||
base::ScopedPtrHashMap<base::FilePath, std::unique_ptr<ScopedTemporaryFile>>
|
||||
external_files_;
|
||||
std::unordered_map<base::FilePath::StringType,
|
||||
std::unique_ptr<ScopedTemporaryFile>> external_files_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(Archive);
|
||||
};
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
#define ATOM_COMMON_ATOM_VERSION_H_
|
||||
|
||||
#define ATOM_MAJOR_VERSION 1
|
||||
#define ATOM_MINOR_VERSION 6
|
||||
#define ATOM_PATCH_VERSION 8
|
||||
#define ATOM_MINOR_VERSION 7
|
||||
#define ATOM_PATCH_VERSION 1
|
||||
|
||||
#define ATOM_VERSION_IS_RELEASE 1
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef 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
|
||||
|
||||
#endif // ATOM_COMMON_CHROME_VERSION_H_
|
||||
|
|
|
@ -31,4 +31,3 @@ namespace IPC {
|
|||
namespace IPC {
|
||||
#include "atom/common/common_message_generator.h"
|
||||
} // namespace IPC
|
||||
|
||||
|
|
|
@ -9,4 +9,5 @@
|
|||
#include "chrome/common/tts_messages.h"
|
||||
#include "chrome/common/widevine_cdm_messages.h"
|
||||
#include "chrome/common/chrome_utility_messages.h"
|
||||
#include "chrome/common/chrome_utility_printing_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 =
|
||||
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_client.StartHandler(handler_path, crashes_dir, crashes_dir,
|
||||
submit_url,
|
||||
StringMap(),
|
||||
std::vector<std::string>(),
|
||||
args,
|
||||
true,
|
||||
false);
|
||||
} // @autoreleasepool
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
#include "content/public/browser/native_web_keyboard_event.h"
|
||||
#include "native_mate/dictionary.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/WebFindOptions.h"
|
||||
#include "ui/base/clipboard/clipboard.h"
|
||||
|
@ -149,12 +150,14 @@ bool Converter<blink::WebInputEvent>::FromV8(
|
|||
mate::Dictionary dict;
|
||||
if (!ConvertFromV8(isolate, val, &dict))
|
||||
return false;
|
||||
if (!dict.Get("type", &out->type))
|
||||
blink::WebInputEvent::Type type;
|
||||
if (!dict.Get("type", &type))
|
||||
return false;
|
||||
out->setType(type);
|
||||
std::vector<blink::WebInputEvent::Modifiers> modifiers;
|
||||
if (dict.Get("modifiers", &modifiers))
|
||||
out->modifiers = VectorToBitArray(modifiers);
|
||||
out->timeStampSeconds = base::Time::Now().ToDoubleT();
|
||||
out->setModifiers(VectorToBitArray(modifiers));
|
||||
out->setTimeStampSeconds(base::Time::Now().ToDoubleT());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -175,19 +178,19 @@ bool Converter<blink::WebKeyboardEvent>::FromV8(
|
|||
ui::KeyboardCode keyCode = atom::KeyboardCodeFromStr(str, &shifted);
|
||||
out->windowsKeyCode = keyCode;
|
||||
if (shifted)
|
||||
out->modifiers |= blink::WebInputEvent::ShiftKey;
|
||||
out->setModifiers(out->modifiers() | blink::WebInputEvent::ShiftKey);
|
||||
|
||||
ui::DomCode domCode = ui::UsLayoutKeyboardCodeToDomCode(keyCode);
|
||||
out->domCode = static_cast<int>(domCode);
|
||||
|
||||
ui::DomKey domKey;
|
||||
ui::KeyboardCode dummy_code;
|
||||
int flags = atom::WebEventModifiersToEventFlags(out->modifiers);
|
||||
int flags = atom::WebEventModifiersToEventFlags(out->modifiers());
|
||||
if (ui::DomCodeToUsLayoutDomKey(domCode, flags, &domKey, &dummy_code))
|
||||
out->domKey = static_cast<int>(domKey);
|
||||
|
||||
if ((out->type == blink::WebInputEvent::Char ||
|
||||
out->type == blink::WebInputEvent::RawKeyDown)) {
|
||||
if ((out->type() == blink::WebInputEvent::Char ||
|
||||
out->type() == blink::WebInputEvent::RawKeyDown)) {
|
||||
// Make sure to not read beyond the buffer in case some bad code doesn't
|
||||
// NULL-terminate it (this is called from plugins).
|
||||
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) {
|
||||
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");
|
||||
else if (in.type == blink::WebInputEvent::Type::KeyUp)
|
||||
else if (in.type() == blink::WebInputEvent::Type::KeyUp)
|
||||
dict.Set("type", "keyUp");
|
||||
dict.Set("key", ui::KeycodeConverter::DomKeyToKeyString(in.domKey));
|
||||
dict.Set("code", ui::KeycodeConverter::DomCodeToCodeString(
|
||||
static_cast<ui::DomCode>(in.domCode)));
|
||||
|
||||
using Modifiers = blink::WebInputEvent::Modifiers;
|
||||
dict.Set("isAutoRepeat", (in.modifiers & Modifiers::IsAutoRepeat) != 0);
|
||||
dict.Set("shift", (in.modifiers & Modifiers::ShiftKey) != 0);
|
||||
dict.Set("control", (in.modifiers & Modifiers::ControlKey) != 0);
|
||||
dict.Set("alt", (in.modifiers & Modifiers::AltKey) != 0);
|
||||
dict.Set("meta", (in.modifiers & Modifiers::MetaKey) != 0);
|
||||
dict.Set("isAutoRepeat", (in.modifiers() & Modifiers::IsAutoRepeat) != 0);
|
||||
dict.Set("shift", (in.modifiers() & Modifiers::ShiftKey) != 0);
|
||||
dict.Set("control", (in.modifiers() & Modifiers::ControlKey) != 0);
|
||||
dict.Set("alt", (in.modifiers() & Modifiers::AltKey) != 0);
|
||||
dict.Set("meta", (in.modifiers() & Modifiers::MetaKey) != 0);
|
||||
|
||||
return dict.GetHandle();
|
||||
}
|
||||
|
@ -277,7 +280,7 @@ bool Converter<blink::WebMouseWheelEvent>::FromV8(
|
|||
bool can_scroll = true;
|
||||
if (dict.Get("canScroll", &can_scroll) && !can_scroll) {
|
||||
out->hasPreciseScrollingDeltas = false;
|
||||
out->modifiers &= ~blink::WebInputEvent::ControlKey;
|
||||
out->setModifiers(out->modifiers() & ~blink::WebInputEvent::ControlKey);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
|
@ -444,7 +447,7 @@ v8::Local<v8::Value> Converter<blink::WebCache::ResourceTypeStat>::ToV8(
|
|||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("count", static_cast<uint32_t>(stat.count));
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#define ATOM_COMMON_NATIVE_MATE_CONVERTERS_BLINK_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"
|
||||
|
||||
namespace blink {
|
||||
|
|
|
@ -167,42 +167,42 @@ base::Value* V8ValueConverter::FromV8Value(
|
|||
v8::Local<v8::Value> V8ValueConverter::ToV8ValueImpl(
|
||||
v8::Isolate* isolate, const base::Value* value) const {
|
||||
switch (value->GetType()) {
|
||||
case base::Value::TYPE_NULL:
|
||||
case base::Value::Type::NONE:
|
||||
return v8::Null(isolate);
|
||||
|
||||
case base::Value::TYPE_BOOLEAN: {
|
||||
case base::Value::Type::BOOLEAN: {
|
||||
bool val = false;
|
||||
value->GetAsBoolean(&val);
|
||||
return v8::Boolean::New(isolate, val);
|
||||
}
|
||||
|
||||
case base::Value::TYPE_INTEGER: {
|
||||
case base::Value::Type::INTEGER: {
|
||||
int val = 0;
|
||||
value->GetAsInteger(&val);
|
||||
return v8::Integer::New(isolate, val);
|
||||
}
|
||||
|
||||
case base::Value::TYPE_DOUBLE: {
|
||||
case base::Value::Type::DOUBLE: {
|
||||
double val = 0.0;
|
||||
value->GetAsDouble(&val);
|
||||
return v8::Number::New(isolate, val);
|
||||
}
|
||||
|
||||
case base::Value::TYPE_STRING: {
|
||||
case base::Value::Type::STRING: {
|
||||
std::string val;
|
||||
value->GetAsString(&val);
|
||||
return v8::String::NewFromUtf8(
|
||||
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));
|
||||
|
||||
case base::Value::TYPE_DICTIONARY:
|
||||
case base::Value::Type::DICTIONARY:
|
||||
return ToV8Object(isolate,
|
||||
static_cast<const base::DictionaryValue*>(value));
|
||||
|
||||
case base::Value::TYPE_BINARY:
|
||||
case base::Value::Type::BINARY:
|
||||
return ToArrayBuffer(isolate,
|
||||
static_cast<const base::BinaryValue*>(value));
|
||||
|
||||
|
@ -314,13 +314,13 @@ base::Value* V8ValueConverter::FromV8ValueImpl(
|
|||
return base::Value::CreateNullValue().release();
|
||||
|
||||
if (val->IsBoolean())
|
||||
return new base::FundamentalValue(val->ToBoolean()->Value());
|
||||
return new base::Value(val->ToBoolean()->Value());
|
||||
|
||||
if (val->IsInt32())
|
||||
return new base::FundamentalValue(val->ToInt32()->Value());
|
||||
return new base::Value(val->ToInt32()->Value());
|
||||
|
||||
if (val->IsNumber())
|
||||
return new base::FundamentalValue(val->ToNumber()->Value());
|
||||
return new base::Value(val->ToNumber()->Value());
|
||||
|
||||
if (val->IsString()) {
|
||||
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
|
||||
// on the browser which doesn't additionally check for null will fail.
|
||||
// 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;
|
||||
|
||||
result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()),
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
#include "v8/include/v8.h"
|
||||
|
||||
namespace base {
|
||||
class BinaryValue;
|
||||
class DictionaryValue;
|
||||
class ListValue;
|
||||
class Value;
|
||||
using BinaryValue = Value;
|
||||
}
|
||||
|
||||
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<base::Value> value(converter->FromV8Value(
|
||||
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()));
|
||||
return true;
|
||||
} 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<base::Value> value(converter->FromV8Value(
|
||||
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()));
|
||||
return true;
|
||||
} else {
|
||||
|
|
|
@ -198,12 +198,6 @@ node::Environment* NodeBindings::CreateEnvironment(
|
|||
PathService::Get(content::CHILD_PROCESS_EXE, &helper_exec_path);
|
||||
process.Set("helperExecPath", helper_exec_path);
|
||||
|
||||
// Set process._debugWaitConnect if --debug-brk was specified to stop
|
||||
// the debugger on the first line
|
||||
if (browser_env_ == BROWSER &&
|
||||
base::CommandLine::ForCurrentProcess()->HasSwitch("debug-brk"))
|
||||
process.Set("_debugWaitConnect", true);
|
||||
|
||||
return env;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "vendor/node/src/env-inl.h"
|
||||
#include "vendor/node/src/node.h"
|
||||
#include "vendor/node/src/node_buffer.h"
|
||||
#include "vendor/node/src/node_debug_options.h"
|
||||
#include "vendor/node/src/node_internals.h"
|
||||
|
||||
#endif // ATOM_COMMON_NODE_INCLUDES_H_
|
||||
|
|
|
@ -172,6 +172,7 @@ const char kGuestInstanceID[] = "guest-instance-id";
|
|||
const char kOpenerID[] = "opener-id";
|
||||
const char kScrollBounce[] = "scroll-bounce";
|
||||
const char kHiddenPage[] = "hidden-page";
|
||||
const char kNativeWindowOpen[] = "native-window-open";
|
||||
|
||||
// Command switch passed to renderer process to control nodeIntegration.
|
||||
const char kNodeIntegrationInWorker[] = "node-integration-in-worker";
|
||||
|
|
|
@ -92,6 +92,7 @@ extern const char kGuestInstanceID[];
|
|||
extern const char kOpenerID[];
|
||||
extern const char kScrollBounce[];
|
||||
extern const char kHiddenPage[];
|
||||
extern const char kNativeWindowOpen[];
|
||||
extern const char kNodeIntegrationInWorker[];
|
||||
|
||||
extern const char kWidevineCdmPath[];
|
||||
|
|
|
@ -6,7 +6,11 @@
|
|||
|
||||
#include <io.h>
|
||||
|
||||
#if !defined(DEBUG)
|
||||
#define U_I18N_IMPLEMENTATION
|
||||
#define U_COMMON_IMPLEMENTATION
|
||||
#define U_COMBINED_IMPLEMENTATION
|
||||
#endif
|
||||
|
||||
#include "third_party/icu/source/common/unicode/ubidi.h"
|
||||
#include "third_party/icu/source/common/unicode/uchar.h"
|
||||
|
@ -15,6 +19,7 @@
|
|||
#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/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/translit.h"
|
||||
#include "third_party/icu/source/i18n/unicode/ucsdet.h"
|
||||
|
@ -22,6 +27,7 @@
|
|||
#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/usearch.h"
|
||||
#include "util-inl.h"
|
||||
#include "v8-profiler.h"
|
||||
#include "v8-inspector.h"
|
||||
|
||||
|
@ -35,6 +41,18 @@ int close(int 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() {
|
||||
// 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,
|
||||
|
@ -60,6 +78,9 @@ void ReferenceSymbols() {
|
|||
UMeasureFormatWidth width = UMEASFMT_WIDTH_WIDE;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,12 @@ namespace node {
|
|||
__declspec(dllexport) int open_osfhandle(intptr_t osfhandle, int flags);
|
||||
__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.
|
||||
__declspec(dllexport) void ReferenceSymbols();
|
||||
|
||||
|
|
|
@ -51,13 +51,13 @@ SpellCheckClient::SpellCheckClient(const std::string& language,
|
|||
|
||||
SpellCheckClient::~SpellCheckClient() {}
|
||||
|
||||
void SpellCheckClient::spellCheck(
|
||||
void SpellCheckClient::checkSpelling(
|
||||
const blink::WebString& text,
|
||||
int& misspelling_start,
|
||||
int& misspelling_len,
|
||||
blink::WebVector<blink::WebString>* optional_suggestions) {
|
||||
std::vector<blink::WebTextCheckingResult> results;
|
||||
SpellCheckText(base::string16(text), true, &results);
|
||||
SpellCheckText(text.utf16(), true, &results);
|
||||
if (results.size() == 1) {
|
||||
misspelling_start = results[0].location;
|
||||
misspelling_len = results[0].length;
|
||||
|
@ -66,10 +66,8 @@ void SpellCheckClient::spellCheck(
|
|||
|
||||
void SpellCheckClient::requestCheckingOfText(
|
||||
const blink::WebString& textToCheck,
|
||||
const blink::WebVector<uint32_t>& markersInText,
|
||||
const blink::WebVector<unsigned>& markerOffsets,
|
||||
blink::WebTextCheckingCompletion* completionCallback) {
|
||||
base::string16 text(textToCheck);
|
||||
base::string16 text(textToCheck.utf16());
|
||||
if (text.empty() || !HasWordCharacters(text, 0)) {
|
||||
completionCallback->didCancelCheckingText();
|
||||
return;
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
#include "native_mate/scoped_persistent.h"
|
||||
#include "third_party/WebKit/public/web/WebSpellCheckClient.h"
|
||||
|
||||
namespace blink {
|
||||
struct WebTextCheckingResult;
|
||||
}
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
@ -27,15 +31,13 @@ class SpellCheckClient : public blink::WebSpellCheckClient {
|
|||
|
||||
private:
|
||||
// blink::WebSpellCheckClient:
|
||||
void spellCheck(
|
||||
void checkSpelling(
|
||||
const blink::WebString& text,
|
||||
int& misspelledOffset,
|
||||
int& misspelledLength,
|
||||
blink::WebVector<blink::WebString>* optionalSuggestions) override;
|
||||
void requestCheckingOfText(
|
||||
const blink::WebString& textToCheck,
|
||||
const blink::WebVector<uint32_t>& markersInText,
|
||||
const blink::WebVector<unsigned>& markerOffsets,
|
||||
blink::WebTextCheckingCompletion* completionCallback) override;
|
||||
void showSpellingUI(bool show) override;
|
||||
bool isShowingSpellingUI() override;
|
||||
|
|
|
@ -16,15 +16,15 @@
|
|||
#include "content/public/renderer/render_view.h"
|
||||
#include "native_mate/dictionary.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/WebFrameWidget.h"
|
||||
#include "third_party/WebKit/public/web/WebInputMethodController.h"
|
||||
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
||||
#include "third_party/WebKit/public/web/WebScriptExecutionCallback.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/Source/platform/weborigin/SchemeRegistry.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(
|
||||
const base::string16& name, v8::Local<v8::Object> options) {
|
||||
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(
|
||||
|
@ -145,15 +146,14 @@ void WebFrame::SetSpellCheckProvider(mate::Arguments* args,
|
|||
|
||||
void WebFrame::RegisterURLSchemeAsSecure(const std::string& scheme) {
|
||||
// TODO(pfrazee): Remove 2.0
|
||||
// Register scheme to secure list (https, wss, data).
|
||||
blink::WebSecurityPolicy::registerURLSchemeAsSecure(
|
||||
blink::WebString::fromUTF8(scheme));
|
||||
blink::SchemeRegistry::registerURLSchemeAsSecure(
|
||||
WTF::String::fromUTF8(scheme.data(), scheme.length()));
|
||||
}
|
||||
|
||||
void WebFrame::RegisterURLSchemeAsBypassingCSP(const std::string& scheme) {
|
||||
// Register scheme to bypass pages's Content Security Policy.
|
||||
blink::WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy(
|
||||
blink::WebString::fromUTF8(scheme));
|
||||
blink::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(
|
||||
WTF::String::fromUTF8(scheme.data(), scheme.length()));
|
||||
}
|
||||
|
||||
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)
|
||||
blink::WebString privileged_scheme(blink::WebString::fromUTF8(scheme));
|
||||
WTF::String privileged_scheme(
|
||||
WTF::String::fromUTF8(scheme.data(), scheme.length()));
|
||||
if (secure) {
|
||||
// TODO(pfrazee): Remove 2.0
|
||||
blink::WebSecurityPolicy::registerURLSchemeAsSecure(privileged_scheme);
|
||||
blink::SchemeRegistry::registerURLSchemeAsSecure(privileged_scheme);
|
||||
}
|
||||
if (bypassCSP) {
|
||||
blink::WebSecurityPolicy::registerURLSchemeAsBypassingContentSecurityPolicy(
|
||||
blink::SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(
|
||||
privileged_scheme);
|
||||
}
|
||||
if (allowServiceWorkers) {
|
||||
blink::WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers(
|
||||
blink::SchemeRegistry::registerURLSchemeAsAllowingServiceWorkers(
|
||||
privileged_scheme);
|
||||
}
|
||||
if (supportFetchAPI) {
|
||||
blink::WebSecurityPolicy::registerURLSchemeAsSupportingFetchAPI(
|
||||
blink::SchemeRegistry::registerURLSchemeAsSupportingFetchAPI(
|
||||
privileged_scheme);
|
||||
}
|
||||
if (corsEnabled) {
|
||||
blink::WebSecurityPolicy::registerURLSchemeAsCORSEnabled(privileged_scheme);
|
||||
blink::SchemeRegistry::registerURLSchemeAsCORSEnabled(privileged_scheme);
|
||||
}
|
||||
}
|
||||
|
||||
void WebFrame::InsertText(const std::string& text) {
|
||||
web_frame_->frameWidget()
|
||||
->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) {
|
||||
|
@ -216,7 +220,7 @@ void WebFrame::ExecuteJavaScript(const base::string16& code,
|
|||
std::unique_ptr<blink::WebScriptExecutionCallback> callback(
|
||||
new ScriptExecutionCallback(completion_callback));
|
||||
web_frame_->requestExecuteScriptAndReturnValue(
|
||||
blink::WebScriptSource(code),
|
||||
blink::WebScriptSource(blink::WebString::fromUTF16(code)),
|
||||
has_user_gesture,
|
||||
callback.release());
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include "atom/renderer/guest_view_container.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "native_mate/wrappable.h"
|
||||
#include "third_party/WebKit/public/web/WebCache.h"
|
||||
#include "third_party/WebKit/public/platform/WebCache.h"
|
||||
|
||||
namespace blink {
|
||||
class WebLocalFrame;
|
||||
|
|
|
@ -24,7 +24,6 @@ void AtomRenderFrameObserver::DidClearWindowObject() {
|
|||
|
||||
void AtomRenderFrameObserver::DidCreateScriptContext(
|
||||
v8::Handle<v8::Context> context,
|
||||
int extension_group,
|
||||
int world_id) {
|
||||
if (ShouldNotifyClient(world_id))
|
||||
renderer_client_->DidCreateScriptContext(context, render_frame_);
|
||||
|
@ -62,8 +61,7 @@ void AtomRenderFrameObserver::CreateIsolatedWorldContext() {
|
|||
|
||||
// Create initial script context in isolated world
|
||||
blink::WebScriptSource source("void 0");
|
||||
frame->executeScriptInIsolatedWorld(
|
||||
World::ISOLATED_WORLD, &source, 1, ExtensionGroup::MAIN_GROUP);
|
||||
frame->executeScriptInIsolatedWorld(World::ISOLATED_WORLD, &source, 1);
|
||||
}
|
||||
|
||||
bool AtomRenderFrameObserver::IsMainWorld(int world_id) {
|
||||
|
|
|
@ -17,10 +17,6 @@ enum World {
|
|||
ISOLATED_WORLD = 999
|
||||
};
|
||||
|
||||
enum ExtensionGroup {
|
||||
MAIN_GROUP = 1
|
||||
};
|
||||
|
||||
// Helper class to forward the messages to the client.
|
||||
class AtomRenderFrameObserver : public content::RenderFrameObserver {
|
||||
public:
|
||||
|
@ -30,7 +26,6 @@ class AtomRenderFrameObserver : public content::RenderFrameObserver {
|
|||
// content::RenderFrameObserver:
|
||||
void DidClearWindowObject() override;
|
||||
void DidCreateScriptContext(v8::Handle<v8::Context> context,
|
||||
int extension_group,
|
||||
int world_id) override;
|
||||
void WillReleaseScriptContext(v8::Local<v8::Context> context,
|
||||
int world_id) override;
|
||||
|
|
|
@ -136,6 +136,7 @@ bool AtomRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
|
|||
bool handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(AtomRenderViewObserver, message)
|
||||
IPC_MESSAGE_HANDLER(AtomViewMsg_Message, OnBrowserMessage)
|
||||
IPC_MESSAGE_HANDLER(AtomViewMsg_Offscreen, OnOffscreen)
|
||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||
IPC_END_MESSAGE_MAP()
|
||||
|
||||
|
@ -169,4 +170,8 @@ void AtomRenderViewObserver::OnBrowserMessage(bool send_to_all,
|
|||
}
|
||||
}
|
||||
|
||||
void AtomRenderViewObserver::OnOffscreen() {
|
||||
blink::WebView::setUseExternalPopupMenus(false);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
|
@ -40,6 +40,8 @@ class AtomRenderViewObserver : public content::RenderViewObserver {
|
|||
const base::string16& channel,
|
||||
const base::ListValue& args);
|
||||
|
||||
void OnOffscreen();
|
||||
|
||||
AtomRendererClient* renderer_client_;
|
||||
|
||||
// Whether the document object has been created.
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom_natives.h" // NOLINT: This file is generated with js2c
|
||||
|
||||
#include "atom/common/api/atom_bindings.h"
|
||||
#include "atom/common/api/event_emitter_caller.h"
|
||||
#include "atom/common/asar/asar_util.h"
|
||||
|
@ -27,6 +25,7 @@
|
|||
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "atom_natives.h" // NOLINT: This file is generated with js2c
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -172,8 +171,7 @@ void AtomRendererClient::WillDestroyWorkerContextOnWorkerThread(
|
|||
v8::Local<v8::Context> AtomRendererClient::GetContext(
|
||||
blink::WebFrame* frame, v8::Isolate* isolate) {
|
||||
if (isolated_world())
|
||||
return frame->worldScriptContext(
|
||||
isolate, World::ISOLATED_WORLD, ExtensionGroup::MAIN_GROUP);
|
||||
return frame->worldScriptContext(isolate, World::ISOLATED_WORLD);
|
||||
else
|
||||
return frame->mainWorldScriptContext();
|
||||
}
|
||||
|
@ -206,6 +204,8 @@ void AtomRendererClient::SetupMainWorldOverrides(
|
|||
dict.Set(options::kOpenerID,
|
||||
command_line->GetSwitchValueASCII(switches::kOpenerID));
|
||||
dict.Set("hiddenPage", command_line->HasSwitch(switches::kHiddenPage));
|
||||
dict.Set("nativeWindowOpen",
|
||||
command_line->HasSwitch(switches::kNativeWindowOpen));
|
||||
|
||||
v8::Local<v8::Value> args[] = { binding };
|
||||
ignore_result(func->Call(context, v8::Null(isolate), 1, args));
|
||||
|
|
|
@ -6,14 +6,11 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "atom_natives.h" // NOLINT: This file is generated with js2c
|
||||
|
||||
#include "atom/common/api/api_messages.h"
|
||||
#include "atom/common/api/atom_bindings.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/value_converter.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "atom/renderer/api/atom_api_renderer_ipc.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/WebView.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "atom_natives.h" // NOLINT: This file is generated with js2c
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "third_party/WebKit/public/web/WebPluginParams.h"
|
||||
#include "third_party/WebKit/public/web/WebScriptSource.h"
|
||||
#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
|
||||
#include "third_party/WebKit/Source/platform/weborigin/SchemeRegistry.h"
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
#include "base/mac/mac_util.h"
|
||||
|
@ -85,6 +86,13 @@ void RendererClientBase::RenderThreadStarted() {
|
|||
blink::WebCustomElement::addEmbedderCustomElementName("webview");
|
||||
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);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
|
@ -126,13 +134,6 @@ void RendererClientBase::RenderFrameCreated(
|
|||
// Allow access to file scheme from pdf viewer.
|
||||
blink::WebSecurityPolicy::addOriginAccessWhitelistEntry(
|
||||
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) {
|
||||
|
|
1
brightray/CPPLINT.cfg
Normal file
1
brightray/CPPLINT.cfg
Normal file
|
@ -0,0 +1 @@
|
|||
filter=-build/header_guard,-build/include_what_you_use,-legal/copyright,-runtime/references
|
19
brightray/LICENSE
Normal file
19
brightray/LICENSE
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2013-2014 Adam Roben <adam@roben.org>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
27
brightray/LICENSE-CHROMIUM
Normal file
27
brightray/LICENSE-CHROMIUM
Normal file
|
@ -0,0 +1,27 @@
|
|||
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the names of its
|
||||
// contributors may be used to endorse or promote products derived from
|
||||
// this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
397
brightray/brightray.gyp
Normal file
397
brightray/brightray.gyp
Normal file
|
@ -0,0 +1,397 @@
|
|||
{
|
||||
'variables': {
|
||||
# The libraries brightray will be compiled to.
|
||||
'linux_system_libraries': 'gtk+-2.0 dbus-1 x11 x11-xcb xcb xi xcursor xdamage xrandr xcomposite xext xfixes xrender xtst xscrnsaver gconf-2.0 gmodule-2.0 nss'
|
||||
},
|
||||
'includes': [
|
||||
'filenames.gypi',
|
||||
],
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'brightray',
|
||||
'type': 'static_library',
|
||||
'include_dirs': [
|
||||
'.',
|
||||
'<(libchromiumcontent_src_dir)',
|
||||
'<(libchromiumcontent_src_dir)/skia/config',
|
||||
'<(libchromiumcontent_src_dir)/third_party/boringssl/src/include',
|
||||
'<(libchromiumcontent_src_dir)/third_party/skia/include/core',
|
||||
'<(libchromiumcontent_src_dir)/third_party/mojo/src',
|
||||
'<(libchromiumcontent_src_dir)/third_party/WebKit',
|
||||
'<(libchromiumcontent_dir)/gen',
|
||||
],
|
||||
'direct_dependent_settings': {
|
||||
'include_dirs': [
|
||||
'.',
|
||||
'../vendor',
|
||||
'<(libchromiumcontent_src_dir)',
|
||||
'<(libchromiumcontent_src_dir)/gpu',
|
||||
'<(libchromiumcontent_src_dir)/skia/config',
|
||||
'<(libchromiumcontent_src_dir)/third_party/boringssl/src/include',
|
||||
'<(libchromiumcontent_src_dir)/third_party/skia/include/core',
|
||||
'<(libchromiumcontent_src_dir)/third_party/skia/include/config',
|
||||
'<(libchromiumcontent_src_dir)/third_party/icu/source/common',
|
||||
'<(libchromiumcontent_src_dir)/third_party/mojo/src',
|
||||
'<(libchromiumcontent_src_dir)/third_party/khronos',
|
||||
'<(libchromiumcontent_src_dir)/third_party/WebKit',
|
||||
'<(libchromiumcontent_dir)/gen',
|
||||
'<(libchromiumcontent_dir)/gen/third_party/WebKit',
|
||||
],
|
||||
},
|
||||
'sources': [ '<@(brightray_sources)' ],
|
||||
'conditions': [
|
||||
# Link with libraries of libchromiumcontent.
|
||||
['OS=="linux" and libchromiumcontent_component==0', {
|
||||
# On Linux we have to use "--whole-archive" to force executable
|
||||
# to include all symbols, otherwise we will have plenty of
|
||||
# unresolved symbols errors.
|
||||
'direct_dependent_settings': {
|
||||
'ldflags': [
|
||||
'-Wl,--whole-archive',
|
||||
'<@(libchromiumcontent_libraries)',
|
||||
'-Wl,--no-whole-archive',
|
||||
],
|
||||
}
|
||||
}, { # (Release build on Linux)
|
||||
'link_settings': {
|
||||
'libraries': [ '<@(libchromiumcontent_libraries)' ]
|
||||
},
|
||||
}], # (Normal builds)
|
||||
# Linux specific link settings.
|
||||
['OS=="linux"', {
|
||||
'link_settings': {
|
||||
'ldflags': [
|
||||
'<!@(<(pkg-config) --libs-only-L --libs-only-other <(linux_system_libraries))',
|
||||
],
|
||||
'libraries': [
|
||||
'-lpthread',
|
||||
'<!@(<(pkg-config) --libs-only-l <(linux_system_libraries))',
|
||||
],
|
||||
},
|
||||
'cflags': [
|
||||
'<!@(<(pkg-config) --cflags <(linux_system_libraries))',
|
||||
# Needed by using libgtkui:
|
||||
'-Wno-deprecated-register',
|
||||
'-Wno-sentinel',
|
||||
],
|
||||
'cflags_cc': [
|
||||
'-Wno-reserved-user-defined-literal',
|
||||
],
|
||||
'direct_dependent_settings': {
|
||||
'cflags': [
|
||||
'<!@(<(pkg-config) --cflags <(linux_system_libraries))',
|
||||
'-Wno-deprecated-register',
|
||||
'-Wno-sentinel',
|
||||
],
|
||||
},
|
||||
'conditions': [
|
||||
['libchromiumcontent_component', {
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
# Following libraries are always linked statically.
|
||||
'<(libchromiumcontent_dir)/libgtkui.a',
|
||||
'<(libchromiumcontent_dir)/libhttp_server.a',
|
||||
'<(libchromiumcontent_dir)/libdesktop_capture.a',
|
||||
'<(libchromiumcontent_dir)/libdom_keycode_converter.a',
|
||||
'<(libchromiumcontent_dir)/libsystem_wrappers.a',
|
||||
'<(libchromiumcontent_dir)/librtc_base.a',
|
||||
'<(libchromiumcontent_dir)/librtc_base_approved.a',
|
||||
'<(libchromiumcontent_dir)/libwebrtc_common.a',
|
||||
'<(libchromiumcontent_dir)/libyuv.a',
|
||||
'<(libchromiumcontent_dir)/librenderer.a',
|
||||
'<(libchromiumcontent_dir)/libsecurity_state.a',
|
||||
# Friends of libpdf.a:
|
||||
# On Linux we have to use "--whole-archive" to include
|
||||
# all symbols, otherwise there will be plenty of
|
||||
# unresolved symbols errors.
|
||||
'-Wl,--whole-archive',
|
||||
'<(libchromiumcontent_dir)/libpdf.a',
|
||||
'<(libchromiumcontent_dir)/libppapi_cpp_objects.a',
|
||||
'<(libchromiumcontent_dir)/libppapi_internal_module.a',
|
||||
'<(libchromiumcontent_dir)/libjpeg.a',
|
||||
'<(libchromiumcontent_dir)/libpdfium.a',
|
||||
'<(libchromiumcontent_dir)/libfdrm.a',
|
||||
'<(libchromiumcontent_dir)/libformfiller.a',
|
||||
'<(libchromiumcontent_dir)/libfpdfapi.a',
|
||||
'<(libchromiumcontent_dir)/libfpdfdoc.a',
|
||||
'<(libchromiumcontent_dir)/libfpdftext.a',
|
||||
'<(libchromiumcontent_dir)/libfxcodec.a',
|
||||
'<(libchromiumcontent_dir)/libfxedit.a',
|
||||
'<(libchromiumcontent_dir)/libfxge.a',
|
||||
'<(libchromiumcontent_dir)/libfxjs.a',
|
||||
'<(libchromiumcontent_dir)/libjavascript.a',
|
||||
'<(libchromiumcontent_dir)/libpdfwindow.a',
|
||||
'<(libchromiumcontent_dir)/libfx_agg.a',
|
||||
'<(libchromiumcontent_dir)/libfx_lcms2.a',
|
||||
'<(libchromiumcontent_dir)/libfx_libopenjpeg.a',
|
||||
'<(libchromiumcontent_dir)/libfx_zlib.a',
|
||||
'-Wl,--no-whole-archive',
|
||||
],
|
||||
},
|
||||
}, {
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
# Link with ffmpeg.
|
||||
'<(libchromiumcontent_dir)/libffmpeg.so',
|
||||
# Following libraries are required by libchromiumcontent:
|
||||
'-lasound',
|
||||
'-lcap',
|
||||
'-lcups',
|
||||
'-lrt',
|
||||
'-ldl',
|
||||
'-lresolv',
|
||||
'-lfontconfig',
|
||||
'-lfreetype',
|
||||
'-lexpat',
|
||||
],
|
||||
},
|
||||
}],
|
||||
['target_arch=="arm"', {
|
||||
'link_settings': {
|
||||
'libraries!': [
|
||||
'<(libchromiumcontent_dir)/libdesktop_capture_differ_sse2.a',
|
||||
],
|
||||
},
|
||||
}],
|
||||
],
|
||||
}], # OS=="linux"
|
||||
['OS=="mac"', {
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'$(SDKROOT)/System/Library/Frameworks/AppKit.framework',
|
||||
# Required by webrtc:
|
||||
'$(SDKROOT)/System/Library/Frameworks/OpenGL.framework',
|
||||
'$(SDKROOT)/System/Library/Frameworks/IOKit.framework',
|
||||
# Required by media:
|
||||
'$(SDKROOT)/System/Library/Frameworks/VideoToolbox.framework',
|
||||
],
|
||||
},
|
||||
'conditions': [
|
||||
['libchromiumcontent_component', {
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
# Following libraries are always linked statically.
|
||||
'<(libchromiumcontent_dir)/libhttp_server.a',
|
||||
'<(libchromiumcontent_dir)/libdesktop_capture.a',
|
||||
'<(libchromiumcontent_dir)/libdom_keycode_converter.a',
|
||||
'<(libchromiumcontent_dir)/librtc_base.a',
|
||||
'<(libchromiumcontent_dir)/librtc_base_approved.a',
|
||||
'<(libchromiumcontent_dir)/libsystem_wrappers.a',
|
||||
'<(libchromiumcontent_dir)/libwebrtc_common.a',
|
||||
'<(libchromiumcontent_dir)/libyuv.a',
|
||||
'<(libchromiumcontent_dir)/librenderer.a',
|
||||
'<(libchromiumcontent_dir)/libsecurity_state.a',
|
||||
# Friends of libpdf.a:
|
||||
'<(libchromiumcontent_dir)/libpdf.a',
|
||||
'<(libchromiumcontent_dir)/libppapi_cpp_objects.a',
|
||||
'<(libchromiumcontent_dir)/libppapi_internal_module.a',
|
||||
'<(libchromiumcontent_dir)/libjpeg.a',
|
||||
'<(libchromiumcontent_dir)/libpdfium.a',
|
||||
'<(libchromiumcontent_dir)/libfdrm.a',
|
||||
'<(libchromiumcontent_dir)/libformfiller.a',
|
||||
'<(libchromiumcontent_dir)/libfpdfapi.a',
|
||||
'<(libchromiumcontent_dir)/libfpdfdoc.a',
|
||||
'<(libchromiumcontent_dir)/libfpdftext.a',
|
||||
'<(libchromiumcontent_dir)/libfxcodec.a',
|
||||
'<(libchromiumcontent_dir)/libfxcrt.a',
|
||||
'<(libchromiumcontent_dir)/libfxedit.a',
|
||||
'<(libchromiumcontent_dir)/libfxge.a',
|
||||
'<(libchromiumcontent_dir)/libfxjs.a',
|
||||
'<(libchromiumcontent_dir)/libjavascript.a',
|
||||
'<(libchromiumcontent_dir)/libpdfwindow.a',
|
||||
'<(libchromiumcontent_dir)/libfx_agg.a',
|
||||
'<(libchromiumcontent_dir)/libfx_freetype.a',
|
||||
'<(libchromiumcontent_dir)/libfx_lcms2.a',
|
||||
'<(libchromiumcontent_dir)/libfx_libopenjpeg.a',
|
||||
'<(libchromiumcontent_dir)/libfx_zlib.a',
|
||||
],
|
||||
},
|
||||
}, {
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
# Link with ffmpeg.
|
||||
'<(libchromiumcontent_dir)/libffmpeg.dylib',
|
||||
# Link with system frameworks.
|
||||
# ui_base.gypi:
|
||||
'$(SDKROOT)/System/Library/Frameworks/Accelerate.framework',
|
||||
# net.gypi:
|
||||
'$(SDKROOT)/System/Library/Frameworks/Foundation.framework',
|
||||
'$(SDKROOT)/System/Library/Frameworks/Security.framework',
|
||||
'$(SDKROOT)/System/Library/Frameworks/SystemConfiguration.framework',
|
||||
'-lresolv',
|
||||
# media.gyp:
|
||||
'$(SDKROOT)/System/Library/Frameworks/AudioToolbox.framework',
|
||||
'$(SDKROOT)/System/Library/Frameworks/AudioUnit.framework',
|
||||
'$(SDKROOT)/System/Library/Frameworks/AVFoundation.framework',
|
||||
'$(SDKROOT)/System/Library/Frameworks/CoreAudio.framework',
|
||||
'$(SDKROOT)/System/Library/Frameworks/CoreMedia.framework',
|
||||
'$(SDKROOT)/System/Library/Frameworks/CoreMIDI.framework',
|
||||
'$(SDKROOT)/System/Library/Frameworks/CoreVideo.framework',
|
||||
# surface.gyp:
|
||||
'$(SDKROOT)/System/Library/Frameworks/IOSurface.framework',
|
||||
# content_common.gypi:
|
||||
'$(SDKROOT)/System/Library/Frameworks/QuartzCore.framework',
|
||||
# base.gyp:
|
||||
'$(SDKROOT)/System/Library/Frameworks/ApplicationServices.framework',
|
||||
'$(SDKROOT)/System/Library/Frameworks/Carbon.framework',
|
||||
'$(SDKROOT)/System/Library/Frameworks/CoreFoundation.framework',
|
||||
# device/gamepad/BUILD.gn:
|
||||
'$(SDKROOT)/System/Library/Frameworks/GameController.framework',
|
||||
# content_browser.gypi:
|
||||
'-lbsm',
|
||||
# content_common.gypi:
|
||||
'-lsandbox',
|
||||
# bluetooth.gyp:
|
||||
'$(SDKROOT)/System/Library/Frameworks/IOBluetooth.framework',
|
||||
# components/wifi/BUILD.gn:
|
||||
'$(SDKROOT)/System/Library/Frameworks/CoreWLAN.framework',
|
||||
],
|
||||
},
|
||||
}],
|
||||
]
|
||||
}], # OS=="mac"
|
||||
['OS=="win"', {
|
||||
'conditions': [
|
||||
['libchromiumcontent_component', {
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
# Needed by desktop_capture.lib:
|
||||
'-ld3d11.lib',
|
||||
'-ldxgi.lib',
|
||||
# Following libs are always linked statically.
|
||||
'<(libchromiumcontent_dir)/base_static.lib',
|
||||
'<(libchromiumcontent_dir)/sandbox.lib',
|
||||
'<(libchromiumcontent_dir)/sandbox_helper_win.lib',
|
||||
'<(libchromiumcontent_dir)/http_server.lib',
|
||||
'<(libchromiumcontent_dir)/desktop_capture.lib',
|
||||
'<(libchromiumcontent_dir)/dom_keycode_converter.lib',
|
||||
'<(libchromiumcontent_dir)/rtc_base.lib',
|
||||
'<(libchromiumcontent_dir)/rtc_base_approved.lib',
|
||||
'<(libchromiumcontent_dir)/system_wrappers.lib',
|
||||
'<(libchromiumcontent_dir)/webrtc_common.lib',
|
||||
'<(libchromiumcontent_dir)/libyuv.lib',
|
||||
'<(libchromiumcontent_dir)/renderer.lib',
|
||||
'<(libchromiumcontent_dir)/security_state.lib',
|
||||
# Friends of pdf.lib:
|
||||
'<(libchromiumcontent_dir)/pdf.lib',
|
||||
'<(libchromiumcontent_dir)/ppapi_cpp_objects.lib',
|
||||
'<(libchromiumcontent_dir)/ppapi_internal_module.lib',
|
||||
'<(libchromiumcontent_dir)/libjpeg.lib',
|
||||
'<(libchromiumcontent_dir)/pdfium.lib',
|
||||
'<(libchromiumcontent_dir)/fdrm.lib',
|
||||
'<(libchromiumcontent_dir)/formfiller.lib',
|
||||
'<(libchromiumcontent_dir)/fpdfapi.lib',
|
||||
'<(libchromiumcontent_dir)/fpdfdoc.lib',
|
||||
'<(libchromiumcontent_dir)/fpdftext.lib',
|
||||
'<(libchromiumcontent_dir)/fpdftext.lib',
|
||||
'<(libchromiumcontent_dir)/fxcodec.lib',
|
||||
'<(libchromiumcontent_dir)/fxcrt.lib',
|
||||
'<(libchromiumcontent_dir)/fxedit.lib',
|
||||
'<(libchromiumcontent_dir)/fxge.lib',
|
||||
'<(libchromiumcontent_dir)/fxjs.lib',
|
||||
'<(libchromiumcontent_dir)/javascript.lib',
|
||||
'<(libchromiumcontent_dir)/pdfwindow.lib',
|
||||
'<(libchromiumcontent_dir)/fx_agg.lib',
|
||||
'<(libchromiumcontent_dir)/fx_freetype.lib',
|
||||
'<(libchromiumcontent_dir)/fx_lcms2.lib',
|
||||
'<(libchromiumcontent_dir)/fx_libopenjpeg.lib',
|
||||
'<(libchromiumcontent_dir)/fx_zlib.lib',
|
||||
],
|
||||
},
|
||||
}, {
|
||||
# Link with system libraries.
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
# Link with ffmpeg.
|
||||
'<(libchromiumcontent_dir)/ffmpeg.dll',
|
||||
# content_browser.gypi:
|
||||
'-lsensorsapi.lib',
|
||||
'-lportabledeviceguids.lib',
|
||||
# content_common.gypi:
|
||||
'-ld3d9.lib',
|
||||
'-ld3d11.lib',
|
||||
'-ldxgi.lib',
|
||||
'-ldxva2.lib',
|
||||
'-lstrmiids.lib',
|
||||
'-lmf.lib',
|
||||
'-lmfplat.lib',
|
||||
'-lmfuuid.lib',
|
||||
# media.gyp:
|
||||
'-ldxguid.lib',
|
||||
'-lmfreadwrite.lib',
|
||||
'-lmfuuid.lib',
|
||||
],
|
||||
'msvs_settings': {
|
||||
'VCLinkerTool': {
|
||||
'AdditionalDependencies': [
|
||||
'advapi32.lib',
|
||||
'dbghelp.lib',
|
||||
'delayimp.lib',
|
||||
'dwmapi.lib',
|
||||
'gdi32.lib',
|
||||
'netapi32.lib',
|
||||
'oleacc.lib',
|
||||
'user32.lib',
|
||||
'usp10.lib',
|
||||
'version.lib',
|
||||
'winspool.lib',
|
||||
'wtsapi32.lib',
|
||||
# bluetooth.gyp:
|
||||
'Bthprops.lib',
|
||||
'BluetoothApis.lib',
|
||||
# base.gyp:
|
||||
'cfgmgr32.lib',
|
||||
'powrprof.lib',
|
||||
'setupapi.lib',
|
||||
# net_common.gypi:
|
||||
'crypt32.lib',
|
||||
'dhcpcsvc.lib',
|
||||
'ncrypt.lib',
|
||||
'rpcrt4.lib',
|
||||
'secur32.lib',
|
||||
'urlmon.lib',
|
||||
'winhttp.lib',
|
||||
# ui/gfx/BUILD.gn:
|
||||
'dwrite.lib',
|
||||
# skia/BUILD.gn:
|
||||
'fontsub.lib',
|
||||
],
|
||||
'DelayLoadDLLs': [
|
||||
'wtsapi32.dll',
|
||||
# content_common.gypi:
|
||||
'd3d9.dll',
|
||||
'd3d11.dll',
|
||||
'dxva2.dll',
|
||||
# media.gyp:
|
||||
'mf.dll',
|
||||
'mfplat.dll',
|
||||
'mfreadwrite.dll',
|
||||
# bluetooth.gyp:
|
||||
'BluetoothApis.dll',
|
||||
'Bthprops.cpl',
|
||||
'setupapi.dll',
|
||||
# base.gyp:
|
||||
'cfgmgr32.dll',
|
||||
'powrprof.dll',
|
||||
'setupapi.dll',
|
||||
# net_common.gypi:
|
||||
'crypt32.dll',
|
||||
'dhcpcsvc.dll',
|
||||
'rpcrt4.dll',
|
||||
'secur32.dll',
|
||||
'urlmon.dll',
|
||||
'winhttp.dll',
|
||||
# windows runtime
|
||||
'API-MS-WIN-CORE-WINRT-L1-1-0.DLL',
|
||||
'API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
}], # libchromiumcontent_component
|
||||
],
|
||||
}], # OS=="win"
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue