mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
Compare commits
293 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1518ff5ddf | ||
|
|
18357512f3 | ||
|
|
1b3d3b6b75 | ||
|
|
1178915f30 | ||
|
|
b7b200c874 | ||
|
|
1c6a07c68d | ||
|
|
3c2539eced | ||
|
|
e2501a80e4 | ||
|
|
29d0a30d63 | ||
|
|
25bc02f332 | ||
|
|
d2ffd87668 | ||
|
|
852e158cc6 | ||
|
|
4fce00148d | ||
|
|
26d4a3b0ba | ||
|
|
02dfdf75a0 | ||
|
|
45e2f35eff | ||
|
|
62c8a00347 | ||
|
|
0a6a8192b6 | ||
|
|
39b6bcb621 | ||
|
|
093b844859 | ||
|
|
6df446baba | ||
|
|
de18f09588 | ||
|
|
2f3578679f | ||
|
|
7b3e998cc6 | ||
|
|
cf694ef32b | ||
|
|
b1f260ac87 | ||
|
|
fb08f56fc8 | ||
|
|
555347e726 | ||
|
|
50b9dfa61a | ||
|
|
4539a6f4d5 | ||
|
|
4abbd65628 | ||
|
|
5973aa36ad | ||
|
|
62a400b7d6 | ||
|
|
75ec73d6fe | ||
|
|
1a3abb61ed | ||
|
|
4a6cbd76c8 | ||
|
|
9e7bcda07d | ||
|
|
93b0a2caa1 | ||
|
|
930a5c6de2 | ||
|
|
daff671afc | ||
|
|
a60f341968 | ||
|
|
604c2470bc | ||
|
|
9fef6a1fd7 | ||
|
|
2cf6a026d8 | ||
|
|
87392ff046 | ||
|
|
dc1c11a841 | ||
|
|
9b2b6da3a3 | ||
|
|
2cacaa443a | ||
|
|
37eebb1dd0 | ||
|
|
94cb605993 | ||
|
|
e99b1709d9 | ||
|
|
4e5b8ac3ee | ||
|
|
0430380de1 | ||
|
|
edbb786fb4 | ||
|
|
6e2f977f7a | ||
|
|
76e5589a31 | ||
|
|
651ea7ef02 | ||
|
|
eb6d92d427 | ||
|
|
e683f28e32 | ||
|
|
8ce1930f0d | ||
|
|
2ee5f6f358 | ||
|
|
06c025050e | ||
|
|
ff718b19db | ||
|
|
1004d205d8 | ||
|
|
24fb560a9d | ||
|
|
a4e25a8917 | ||
|
|
2cfa67bdff | ||
|
|
a851695bb9 | ||
|
|
e2e33a8cf0 | ||
|
|
515f689814 | ||
|
|
640b03f7d0 | ||
|
|
b67d515a76 | ||
|
|
9e189b9d2d | ||
|
|
1234b61fa6 | ||
|
|
104cae8f68 | ||
|
|
e1281342f6 | ||
|
|
2ad46f1842 | ||
|
|
8e69f94df0 | ||
|
|
330ac5f266 | ||
|
|
56a8eb3a94 | ||
|
|
ddedcf22d1 | ||
|
|
f6410d3b77 | ||
|
|
c213971a2d | ||
|
|
bc2f1e8199 | ||
|
|
63d8137da2 | ||
|
|
45986405b8 | ||
|
|
b04db2e546 | ||
|
|
a0b24bd155 | ||
|
|
67f7a60524 | ||
|
|
41ea169784 | ||
|
|
49c6446267 | ||
|
|
26e3ad3c2e | ||
|
|
c13ea6eb36 | ||
|
|
f104e019be | ||
|
|
8e39aea34a | ||
|
|
d8a16a8ffb | ||
|
|
1f5518b91e | ||
|
|
90470617ab | ||
|
|
ce6a46ee59 | ||
|
|
108a3473ed | ||
|
|
4985e073c4 | ||
|
|
7b03c05b4e | ||
|
|
ce472315f4 | ||
|
|
43ef4faf79 | ||
|
|
795b674996 | ||
|
|
170c51ae85 | ||
|
|
241773f2f0 | ||
|
|
d453dbdb40 | ||
|
|
2814e04e7d | ||
|
|
f1cd1c6dff | ||
|
|
4107174cfd | ||
|
|
91f8d6092b | ||
|
|
1f07cf2545 | ||
|
|
d4b44d8b69 | ||
|
|
61aff5ed35 | ||
|
|
6bb331356e | ||
|
|
284ca3114b | ||
|
|
e1fe5f4fbf | ||
|
|
2762ead5a4 | ||
|
|
0ca5ad754e | ||
|
|
4f6750a460 | ||
|
|
1960327918 | ||
|
|
8c9ebbeec2 | ||
|
|
9f03a166f7 | ||
|
|
fb741285c6 | ||
|
|
7a0a87a6f3 | ||
|
|
034230e2ae | ||
|
|
68ca873fa8 | ||
|
|
3312f98121 | ||
|
|
33820ffb85 | ||
|
|
593a3de850 | ||
|
|
05b6f95ab8 | ||
|
|
68eaf1fb9f | ||
|
|
851a7578fa | ||
|
|
0d259a6eb0 | ||
|
|
86521f325b | ||
|
|
64a1b1c474 | ||
|
|
cf54c4cbb2 | ||
|
|
91ed9aeeee | ||
|
|
bc001f8816 | ||
|
|
56882c31bd | ||
|
|
8fe8dfa410 | ||
|
|
f9dc08baf6 | ||
|
|
54559f99a0 | ||
|
|
91c70a66cb | ||
|
|
edcea3e800 | ||
|
|
11f2574fda | ||
|
|
a7a3aa848e | ||
|
|
b145131505 | ||
|
|
410f3c03d4 | ||
|
|
8a22139d57 | ||
|
|
6a80cd2b7e | ||
|
|
22b21d04bd | ||
|
|
2cddb5bb4e | ||
|
|
a560df3327 | ||
|
|
14d48e9653 | ||
|
|
c374e37cc4 | ||
|
|
54e2c480cb | ||
|
|
43067e01e9 | ||
|
|
ab4a055c05 | ||
|
|
c774bb47c5 | ||
|
|
a52d780e7a | ||
|
|
b6d0201c73 | ||
|
|
1b036a284d | ||
|
|
602db2e04f | ||
|
|
f0ceb4f065 | ||
|
|
d71f10c5a3 | ||
|
|
39ddeff5c3 | ||
|
|
cc183524fd | ||
|
|
b0ee46f862 | ||
|
|
443040e8d7 | ||
|
|
d6eb0d6629 | ||
|
|
017df93ffa | ||
|
|
2f5acfedcd | ||
|
|
18675cc6c1 | ||
|
|
977680d00b | ||
|
|
2f26dbf39e | ||
|
|
873e6e5e6b | ||
|
|
20b70b367e | ||
|
|
f2a30afcf1 | ||
|
|
ec134e7536 | ||
|
|
0568fa30ca | ||
|
|
6e0762a540 | ||
|
|
af212a9f67 | ||
|
|
ebb4c93994 | ||
|
|
fd2fdb5475 | ||
|
|
88f6f5d1b2 | ||
|
|
93a27fd3a9 | ||
|
|
497f5a1199 | ||
|
|
bdc334d797 | ||
|
|
6520396466 | ||
|
|
9716e2745b | ||
|
|
5b3d0f86f7 | ||
|
|
b90e23306e | ||
|
|
8cc29c2e22 | ||
|
|
a3af6bd9f5 | ||
|
|
a23d8ed702 | ||
|
|
3766fb6652 | ||
|
|
a7891e584a | ||
|
|
e82b41724d | ||
|
|
6af7cfff33 | ||
|
|
057fda5352 | ||
|
|
71512ad244 | ||
|
|
edb3967a0f | ||
|
|
dc5129f32e | ||
|
|
ade16a7823 | ||
|
|
f7bdf5d04e | ||
|
|
dcbc10ac38 | ||
|
|
feac8685f4 | ||
|
|
11259b0ea2 | ||
|
|
ac0ba74e87 | ||
|
|
96b7d3653c | ||
|
|
9ccc78c62f | ||
|
|
1d824d4645 | ||
|
|
b26428c43c | ||
|
|
815cb1b31c | ||
|
|
dcf9a395c2 | ||
|
|
2e62d81c24 | ||
|
|
13acf7a6a3 | ||
|
|
f35224b0e4 | ||
|
|
6bcfd0630c | ||
|
|
f4f0174746 | ||
|
|
37b7dda3c5 | ||
|
|
fbcbfbda6a | ||
|
|
de4be56b09 | ||
|
|
f3852c57fc | ||
|
|
2e6d08c652 | ||
|
|
bb260343de | ||
|
|
3f7b3c4bd7 | ||
|
|
95054f443f | ||
|
|
eef72647b4 | ||
|
|
33b6ab11f2 | ||
|
|
dacfb2f596 | ||
|
|
3ac6019f42 | ||
|
|
0f7af8043a | ||
|
|
14a1e673c6 | ||
|
|
802ed62d5b | ||
|
|
572fc058d3 | ||
|
|
b348cdeae8 | ||
|
|
ea2273dde5 | ||
|
|
ad3b837ad5 | ||
|
|
b56bdc83af | ||
|
|
2e7dbe6c6b | ||
|
|
309ac75284 | ||
|
|
4f5c725dde | ||
|
|
5b6397aaa6 | ||
|
|
2928fe5c43 | ||
|
|
5da4f032c3 | ||
|
|
c5e68ec165 | ||
|
|
78e0b80dc7 | ||
|
|
073d8c2177 | ||
|
|
d194a84ae4 | ||
|
|
4bca6fe672 | ||
|
|
cdf33ff3dc | ||
|
|
08b203fed1 | ||
|
|
736befe90f | ||
|
|
b6c5e9a126 | ||
|
|
4ebe54043a | ||
|
|
e6f5f60f3a | ||
|
|
48facf6343 | ||
|
|
170f2f61f9 | ||
|
|
0244a73c49 | ||
|
|
9089d55342 | ||
|
|
9e0547b98f | ||
|
|
b97db68f0c | ||
|
|
436a6d5c0f | ||
|
|
a64bdbd306 | ||
|
|
ac6aeae915 | ||
|
|
f92f851f11 | ||
|
|
99e21a2235 | ||
|
|
f7d3dc742d | ||
|
|
cf6e215a66 | ||
|
|
e4688f1c5a | ||
|
|
315daf1a10 | ||
|
|
75e81f00e2 | ||
|
|
ec71440f09 | ||
|
|
2a825310ea | ||
|
|
323edb9d53 | ||
|
|
726bab0293 | ||
|
|
b52367e3b2 | ||
|
|
9ff1f6bbde | ||
|
|
97dd680b32 | ||
|
|
8098ca3b66 | ||
|
|
8f63fdb278 | ||
|
|
c5da330cdf | ||
|
|
9e89ec041e | ||
|
|
070bbcfc3d | ||
|
|
cef9cd3cfc | ||
|
|
ed4f4b3954 | ||
|
|
fb35f06114 | ||
|
|
58fa8add31 | ||
|
|
34afa3b8a5 | ||
|
|
17ef05672b |
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -12,7 +12,7 @@
|
||||
url = https://github.com/electron/chromium-breakpad.git
|
||||
[submodule "vendor/native_mate"]
|
||||
path = vendor/native_mate
|
||||
url = https://github.com/zcbenz/native-mate.git
|
||||
url = https://github.com/electron/native-mate.git
|
||||
[submodule "vendor/crashpad"]
|
||||
path = vendor/crashpad
|
||||
url = https://github.com/electron/crashpad.git
|
||||
|
||||
@@ -1 +1 @@
|
||||
v6.3.0
|
||||
v7.4.0
|
||||
|
||||
@@ -7,18 +7,16 @@
|
||||
#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"
|
||||
#include "base/command_line.h"
|
||||
#include "base/feature_list.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "gin/array_buffer.h"
|
||||
#include "gin/public/isolate_holder.h"
|
||||
#include "gin/v8_initializer.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "atom/common/api/atom_bindings.h"
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#endif
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
@@ -48,19 +46,26 @@ int NodeMain(int argc, char *argv[]) {
|
||||
const char** exec_argv;
|
||||
node::Init(&argc, const_cast<const char**>(argv), &exec_argc, &exec_argv);
|
||||
|
||||
node::IsolateData isolate_data(gin_env.isolate(), loop);
|
||||
node::Environment* env = node::CreateEnvironment(
|
||||
gin_env.isolate(), loop, gin_env.context(), argc, 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());
|
||||
env->AssignToContext(v8::Debug::GetDebugContext(gin_env.isolate()));
|
||||
|
||||
#if defined(OS_WIN)
|
||||
mate::Dictionary process(gin_env.isolate(), env->process_object());
|
||||
#if defined(OS_WIN)
|
||||
process.SetMethod("log", &AtomBindings::Log);
|
||||
#endif
|
||||
process.SetMethod("crash", &AtomBindings::Crash);
|
||||
|
||||
// Setup process.crashReporter.start in child node processes
|
||||
auto reporter = mate::Dictionary::CreateEmpty(gin_env.isolate());
|
||||
reporter.SetMethod("start", &crash_reporter::CrashReporter::StartInstance);
|
||||
process.Set("crashReporter", reporter);
|
||||
|
||||
node::LoadEnvironment(env);
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "atom/browser/api/atom_api_web_contents.h"
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/login_handler.h"
|
||||
#include "atom/browser/relauncher.h"
|
||||
#include "atom/common/atom_command_line.h"
|
||||
@@ -298,6 +297,8 @@ struct Converter<Browser::LoginItemSettings> {
|
||||
|
||||
dict.Get("openAtLogin", &(out->open_at_login));
|
||||
dict.Get("openAsHidden", &(out->open_as_hidden));
|
||||
dict.Get("path", &(out->path));
|
||||
dict.Get("args", &(out->args));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -312,8 +313,21 @@ struct Converter<Browser::LoginItemSettings> {
|
||||
return dict.GetHandle();
|
||||
}
|
||||
};
|
||||
} // namespace mate
|
||||
|
||||
template<>
|
||||
struct Converter<content::CertificateRequestResultType> {
|
||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
||||
content::CertificateRequestResultType* out) {
|
||||
bool b;
|
||||
if (!ConvertFromV8(isolate, val, &b))
|
||||
return false;
|
||||
*out = b ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE :
|
||||
content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mate
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -573,8 +587,8 @@ void App::AllowCertificateError(
|
||||
bool overridable,
|
||||
bool strict_enforcement,
|
||||
bool expired_previous_decision,
|
||||
const base::Callback<void(bool)>& callback,
|
||||
content::CertificateRequestResultType* request) {
|
||||
const base::Callback<void(content::CertificateRequestResultType)>&
|
||||
callback) {
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
bool prevent_default = Emit("certificate-error",
|
||||
@@ -586,7 +600,7 @@ void App::AllowCertificateError(
|
||||
|
||||
// Deny the certificate by default.
|
||||
if (!prevent_default)
|
||||
*request = content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY;
|
||||
callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY);
|
||||
}
|
||||
|
||||
void App::SelectClientCertificate(
|
||||
@@ -733,6 +747,12 @@ bool App::IsAccessibilitySupportEnabled() {
|
||||
return ax_state->IsAccessibleBrowser();
|
||||
}
|
||||
|
||||
Browser::LoginItemSettings App::GetLoginItemSettings(mate::Arguments* args) {
|
||||
Browser::LoginItemSettings options;
|
||||
args->GetNext(&options);
|
||||
return Browser::Get()->GetLoginItemSettings(options);
|
||||
}
|
||||
|
||||
#if defined(USE_NSS_CERTS)
|
||||
void App::ImportCertificate(
|
||||
const base::DictionaryValue& options,
|
||||
@@ -854,8 +874,7 @@ void App::BuildPrototype(
|
||||
base::Bind(&Browser::RemoveAsDefaultProtocolClient, browser))
|
||||
.SetMethod("setBadgeCount", base::Bind(&Browser::SetBadgeCount, browser))
|
||||
.SetMethod("getBadgeCount", base::Bind(&Browser::GetBadgeCount, browser))
|
||||
.SetMethod("getLoginItemSettings",
|
||||
base::Bind(&Browser::GetLoginItemSettings, browser))
|
||||
.SetMethod("getLoginItemSettings", &App::GetLoginItemSettings)
|
||||
.SetMethod("setLoginItemSettings",
|
||||
base::Bind(&Browser::SetLoginItemSettings, browser))
|
||||
#if defined(OS_MACOSX)
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "atom/browser/api/event_emitter.h"
|
||||
#include "atom/browser/atom_browser_client.h"
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/browser_observer.h"
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "chrome/browser/process_singleton.h"
|
||||
@@ -98,8 +99,8 @@ class App : public AtomBrowserClient::Delegate,
|
||||
bool overridable,
|
||||
bool strict_enforcement,
|
||||
bool expired_previous_decision,
|
||||
const base::Callback<void(bool)>& callback,
|
||||
content::CertificateRequestResultType* request) override;
|
||||
const base::Callback<void(content::CertificateRequestResultType)>&
|
||||
callback) override;
|
||||
void SelectClientCertificate(
|
||||
content::WebContents* web_contents,
|
||||
net::SSLCertRequestInfo* cert_request_info,
|
||||
@@ -123,6 +124,7 @@ class App : public AtomBrowserClient::Delegate,
|
||||
bool Relaunch(mate::Arguments* args);
|
||||
void DisableHardwareAcceleration(mate::Arguments* args);
|
||||
bool IsAccessibilitySupportEnabled();
|
||||
Browser::LoginItemSettings GetLoginItemSettings(mate::Arguments* args);
|
||||
#if defined(USE_NSS_CERTS)
|
||||
void ImportCertificate(const base::DictionaryValue& options,
|
||||
const net::CompletionCallback& callback);
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include "atom/common/native_mate_converters/callback.h"
|
||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||
#include "atom/common/native_mate_converters/gurl_converter.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "net/base/filename_util.h"
|
||||
|
||||
@@ -80,7 +80,8 @@ void DownloadItem::OnDownloadUpdated(content::DownloadItem* item) {
|
||||
Emit("done", item->GetState());
|
||||
|
||||
// Destroy the item once item is downloaded.
|
||||
base::MessageLoop::current()->PostTask(FROM_HERE, GetDestroyClosure());
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE, GetDestroyClosure());
|
||||
} else {
|
||||
Emit("updated", item->GetState());
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
namespace mate {
|
||||
|
||||
template<>
|
||||
@@ -76,10 +78,8 @@ void PowerSaveBlocker::UpdatePowerSaveBlocker() {
|
||||
new_blocker_type,
|
||||
device::PowerSaveBlocker::kReasonOther,
|
||||
ATOM_PRODUCT_NAME,
|
||||
content::BrowserThread::GetMessageLoopProxyForThread(
|
||||
content::BrowserThread::UI),
|
||||
content::BrowserThread::GetMessageLoopProxyForThread(
|
||||
content::BrowserThread::FILE)));
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)));
|
||||
power_save_blocker_.swap(new_blocker);
|
||||
current_blocker_type_ = new_blocker_type;
|
||||
}
|
||||
|
||||
@@ -254,8 +254,8 @@ class ResolveProxyHelper {
|
||||
|
||||
// Start the request.
|
||||
int result = proxy_service->ResolveProxy(
|
||||
url, "GET", net::LOAD_NORMAL, &proxy_info_, completion_callback,
|
||||
&pac_req_, nullptr, net::BoundNetLog());
|
||||
url, "GET", &proxy_info_, completion_callback, &pac_req_, nullptr,
|
||||
net::BoundNetLog());
|
||||
|
||||
// Completed synchronously.
|
||||
if (result != net::ERR_IO_PENDING)
|
||||
|
||||
@@ -14,11 +14,7 @@ namespace atom {
|
||||
|
||||
namespace api {
|
||||
|
||||
SystemPreferences::SystemPreferences(v8::Isolate* isolate)
|
||||
#if defined(OS_WIN)
|
||||
: color_change_listener_(this)
|
||||
#endif
|
||||
{
|
||||
SystemPreferences::SystemPreferences(v8::Isolate* isolate) {
|
||||
Init(isolate);
|
||||
#if defined(OS_WIN)
|
||||
InitializeWindow();
|
||||
@@ -26,6 +22,9 @@ SystemPreferences::SystemPreferences(v8::Isolate* isolate)
|
||||
}
|
||||
|
||||
SystemPreferences::~SystemPreferences() {
|
||||
#if defined(OS_WIN)
|
||||
Browser::Get()->RemoveObserver(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "native_mate/handle.h"
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/browser/browser_observer.h"
|
||||
#include "ui/gfx/sys_color_change_listener.h"
|
||||
#endif
|
||||
|
||||
@@ -26,6 +28,7 @@ namespace api {
|
||||
|
||||
class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
#if defined(OS_WIN)
|
||||
, public BrowserObserver
|
||||
, public gfx::SysColorChangeListener
|
||||
#endif
|
||||
{
|
||||
@@ -51,6 +54,9 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
// gfx::SysColorChangeListener:
|
||||
void OnSysColorChange() override;
|
||||
|
||||
// BrowserObserver:
|
||||
void OnFinishLaunching(const base::DictionaryValue& launch_info) override;
|
||||
|
||||
#elif defined(OS_MACOSX)
|
||||
using NotificationCallback = base::Callback<
|
||||
void(const std::string&, const base::DictionaryValue&)>;
|
||||
@@ -111,7 +117,7 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||
|
||||
bool invertered_color_scheme_;
|
||||
|
||||
gfx::ScopedSysColorChangeListener color_change_listener_;
|
||||
std::unique_ptr<gfx::ScopedSysColorChangeListener> color_change_listener_;
|
||||
#endif
|
||||
DISALLOW_COPY_AND_ASSIGN(SystemPreferences);
|
||||
};
|
||||
|
||||
@@ -117,6 +117,14 @@ std::string SystemPreferences::GetColor(const std::string& color,
|
||||
void SystemPreferences::InitializeWindow() {
|
||||
invertered_color_scheme_ = IsInvertedColorScheme();
|
||||
|
||||
// Wait until app is ready before creating sys color listener
|
||||
// Creating this listener before the app is ready causes global shortcuts
|
||||
// to not fire
|
||||
if (Browser::Get()->is_ready())
|
||||
color_change_listener_.reset(new gfx::ScopedSysColorChangeListener(this));
|
||||
else
|
||||
Browser::Get()->AddObserver(this);
|
||||
|
||||
WNDCLASSEX window_class;
|
||||
base::win::InitializeWindowClass(
|
||||
kSystemPreferencesWindowClass,
|
||||
@@ -172,6 +180,11 @@ void SystemPreferences::OnSysColorChange() {
|
||||
Emit("color-changed");
|
||||
}
|
||||
|
||||
void SystemPreferences::OnFinishLaunching(
|
||||
const base::DictionaryValue& launch_info) {
|
||||
color_change_listener_.reset(new gfx::ScopedSysColorChangeListener(this));
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "atom/common/native_mate_converters/image_converter.h"
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "native_mate/constructor.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
@@ -71,7 +72,8 @@ Tray::Tray(v8::Isolate* isolate, v8::Local<v8::Object> wrapper,
|
||||
|
||||
Tray::~Tray() {
|
||||
// Destroy the native tray in next tick.
|
||||
base::MessageLoop::current()->DeleteSoon(FROM_HERE, tray_icon_.release());
|
||||
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(
|
||||
FROM_HERE, tray_icon_.release());
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "brightray/browser/inspectable_web_contents.h"
|
||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||
#include "chrome/browser/printing/print_preview_message_handler.h"
|
||||
@@ -419,9 +420,11 @@ void WebContents::AddNewContents(content::WebContents* source,
|
||||
v8::Locker locker(isolate());
|
||||
v8::HandleScope handle_scope(isolate());
|
||||
auto api_web_contents = CreateFrom(isolate(), new_contents);
|
||||
Emit("-add-new-contents", api_web_contents, disposition, user_gesture,
|
||||
if (Emit("-add-new-contents", api_web_contents, disposition, user_gesture,
|
||||
initial_rect.x(), initial_rect.y(), initial_rect.width(),
|
||||
initial_rect.height());
|
||||
initial_rect.height())) {
|
||||
api_web_contents->DestroyWebContents();
|
||||
}
|
||||
}
|
||||
|
||||
content::WebContents* WebContents::OpenURLFromTab(
|
||||
@@ -828,7 +831,8 @@ void WebContents::WebContentsDestroyed() {
|
||||
Emit("destroyed");
|
||||
|
||||
// Destroy the native class in next tick.
|
||||
base::MessageLoop::current()->PostTask(FROM_HERE, GetDestroyClosure());
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE, GetDestroyClosure());
|
||||
}
|
||||
|
||||
void WebContents::NavigationEntryCommitted(
|
||||
@@ -857,7 +861,7 @@ bool WebContents::Equal(const WebContents* web_contents) const {
|
||||
}
|
||||
|
||||
void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
|
||||
if (!url.is_valid()) {
|
||||
if (!url.is_valid() || url.spec().size() > url::kMaxURLChars) {
|
||||
Emit("did-fail-load",
|
||||
static_cast<int>(net::ERR_INVALID_URL),
|
||||
net::ErrorToShortString(net::ERR_INVALID_URL),
|
||||
@@ -896,14 +900,16 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
|
||||
// We have to call it right after LoadURL because the RenderViewHost is only
|
||||
// created after loading a page.
|
||||
const auto view = web_contents()->GetRenderWidgetHostView();
|
||||
WebContentsPreferences* web_preferences =
|
||||
WebContentsPreferences::FromWebContents(web_contents());
|
||||
std::string color_name;
|
||||
if (web_preferences->web_preferences()->GetString(options::kBackgroundColor,
|
||||
&color_name)) {
|
||||
view->SetBackgroundColor(ParseHexColor(color_name));
|
||||
} else {
|
||||
view->SetBackgroundColor(SK_ColorTRANSPARENT);
|
||||
if (view) {
|
||||
WebContentsPreferences* web_preferences =
|
||||
WebContentsPreferences::FromWebContents(web_contents());
|
||||
std::string color_name;
|
||||
if (web_preferences->web_preferences()->GetString(options::kBackgroundColor,
|
||||
&color_name)) {
|
||||
view->SetBackgroundColor(ParseHexColor(color_name));
|
||||
} else {
|
||||
view->SetBackgroundColor(SK_ColorTRANSPARENT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -973,10 +979,6 @@ std::string WebContents::GetUserAgent() {
|
||||
return web_contents()->GetUserAgentOverride();
|
||||
}
|
||||
|
||||
void WebContents::InsertCSS(const std::string& css) {
|
||||
web_contents()->InsertCSS(css);
|
||||
}
|
||||
|
||||
bool WebContents::SavePage(const base::FilePath& full_file_path,
|
||||
const content::SavePageType& save_type,
|
||||
const SavePageHandler::SavePageCallback& callback) {
|
||||
@@ -1062,9 +1064,7 @@ void WebContents::InspectElement(int x, int y) {
|
||||
|
||||
if (!managed_web_contents()->GetDevToolsWebContents())
|
||||
OpenDevTools(nullptr);
|
||||
scoped_refptr<content::DevToolsAgentHost> agent(
|
||||
content::DevToolsAgentHost::GetOrCreateFor(web_contents()));
|
||||
agent->InspectElement(x, y);
|
||||
managed_web_contents()->InspectElement(x, y);
|
||||
}
|
||||
|
||||
void WebContents::InspectServiceWorker() {
|
||||
@@ -1327,17 +1327,25 @@ void WebContents::StartDrag(const mate::Dictionary& item,
|
||||
|
||||
// Error checking.
|
||||
if (icon.IsEmpty()) {
|
||||
args->ThrowError("icon must be set");
|
||||
args->ThrowError("Must specify 'icon' option");
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
// NSWindow.dragImage requires a non-empty NSImage
|
||||
if (icon->image().IsEmpty()) {
|
||||
args->ThrowError("Must specify non-empty 'icon' option");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Start dragging.
|
||||
if (!files.empty()) {
|
||||
base::MessageLoop::ScopedNestableTaskAllower allow(
|
||||
base::MessageLoop::current());
|
||||
DragFileItems(files, icon->image(), web_contents()->GetNativeView());
|
||||
} else {
|
||||
args->ThrowError("There is nothing to drag");
|
||||
args->ThrowError("Must specify either 'file' or 'files' option");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1556,7 +1564,6 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
||||
.SetMethod("isCrashed", &WebContents::IsCrashed)
|
||||
.SetMethod("setUserAgent", &WebContents::SetUserAgent)
|
||||
.SetMethod("getUserAgent", &WebContents::GetUserAgent)
|
||||
.SetMethod("insertCSS", &WebContents::InsertCSS)
|
||||
.SetMethod("savePage", &WebContents::SavePage)
|
||||
.SetMethod("openDevTools", &WebContents::OpenDevTools)
|
||||
.SetMethod("closeDevTools", &WebContents::CloseDevTools)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "native_mate/constructor.h"
|
||||
@@ -152,7 +153,7 @@ Window::~Window() {
|
||||
|
||||
// Destroy the native window in next tick because the native code might be
|
||||
// iterating all windows.
|
||||
base::MessageLoop::current()->DeleteSoon(FROM_HERE, window_.release());
|
||||
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, window_.release());
|
||||
}
|
||||
|
||||
void Window::WillCloseWindow(bool* prevent_default) {
|
||||
@@ -185,7 +186,8 @@ void Window::OnWindowClosed() {
|
||||
RemoveFromParentChildWindows();
|
||||
|
||||
// Destroy the native class when window is closed.
|
||||
base::MessageLoop::current()->PostTask(FROM_HERE, GetDestroyClosure());
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE, GetDestroyClosure());
|
||||
}
|
||||
|
||||
void Window::OnWindowBlur() {
|
||||
@@ -510,8 +512,17 @@ bool Window::IsClosable() {
|
||||
|
||||
void Window::SetAlwaysOnTop(bool top, mate::Arguments* args) {
|
||||
std::string level = "floating";
|
||||
int relativeLevel = 0;
|
||||
std::string error;
|
||||
|
||||
args->GetNext(&level);
|
||||
window_->SetAlwaysOnTop(top, level);
|
||||
args->GetNext(&relativeLevel);
|
||||
|
||||
window_->SetAlwaysOnTop(top, level, relativeLevel, &error);
|
||||
|
||||
if (!error.empty()) {
|
||||
args->ThrowError(error);
|
||||
}
|
||||
}
|
||||
|
||||
bool Window::IsAlwaysOnTop() {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "atom/common/google_api_key.h"
|
||||
#include "base/environment.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/geolocation_provider.h"
|
||||
#include "device/geolocation/geolocation_provider.h"
|
||||
|
||||
using content::BrowserThread;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace internal {
|
||||
class TokenLoadingJob : public base::RefCountedThreadSafe<TokenLoadingJob> {
|
||||
public:
|
||||
explicit TokenLoadingJob(
|
||||
const content::AccessTokenStore::LoadAccessTokensCallback& callback)
|
||||
const device::AccessTokenStore::LoadAccessTokensCallback& callback)
|
||||
: callback_(callback), request_context_getter_(nullptr) {}
|
||||
|
||||
void Run(AtomBrowserContext* browser_context) {
|
||||
@@ -47,7 +47,7 @@ class TokenLoadingJob : public base::RefCountedThreadSafe<TokenLoadingJob> {
|
||||
// Equivalent to access_token_map[kGeolocationProviderURL].
|
||||
// Somehow base::string16 is causing compilation errors when used in a pair
|
||||
// of std::map on Linux, this can work around it.
|
||||
content::AccessTokenStore::AccessTokenMap access_token_map;
|
||||
device::AccessTokenStore::AccessTokenMap access_token_map;
|
||||
std::pair<GURL, base::string16> token_pair;
|
||||
token_pair.first = GURL(GOOGLEAPIS_ENDPOINT + api_key_);
|
||||
access_token_map.insert(token_pair);
|
||||
@@ -55,7 +55,7 @@ class TokenLoadingJob : public base::RefCountedThreadSafe<TokenLoadingJob> {
|
||||
callback_.Run(access_token_map, request_context_getter_);
|
||||
}
|
||||
|
||||
content::AccessTokenStore::LoadAccessTokensCallback callback_;
|
||||
device::AccessTokenStore::LoadAccessTokensCallback callback_;
|
||||
net::URLRequestContextGetter* request_context_getter_;
|
||||
std::string api_key_;
|
||||
};
|
||||
@@ -64,7 +64,7 @@ class TokenLoadingJob : public base::RefCountedThreadSafe<TokenLoadingJob> {
|
||||
|
||||
AtomAccessTokenStore::AtomAccessTokenStore() {
|
||||
browser_context_ = AtomBrowserContext::From("", false);
|
||||
content::GeolocationProvider::GetInstance()->UserDidOptIntoLocationServices();
|
||||
device::GeolocationProvider::GetInstance()->UserDidOptIntoLocationServices();
|
||||
}
|
||||
|
||||
AtomAccessTokenStore::~AtomAccessTokenStore() {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#ifndef ATOM_BROWSER_ATOM_ACCESS_TOKEN_STORE_H_
|
||||
#define ATOM_BROWSER_ATOM_ACCESS_TOKEN_STORE_H_
|
||||
|
||||
#include "content/public/browser/access_token_store.h"
|
||||
#include "device/geolocation/access_token_store.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
@@ -15,12 +15,12 @@ namespace internal {
|
||||
class TokenLoadingJob;
|
||||
}
|
||||
|
||||
class AtomAccessTokenStore : public content::AccessTokenStore {
|
||||
class AtomAccessTokenStore : public device::AccessTokenStore {
|
||||
public:
|
||||
AtomAccessTokenStore();
|
||||
~AtomAccessTokenStore();
|
||||
|
||||
// content::AccessTokenStore:
|
||||
// device::AccessTokenStore:
|
||||
void LoadAccessTokens(
|
||||
const LoadAccessTokensCallback& callback) override;
|
||||
void SaveAccessToken(const GURL& server_url,
|
||||
|
||||
@@ -73,7 +73,7 @@ void AtomBlobReader::StartReading(
|
||||
|
||||
auto blob_reader = blob_data_handle->CreateReader(
|
||||
file_system_context_.get(),
|
||||
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get());
|
||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE).get());
|
||||
BlobReadHelper* blob_read_helper =
|
||||
new BlobReadHelper(std::move(blob_reader), callback);
|
||||
blob_read_helper->Read();
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "atom/browser/api/atom_api_app.h"
|
||||
#include "atom/browser/api/atom_api_protocol.h"
|
||||
#include "atom/browser/atom_access_token_store.h"
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
#include "atom/browser/atom_quota_permission_context.h"
|
||||
@@ -33,7 +32,6 @@
|
||||
#include "content/common/resource_request_body_impl.h"
|
||||
#include "content/public/browser/browser_ppapi_host.h"
|
||||
#include "content/public/browser/client_certificate_delegate.h"
|
||||
#include "content/public/browser/geolocation_delegate.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/resource_dispatcher_host.h"
|
||||
@@ -56,19 +54,6 @@ bool g_suppress_renderer_process_restart = false;
|
||||
// Custom schemes to be registered to handle service worker.
|
||||
std::string g_custom_service_worker_schemes = "";
|
||||
|
||||
// A provider of Geolocation services to override AccessTokenStore.
|
||||
class AtomGeolocationDelegate : public content::GeolocationDelegate {
|
||||
public:
|
||||
AtomGeolocationDelegate() = default;
|
||||
|
||||
content::AccessTokenStore* CreateAccessTokenStore() final {
|
||||
return new AtomAccessTokenStore();
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomGeolocationDelegate);
|
||||
};
|
||||
|
||||
void Noop(scoped_refptr<content::SiteInstance>) {
|
||||
}
|
||||
|
||||
@@ -93,7 +78,7 @@ AtomBrowserClient::~AtomBrowserClient() {
|
||||
content::WebContents* AtomBrowserClient::GetWebContentsFromProcessID(
|
||||
int process_id) {
|
||||
// If the process is a pending process, we should use the old one.
|
||||
if (ContainsKey(pending_processes_, process_id))
|
||||
if (base::ContainsKey(pending_processes_, process_id))
|
||||
process_id = pending_processes_[process_id];
|
||||
|
||||
// Certain render process will be created with no associated render view,
|
||||
@@ -160,11 +145,6 @@ content::SpeechRecognitionManagerDelegate*
|
||||
return new AtomSpeechRecognitionManagerDelegate;
|
||||
}
|
||||
|
||||
content::GeolocationDelegate*
|
||||
AtomBrowserClient::CreateGeolocationDelegate() {
|
||||
return new AtomGeolocationDelegate();
|
||||
}
|
||||
|
||||
void AtomBrowserClient::OverrideWebkitPrefs(
|
||||
content::RenderViewHost* host, content::WebPreferences* prefs) {
|
||||
prefs->javascript_enabled = true;
|
||||
@@ -283,13 +263,13 @@ void AtomBrowserClient::AllowCertificateError(
|
||||
bool overridable,
|
||||
bool strict_enforcement,
|
||||
bool expired_previous_decision,
|
||||
const base::Callback<void(bool)>& callback,
|
||||
content::CertificateRequestResultType* request) {
|
||||
const base::Callback<void(content::CertificateRequestResultType)>&
|
||||
callback) {
|
||||
if (delegate_) {
|
||||
delegate_->AllowCertificateError(
|
||||
web_contents, cert_error, ssl_info, request_url,
|
||||
resource_type, overridable, strict_enforcement,
|
||||
expired_previous_decision, callback, request);
|
||||
expired_previous_decision, callback);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,9 +295,9 @@ bool AtomBrowserClient::CanCreateWindow(
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
WindowContainerType container_type,
|
||||
const std::string& frame_name,
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::WebWindowFeatures& features,
|
||||
const std::vector<base::string16>& additional_features,
|
||||
|
||||
@@ -50,7 +50,6 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
|
||||
content::SpeechRecognitionManagerDelegate*
|
||||
CreateSpeechRecognitionManagerDelegate() override;
|
||||
content::GeolocationDelegate* CreateGeolocationDelegate() override;
|
||||
void OverrideWebkitPrefs(content::RenderViewHost* render_view_host,
|
||||
content::WebPreferences* prefs) override;
|
||||
std::string GetApplicationLocale() override;
|
||||
@@ -72,8 +71,8 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
bool overridable,
|
||||
bool strict_enforcement,
|
||||
bool expired_previous_decision,
|
||||
const base::Callback<void(bool)>& callback,
|
||||
content::CertificateRequestResultType* request) override;
|
||||
const base::Callback<void(content::CertificateRequestResultType)>&
|
||||
callback) override;
|
||||
void SelectClientCertificate(
|
||||
content::WebContents* web_contents,
|
||||
net::SSLCertRequestInfo* cert_request_info,
|
||||
@@ -84,9 +83,9 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||
const GURL& opener_top_level_frame_url,
|
||||
const GURL& source_origin,
|
||||
WindowContainerType container_type,
|
||||
const std::string& frame_name,
|
||||
const GURL& target_url,
|
||||
const content::Referrer& referrer,
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::WebWindowFeatures& features,
|
||||
const std::vector<base::string16>& additional_features,
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "atom/browser/atom_browser_main_parts.h"
|
||||
|
||||
#include "atom/browser/api/trackable_object.h"
|
||||
#include "atom/browser/atom_access_token_store.h"
|
||||
#include "atom/browser/atom_browser_client.h"
|
||||
#include "atom/browser/atom_browser_context.h"
|
||||
#include "atom/browser/bridge_task_runner.h"
|
||||
@@ -18,6 +19,8 @@
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "content/public/browser/child_process_security_policy.h"
|
||||
#include "device/geolocation/geolocation_delegate.h"
|
||||
#include "device/geolocation/geolocation_provider.h"
|
||||
#include "v8/include/v8-debug.h"
|
||||
|
||||
#if defined(USE_X11)
|
||||
@@ -27,11 +30,28 @@
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
// A provider of Geolocation services to override AccessTokenStore.
|
||||
class AtomGeolocationDelegate : public device::GeolocationDelegate {
|
||||
public:
|
||||
AtomGeolocationDelegate() = default;
|
||||
|
||||
scoped_refptr<device::AccessTokenStore> CreateAccessTokenStore() final {
|
||||
return new AtomAccessTokenStore();
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomGeolocationDelegate);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
void Erase(T* container, typename T::iterator iter) {
|
||||
container->erase(iter);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
AtomBrowserMainParts* AtomBrowserMainParts::self_ = nullptr;
|
||||
|
||||
@@ -115,7 +135,7 @@ void AtomBrowserMainParts::PostEarlyInitialization() {
|
||||
|
||||
// Make sure node can get correct environment when debugging.
|
||||
if (node_debugger_->IsRunning())
|
||||
env->AssignToContext(v8::Debug::GetDebugContext());
|
||||
env->AssignToContext(v8::Debug::GetDebugContext(js_env_->isolate()));
|
||||
|
||||
// Add Electron extended APIs.
|
||||
atom_bindings_->BindTo(js_env_->isolate(), env->process_object());
|
||||
@@ -171,6 +191,8 @@ void AtomBrowserMainParts::PostMainMessageLoopStart() {
|
||||
#if defined(OS_POSIX)
|
||||
HandleShutdownSignals();
|
||||
#endif
|
||||
device::GeolocationProvider::SetGeolocationDelegate(
|
||||
new AtomGeolocationDelegate());
|
||||
}
|
||||
|
||||
void AtomBrowserMainParts::PostMainMessageLoopRun() {
|
||||
|
||||
@@ -26,10 +26,52 @@ bool WebContentsDestroyed(int process_id) {
|
||||
return contents->IsBeingDestroyed();
|
||||
}
|
||||
|
||||
void PermissionRequestResponseCallbackWrapper(
|
||||
const AtomPermissionManager::StatusCallback& callback,
|
||||
const std::vector<blink::mojom::PermissionStatus>& vector) {
|
||||
callback.Run(vector[0]);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
AtomPermissionManager::AtomPermissionManager()
|
||||
: request_id_(0) {
|
||||
class AtomPermissionManager::PendingRequest {
|
||||
public:
|
||||
PendingRequest(content::RenderFrameHost* render_frame_host,
|
||||
const std::vector<content::PermissionType>& permissions,
|
||||
const StatusesCallback& callback)
|
||||
: render_process_id_(render_frame_host->GetProcess()->GetID()),
|
||||
callback_(callback),
|
||||
results_(permissions.size(), blink::mojom::PermissionStatus::DENIED),
|
||||
remaining_results_(permissions.size()) {}
|
||||
|
||||
void SetPermissionStatus(int permission_id,
|
||||
blink::mojom::PermissionStatus status) {
|
||||
DCHECK(!IsComplete());
|
||||
|
||||
results_[permission_id] = status;
|
||||
--remaining_results_;
|
||||
}
|
||||
|
||||
int render_process_id() const {
|
||||
return render_process_id_;
|
||||
}
|
||||
|
||||
bool IsComplete() const {
|
||||
return remaining_results_ == 0;
|
||||
}
|
||||
|
||||
void RunCallback() const {
|
||||
callback_.Run(results_);
|
||||
}
|
||||
|
||||
private:
|
||||
int render_process_id_;
|
||||
const StatusesCallback callback_;
|
||||
std::vector<blink::mojom::PermissionStatus> results_;
|
||||
size_t remaining_results_;
|
||||
};
|
||||
|
||||
AtomPermissionManager::AtomPermissionManager() {
|
||||
}
|
||||
|
||||
AtomPermissionManager::~AtomPermissionManager() {
|
||||
@@ -37,12 +79,14 @@ AtomPermissionManager::~AtomPermissionManager() {
|
||||
|
||||
void AtomPermissionManager::SetPermissionRequestHandler(
|
||||
const RequestHandler& handler) {
|
||||
if (handler.is_null() && !pending_requests_.empty()) {
|
||||
for (const auto& request : pending_requests_) {
|
||||
if (!WebContentsDestroyed(request.second.render_process_id))
|
||||
request.second.callback.Run(blink::mojom::PermissionStatus::DENIED);
|
||||
if (handler.is_null() && !pending_requests_.IsEmpty()) {
|
||||
for (PendingRequestsMap::const_iterator iter(&pending_requests_);
|
||||
!iter.IsAtEnd(); iter.Advance()) {
|
||||
auto request = iter.GetCurrentValue();
|
||||
if (!WebContentsDestroyed(request->render_process_id()))
|
||||
request->RunCallback();
|
||||
}
|
||||
pending_requests_.clear();
|
||||
pending_requests_.Clear();
|
||||
}
|
||||
request_handler_ = handler;
|
||||
}
|
||||
@@ -51,71 +95,83 @@ int AtomPermissionManager::RequestPermission(
|
||||
content::PermissionType permission,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin,
|
||||
const ResponseCallback& response_callback) {
|
||||
int process_id = render_frame_host->GetProcess()->GetID();
|
||||
|
||||
if (permission == content::PermissionType::MIDI_SYSEX) {
|
||||
content::ChildProcessSecurityPolicy::GetInstance()->
|
||||
GrantSendMidiSysExMessage(process_id);
|
||||
}
|
||||
|
||||
if (!request_handler_.is_null()) {
|
||||
auto web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
++request_id_;
|
||||
auto callback = base::Bind(&AtomPermissionManager::OnPermissionResponse,
|
||||
base::Unretained(this),
|
||||
request_id_,
|
||||
requesting_origin,
|
||||
response_callback);
|
||||
pending_requests_[request_id_] = { process_id, callback };
|
||||
request_handler_.Run(web_contents, permission, callback);
|
||||
return request_id_;
|
||||
}
|
||||
|
||||
response_callback.Run(blink::mojom::PermissionStatus::GRANTED);
|
||||
return kNoPendingOperation;
|
||||
bool user_gesture,
|
||||
const StatusCallback& response_callback) {
|
||||
return RequestPermissions(
|
||||
std::vector<content::PermissionType>(1, permission),
|
||||
render_frame_host,
|
||||
requesting_origin,
|
||||
user_gesture,
|
||||
base::Bind(&PermissionRequestResponseCallbackWrapper, response_callback));
|
||||
}
|
||||
|
||||
int AtomPermissionManager::RequestPermissions(
|
||||
const std::vector<content::PermissionType>& permissions,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin,
|
||||
const base::Callback<void(
|
||||
const std::vector<blink::mojom::PermissionStatus>&)>& callback) {
|
||||
// FIXME(zcbenz): Just ignore multiple permissions request for now.
|
||||
std::vector<blink::mojom::PermissionStatus> permissionStatuses;
|
||||
for (auto permission : permissions) {
|
||||
bool user_gesture,
|
||||
const StatusesCallback& response_callback) {
|
||||
if (permissions.empty()) {
|
||||
response_callback.Run(std::vector<blink::mojom::PermissionStatus>());
|
||||
return kNoPendingOperation;
|
||||
}
|
||||
|
||||
if (request_handler_.is_null()) {
|
||||
std::vector<blink::mojom::PermissionStatus> statuses;
|
||||
for (auto permission : permissions) {
|
||||
if (permission == content::PermissionType::MIDI_SYSEX) {
|
||||
content::ChildProcessSecurityPolicy::GetInstance()->
|
||||
GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
|
||||
}
|
||||
statuses.push_back(blink::mojom::PermissionStatus::GRANTED);
|
||||
}
|
||||
response_callback.Run(statuses);
|
||||
return kNoPendingOperation;
|
||||
}
|
||||
|
||||
auto web_contents =
|
||||
content::WebContents::FromRenderFrameHost(render_frame_host);
|
||||
int request_id = pending_requests_.Add(new PendingRequest(
|
||||
render_frame_host, permissions, response_callback));
|
||||
|
||||
for (size_t i = 0; i < permissions.size(); ++i) {
|
||||
auto permission = permissions[i];
|
||||
if (permission == content::PermissionType::MIDI_SYSEX) {
|
||||
content::ChildProcessSecurityPolicy::GetInstance()->
|
||||
GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
|
||||
}
|
||||
permissionStatuses.push_back(blink::mojom::PermissionStatus::GRANTED);
|
||||
const auto callback =
|
||||
base::Bind(&AtomPermissionManager::OnPermissionResponse,
|
||||
base::Unretained(this), request_id, i);
|
||||
request_handler_.Run(web_contents, permission, callback);
|
||||
}
|
||||
callback.Run(permissionStatuses);
|
||||
return kNoPendingOperation;
|
||||
|
||||
return request_id;
|
||||
}
|
||||
|
||||
void AtomPermissionManager::OnPermissionResponse(
|
||||
int request_id,
|
||||
const GURL& origin,
|
||||
const ResponseCallback& callback,
|
||||
int permission_id,
|
||||
blink::mojom::PermissionStatus status) {
|
||||
auto request = pending_requests_.find(request_id);
|
||||
if (request != pending_requests_.end()) {
|
||||
if (!WebContentsDestroyed(request->second.render_process_id))
|
||||
callback.Run(status);
|
||||
pending_requests_.erase(request);
|
||||
auto pending_request = pending_requests_.Lookup(request_id);
|
||||
if (!pending_request)
|
||||
return;
|
||||
|
||||
pending_request->SetPermissionStatus(permission_id, status);
|
||||
if (pending_request->IsComplete()) {
|
||||
pending_request->RunCallback();
|
||||
pending_requests_.Remove(request_id);
|
||||
}
|
||||
}
|
||||
|
||||
void AtomPermissionManager::CancelPermissionRequest(int request_id) {
|
||||
auto request = pending_requests_.find(request_id);
|
||||
if (request != pending_requests_.end()) {
|
||||
if (!WebContentsDestroyed(request->second.render_process_id))
|
||||
request->second.callback.Run(blink::mojom::PermissionStatus::DENIED);
|
||||
pending_requests_.erase(request);
|
||||
}
|
||||
auto pending_request = pending_requests_.Lookup(request_id);
|
||||
if (!pending_request)
|
||||
return;
|
||||
|
||||
if (!WebContentsDestroyed(pending_request->render_process_id()))
|
||||
pending_request->RunCallback();
|
||||
pending_requests_.Remove(request_id);
|
||||
}
|
||||
|
||||
void AtomPermissionManager::ResetPermission(
|
||||
@@ -141,7 +197,7 @@ int AtomPermissionManager::SubscribePermissionStatusChange(
|
||||
content::PermissionType permission,
|
||||
const GURL& requesting_origin,
|
||||
const GURL& embedding_origin,
|
||||
const ResponseCallback& callback) {
|
||||
const StatusCallback& callback) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "base/id_map.h"
|
||||
#include "content/public/browser/permission_manager.h"
|
||||
|
||||
namespace content {
|
||||
@@ -22,12 +23,14 @@ class AtomPermissionManager : public content::PermissionManager {
|
||||
AtomPermissionManager();
|
||||
~AtomPermissionManager() override;
|
||||
|
||||
using ResponseCallback =
|
||||
using StatusCallback =
|
||||
base::Callback<void(blink::mojom::PermissionStatus)>;
|
||||
using StatusesCallback =
|
||||
base::Callback<void(const std::vector<blink::mojom::PermissionStatus>&)>;
|
||||
using RequestHandler =
|
||||
base::Callback<void(content::WebContents*,
|
||||
content::PermissionType,
|
||||
const ResponseCallback&)>;
|
||||
const StatusCallback&)>;
|
||||
|
||||
// Handler to dispatch permission requests in JS.
|
||||
void SetPermissionRequestHandler(const RequestHandler& handler);
|
||||
@@ -37,18 +40,21 @@ class AtomPermissionManager : public content::PermissionManager {
|
||||
content::PermissionType permission,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin,
|
||||
const ResponseCallback& callback) override;
|
||||
bool user_gesture,
|
||||
const base::Callback<void(blink::mojom::PermissionStatus)>& callback)
|
||||
override;
|
||||
int RequestPermissions(
|
||||
const std::vector<content::PermissionType>& permissions,
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const GURL& requesting_origin,
|
||||
bool user_gesture,
|
||||
const base::Callback<void(
|
||||
const std::vector<blink::mojom::PermissionStatus>&)>& callback) override;
|
||||
const std::vector<blink::mojom::PermissionStatus>&)>& callback)
|
||||
override;
|
||||
|
||||
protected:
|
||||
void OnPermissionResponse(int request_id,
|
||||
const GURL& url,
|
||||
const ResponseCallback& callback,
|
||||
int permission_id,
|
||||
blink::mojom::PermissionStatus status);
|
||||
|
||||
// content::PermissionManager:
|
||||
@@ -72,16 +78,12 @@ class AtomPermissionManager : public content::PermissionManager {
|
||||
void UnsubscribePermissionStatusChange(int subscription_id) override;
|
||||
|
||||
private:
|
||||
struct RequestInfo {
|
||||
int render_process_id;
|
||||
ResponseCallback callback;
|
||||
};
|
||||
class PendingRequest;
|
||||
using PendingRequestsMap = IDMap<PendingRequest, IDMapOwnPointer>;
|
||||
|
||||
RequestHandler request_handler_;
|
||||
|
||||
std::map<int, RequestInfo> pending_requests_;
|
||||
|
||||
int request_id_;
|
||||
PendingRequestsMap pending_requests_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomPermissionManager);
|
||||
};
|
||||
|
||||
@@ -81,7 +81,7 @@ void AtomSecurityStateModelClient::GetVisibleSecurityState(
|
||||
return;
|
||||
}
|
||||
|
||||
state->initialized = true;
|
||||
state->connection_info_initialized = true;
|
||||
state->url = entry->GetURL();
|
||||
const content::SSLStatus& ssl = entry->GetSSL();
|
||||
state->initial_security_level =
|
||||
@@ -91,14 +91,9 @@ void AtomSecurityStateModelClient::GetVisibleSecurityState(
|
||||
state->connection_status = ssl.connection_status;
|
||||
state->security_bits = ssl.security_bits;
|
||||
state->sct_verify_statuses.clear();
|
||||
state->sct_verify_statuses.insert(state->sct_verify_statuses.end(),
|
||||
ssl.num_unknown_scts,
|
||||
net::ct::SCT_STATUS_LOG_UNKNOWN);
|
||||
state->sct_verify_statuses.insert(state->sct_verify_statuses.end(),
|
||||
ssl.num_invalid_scts,
|
||||
net::ct::SCT_STATUS_INVALID);
|
||||
state->sct_verify_statuses.insert(state->sct_verify_statuses.end(),
|
||||
ssl.num_valid_scts, net::ct::SCT_STATUS_OK);
|
||||
state->sct_verify_statuses.insert(state->sct_verify_statuses.begin(),
|
||||
ssl.sct_statuses.begin(),
|
||||
ssl.sct_statuses.end());
|
||||
state->displayed_mixed_content =
|
||||
(ssl.content_status & content::SSLStatus::DISPLAYED_INSECURE_CONTENT)
|
||||
? true
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include "atom/browser/native_window.h"
|
||||
#include "atom/browser/window_list.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "brightray/browser/brightray_paths.h"
|
||||
|
||||
namespace atom {
|
||||
@@ -85,7 +85,7 @@ void Browser::Shutdown() {
|
||||
FOR_EACH_OBSERVER(BrowserObserver, observers_, OnQuit());
|
||||
|
||||
if (base::MessageLoop::current()) {
|
||||
base::MessageLoop::current()->PostTask(
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
|
||||
} else {
|
||||
// There is no message loop available so we are in early stage.
|
||||
|
||||
@@ -98,9 +98,11 @@ class Browser : public WindowListObserver {
|
||||
bool restore_state = false;
|
||||
bool opened_at_login = false;
|
||||
bool opened_as_hidden = false;
|
||||
base::string16 path;
|
||||
std::vector<base::string16> args;
|
||||
};
|
||||
void SetLoginItemSettings(LoginItemSettings settings);
|
||||
LoginItemSettings GetLoginItemSettings();
|
||||
LoginItemSettings GetLoginItemSettings(LoginItemSettings options);
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
// Hide the application.
|
||||
|
||||
@@ -63,7 +63,8 @@ bool Browser::SetBadgeCount(int count) {
|
||||
void Browser::SetLoginItemSettings(LoginItemSettings settings) {
|
||||
}
|
||||
|
||||
Browser::LoginItemSettings Browser::GetLoginItemSettings() {
|
||||
Browser::LoginItemSettings Browser::GetLoginItemSettings(
|
||||
LoginItemSettings options) {
|
||||
return LoginItemSettings();
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,8 @@ bool Browser::ContinueUserActivity(const std::string& type,
|
||||
return prevent_default;
|
||||
}
|
||||
|
||||
Browser::LoginItemSettings Browser::GetLoginItemSettings() {
|
||||
Browser::LoginItemSettings Browser::GetLoginItemSettings(
|
||||
LoginItemSettings options) {
|
||||
LoginItemSettings settings;
|
||||
settings.open_at_login = base::mac::CheckLoginItemStatus(
|
||||
&settings.open_as_hidden);
|
||||
|
||||
@@ -43,15 +43,19 @@ BOOL CALLBACK WindowsEnumerationHandler(HWND hwnd, LPARAM param) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool GetProcessExecPath(base::string16* exe) {
|
||||
base::FilePath path;
|
||||
if (!PathService::Get(base::FILE_EXE, &path)) {
|
||||
LOG(ERROR) << "Error getting app exe path";
|
||||
return false;
|
||||
}
|
||||
*exe = path.value();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetProtocolLaunchPath(mate::Arguments* args, base::string16* exe) {
|
||||
// Executable Path
|
||||
if (!args->GetNext(exe)) {
|
||||
base::FilePath path;
|
||||
if (!PathService::Get(base::FILE_EXE, &path)) {
|
||||
LOG(ERROR) << "Error getting app exe path";
|
||||
return false;
|
||||
}
|
||||
*exe = path.value();
|
||||
if (!args->GetNext(exe) && !GetProcessExecPath(exe)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read in optional args arg
|
||||
@@ -65,6 +69,22 @@ bool GetProtocolLaunchPath(mate::Arguments* args, base::string16* exe) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FormatCommandLineString(base::string16* exe,
|
||||
const std::vector<base::string16>& launch_args) {
|
||||
if (exe->empty() && !GetProcessExecPath(exe)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!launch_args.empty()) {
|
||||
base::string16 formatString = L"%s %s";
|
||||
*exe = base::StringPrintf(formatString.c_str(),
|
||||
exe->c_str(),
|
||||
base::JoinString(launch_args, L" ").c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void Browser::Focus() {
|
||||
@@ -257,34 +277,32 @@ void Browser::SetLoginItemSettings(LoginItemSettings settings) {
|
||||
base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS);
|
||||
|
||||
if (settings.open_at_login) {
|
||||
base::FilePath path;
|
||||
if (PathService::Get(base::FILE_EXE, &path)) {
|
||||
base::string16 exePath(path.value());
|
||||
key.WriteValue(GetAppUserModelID(), exePath.c_str());
|
||||
base::string16 exe = settings.path;
|
||||
if (FormatCommandLineString(&exe, settings.args)) {
|
||||
key.WriteValue(GetAppUserModelID(), exe.c_str());
|
||||
}
|
||||
} else {
|
||||
key.DeleteValue(GetAppUserModelID());
|
||||
}
|
||||
}
|
||||
|
||||
Browser::LoginItemSettings Browser::GetLoginItemSettings() {
|
||||
Browser::LoginItemSettings Browser::GetLoginItemSettings(
|
||||
LoginItemSettings options) {
|
||||
LoginItemSettings settings;
|
||||
base::string16 keyPath = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
||||
base::win::RegKey key(HKEY_CURRENT_USER, keyPath.c_str(), KEY_ALL_ACCESS);
|
||||
base::string16 keyVal;
|
||||
|
||||
if (!FAILED(key.ReadValue(GetAppUserModelID(), &keyVal))) {
|
||||
base::FilePath path;
|
||||
if (PathService::Get(base::FILE_EXE, &path)) {
|
||||
base::string16 exePath(path.value());
|
||||
settings.open_at_login = keyVal == exePath;
|
||||
base::string16 exe = options.path;
|
||||
if (FormatCommandLineString(&exe, options.args)) {
|
||||
settings.open_at_login = keyVal == exe;
|
||||
}
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
PCWSTR Browser::GetAppUserModelID() {
|
||||
if (app_user_model_id_.empty()) {
|
||||
SetAppUserModelID(base::ReplaceStringPlaceholders(
|
||||
|
||||
@@ -331,14 +331,14 @@ content::SecurityStyle CommonWebContentsDelegate::GetSecurityStyle(
|
||||
|
||||
explanations->ran_insecure_content =
|
||||
security_info.mixed_content_status ==
|
||||
SecurityStateModel::RAN_MIXED_CONTENT ||
|
||||
security_state::SecurityStateModel::CONTENT_STATUS_RAN ||
|
||||
security_info.mixed_content_status ==
|
||||
SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT;
|
||||
security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN;
|
||||
explanations->displayed_insecure_content =
|
||||
security_info.mixed_content_status ==
|
||||
SecurityStateModel::DISPLAYED_MIXED_CONTENT ||
|
||||
security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED ||
|
||||
security_info.mixed_content_status ==
|
||||
SecurityStateModel::RAN_AND_DISPLAYED_MIXED_CONTENT;
|
||||
security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED_AND_RAN;
|
||||
|
||||
if (net::IsCertStatusError(security_info.cert_status)) {
|
||||
std::string error_string = net::ErrorToString(
|
||||
@@ -364,13 +364,6 @@ content::SecurityStyle CommonWebContentsDelegate::GetSecurityStyle(
|
||||
}
|
||||
}
|
||||
|
||||
if (security_info.is_secure_protocol_and_ciphersuite) {
|
||||
explanations->secure_explanations.push_back(
|
||||
content::SecurityStyleExplanation(
|
||||
kSecureProtocol,
|
||||
kSecureProtocolDescription));
|
||||
}
|
||||
|
||||
return security_style;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,8 +89,12 @@ void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) {
|
||||
}
|
||||
}
|
||||
|
||||
void BluetoothChooser::AddDevice(const std::string& device_id,
|
||||
const base::string16& device_name) {
|
||||
void BluetoothChooser::AddOrUpdateDevice(const std::string& device_id,
|
||||
bool should_update_name,
|
||||
const base::string16& device_name,
|
||||
bool is_gatt_connected,
|
||||
bool is_paired,
|
||||
int signal_strength_level) {
|
||||
DeviceInfo info = {device_id, device_name};
|
||||
device_list_.push_back(info);
|
||||
}
|
||||
|
||||
@@ -27,8 +27,12 @@ class BluetoothChooser : public content::BluetoothChooser {
|
||||
// content::BluetoothChooser:
|
||||
void SetAdapterPresence(AdapterPresence presence) override;
|
||||
void ShowDiscoveryState(DiscoveryState state) override;
|
||||
void AddDevice(const std::string& device_id,
|
||||
const base::string16& device_name) override;
|
||||
void AddOrUpdateDevice(const std::string& device_id,
|
||||
bool should_update_name,
|
||||
const base::string16& device_name,
|
||||
bool is_gatt_connected,
|
||||
bool is_paired,
|
||||
int signal_strength_level) override;
|
||||
void RemoveDevice(const std::string& device_id) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "base/json/json_writer.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "brightray/browser/inspectable_web_contents.h"
|
||||
#include "brightray/browser/inspectable_web_contents_view.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
@@ -604,7 +605,7 @@ void NativeWindow::DidFirstVisuallyNonEmptyPaint() {
|
||||
view->SetSize(GetContentSize());
|
||||
|
||||
// Emit the ReadyToShow event in next tick in case of pending drawing work.
|
||||
base::MessageLoop::current()->PostTask(
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&NativeWindow::NotifyReadyToShow, GetWeakPtr()));
|
||||
}
|
||||
@@ -635,7 +636,7 @@ void NativeWindow::ScheduleUnresponsiveEvent(int ms) {
|
||||
window_unresposive_closure_.Reset(
|
||||
base::Bind(&NativeWindow::NotifyWindowUnresponsive,
|
||||
weak_factory_.GetWeakPtr()));
|
||||
base::MessageLoop::current()->PostDelayedTask(
|
||||
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
||||
FROM_HERE,
|
||||
window_unresposive_closure_.callback(),
|
||||
base::TimeDelta::FromMilliseconds(ms));
|
||||
|
||||
@@ -119,7 +119,9 @@ class NativeWindow : public base::SupportsUserData,
|
||||
virtual void SetClosable(bool closable) = 0;
|
||||
virtual bool IsClosable() = 0;
|
||||
virtual void SetAlwaysOnTop(bool top,
|
||||
const std::string& level = "floating") = 0;
|
||||
const std::string& level = "floating",
|
||||
int relativeLevel = 0,
|
||||
std::string* error = nullptr) = 0;
|
||||
virtual bool IsAlwaysOnTop() = 0;
|
||||
virtual void Center() = 0;
|
||||
virtual void SetTitle(const std::string& title) = 0;
|
||||
|
||||
@@ -67,7 +67,8 @@ class NativeWindowMac : public NativeWindow,
|
||||
bool IsFullScreenable() override;
|
||||
void SetClosable(bool closable) override;
|
||||
bool IsClosable() override;
|
||||
void SetAlwaysOnTop(bool top, const std::string& level) override;
|
||||
void SetAlwaysOnTop(bool top, const std::string& level,
|
||||
int relativeLevel, std::string* error) override;
|
||||
bool IsAlwaysOnTop() override;
|
||||
void Center() override;
|
||||
void SetTitle(const std::string& title) override;
|
||||
@@ -162,6 +163,8 @@ class NativeWindowMac : public NativeWindow,
|
||||
|
||||
bool is_kiosk_;
|
||||
|
||||
bool was_fullscreen_;
|
||||
|
||||
bool zoom_to_page_width_;
|
||||
|
||||
NSInteger attention_request_id_; // identifier from requestUserAttention
|
||||
|
||||
@@ -619,6 +619,7 @@ NativeWindowMac::NativeWindowMac(
|
||||
NativeWindow* parent)
|
||||
: NativeWindow(web_contents, options, parent),
|
||||
is_kiosk_(false),
|
||||
was_fullscreen_(false),
|
||||
zoom_to_page_width_(false),
|
||||
attention_request_id_(0),
|
||||
title_bar_style_(NORMAL) {
|
||||
@@ -1055,8 +1056,12 @@ bool NativeWindowMac::IsClosable() {
|
||||
return [window_ styleMask] & NSClosableWindowMask;
|
||||
}
|
||||
|
||||
void NativeWindowMac::SetAlwaysOnTop(bool top, const std::string& level) {
|
||||
void NativeWindowMac::SetAlwaysOnTop(bool top, const std::string& level,
|
||||
int relativeLevel, std::string* error) {
|
||||
int windowLevel = NSNormalWindowLevel;
|
||||
CGWindowLevel maxWindowLevel = CGWindowLevelForKey(kCGMaximumWindowLevelKey);
|
||||
CGWindowLevel minWindowLevel = CGWindowLevelForKey(kCGMinimumWindowLevelKey);
|
||||
|
||||
if (top) {
|
||||
if (level == "floating") {
|
||||
windowLevel = NSFloatingWindowLevel;
|
||||
@@ -1077,7 +1082,15 @@ void NativeWindowMac::SetAlwaysOnTop(bool top, const std::string& level) {
|
||||
windowLevel = NSDockWindowLevel;
|
||||
}
|
||||
}
|
||||
[window_ setLevel:windowLevel];
|
||||
|
||||
NSInteger newLevel = windowLevel + relativeLevel;
|
||||
if (newLevel >= minWindowLevel && newLevel <= maxWindowLevel) {
|
||||
[window_ setLevel:newLevel];
|
||||
} else {
|
||||
*error = std::string([[NSString stringWithFormat:
|
||||
@"relativeLevel must be between %d and %d", minWindowLevel,
|
||||
maxWindowLevel] UTF8String]);
|
||||
}
|
||||
}
|
||||
|
||||
bool NativeWindowMac::IsAlwaysOnTop() {
|
||||
@@ -1126,10 +1139,11 @@ void NativeWindowMac::SetKiosk(bool kiosk) {
|
||||
NSApplicationPresentationDisableHideApplication;
|
||||
[NSApp setPresentationOptions:options];
|
||||
is_kiosk_ = true;
|
||||
SetFullScreen(true);
|
||||
was_fullscreen_ = IsFullscreen();
|
||||
if (!was_fullscreen_) SetFullScreen(true);
|
||||
} else if (!kiosk && is_kiosk_) {
|
||||
is_kiosk_ = false;
|
||||
SetFullScreen(false);
|
||||
if (!was_fullscreen_) SetFullScreen(false);
|
||||
[NSApp setPresentationOptions:kiosk_options_];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,6 +487,20 @@ void NativeWindowViews::SetFullScreen(bool fullscreen) {
|
||||
NotifyWindowLeaveFullScreen();
|
||||
}
|
||||
|
||||
// For window without WS_THICKFRAME style, we can not call SetFullscreen().
|
||||
// This path will be used for transparent windows as well.
|
||||
if (!thick_frame_) {
|
||||
if (fullscreen) {
|
||||
restore_bounds_ = GetBounds();
|
||||
auto display =
|
||||
display::Screen::GetScreen()->GetDisplayNearestPoint(GetPosition());
|
||||
SetBounds(display.bounds(), false);
|
||||
} else {
|
||||
SetBounds(restore_bounds_, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// We set the new value after notifying, so we can handle the size event
|
||||
// correctly.
|
||||
window_->SetFullscreen(fullscreen);
|
||||
@@ -668,7 +682,8 @@ bool NativeWindowViews::IsClosable() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void NativeWindowViews::SetAlwaysOnTop(bool top, const std::string& level) {
|
||||
void NativeWindowViews::SetAlwaysOnTop(bool top, const std::string& level,
|
||||
int relativeLevel, std::string* error) {
|
||||
window_->SetAlwaysOnTop(top);
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,8 @@ class NativeWindowViews : public NativeWindow,
|
||||
bool IsFullScreenable() override;
|
||||
void SetClosable(bool closable) override;
|
||||
bool IsClosable() override;
|
||||
void SetAlwaysOnTop(bool top, const std::string& level) override;
|
||||
void SetAlwaysOnTop(bool top, const std::string& level,
|
||||
int relativeLevel, std::string* error) override;
|
||||
bool IsAlwaysOnTop() override;
|
||||
void Center() override;
|
||||
void SetTitle(const std::string& title) override;
|
||||
|
||||
@@ -232,7 +232,7 @@ int AtomNetworkDelegate::OnBeforeURLRequest(
|
||||
net::URLRequest* request,
|
||||
const net::CompletionCallback& callback,
|
||||
GURL* new_url) {
|
||||
if (!ContainsKey(response_listeners_, kOnBeforeRequest))
|
||||
if (!base::ContainsKey(response_listeners_, kOnBeforeRequest))
|
||||
return brightray::NetworkDelegate::OnBeforeURLRequest(
|
||||
request, callback, new_url);
|
||||
|
||||
@@ -253,7 +253,7 @@ int AtomNetworkDelegate::OnBeforeStartTransaction(
|
||||
headers->SetHeader(
|
||||
DevToolsNetworkTransaction::kDevToolsEmulateNetworkConditionsClientId,
|
||||
client_id);
|
||||
if (!ContainsKey(response_listeners_, kOnBeforeSendHeaders))
|
||||
if (!base::ContainsKey(response_listeners_, kOnBeforeSendHeaders))
|
||||
return brightray::NetworkDelegate::OnBeforeStartTransaction(
|
||||
request, callback, headers);
|
||||
|
||||
@@ -264,7 +264,7 @@ int AtomNetworkDelegate::OnBeforeStartTransaction(
|
||||
void AtomNetworkDelegate::OnStartTransaction(
|
||||
net::URLRequest* request,
|
||||
const net::HttpRequestHeaders& headers) {
|
||||
if (!ContainsKey(simple_listeners_, kOnSendHeaders)) {
|
||||
if (!base::ContainsKey(simple_listeners_, kOnSendHeaders)) {
|
||||
brightray::NetworkDelegate::OnStartTransaction(request, headers);
|
||||
return;
|
||||
}
|
||||
@@ -278,7 +278,7 @@ int AtomNetworkDelegate::OnHeadersReceived(
|
||||
const net::HttpResponseHeaders* original,
|
||||
scoped_refptr<net::HttpResponseHeaders>* override,
|
||||
GURL* allowed) {
|
||||
if (!ContainsKey(response_listeners_, kOnHeadersReceived))
|
||||
if (!base::ContainsKey(response_listeners_, kOnHeadersReceived))
|
||||
return brightray::NetworkDelegate::OnHeadersReceived(
|
||||
request, callback, original, override, allowed);
|
||||
|
||||
@@ -289,7 +289,7 @@ int AtomNetworkDelegate::OnHeadersReceived(
|
||||
|
||||
void AtomNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
|
||||
const GURL& new_location) {
|
||||
if (!ContainsKey(simple_listeners_, kOnBeforeRedirect)) {
|
||||
if (!base::ContainsKey(simple_listeners_, kOnBeforeRedirect)) {
|
||||
brightray::NetworkDelegate::OnBeforeRedirect(request, new_location);
|
||||
return;
|
||||
}
|
||||
@@ -300,7 +300,7 @@ void AtomNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
|
||||
}
|
||||
|
||||
void AtomNetworkDelegate::OnResponseStarted(net::URLRequest* request) {
|
||||
if (!ContainsKey(simple_listeners_, kOnResponseStarted)) {
|
||||
if (!base::ContainsKey(simple_listeners_, kOnResponseStarted)) {
|
||||
brightray::NetworkDelegate::OnResponseStarted(request);
|
||||
return;
|
||||
}
|
||||
@@ -329,7 +329,7 @@ void AtomNetworkDelegate::OnCompleted(net::URLRequest* request, bool started) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ContainsKey(simple_listeners_, kOnCompleted)) {
|
||||
if (!base::ContainsKey(simple_listeners_, kOnCompleted)) {
|
||||
brightray::NetworkDelegate::OnCompleted(request, started);
|
||||
return;
|
||||
}
|
||||
@@ -344,7 +344,7 @@ void AtomNetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) {
|
||||
|
||||
void AtomNetworkDelegate::OnErrorOccurred(
|
||||
net::URLRequest* request, bool started) {
|
||||
if (!ContainsKey(simple_listeners_, kOnErrorOccurred)) {
|
||||
if (!base::ContainsKey(simple_listeners_, kOnErrorOccurred)) {
|
||||
brightray::NetworkDelegate::OnCompleted(request, started);
|
||||
return;
|
||||
}
|
||||
@@ -399,7 +399,7 @@ template<typename T>
|
||||
void AtomNetworkDelegate::OnListenerResultInIO(
|
||||
uint64_t id, T out, std::unique_ptr<base::DictionaryValue> response) {
|
||||
// The request has been destroyed.
|
||||
if (!ContainsKey(callbacks_, id))
|
||||
if (!base::ContainsKey(callbacks_, id))
|
||||
return;
|
||||
|
||||
ReadFromResponseObject(*response.get(), out);
|
||||
|
||||
@@ -36,7 +36,7 @@ bool AtomURLRequestJobFactory::SetProtocolHandler(
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ContainsKey(protocol_handler_map_, scheme))
|
||||
if (base::ContainsKey(protocol_handler_map_, scheme))
|
||||
return false;
|
||||
protocol_handler_map_[scheme] = protocol_handler.release();
|
||||
return true;
|
||||
@@ -45,8 +45,8 @@ bool AtomURLRequestJobFactory::SetProtocolHandler(
|
||||
bool AtomURLRequestJobFactory::InterceptProtocol(
|
||||
const std::string& scheme,
|
||||
std::unique_ptr<ProtocolHandler> protocol_handler) {
|
||||
if (!ContainsKey(protocol_handler_map_, scheme) ||
|
||||
ContainsKey(original_protocols_, scheme))
|
||||
if (!base::ContainsKey(protocol_handler_map_, scheme) ||
|
||||
base::ContainsKey(original_protocols_, scheme))
|
||||
return false;
|
||||
ProtocolHandler* original_protocol_handler = protocol_handler_map_[scheme];
|
||||
protocol_handler_map_[scheme] = protocol_handler.release();
|
||||
@@ -74,11 +74,11 @@ ProtocolHandler* AtomURLRequestJobFactory::GetProtocolHandler(
|
||||
|
||||
bool AtomURLRequestJobFactory::HasProtocolHandler(
|
||||
const std::string& scheme) const {
|
||||
return ContainsKey(protocol_handler_map_, scheme);
|
||||
return base::ContainsKey(protocol_handler_map_, scheme);
|
||||
}
|
||||
|
||||
void AtomURLRequestJobFactory::Clear() {
|
||||
STLDeleteValues(&protocol_handler_map_);
|
||||
base::STLDeleteValues(&protocol_handler_map_);
|
||||
}
|
||||
|
||||
net::URLRequestJob* AtomURLRequestJobFactory::MaybeCreateJobWithProtocolHandler(
|
||||
|
||||
@@ -51,8 +51,9 @@ NodeDebugger::NodeDebugger(v8::Isolate* isolate)
|
||||
base::StringToInt(port_str, &port);
|
||||
|
||||
isolate_->SetData(kIsolateSlot, this);
|
||||
v8::Debug::SetMessageHandler(DebugMessageHandler);
|
||||
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.
|
||||
@@ -64,7 +65,7 @@ NodeDebugger::NodeDebugger(v8::Isolate* isolate)
|
||||
}
|
||||
|
||||
// Start the server in new IO thread.
|
||||
thread_.message_loop()->PostTask(
|
||||
thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&NodeDebugger::StartServer, weak_factory_.GetWeakPtr(),
|
||||
port));
|
||||
@@ -126,7 +127,8 @@ void NodeDebugger::SendConnectMessage() {
|
||||
|
||||
// static
|
||||
void NodeDebugger::ProcessMessageInUI(uv_async_t* handle) {
|
||||
v8::Debug::ProcessDebugMessages();
|
||||
NodeDebugger* self = static_cast<NodeDebugger*>(handle->data);
|
||||
v8::Debug::ProcessDebugMessages(self->isolate_);
|
||||
}
|
||||
|
||||
// static
|
||||
@@ -136,7 +138,7 @@ void NodeDebugger::DebugMessageHandler(const v8::Debug::Message& message) {
|
||||
|
||||
if (self) {
|
||||
std::string message8(*v8::String::Utf8Value(message.GetJSON()));
|
||||
self->thread_.message_loop()->PostTask(
|
||||
self->thread_.task_runner()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&NodeDebugger::SendMessage, self->weak_factory_.GetWeakPtr(),
|
||||
message8));
|
||||
|
||||
@@ -302,8 +302,8 @@ class AtomBeginFrameTimer : public cc::DelayBasedTimeSourceClient {
|
||||
const base::Closure& callback)
|
||||
: callback_(callback) {
|
||||
time_source_.reset(new cc::DelayBasedTimeSource(
|
||||
content::BrowserThread::GetMessageLoopProxyForThread(
|
||||
content::BrowserThread::UI).get()));
|
||||
content::BrowserThread::GetTaskRunnerForThread(
|
||||
content::BrowserThread::UI).get()));
|
||||
time_source_->SetClient(this);
|
||||
}
|
||||
|
||||
@@ -424,7 +424,7 @@ bool OffScreenRenderWidgetHostView::OnMessageReceived(
|
||||
bool handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(OffScreenRenderWidgetHostView, message)
|
||||
IPC_MESSAGE_HANDLER(ViewHostMsg_SetNeedsBeginFrames,
|
||||
OnSetNeedsBeginFrames)
|
||||
SetNeedsBeginFrames)
|
||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||
IPC_END_MESSAGE_MAP()
|
||||
|
||||
@@ -678,22 +678,6 @@ bool OffScreenRenderWidgetHostView::HasAcceleratedSurface(const gfx::Size &) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void OffScreenRenderWidgetHostView::GetScreenInfo(
|
||||
blink::WebScreenInfo* results) {
|
||||
results->rect = gfx::Rect(size_);
|
||||
results->availableRect = gfx::Rect(size_);
|
||||
results->depth = 24;
|
||||
results->depthPerComponent = 8;
|
||||
results->deviceScaleFactor = scale_factor_;
|
||||
results->orientationAngle = 0;
|
||||
results->orientationType = blink::WebScreenOrientationLandscapePrimary;
|
||||
}
|
||||
|
||||
bool OffScreenRenderWidgetHostView::GetScreenColorProfile(
|
||||
blink::WebVector<char>*) {
|
||||
return false;
|
||||
}
|
||||
|
||||
gfx::Rect OffScreenRenderWidgetHostView::GetBoundsInRootWindow() {
|
||||
return gfx::Rect(size_);
|
||||
}
|
||||
@@ -716,12 +700,7 @@ gfx::Size OffScreenRenderWidgetHostView::GetRequestedRendererSize() const {
|
||||
return size_;
|
||||
}
|
||||
|
||||
int OffScreenRenderWidgetHostView::
|
||||
DelegatedFrameHostGetGpuMemoryBufferClientId()
|
||||
const {
|
||||
return render_widget_host_->GetProcess()->GetID();
|
||||
}
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
ui::Layer* OffScreenRenderWidgetHostView::DelegatedFrameHostGetLayer() const {
|
||||
return const_cast<ui::Layer*>(root_layer_.get());
|
||||
}
|
||||
@@ -754,19 +733,14 @@ void OffScreenRenderWidgetHostView::DelegatedFrameHostResizeLockWasReleased() {
|
||||
return render_widget_host_->WasResized();
|
||||
}
|
||||
|
||||
void OffScreenRenderWidgetHostView::DelegatedFrameHostSendCompositorSwapAck(
|
||||
int output_surface_id, const cc::CompositorFrameAck& ack) {
|
||||
render_widget_host_->Send(new ViewMsg_SwapCompositorFrameAck(
|
||||
render_widget_host_->GetRoutingID(),
|
||||
output_surface_id, ack));
|
||||
}
|
||||
|
||||
void OffScreenRenderWidgetHostView::
|
||||
DelegatedFrameHostSendReclaimCompositorResources(
|
||||
int output_surface_id, const cc::CompositorFrameAck& ack) {
|
||||
void
|
||||
OffScreenRenderWidgetHostView::DelegatedFrameHostSendReclaimCompositorResources(
|
||||
int output_surface_id,
|
||||
bool is_swap_ack,
|
||||
const cc::ReturnedResourceArray& resources) {
|
||||
render_widget_host_->Send(new ViewMsg_ReclaimCompositorResources(
|
||||
render_widget_host_->GetRoutingID(),
|
||||
output_surface_id, ack));
|
||||
render_widget_host_->GetRoutingID(), output_surface_id, is_swap_ack,
|
||||
resources));
|
||||
}
|
||||
|
||||
void OffScreenRenderWidgetHostView::
|
||||
@@ -783,6 +757,8 @@ void OffScreenRenderWidgetHostView::SetBeginFrameSource(
|
||||
cc::BeginFrameSource* source) {
|
||||
}
|
||||
|
||||
#endif // !defined(OS_MACOSX)
|
||||
|
||||
std::unique_ptr<cc::SoftwareOutputDevice>
|
||||
OffScreenRenderWidgetHostView::CreateSoftwareOutputDevice(
|
||||
ui::Compositor* compositor) {
|
||||
@@ -814,13 +790,14 @@ bool OffScreenRenderWidgetHostView::IsAutoResizeEnabled() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void OffScreenRenderWidgetHostView::OnSetNeedsBeginFrames(bool enabled) {
|
||||
void OffScreenRenderWidgetHostView::SetNeedsBeginFrames(
|
||||
bool needs_begin_frames) {
|
||||
SetupFrameRate(false);
|
||||
|
||||
begin_frame_timer_->SetActive(enabled);
|
||||
begin_frame_timer_->SetActive(needs_begin_frames);
|
||||
|
||||
if (software_output_device_) {
|
||||
software_output_device_->SetActive(enabled && painting_);
|
||||
software_output_device_->SetActive(needs_begin_frames && painting_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,9 @@ class MacHelper;
|
||||
class OffScreenRenderWidgetHostView
|
||||
: public content::RenderWidgetHostViewBase,
|
||||
public ui::CompositorDelegate,
|
||||
#if !defined(OS_MACOSX)
|
||||
public content::DelegatedFrameHostClient,
|
||||
#endif
|
||||
public NativeWindowObserver {
|
||||
public:
|
||||
OffScreenRenderWidgetHostView(bool transparent,
|
||||
@@ -92,6 +94,7 @@ class OffScreenRenderWidgetHostView
|
||||
void SetBackgroundColor(SkColor color) override;
|
||||
bool LockMouse(void) override;
|
||||
void UnlockMouse(void) override;
|
||||
void SetNeedsBeginFrames(bool needs_begin_frames) override;
|
||||
#if defined(OS_MACOSX)
|
||||
ui::AcceleratedWidgetMac* GetAcceleratedWidgetMac() const override;
|
||||
void SetActive(bool active) override;
|
||||
@@ -137,8 +140,6 @@ class OffScreenRenderWidgetHostView
|
||||
std::unique_ptr<content::RenderWidgetHostViewFrameSubscriber>) override;
|
||||
void EndFrameSubscription() override;
|
||||
bool HasAcceleratedSurface(const gfx::Size &) override;
|
||||
void GetScreenInfo(blink::WebScreenInfo *) override;
|
||||
bool GetScreenColorProfile(blink::WebVector<char>*);
|
||||
gfx::Rect GetBoundsInRootWindow(void) override;
|
||||
void LockCompositingSurface(void) override;
|
||||
void UnlockCompositingSurface(void) override;
|
||||
@@ -147,6 +148,7 @@ class OffScreenRenderWidgetHostView
|
||||
gfx::Size GetPhysicalBackingSize() const override;
|
||||
gfx::Size GetRequestedRendererSize() const override;
|
||||
|
||||
#if !defined(OS_MACOSX)
|
||||
// content::DelegatedFrameHostClient:
|
||||
int DelegatedFrameHostGetGpuMemoryBufferClientId(void) const;
|
||||
ui::Layer *DelegatedFrameHostGetLayer(void) const override;
|
||||
@@ -157,14 +159,15 @@ class OffScreenRenderWidgetHostView
|
||||
std::unique_ptr<content::ResizeLock> DelegatedFrameHostCreateResizeLock(
|
||||
bool defer_compositor_lock) override;
|
||||
void DelegatedFrameHostResizeLockWasReleased(void) override;
|
||||
void DelegatedFrameHostSendCompositorSwapAck(
|
||||
int, const cc::CompositorFrameAck &) override;
|
||||
void DelegatedFrameHostSendReclaimCompositorResources(
|
||||
int, const cc::CompositorFrameAck &) override;
|
||||
int output_surface_id,
|
||||
bool is_swap_ack,
|
||||
const cc::ReturnedResourceArray& resources) override;
|
||||
void DelegatedFrameHostOnLostCompositorResources(void) override;
|
||||
void DelegatedFrameHostUpdateVSyncParameters(
|
||||
const base::TimeTicks &, const base::TimeDelta &) override;
|
||||
void SetBeginFrameSource(cc::BeginFrameSource* source) override;
|
||||
#endif // !defined(OS_MACOSX)
|
||||
|
||||
// ui::CompositorDelegate:
|
||||
std::unique_ptr<cc::SoftwareOutputDevice> CreateSoftwareOutputDevice(
|
||||
@@ -172,7 +175,6 @@ class OffScreenRenderWidgetHostView
|
||||
|
||||
bool InstallTransparency();
|
||||
bool IsAutoResizeEnabled() const;
|
||||
void OnSetNeedsBeginFrames(bool enabled);
|
||||
|
||||
// NativeWindowObserver:
|
||||
void OnWindowResize() override;
|
||||
@@ -204,6 +206,8 @@ class OffScreenRenderWidgetHostView
|
||||
content::RenderWidgetHostImpl* render_widget_host() const
|
||||
{ return render_widget_host_; }
|
||||
NativeWindow* window() const { return native_window_; }
|
||||
gfx::Size size() const { return size_; }
|
||||
float scale_factor() const { return scale_factor_; }
|
||||
|
||||
private:
|
||||
void SetupFrameRate(bool force);
|
||||
|
||||
@@ -38,18 +38,13 @@ class MacHelper :
|
||||
return color;
|
||||
}
|
||||
|
||||
void BrowserCompositorMacSendCompositorSwapAck(
|
||||
int output_surface_id,
|
||||
const cc::CompositorFrameAck& ack) override {
|
||||
view_->render_widget_host()->Send(new ViewMsg_SwapCompositorFrameAck(
|
||||
view_->render_widget_host()->GetRoutingID(), output_surface_id, ack));
|
||||
}
|
||||
|
||||
void BrowserCompositorMacSendReclaimCompositorResources(
|
||||
int output_surface_id,
|
||||
const cc::CompositorFrameAck& ack) override {
|
||||
bool is_swap_ack,
|
||||
const cc::ReturnedResourceArray& resources) override {
|
||||
view_->render_widget_host()->Send(new ViewMsg_ReclaimCompositorResources(
|
||||
view_->render_widget_host()->GetRoutingID(), output_surface_id, ack));
|
||||
view_->render_widget_host()->GetRoutingID(), output_surface_id,
|
||||
is_swap_ack, resources));
|
||||
}
|
||||
|
||||
void BrowserCompositorMacOnLostCompositorResources() override {
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "atom/browser/osr/osr_web_contents_view.h"
|
||||
|
||||
#include "third_party/WebKit/public/platform/WebScreenInfo.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
OffScreenWebContentsView::OffScreenWebContentsView(
|
||||
@@ -106,6 +108,18 @@ void OffScreenWebContentsView::RenderViewSwappedIn(
|
||||
void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled) {
|
||||
}
|
||||
|
||||
void OffScreenWebContentsView::GetScreenInfo(
|
||||
blink::WebScreenInfo* web_screen_info) const {
|
||||
web_screen_info->rect = gfx::Rect(view_->size());
|
||||
web_screen_info->availableRect = gfx::Rect(view_->size());
|
||||
web_screen_info->depth = 24;
|
||||
web_screen_info->depthPerComponent = 8;
|
||||
web_screen_info->deviceScaleFactor = view_->scale_factor();
|
||||
web_screen_info->orientationAngle = 0;
|
||||
web_screen_info->orientationType =
|
||||
blink::WebScreenOrientationLandscapePrimary;
|
||||
}
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
void OffScreenWebContentsView::SetAllowOtherViews(bool allow) {
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ class OffScreenWebContentsView : public content::WebContentsView,
|
||||
void RenderViewCreated(content::RenderViewHost* host) override;
|
||||
void RenderViewSwappedIn(content::RenderViewHost* host) override;
|
||||
void SetOverscrollControllerEnabled(bool enabled) override;
|
||||
void GetScreenInfo(blink::WebScreenInfo* web_screen_info) const override;
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
void SetAllowOtherViews(bool allow) override;
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>electron.icns</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.4.14</string>
|
||||
<string>1.5.1</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.4.14</string>
|
||||
<string>1.5.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,4,14,0
|
||||
PRODUCTVERSION 1,4,14,0
|
||||
FILEVERSION 1,5,1,0
|
||||
PRODUCTVERSION 1,5,1,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -74,12 +74,12 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "GitHub, Inc."
|
||||
VALUE "FileDescription", "Electron"
|
||||
VALUE "FileVersion", "1.4.14"
|
||||
VALUE "FileVersion", "1.5.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.4.14"
|
||||
VALUE "ProductVersion", "1.5.1"
|
||||
VALUE "SquirrelAwareVersion", "1"
|
||||
END
|
||||
END
|
||||
|
||||
@@ -88,7 +88,7 @@ void GenerateAcceleratorTable(AcceleratorTable* table,
|
||||
|
||||
bool TriggerAcceleratorTableCommand(AcceleratorTable* table,
|
||||
const ui::Accelerator& accelerator) {
|
||||
if (ContainsKey(*table, accelerator)) {
|
||||
if (base::ContainsKey(*table, accelerator)) {
|
||||
const accelerator_util::MenuItem& item = (*table)[accelerator];
|
||||
if (item.model->IsEnabledAt(item.position)) {
|
||||
item.model->ActivatedAt(item.position);
|
||||
|
||||
@@ -23,7 +23,7 @@ void AtomMenuModel::SetRole(int index, const base::string16& role) {
|
||||
|
||||
base::string16 AtomMenuModel::GetRoleAt(int index) {
|
||||
int command_id = GetCommandIdAt(index);
|
||||
if (ContainsKey(roles_, command_id))
|
||||
if (base::ContainsKey(roles_, command_id))
|
||||
return roles_[command_id];
|
||||
else
|
||||
return base::string16();
|
||||
|
||||
@@ -26,7 +26,7 @@ class AtomMenuModel : public ui::SimpleMenuModel {
|
||||
private:
|
||||
// ui::SimpleMenuModel::Delegate:
|
||||
bool GetAcceleratorForCommandId(int command_id,
|
||||
ui::Accelerator* accelerator) {
|
||||
ui::Accelerator* accelerator) const {
|
||||
return GetAcceleratorForCommandIdWithParams(
|
||||
command_id, false, accelerator);
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ enum FileDialogProperty {
|
||||
FILE_DIALOG_MULTI_SELECTIONS = 1 << 2,
|
||||
FILE_DIALOG_CREATE_DIRECTORY = 1 << 3,
|
||||
FILE_DIALOG_SHOW_HIDDEN_FILES = 1 << 4,
|
||||
FILE_DIALOG_PROMPT_TO_CREATE = 1 << 5,
|
||||
};
|
||||
|
||||
typedef base::Callback<void(
|
||||
|
||||
@@ -205,6 +205,8 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window,
|
||||
options |= FOS_ALLOWMULTISELECT;
|
||||
if (properties & FILE_DIALOG_SHOW_HIDDEN_FILES)
|
||||
options |= FOS_FORCESHOWHIDDEN;
|
||||
if (properties & FILE_DIALOG_PROMPT_TO_CREATE)
|
||||
options |= FOS_CREATEPROMPT;
|
||||
|
||||
FileDialog<CShellFileOpenDialog> open_dialog(
|
||||
default_path, title, button_label, filters, options);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#include "atom/browser/native_window_views.h"
|
||||
#include "ui/display/win/screen_win.h"
|
||||
#endif
|
||||
|
||||
namespace atom {
|
||||
@@ -13,13 +14,17 @@ namespace atom {
|
||||
namespace {
|
||||
|
||||
#if defined(OS_WIN)
|
||||
gfx::Rect SubstractBorderSize(gfx::Rect bounds) {
|
||||
int border_width = GetSystemMetrics(SM_CXSIZEFRAME) - 1;
|
||||
int border_height = GetSystemMetrics(SM_CYSIZEFRAME) - 1;
|
||||
bounds.set_x(bounds.x() + border_width);
|
||||
bounds.set_y(bounds.y() + border_height);
|
||||
bounds.set_width(bounds.width() - 2 * border_width);
|
||||
bounds.set_height(bounds.height() - 2 * border_height);
|
||||
gfx::Rect SubtractBorderSize(gfx::Rect bounds) {
|
||||
gfx::Point borderSize = gfx::Point(
|
||||
GetSystemMetrics(SM_CXSIZEFRAME) - 1, // width
|
||||
GetSystemMetrics(SM_CYSIZEFRAME) - 1); // height
|
||||
gfx::Point dpiAdjustedSize =
|
||||
display::win::ScreenWin::ScreenToDIPPoint(borderSize);
|
||||
|
||||
bounds.set_x(bounds.x() + dpiAdjustedSize.x());
|
||||
bounds.set_y(bounds.y() + dpiAdjustedSize.y());
|
||||
bounds.set_width(bounds.width() - 2 * dpiAdjustedSize.x());
|
||||
bounds.set_height(bounds.height() - 2 * dpiAdjustedSize.y());
|
||||
return bounds;
|
||||
}
|
||||
#endif
|
||||
@@ -39,7 +44,7 @@ void MenuLayout::Layout(views::View* host) {
|
||||
// Reserve border space for maximized frameless window so we won't have the
|
||||
// content go outside of screen.
|
||||
if (!window_->has_frame() && window_->IsMaximized()) {
|
||||
gfx::Rect bounds = SubstractBorderSize(host->GetContentsBounds());
|
||||
gfx::Rect bounds = SubtractBorderSize(host->GetContentsBounds());
|
||||
host->child_at(0)->SetBoundsRect(bounds);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ SubmenuButton::SubmenuButton(const base::string16& title,
|
||||
gfx::Canvas::SizeStringInt(GetText(), GetFontList(), &text_width_,
|
||||
&text_height_, 0, 0);
|
||||
|
||||
SetHasInkDrop(true);
|
||||
SetInkDropMode(InkDropMode::ON);
|
||||
set_ink_drop_base_color(
|
||||
color_utils::BlendTowardOppositeLuma(background_color_, 0x61));
|
||||
}
|
||||
|
||||
@@ -25,4 +25,12 @@ bool AtomDesktopWindowTreeHostWin::PreHandleMSG(
|
||||
return delegate_->PreHandleMSG(message, w_param, l_param, result);
|
||||
}
|
||||
|
||||
/** Override the client area inset
|
||||
* Returning true forces a border of 0 for frameless windows
|
||||
*/
|
||||
bool AtomDesktopWindowTreeHostWin::GetClientAreaInsets(
|
||||
gfx::Insets* insets) const {
|
||||
return !HasFrame();
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -27,6 +27,7 @@ class AtomDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin {
|
||||
protected:
|
||||
bool PreHandleMSG(
|
||||
UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) override;
|
||||
bool GetClientAreaInsets(gfx::Insets* insets) const override;
|
||||
|
||||
private:
|
||||
MessageHandlerDelegate* delegate_; // weak ref
|
||||
|
||||
@@ -87,7 +87,8 @@ NotifyIconHost::~NotifyIconHost() {
|
||||
UnregisterClass(MAKEINTATOM(atom_), instance_);
|
||||
|
||||
NotifyIcons copied_container(notify_icons_);
|
||||
STLDeleteContainerPointers(copied_container.begin(), copied_container.end());
|
||||
base::STLDeleteContainerPointers(
|
||||
copied_container.begin(), copied_container.end());
|
||||
}
|
||||
|
||||
NotifyIcon* NotifyIconHost::CreateNotifyIcon() {
|
||||
|
||||
@@ -60,7 +60,7 @@ void WebContentsPermissionHelper::RequestPermission(
|
||||
web_contents_->GetBrowserContext()->GetPermissionManager());
|
||||
auto origin = web_contents_->GetLastCommittedURL();
|
||||
permission_manager->RequestPermission(
|
||||
permission, rfh, origin,
|
||||
permission, rfh, origin, false,
|
||||
base::Bind(&OnPermissionResponse, callback));
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +119,12 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
|
||||
LOG(ERROR) << "preload url must be file:// protocol.";
|
||||
}
|
||||
|
||||
// Run Electron APIs and preload script in isolated world
|
||||
bool isolated;
|
||||
if (web_preferences.GetBoolean(options::kContextIsolation, &isolated) &&
|
||||
isolated)
|
||||
command_line->AppendSwitch(switches::kContextIsolation);
|
||||
|
||||
// --background-color.
|
||||
std::string color;
|
||||
if (web_preferences.GetString(options::kBackgroundColor, &color))
|
||||
@@ -190,14 +196,8 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches(
|
||||
if (window) {
|
||||
bool visible = window->IsVisible() && !window->IsMinimized();
|
||||
if (!visible) // Default state is visible.
|
||||
command_line->AppendSwitch("hidden-page");
|
||||
command_line->AppendSwitch(switches::kHiddenPage);
|
||||
}
|
||||
|
||||
// Use frame scheduling for offscreen renderers.
|
||||
// TODO(zcbenz): Remove this after Chrome 54, on which it becomes default.
|
||||
bool offscreen;
|
||||
if (web_preferences.GetBoolean("offscreen", &offscreen) && offscreen)
|
||||
command_line->AppendSwitch(cc::switches::kEnableBeginFrameScheduling);
|
||||
}
|
||||
|
||||
bool WebContentsPreferences::IsSandboxed(content::WebContents* web_contents) {
|
||||
|
||||
@@ -29,7 +29,7 @@ void WebViewManager::AddGuest(int guest_instance_id,
|
||||
}
|
||||
|
||||
void WebViewManager::RemoveGuest(int guest_instance_id) {
|
||||
if (!ContainsKey(web_contents_embedder_map_, guest_instance_id))
|
||||
if (!base::ContainsKey(web_contents_embedder_map_, guest_instance_id))
|
||||
return;
|
||||
|
||||
web_contents_embedder_map_.erase(guest_instance_id);
|
||||
@@ -43,7 +43,7 @@ void WebViewManager::RemoveGuest(int guest_instance_id) {
|
||||
}
|
||||
|
||||
content::WebContents* WebViewManager::GetEmbedder(int guest_instance_id) {
|
||||
if (ContainsKey(web_contents_embedder_map_, guest_instance_id))
|
||||
if (base::ContainsKey(web_contents_embedder_map_, guest_instance_id))
|
||||
return web_contents_embedder_map_[guest_instance_id].embedder;
|
||||
else
|
||||
return nullptr;
|
||||
@@ -53,11 +53,11 @@ content::WebContents* WebViewManager::GetGuestByInstanceID(
|
||||
int owner_process_id,
|
||||
int element_instance_id) {
|
||||
ElementInstanceKey key(owner_process_id, element_instance_id);
|
||||
if (!ContainsKey(element_instance_id_to_guest_map_, key))
|
||||
if (!base::ContainsKey(element_instance_id_to_guest_map_, key))
|
||||
return nullptr;
|
||||
|
||||
int guest_instance_id = element_instance_id_to_guest_map_[key];
|
||||
if (ContainsKey(web_contents_embedder_map_, guest_instance_id))
|
||||
if (base::ContainsKey(web_contents_embedder_map_, guest_instance_id))
|
||||
return web_contents_embedder_map_[guest_instance_id].web_contents;
|
||||
else
|
||||
return nullptr;
|
||||
|
||||
@@ -132,12 +132,12 @@ void InitAsarSupport(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> require) {
|
||||
// Evaluate asar_init.coffee.
|
||||
const char* asar_init_native = reinterpret_cast<const char*>(
|
||||
static_cast<const unsigned char*>(node::asar_init_native));
|
||||
static_cast<const unsigned char*>(node::asar_init_data));
|
||||
v8::Local<v8::Script> asar_init = v8::Script::Compile(v8::String::NewFromUtf8(
|
||||
isolate,
|
||||
asar_init_native,
|
||||
v8::String::kNormalString,
|
||||
sizeof(node::asar_init_native) -1));
|
||||
sizeof(node::asar_init_data) -1));
|
||||
v8::Local<v8::Value> result = asar_init->Run();
|
||||
|
||||
// Initialize asar support.
|
||||
@@ -146,10 +146,10 @@ void InitAsarSupport(v8::Isolate* isolate,
|
||||
std::string)> init;
|
||||
if (mate::ConvertFromV8(isolate, result, &init)) {
|
||||
const char* asar_native = reinterpret_cast<const char*>(
|
||||
static_cast<const unsigned char*>(node::asar_native));
|
||||
static_cast<const unsigned char*>(node::asar_data));
|
||||
init.Run(process,
|
||||
require,
|
||||
std::string(asar_native, sizeof(node::asar_native) - 1));
|
||||
std::string(asar_native, sizeof(node::asar_data) - 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -238,6 +238,8 @@ v8::Local<v8::Value> NativeImage::ToPNG(v8::Isolate* isolate) {
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> NativeImage::ToBitmap(v8::Isolate* isolate) {
|
||||
if (IsEmpty()) return node::Buffer::New(isolate, 0).ToLocalChecked();
|
||||
|
||||
const SkBitmap* bitmap = image_.ToSkBitmap();
|
||||
SkPixelRef* ref = bitmap->pixelRef();
|
||||
return node::Buffer::Copy(isolate,
|
||||
@@ -264,6 +266,8 @@ std::string NativeImage::ToDataURL() {
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> NativeImage::GetBitmap(v8::Isolate* isolate) {
|
||||
if (IsEmpty()) return node::Buffer::New(isolate, 0).ToLocalChecked();
|
||||
|
||||
const SkBitmap* bitmap = image_.ToSkBitmap();
|
||||
SkPixelRef* ref = bitmap->pixelRef();
|
||||
return node::Buffer::New(isolate,
|
||||
@@ -276,6 +280,8 @@ v8::Local<v8::Value> NativeImage::GetBitmap(v8::Isolate* isolate) {
|
||||
v8::Local<v8::Value> NativeImage::GetNativeHandle(v8::Isolate* isolate,
|
||||
mate::Arguments* args) {
|
||||
#if defined(OS_MACOSX)
|
||||
if (IsEmpty()) return node::Buffer::New(isolate, 0).ToLocalChecked();
|
||||
|
||||
NSImage* ptr = image_.AsNSImage();
|
||||
return node::Buffer::Copy(
|
||||
isolate,
|
||||
|
||||
@@ -23,10 +23,6 @@ namespace {
|
||||
// Dummy class type that used for crashing the program.
|
||||
struct DummyClass { bool crash; };
|
||||
|
||||
void Crash() {
|
||||
static_cast<DummyClass*>(nullptr)->crash = true;
|
||||
}
|
||||
|
||||
void Hang() {
|
||||
for (;;)
|
||||
base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1));
|
||||
@@ -76,7 +72,7 @@ v8::Local<v8::Value> GetSystemMemoryInfo(v8::Isolate* isolate,
|
||||
// we can get the stack trace.
|
||||
void FatalErrorCallback(const char* location, const char* message) {
|
||||
LOG(ERROR) << "Fatal error in V8: " << location << " " << message;
|
||||
Crash();
|
||||
AtomBindings::Crash();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -95,7 +91,7 @@ void AtomBindings::BindTo(v8::Isolate* isolate,
|
||||
v8::V8::SetFatalErrorHandler(FatalErrorCallback);
|
||||
|
||||
mate::Dictionary dict(isolate, process);
|
||||
dict.SetMethod("crash", &Crash);
|
||||
dict.SetMethod("crash", &AtomBindings::Crash);
|
||||
dict.SetMethod("hang", &Hang);
|
||||
dict.SetMethod("log", &Log);
|
||||
dict.SetMethod("getProcessMemoryInfo", &GetProcessMemoryInfo);
|
||||
@@ -112,6 +108,7 @@ void AtomBindings::BindTo(v8::Isolate* isolate,
|
||||
|
||||
mate::Dictionary versions;
|
||||
if (dict.Get("versions", &versions)) {
|
||||
// TODO(kevinsawicki): Make read-only in 2.0 to match node
|
||||
versions.Set(ATOM_PROJECT_NAME, ATOM_VERSION_STRING);
|
||||
versions.Set("chrome", CHROME_VERSION_STRING);
|
||||
|
||||
@@ -158,4 +155,9 @@ void AtomBindings::Log(const base::string16& message) {
|
||||
std::cout << message << std::flush;
|
||||
}
|
||||
|
||||
// static
|
||||
void AtomBindings::Crash() {
|
||||
static_cast<DummyClass*>(nullptr)->crash = true;
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -28,6 +28,7 @@ class AtomBindings {
|
||||
void BindTo(v8::Isolate* isolate, v8::Local<v8::Object> process);
|
||||
|
||||
static void Log(const base::string16& message);
|
||||
static void Crash();
|
||||
|
||||
private:
|
||||
void ActivateUVLoop(v8::Isolate* isolate);
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#define ATOM_COMMON_ATOM_VERSION_H_
|
||||
|
||||
#define ATOM_MAJOR_VERSION 1
|
||||
#define ATOM_MINOR_VERSION 4
|
||||
#define ATOM_PATCH_VERSION 14
|
||||
#define ATOM_MINOR_VERSION 5
|
||||
#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 "53.0.2785.143"
|
||||
#define CHROME_VERSION_STRING "54.0.2840.101"
|
||||
#define CHROME_VERSION "v" CHROME_VERSION_STRING
|
||||
|
||||
#endif // ATOM_COMMON_CHROME_VERSION_H_
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/common/atom_version.h"
|
||||
#include "atom/common/native_mate_converters/file_path_converter.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
@@ -93,4 +94,26 @@ CrashReporter* CrashReporter::GetInstance() {
|
||||
}
|
||||
#endif
|
||||
|
||||
void CrashReporter::StartInstance(const mate::Dictionary& options) {
|
||||
auto reporter = GetInstance();
|
||||
if (!reporter) return;
|
||||
|
||||
std::string product_name;
|
||||
options.Get("productName", &product_name);
|
||||
std::string company_name;
|
||||
options.Get("companyName", &company_name);
|
||||
std::string submit_url;
|
||||
options.Get("submitURL", &submit_url);
|
||||
base::FilePath crashes_dir;
|
||||
options.Get("crashesDirectory", &crashes_dir);
|
||||
StringMap extra_parameters;
|
||||
options.Get("extra", &extra_parameters);
|
||||
|
||||
extra_parameters["_productName"] = product_name;
|
||||
extra_parameters["_companyName"] = company_name;
|
||||
|
||||
reporter->Start(product_name, company_name, submit_url, crashes_dir, true,
|
||||
false, extra_parameters);
|
||||
}
|
||||
|
||||
} // namespace crash_reporter
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/macros.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
namespace crash_reporter {
|
||||
|
||||
@@ -21,6 +22,7 @@ class CrashReporter {
|
||||
typedef std::pair<int, std::string> UploadReportResult; // upload-date, id
|
||||
|
||||
static CrashReporter* GetInstance();
|
||||
static void StartInstance(const mate::Dictionary& options);
|
||||
|
||||
void Start(const std::string& product_name,
|
||||
const std::string& company_name,
|
||||
|
||||
@@ -90,11 +90,11 @@ struct Converter<blink::WebMouseEvent::Button> {
|
||||
blink::WebMouseEvent::Button* out) {
|
||||
std::string button = base::ToLowerASCII(V8ToString(val));
|
||||
if (button == "left")
|
||||
*out = blink::WebMouseEvent::Button::ButtonLeft;
|
||||
*out = blink::WebMouseEvent::Button::Left;
|
||||
else if (button == "middle")
|
||||
*out = blink::WebMouseEvent::Button::ButtonMiddle;
|
||||
*out = blink::WebMouseEvent::Button::Middle;
|
||||
else if (button == "right")
|
||||
*out = blink::WebMouseEvent::Button::ButtonRight;
|
||||
*out = blink::WebMouseEvent::Button::Right;
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
@@ -176,7 +176,6 @@ bool Converter<blink::WebKeyboardEvent>::FromV8(
|
||||
out->windowsKeyCode = keyCode;
|
||||
if (shifted)
|
||||
out->modifiers |= blink::WebInputEvent::ShiftKey;
|
||||
out->setKeyIdentifierFromWindowsKeyCode();
|
||||
|
||||
ui::DomCode domCode = ui::UsLayoutKeyboardCodeToDomCode(keyCode);
|
||||
out->domCode = static_cast<int>(domCode);
|
||||
@@ -225,6 +224,8 @@ v8::Local<v8::Value> Converter<content::NativeWebKeyboardEvent>::ToV8(
|
||||
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);
|
||||
@@ -246,7 +247,7 @@ bool Converter<blink::WebMouseEvent>::FromV8(
|
||||
if (!dict.Get("x", &out->x) || !dict.Get("y", &out->y))
|
||||
return false;
|
||||
if (!dict.Get("button", &out->button))
|
||||
out->button = blink::WebMouseEvent::Button::ButtonLeft;
|
||||
out->button = blink::WebMouseEvent::Button::Left;
|
||||
dict.Get("globalX", &out->globalX);
|
||||
dict.Get("globalY", &out->globalY);
|
||||
dict.Get("movementX", &out->movementX);
|
||||
|
||||
@@ -15,8 +15,9 @@
|
||||
#include "base/command_line.h"
|
||||
#include "base/environment.h"
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "base/trace_event/trace_event.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/common/content_paths.h"
|
||||
@@ -63,14 +64,6 @@ REFERENCE_MODULE(atom_renderer_ipc);
|
||||
REFERENCE_MODULE(atom_renderer_web_frame);
|
||||
#undef REFERENCE_MODULE
|
||||
|
||||
// The "v8::Function::kLineOffsetNotFound" is exported in node.dll, but the
|
||||
// linker can not find it, could be a bug of VS.
|
||||
#if defined(OS_WIN) && !defined(DEBUG)
|
||||
namespace v8 {
|
||||
const int Function::kLineOffsetNotFound = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
@@ -107,7 +100,6 @@ base::FilePath GetResourcesPath(bool is_browser) {
|
||||
|
||||
NodeBindings::NodeBindings(bool is_browser)
|
||||
: is_browser_(is_browser),
|
||||
message_loop_(nullptr),
|
||||
uv_loop_(uv_default_loop()),
|
||||
embed_closed_(false),
|
||||
uv_env_(nullptr),
|
||||
@@ -168,12 +160,16 @@ node::Environment* NodeBindings::CreateEnvironment(
|
||||
|
||||
std::unique_ptr<const char*[]> c_argv = StringVectorToArgArray(args);
|
||||
node::Environment* env = node::CreateEnvironment(
|
||||
context->GetIsolate(), uv_default_loop(), context,
|
||||
new node::IsolateData(context->GetIsolate(), uv_default_loop()), context,
|
||||
args.size(), c_argv.get(), 0, nullptr);
|
||||
|
||||
// Node uses the deprecated SetAutorunMicrotasks(false) mode, we should switch
|
||||
// to use the scoped policy to match blink's behavior.
|
||||
if (!is_browser_) {
|
||||
if (is_browser_) {
|
||||
// SetAutorunMicrotasks is no longer called in node::CreateEnvironment
|
||||
// so instead call it here to match expected node behavior
|
||||
context->GetIsolate()->SetMicrotasksPolicy(v8::MicrotasksPolicy::kExplicit);
|
||||
} else {
|
||||
// Node uses the deprecated SetAutorunMicrotasks(false) mode, we should
|
||||
// switch to use the scoped policy to match blink's behavior.
|
||||
context->GetIsolate()->SetMicrotasksPolicy(v8::MicrotasksPolicy::kScoped);
|
||||
}
|
||||
|
||||
@@ -218,7 +214,7 @@ void NodeBindings::RunMessageLoop() {
|
||||
DCHECK(!is_browser_ || BrowserThread::CurrentlyOn(BrowserThread::UI));
|
||||
|
||||
// The MessageLoop should have been created, remember the one in main thread.
|
||||
message_loop_ = base::MessageLoop::current();
|
||||
task_runner_ = base::ThreadTaskRunnerHandle::Get();
|
||||
|
||||
// Run uv loop for once to give the uv__io_poll a chance to add all events.
|
||||
UvRunOnce();
|
||||
@@ -250,16 +246,16 @@ void NodeBindings::UvRunOnce() {
|
||||
TRACE_EVENT_END0("devtools.timeline", "FunctionCall");
|
||||
|
||||
if (r == 0)
|
||||
message_loop_->QuitWhenIdle(); // Quit from uv.
|
||||
base::RunLoop().QuitWhenIdle(); // Quit from uv.
|
||||
|
||||
// Tell the worker thread to continue polling.
|
||||
uv_sem_post(&embed_sem_);
|
||||
}
|
||||
|
||||
void NodeBindings::WakeupMainThread() {
|
||||
DCHECK(message_loop_);
|
||||
message_loop_->PostTask(FROM_HERE, base::Bind(&NodeBindings::UvRunOnce,
|
||||
weak_factory_.GetWeakPtr()));
|
||||
DCHECK(task_runner_);
|
||||
task_runner_->PostTask(FROM_HERE, base::Bind(&NodeBindings::UvRunOnce,
|
||||
weak_factory_.GetWeakPtr()));
|
||||
}
|
||||
|
||||
void NodeBindings::WakeupEmbedThread() {
|
||||
|
||||
@@ -64,7 +64,7 @@ class NodeBindings {
|
||||
bool is_browser_;
|
||||
|
||||
// Main thread's MessageLoop.
|
||||
base::MessageLoop* message_loop_;
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
|
||||
|
||||
// Main thread's libuv loop.
|
||||
uv_loop_t* uv_loop_;
|
||||
|
||||
@@ -99,7 +99,10 @@ const char kPreloadURL[] = "preloadURL";
|
||||
// Enable the node integration.
|
||||
const char kNodeIntegration[] = "nodeIntegration";
|
||||
|
||||
// Instancd ID of guest WebContents.
|
||||
// Enable context isolation of Electron APIs and preload script
|
||||
const char kContextIsolation[] = "contextIsolation";
|
||||
|
||||
// Instance ID of guest WebContents.
|
||||
const char kGuestInstanceID[] = "guestInstanceId";
|
||||
|
||||
// Web runtime features.
|
||||
@@ -158,14 +161,16 @@ const char kCipherSuiteBlacklist[] = "cipher-suite-blacklist";
|
||||
const char kAppUserModelId[] = "app-user-model-id";
|
||||
|
||||
// The command line switch versions of the options.
|
||||
const char kBackgroundColor[] = "background-color";
|
||||
const char kZoomFactor[] = "zoom-factor";
|
||||
const char kPreloadScript[] = "preload";
|
||||
const char kPreloadURL[] = "preload-url";
|
||||
const char kNodeIntegration[] = "node-integration";
|
||||
const char kGuestInstanceID[] = "guest-instance-id";
|
||||
const char kOpenerID[] = "opener-id";
|
||||
const char kScrollBounce[] = "scroll-bounce";
|
||||
const char kBackgroundColor[] = "background-color";
|
||||
const char kZoomFactor[] = "zoom-factor";
|
||||
const char kPreloadScript[] = "preload";
|
||||
const char kPreloadURL[] = "preload-url";
|
||||
const char kNodeIntegration[] = "node-integration";
|
||||
const char kContextIsolation[] = "context-isolation";
|
||||
const char kGuestInstanceID[] = "guest-instance-id";
|
||||
const char kOpenerID[] = "opener-id";
|
||||
const char kScrollBounce[] = "scroll-bounce";
|
||||
const char kHiddenPage[] = "hidden-page";
|
||||
|
||||
// Widevine options
|
||||
// Path to Widevine CDM binaries.
|
||||
|
||||
@@ -54,6 +54,7 @@ extern const char kZoomFactor[];
|
||||
extern const char kPreloadScript[];
|
||||
extern const char kPreloadURL[];
|
||||
extern const char kNodeIntegration[];
|
||||
extern const char kContextIsolation[];
|
||||
extern const char kGuestInstanceID[];
|
||||
extern const char kExperimentalFeatures[];
|
||||
extern const char kExperimentalCanvasFeatures[];
|
||||
@@ -86,9 +87,11 @@ extern const char kZoomFactor[];
|
||||
extern const char kPreloadScript[];
|
||||
extern const char kPreloadURL[];
|
||||
extern const char kNodeIntegration[];
|
||||
extern const char kContextIsolation[];
|
||||
extern const char kGuestInstanceID[];
|
||||
extern const char kOpenerID[];
|
||||
extern const char kScrollBounce[];
|
||||
extern const char kHiddenPage[];
|
||||
|
||||
extern const char kWidevineCdmPath[];
|
||||
extern const char kWidevineCdmVersion[];
|
||||
|
||||
@@ -64,19 +64,6 @@ void SpellCheckClient::spellCheck(
|
||||
}
|
||||
}
|
||||
|
||||
void SpellCheckClient::checkTextOfParagraph(
|
||||
const blink::WebString& text,
|
||||
blink::WebTextCheckingTypeMask mask,
|
||||
blink::WebVector<blink::WebTextCheckingResult>* results) {
|
||||
if (!results)
|
||||
return;
|
||||
|
||||
if (!(mask & blink::WebTextCheckingTypeSpelling))
|
||||
return;
|
||||
|
||||
NOTREACHED() << "checkTextOfParagraph should never be called";
|
||||
}
|
||||
|
||||
void SpellCheckClient::requestCheckingOfText(
|
||||
const blink::WebString& textToCheck,
|
||||
const blink::WebVector<uint32_t>& markersInText,
|
||||
|
||||
@@ -32,10 +32,6 @@ class SpellCheckClient : public blink::WebSpellCheckClient {
|
||||
int& misspelledOffset,
|
||||
int& misspelledLength,
|
||||
blink::WebVector<blink::WebString>* optionalSuggestions) override;
|
||||
void checkTextOfParagraph(
|
||||
const blink::WebString&,
|
||||
blink::WebTextCheckingTypeMask mask,
|
||||
blink::WebVector<blink::WebTextCheckingResult>* results) override;
|
||||
void requestCheckingOfText(
|
||||
const blink::WebString& textToCheck,
|
||||
const blink::WebVector<uint32_t>& markersInText,
|
||||
|
||||
@@ -190,6 +190,10 @@ void WebFrame::InsertText(const std::string& text) {
|
||||
web_frame_->insertText(blink::WebString::fromUTF8(text));
|
||||
}
|
||||
|
||||
void WebFrame::InsertCSS(const std::string& css) {
|
||||
web_frame_->document().insertStyleSheet(blink::WebString::fromUTF8(css));
|
||||
}
|
||||
|
||||
void WebFrame::ExecuteJavaScript(const base::string16& code,
|
||||
mate::Arguments* args) {
|
||||
bool has_user_gesture = false;
|
||||
@@ -251,6 +255,7 @@ void WebFrame::BuildPrototype(
|
||||
.SetMethod("registerURLSchemeAsPrivileged",
|
||||
&WebFrame::RegisterURLSchemeAsPrivileged)
|
||||
.SetMethod("insertText", &WebFrame::InsertText)
|
||||
.SetMethod("insertCSS", &WebFrame::InsertCSS)
|
||||
.SetMethod("executeJavaScript", &WebFrame::ExecuteJavaScript)
|
||||
.SetMethod("getResourceUsage", &WebFrame::GetResourceUsage)
|
||||
.SetMethod("clearCache", &WebFrame::ClearCache)
|
||||
|
||||
@@ -69,6 +69,7 @@ class WebFrame : public mate::Wrappable<WebFrame> {
|
||||
|
||||
// Editing.
|
||||
void InsertText(const std::string& text);
|
||||
void InsertCSS(const std::string& css);
|
||||
|
||||
// Excecuting scripts.
|
||||
void ExecuteJavaScript(const base::string16& code, mate::Arguments* args);
|
||||
|
||||
@@ -76,6 +76,7 @@ AtomRenderViewObserver::AtomRenderViewObserver(
|
||||
content::RenderView* render_view,
|
||||
AtomRendererClient* renderer_client)
|
||||
: content::RenderViewObserver(render_view),
|
||||
renderer_client_(renderer_client),
|
||||
document_created_(false) {
|
||||
// Initialise resource for directory listing.
|
||||
net::NetModule::SetResourceProvider(NetResourceProvider);
|
||||
@@ -93,7 +94,7 @@ void AtomRenderViewObserver::EmitIPCEvent(blink::WebFrame* frame,
|
||||
v8::Isolate* isolate = blink::mainThreadIsolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
|
||||
v8::Local<v8::Context> context = frame->mainWorldScriptContext();
|
||||
v8::Local<v8::Context> context = renderer_client_->GetContext(frame, isolate);
|
||||
v8::Context::Scope context_scope(context);
|
||||
|
||||
// Only emit IPC event for context with node integration.
|
||||
|
||||
@@ -40,6 +40,8 @@ class AtomRenderViewObserver : public content::RenderViewObserver {
|
||||
const base::string16& channel,
|
||||
const base::ListValue& args);
|
||||
|
||||
AtomRendererClient* renderer_client_;
|
||||
|
||||
// Whether the document object has been created.
|
||||
bool document_created_;
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#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/api/event_emitter_caller.h"
|
||||
@@ -14,6 +16,7 @@
|
||||
#include "atom/common/native_mate_converters/value_converter.h"
|
||||
#include "atom/common/node_bindings.h"
|
||||
#include "atom/common/options_switches.h"
|
||||
#include "atom/renderer/api/atom_api_renderer_ipc.h"
|
||||
#include "atom/renderer/atom_render_view_observer.h"
|
||||
#include "atom/renderer/content_settings_observer.h"
|
||||
#include "atom/renderer/guest_view_container.h"
|
||||
@@ -57,6 +60,17 @@ namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
enum World {
|
||||
MAIN_WORLD = 0,
|
||||
// Use a high number far away from 0 to not collide with any other world
|
||||
// IDs created internally by Chrome.
|
||||
ISOLATED_WORLD = 999
|
||||
};
|
||||
|
||||
enum ExtensionGroup {
|
||||
MAIN_GROUP = 1
|
||||
};
|
||||
|
||||
// Helper class to forward the messages to the client.
|
||||
class AtomRenderFrameObserver : public content::RenderFrameObserver {
|
||||
public:
|
||||
@@ -64,7 +78,6 @@ class AtomRenderFrameObserver : public content::RenderFrameObserver {
|
||||
AtomRendererClient* renderer_client)
|
||||
: content::RenderFrameObserver(frame),
|
||||
render_frame_(frame),
|
||||
world_id_(-1),
|
||||
renderer_client_(renderer_client) {}
|
||||
|
||||
// content::RenderFrameObserver:
|
||||
@@ -72,19 +85,82 @@ class AtomRenderFrameObserver : public content::RenderFrameObserver {
|
||||
renderer_client_->DidClearWindowObject(render_frame_);
|
||||
}
|
||||
|
||||
void CreateIsolatedWorldContext() {
|
||||
// This maps to the name shown in the context combo box in the Console tab
|
||||
// of the dev tools.
|
||||
render_frame_->GetWebFrame()->setIsolatedWorldHumanReadableName(
|
||||
World::ISOLATED_WORLD,
|
||||
blink::WebString::fromUTF8("Electron Isolated Context"));
|
||||
|
||||
blink::WebScriptSource source("void 0");
|
||||
render_frame_->GetWebFrame()->executeScriptInIsolatedWorld(
|
||||
World::ISOLATED_WORLD, &source, 1, ExtensionGroup::MAIN_GROUP);
|
||||
}
|
||||
|
||||
void SetupMainWorldOverrides(v8::Handle<v8::Context> context) {
|
||||
// Setup window overrides in the main world context
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
|
||||
// Wrap the bundle into a function that receives the binding object as
|
||||
// an argument.
|
||||
std::string bundle(node::isolated_bundle_data,
|
||||
node::isolated_bundle_data + sizeof(node::isolated_bundle_data));
|
||||
std::string wrapper = "(function (binding) {\n" + bundle + "\n})";
|
||||
auto script = v8::Script::Compile(
|
||||
mate::ConvertToV8(isolate, wrapper)->ToString());
|
||||
auto func = v8::Handle<v8::Function>::Cast(
|
||||
script->Run(context).ToLocalChecked());
|
||||
|
||||
auto binding = v8::Object::New(isolate);
|
||||
api::Initialize(binding, v8::Null(isolate), context, nullptr);
|
||||
|
||||
// Pass in CLI flags needed to setup window
|
||||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
||||
mate::Dictionary dict(isolate, binding);
|
||||
if (command_line->HasSwitch(switches::kGuestInstanceID))
|
||||
dict.Set(options::kGuestInstanceID,
|
||||
command_line->GetSwitchValueASCII(switches::kGuestInstanceID));
|
||||
if (command_line->HasSwitch(switches::kOpenerID))
|
||||
dict.Set(options::kOpenerID,
|
||||
command_line->GetSwitchValueASCII(switches::kOpenerID));
|
||||
dict.Set("hiddenPage", command_line->HasSwitch(switches::kHiddenPage));
|
||||
|
||||
v8::Local<v8::Value> args[] = { binding };
|
||||
ignore_result(func->Call(context, v8::Null(isolate), 1, args));
|
||||
}
|
||||
|
||||
bool IsMainWorld(int world_id) {
|
||||
return world_id == World::MAIN_WORLD;
|
||||
}
|
||||
|
||||
bool IsIsolatedWorld(int world_id) {
|
||||
return world_id == World::ISOLATED_WORLD;
|
||||
}
|
||||
|
||||
bool ShouldNotifyClient(int world_id) {
|
||||
if (renderer_client_->isolated_world() && render_frame_->IsMainFrame())
|
||||
return IsIsolatedWorld(world_id);
|
||||
else
|
||||
return IsMainWorld(world_id);
|
||||
}
|
||||
|
||||
void DidCreateScriptContext(v8::Handle<v8::Context> context,
|
||||
int extension_group,
|
||||
int world_id) override {
|
||||
if (world_id_ != -1 && world_id_ != world_id)
|
||||
return;
|
||||
world_id_ = world_id;
|
||||
renderer_client_->DidCreateScriptContext(context, render_frame_);
|
||||
if (ShouldNotifyClient(world_id))
|
||||
renderer_client_->DidCreateScriptContext(context, render_frame_);
|
||||
|
||||
if (renderer_client_->isolated_world() && IsMainWorld(world_id)
|
||||
&& render_frame_->IsMainFrame()) {
|
||||
CreateIsolatedWorldContext();
|
||||
SetupMainWorldOverrides(context);
|
||||
}
|
||||
}
|
||||
|
||||
void WillReleaseScriptContext(v8::Local<v8::Context> context,
|
||||
int world_id) override {
|
||||
if (world_id_ != world_id)
|
||||
return;
|
||||
renderer_client_->WillReleaseScriptContext(context, render_frame_);
|
||||
if (ShouldNotifyClient(world_id))
|
||||
renderer_client_->WillReleaseScriptContext(context, render_frame_);
|
||||
}
|
||||
|
||||
void OnDestruct() override {
|
||||
@@ -93,7 +169,6 @@ class AtomRenderFrameObserver : public content::RenderFrameObserver {
|
||||
|
||||
private:
|
||||
content::RenderFrame* render_frame_;
|
||||
int world_id_;
|
||||
AtomRendererClient* renderer_client_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomRenderFrameObserver);
|
||||
@@ -133,6 +208,8 @@ std::vector<std::string> ParseSchemesCLISwitch(const char* switch_name) {
|
||||
AtomRendererClient::AtomRendererClient()
|
||||
: node_bindings_(NodeBindings::Create(false)),
|
||||
atom_bindings_(new AtomBindings) {
|
||||
isolated_world_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
switches::kContextIsolation);
|
||||
// Parse --standard-schemes=scheme1,scheme2
|
||||
std::vector<std::string> standard_schemes_list =
|
||||
ParseSchemesCLISwitch(switches::kStandardSchemes);
|
||||
@@ -336,4 +413,13 @@ void AtomRendererClient::AddSupportedKeySystems(
|
||||
AddChromeKeySystems(key_systems);
|
||||
}
|
||||
|
||||
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);
|
||||
else
|
||||
return frame->mainWorldScriptContext();
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
||||
@@ -27,6 +27,11 @@ class AtomRendererClient : public content::ContentRendererClient {
|
||||
void WillReleaseScriptContext(
|
||||
v8::Handle<v8::Context> context, content::RenderFrame* render_frame);
|
||||
|
||||
// Get the context that the Electron API is running in.
|
||||
v8::Local<v8::Context> GetContext(
|
||||
blink::WebFrame* frame, v8::Isolate* isolate);
|
||||
bool isolated_world() { return isolated_world_; }
|
||||
|
||||
private:
|
||||
enum NodeIntegration {
|
||||
ALL,
|
||||
@@ -64,6 +69,7 @@ class AtomRendererClient : public content::ContentRendererClient {
|
||||
std::unique_ptr<NodeBindings> node_bindings_;
|
||||
std::unique_ptr<AtomBindings> atom_bindings_;
|
||||
std::unique_ptr<PreferencesManager> preferences_manager_;
|
||||
bool isolated_world_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomRendererClient);
|
||||
};
|
||||
|
||||
@@ -144,8 +144,8 @@ void AtomSandboxedRendererClient::DidCreateScriptContext(
|
||||
v8::Context::Scope context_scope(context);
|
||||
// Wrap the bundle into a function that receives the binding object and the
|
||||
// preload script path as arguments.
|
||||
std::string preload_bundle_native(node::preload_bundle_native,
|
||||
node::preload_bundle_native + sizeof(node::preload_bundle_native));
|
||||
std::string preload_bundle_native(node::preload_bundle_data,
|
||||
node::preload_bundle_data + sizeof(node::preload_bundle_data));
|
||||
std::stringstream ss;
|
||||
ss << "(function(binding, preloadPath) {\n";
|
||||
ss << preload_bundle_native << "\n";
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
|
||||
namespace atom {
|
||||
@@ -53,7 +53,7 @@ void GuestViewContainer::DidResizeElement(const gfx::Size& new_size) {
|
||||
if (element_resize_callback_.is_null())
|
||||
return;
|
||||
|
||||
base::MessageLoop::current()->PostTask(
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE, base::Bind(element_resize_callback_, new_size));
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,8 @@ void AtomContentUtilityClient::UtilityThreadStarted() {
|
||||
|
||||
bool AtomContentUtilityClient::OnMessageReceived(
|
||||
const IPC::Message& message) {
|
||||
if (filter_messages_ && !ContainsKey(message_id_whitelist_, message.type()))
|
||||
if (filter_messages_ &&
|
||||
!base::ContainsKey(message_id_whitelist_, message.type()))
|
||||
return false;
|
||||
|
||||
bool handled = true;
|
||||
|
||||
@@ -9,10 +9,9 @@
|
||||
|
||||
BrowserProcess* g_browser_process = NULL;
|
||||
|
||||
BrowserProcess::BrowserProcess() {
|
||||
BrowserProcess::BrowserProcess()
|
||||
: print_job_manager_(new printing::PrintJobManager) {
|
||||
g_browser_process = this;
|
||||
|
||||
print_job_manager_.reset(new printing::PrintJobManager);
|
||||
}
|
||||
|
||||
BrowserProcess::~BrowserProcess() {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/files/scoped_temp_dir.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "chrome/common/chrome_utility_messages.h"
|
||||
#include "chrome/common/print_messages.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
@@ -59,10 +60,11 @@ class LazyEmf : public MetafilePlayer {
|
||||
public:
|
||||
LazyEmf(const scoped_refptr<RefCountedTempDir>& temp_dir, ScopedTempFile file)
|
||||
: temp_dir_(temp_dir), file_(std::move(file)) {}
|
||||
virtual ~LazyEmf() { Close(); }
|
||||
~LazyEmf() override { Close(); }
|
||||
|
||||
virtual bool SafePlayback(HDC hdc) const override;
|
||||
virtual bool SaveTo(base::File* file) const override;
|
||||
bool SafePlayback(HDC hdc) const override;
|
||||
bool GetDataAsVector(std::vector<char>* buffer) const override;
|
||||
bool SaveTo(base::File* file) const override;
|
||||
|
||||
private:
|
||||
void Close() const;
|
||||
@@ -242,6 +244,11 @@ bool LazyEmf::SafePlayback(HDC hdc) const {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool LazyEmf::GetDataAsVector(std::vector<char>* buffer) const {
|
||||
NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LazyEmf::SaveTo(base::File* file) const {
|
||||
Emf emf;
|
||||
return LoadEmf(&emf) && emf.SaveTo(file);
|
||||
@@ -392,7 +399,7 @@ void PdfToEmfUtilityProcessHostClient::OnPageDone(bool success,
|
||||
ScopedTempFile temp_emf = data.TakeEmf();
|
||||
if (!temp_emf) // Unexpected message from utility process.
|
||||
return OnFailed();
|
||||
emf.reset(new LazyEmf(temp_dir_, std::move(temp_emf)));
|
||||
emf = base::MakeUnique<LazyEmf>(temp_dir_, std::move(temp_emf));
|
||||
}
|
||||
|
||||
BrowserThread::PostTask(BrowserThread::UI,
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/bind_helpers.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "base/threading/worker_pool.h"
|
||||
#include "base/timer/timer.h"
|
||||
#include "chrome/browser/chrome_notification_types.h"
|
||||
@@ -196,12 +198,13 @@ bool PrintJob::FlushJob(base::TimeDelta timeout) {
|
||||
// Make sure the object outlive this message loop.
|
||||
scoped_refptr<PrintJob> handle(this);
|
||||
|
||||
base::MessageLoop::current()->PostDelayedTask(FROM_HERE,
|
||||
base::Bind(&PrintJob::Quit, quit_factory_.GetWeakPtr()), timeout);
|
||||
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
||||
FROM_HERE, base::Bind(&PrintJob::Quit, quit_factory_.GetWeakPtr()),
|
||||
timeout);
|
||||
|
||||
base::MessageLoop::ScopedNestableTaskAllower allow(
|
||||
base::MessageLoop::current());
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -362,7 +365,7 @@ void PrintJob::OnNotifyPrintJobEvent(const JobEventDetails& event_details) {
|
||||
}
|
||||
case JobEventDetails::DOC_DONE: {
|
||||
// This will call Stop() and broadcast a JOB_DONE message.
|
||||
base::MessageLoop::current()->PostTask(
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE, base::Bind(&PrintJob::OnDocumentDone, this));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "base/callback.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "base/values.h"
|
||||
#include "chrome/browser/browser_process.h"
|
||||
#include "chrome/browser/chrome_notification_types.h"
|
||||
@@ -278,7 +279,7 @@ void PrintJobWorker::OnNewPage() {
|
||||
scoped_refptr<PrintedPage> page = document_->GetPage(page_number_.ToInt());
|
||||
if (!page.get()) {
|
||||
// We need to wait for the page to be available.
|
||||
base::MessageLoop::current()->PostDelayedTask(
|
||||
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&PrintJobWorker::OnNewPage, weak_factory_.GetWeakPtr()),
|
||||
base::TimeDelta::FromMilliseconds(500));
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/memory/ref_counted_memory.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/timer/timer.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
@@ -424,7 +425,7 @@ bool PrintViewManagerBase::RunInnerMessageLoop() {
|
||||
{
|
||||
base::MessageLoop::ScopedNestableTaskAllower allow(
|
||||
base::MessageLoop::current());
|
||||
base::MessageLoop::current()->Run();
|
||||
base::RunLoop().Run();
|
||||
}
|
||||
|
||||
bool success = true;
|
||||
|
||||
@@ -32,7 +32,7 @@ PepperBrokerMessageFilter::~PepperBrokerMessageFilter() {}
|
||||
scoped_refptr<base::TaskRunner>
|
||||
PepperBrokerMessageFilter::OverrideTaskRunnerForMessage(
|
||||
const IPC::Message& message) {
|
||||
return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI);
|
||||
return BrowserThread::GetTaskRunnerForThread(BrowserThread::UI);
|
||||
}
|
||||
|
||||
int32_t PepperBrokerMessageFilter::OnResourceMessageReceived(
|
||||
|
||||
@@ -110,16 +110,16 @@ PepperFlashClipboardMessageFilter::OverrideTaskRunnerForMessage(
|
||||
// restrictions of various platform APIs. In general, the clipboard is not
|
||||
// thread-safe, so all clipboard calls should be serviced from the UI thread.
|
||||
if (msg.type() == PpapiHostMsg_FlashClipboard_WriteData::ID)
|
||||
return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI);
|
||||
return BrowserThread::GetTaskRunnerForThread(BrowserThread::UI);
|
||||
|
||||
// Windows needs clipboard reads to be serviced from the IO thread because
|
||||
// these are sync IPCs which can result in deadlocks with plugins if serviced
|
||||
// from the UI thread. Note that Windows clipboard calls ARE thread-safe so it
|
||||
// is ok for reads and writes to be serviced from different threads.
|
||||
#if !defined(OS_WIN)
|
||||
return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI);
|
||||
return BrowserThread::GetTaskRunnerForThread(BrowserThread::UI);
|
||||
#else
|
||||
return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
|
||||
return BrowserThread::GetTaskRunnerForThread(BrowserThread::IO);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ PepperIsolatedFileSystemMessageFilter::OverrideTaskRunnerForMessage(
|
||||
const IPC::Message& msg) {
|
||||
// In order to reach ExtensionSystem, we need to get ProfileManager first.
|
||||
// ProfileManager lives in UI thread, so we need to do this in UI thread.
|
||||
return content::BrowserThread::GetMessageLoopProxyForThread(
|
||||
return content::BrowserThread::GetTaskRunnerForThread(
|
||||
content::BrowserThread::UI);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "net/base/escape.h"
|
||||
#include "printing/pdf_metafile_skia.h"
|
||||
#include "printing/units.h"
|
||||
#include "third_party/WebKit/public/platform/WebDoubleSize.h"
|
||||
#include "third_party/WebKit/public/platform/WebSize.h"
|
||||
#include "third_party/WebKit/public/platform/WebURLRequest.h"
|
||||
#include "third_party/WebKit/public/web/WebConsoleMessage.h"
|
||||
@@ -69,15 +70,15 @@ bool PrintMsg_Print_Params_IsValid(const PrintMsg_Print_Params& params) {
|
||||
}
|
||||
|
||||
PrintMsg_Print_Params GetCssPrintParams(
|
||||
blink::WebFrame* frame,
|
||||
blink::WebLocalFrame* frame,
|
||||
int page_index,
|
||||
const PrintMsg_Print_Params& page_params) {
|
||||
PrintMsg_Print_Params page_css_params = page_params;
|
||||
int dpi = GetDPI(&page_params);
|
||||
|
||||
blink::WebSize page_size_in_pixels(
|
||||
ConvertUnit(page_params.page_size.width(), dpi, kPixelsPerInch),
|
||||
ConvertUnit(page_params.page_size.height(), dpi, kPixelsPerInch));
|
||||
blink::WebDoubleSize page_size_in_pixels(
|
||||
ConvertUnitDouble(page_params.page_size.width(), dpi, kPixelsPerInch),
|
||||
ConvertUnitDouble(page_params.page_size.height(), dpi, kPixelsPerInch));
|
||||
int margin_top_in_pixels =
|
||||
ConvertUnit(page_params.margin_top, dpi, kPixelsPerInch);
|
||||
int margin_right_in_pixels = ConvertUnit(
|
||||
@@ -92,8 +93,6 @@ PrintMsg_Print_Params GetCssPrintParams(
|
||||
page_params.margin_left,
|
||||
dpi, kPixelsPerInch);
|
||||
|
||||
blink::WebSize original_page_size_in_pixels = page_size_in_pixels;
|
||||
|
||||
if (frame) {
|
||||
frame->pageSizeAndMarginsInPixels(page_index,
|
||||
page_size_in_pixels,
|
||||
@@ -103,9 +102,9 @@ PrintMsg_Print_Params GetCssPrintParams(
|
||||
margin_left_in_pixels);
|
||||
}
|
||||
|
||||
int new_content_width = page_size_in_pixels.width -
|
||||
double new_content_width = page_size_in_pixels.width() -
|
||||
margin_left_in_pixels - margin_right_in_pixels;
|
||||
int new_content_height = page_size_in_pixels.height -
|
||||
double new_content_height = page_size_in_pixels.height() -
|
||||
margin_top_in_pixels - margin_bottom_in_pixels;
|
||||
|
||||
// Invalid page size and/or margins. We just use the default setting.
|
||||
@@ -115,20 +114,12 @@ PrintMsg_Print_Params GetCssPrintParams(
|
||||
return page_css_params;
|
||||
}
|
||||
|
||||
page_css_params.content_size = gfx::Size(
|
||||
ConvertUnit(new_content_width, kPixelsPerInch, dpi),
|
||||
ConvertUnit(new_content_height, kPixelsPerInch, dpi));
|
||||
|
||||
if (original_page_size_in_pixels != page_size_in_pixels) {
|
||||
page_css_params.page_size = gfx::Size(
|
||||
ConvertUnit(page_size_in_pixels.width, kPixelsPerInch, dpi),
|
||||
ConvertUnit(page_size_in_pixels.height, kPixelsPerInch, dpi));
|
||||
} else {
|
||||
// Printing frame doesn't have any page size css. Pixels to dpi conversion
|
||||
// causes rounding off errors. Therefore use the default page size values
|
||||
// directly.
|
||||
page_css_params.page_size = page_params.page_size;
|
||||
}
|
||||
page_css_params.page_size =
|
||||
gfx::Size(ConvertUnit(page_size_in_pixels.width(), kPixelsPerInch, dpi),
|
||||
ConvertUnit(page_size_in_pixels.height(), kPixelsPerInch, dpi));
|
||||
page_css_params.content_size =
|
||||
gfx::Size(ConvertUnit(new_content_width, kPixelsPerInch, dpi),
|
||||
ConvertUnit(new_content_height, kPixelsPerInch, dpi));
|
||||
|
||||
page_css_params.margin_top =
|
||||
ConvertUnit(margin_top_in_pixels, kPixelsPerInch, dpi);
|
||||
@@ -274,7 +265,7 @@ MarginType GetMarginsForPdf(blink::WebFrame* frame,
|
||||
}
|
||||
|
||||
PrintMsg_Print_Params CalculatePrintParamsForCss(
|
||||
blink::WebFrame* frame,
|
||||
blink::WebLocalFrame* frame,
|
||||
int page_index,
|
||||
const PrintMsg_Print_Params& page_params,
|
||||
bool ignore_css_margins,
|
||||
@@ -429,7 +420,6 @@ class PrepareFrameAndViewForPrint : public blink::WebViewClient,
|
||||
const blink::WebString& unique_name,
|
||||
blink::WebSandboxFlags sandbox_flags,
|
||||
const blink::WebFrameOwnerProperties& frame_owner_properties) override;
|
||||
void frameDetached(blink::WebFrame* frame, DetachType type) override;
|
||||
|
||||
private:
|
||||
void CallOnReady();
|
||||
@@ -567,10 +557,9 @@ void PrepareFrameAndViewForPrint::didStopLoading() {
|
||||
DCHECK(!on_ready_.is_null());
|
||||
// Don't call callback here, because it can delete |this| and WebView that is
|
||||
// called didStopLoading.
|
||||
base::MessageLoop::current()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&PrepareFrameAndViewForPrint::CallOnReady,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE, base::Bind(&PrepareFrameAndViewForPrint::CallOnReady,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
}
|
||||
|
||||
blink::WebFrame* PrepareFrameAndViewForPrint::createChildFrame(
|
||||
@@ -585,14 +574,6 @@ blink::WebFrame* PrepareFrameAndViewForPrint::createChildFrame(
|
||||
return frame;
|
||||
}
|
||||
|
||||
void PrepareFrameAndViewForPrint::frameDetached(blink::WebFrame* frame,
|
||||
DetachType type) {
|
||||
DCHECK(type == DetachType::Remove);
|
||||
if (frame->parent())
|
||||
frame->parent()->removeChild(frame);
|
||||
frame->close();
|
||||
}
|
||||
|
||||
void PrepareFrameAndViewForPrint::CallOnReady() {
|
||||
return on_ready_.Run(); // Can delete |this|.
|
||||
}
|
||||
@@ -640,6 +621,7 @@ PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view)
|
||||
print_node_in_progress_(false),
|
||||
is_loading_(false),
|
||||
is_scripted_preview_delayed_(false),
|
||||
ipc_nesting_level_(0),
|
||||
weak_ptr_factory_(this) {
|
||||
}
|
||||
|
||||
@@ -653,6 +635,15 @@ void PrintWebViewHelper::PrintPage(blink::WebLocalFrame* frame,
|
||||
}
|
||||
|
||||
bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) {
|
||||
// The class is not designed to handle recursive messages. This is not
|
||||
// expected during regular flow. However, during rendering of content for
|
||||
// printing, lower level code may run nested message loop. E.g. PDF may has
|
||||
// script to show message box http://crbug.com/502562. In that moment browser
|
||||
// may receive updated printer capabilities and decide to restart print
|
||||
// preview generation. When this happened message handling function may
|
||||
// choose to ignore message or safely crash process.
|
||||
++ipc_nesting_level_;
|
||||
|
||||
bool handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(PrintWebViewHelper, message)
|
||||
IPC_MESSAGE_HANDLER(PrintMsg_PrintPages, OnPrintPages)
|
||||
@@ -660,6 +651,8 @@ bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) {
|
||||
IPC_MESSAGE_HANDLER(PrintMsg_PrintPreview, OnPrintPreview)
|
||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||
IPC_END_MESSAGE_MAP()
|
||||
|
||||
--ipc_nesting_level_;
|
||||
return handled;
|
||||
}
|
||||
|
||||
@@ -667,28 +660,14 @@ void PrintWebViewHelper::OnDestruct() {
|
||||
delete this;
|
||||
}
|
||||
|
||||
bool PrintWebViewHelper::GetPrintFrame(blink::WebLocalFrame** frame) {
|
||||
DCHECK(frame);
|
||||
blink::WebView* webView = render_view()->GetWebView();
|
||||
DCHECK(webView);
|
||||
if (!webView)
|
||||
return false;
|
||||
|
||||
// If the user has selected text in the currently focused frame we print
|
||||
// only that frame (this makes print selection work for multiple frames).
|
||||
blink::WebLocalFrame* focusedFrame =
|
||||
webView->focusedFrame()->toWebLocalFrame();
|
||||
*frame = focusedFrame->hasSelection()
|
||||
? focusedFrame
|
||||
: webView->mainFrame()->toWebLocalFrame();
|
||||
return true;
|
||||
}
|
||||
|
||||
#if !defined(DISABLE_BASIC_PRINTING)
|
||||
void PrintWebViewHelper::OnPrintPages(bool silent, bool print_background) {
|
||||
blink::WebLocalFrame* frame;
|
||||
if (GetPrintFrame(&frame))
|
||||
Print(frame, blink::WebNode(), silent, print_background);
|
||||
if (ipc_nesting_level_> 1)
|
||||
return;
|
||||
|
||||
blink::WebLocalFrame* frame =
|
||||
render_view()->GetMainRenderFrame()->GetWebFrame();
|
||||
Print(frame, blink::WebNode(), silent, print_background);
|
||||
}
|
||||
#endif // !DISABLE_BASIC_PRINTING
|
||||
|
||||
@@ -725,22 +704,25 @@ void PrintWebViewHelper::OnPrintingDone(bool success) {
|
||||
}
|
||||
|
||||
void PrintWebViewHelper::OnPrintPreview(const base::DictionaryValue& settings) {
|
||||
blink::WebLocalFrame* frame;
|
||||
if (GetPrintFrame(&frame)) {
|
||||
print_preview_context_.InitWithFrame(frame);
|
||||
if (!print_preview_context_.source_frame()) {
|
||||
DidFinishPrinting(FAIL_PREVIEW);
|
||||
return;
|
||||
}
|
||||
if (ipc_nesting_level_ > 1)
|
||||
return;
|
||||
|
||||
if (!UpdatePrintSettings(print_preview_context_.source_frame(),
|
||||
print_preview_context_.source_node(), settings)) {
|
||||
DidFinishPrinting(FAIL_PREVIEW);
|
||||
return;
|
||||
}
|
||||
is_print_ready_metafile_sent_ = false;
|
||||
PrepareFrameForPreviewDocument();
|
||||
blink::WebLocalFrame* frame =
|
||||
render_view()->GetMainRenderFrame()->GetWebFrame();
|
||||
|
||||
print_preview_context_.InitWithFrame(frame);
|
||||
if (!print_preview_context_.source_frame()) {
|
||||
DidFinishPrinting(FAIL_PREVIEW);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UpdatePrintSettings(print_preview_context_.source_frame(),
|
||||
print_preview_context_.source_node(), settings)) {
|
||||
DidFinishPrinting(FAIL_PREVIEW);
|
||||
return;
|
||||
}
|
||||
is_print_ready_metafile_sent_ = false;
|
||||
PrepareFrameForPreviewDocument();
|
||||
}
|
||||
|
||||
void PrintWebViewHelper::PrepareFrameForPreviewDocument() {
|
||||
@@ -972,7 +954,7 @@ void PrintWebViewHelper::FinishFramePrinting() {
|
||||
}
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame,
|
||||
bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame,
|
||||
int page_count) {
|
||||
const PrintMsg_PrintPages_Params& params = *print_pages_params_;
|
||||
const PrintMsg_Print_Params& print_params = params.params;
|
||||
@@ -999,7 +981,7 @@ bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame,
|
||||
|
||||
// static - Not anonymous so that platform implementations can use it.
|
||||
void PrintWebViewHelper::ComputePageLayoutInPointsForCss(
|
||||
blink::WebFrame* frame,
|
||||
blink::WebLocalFrame* frame,
|
||||
int page_index,
|
||||
const PrintMsg_Print_Params& page_params,
|
||||
bool ignore_css_margins,
|
||||
@@ -1120,7 +1102,7 @@ bool PrintWebViewHelper::UpdatePrintSettings(
|
||||
}
|
||||
|
||||
|
||||
bool PrintWebViewHelper::GetPrintSettingsFromUser(blink::WebFrame* frame,
|
||||
bool PrintWebViewHelper::GetPrintSettingsFromUser(blink::WebLocalFrame* frame,
|
||||
const blink::WebNode& node,
|
||||
int expected_pages_count) {
|
||||
PrintHostMsg_ScriptedPrint_Params params;
|
||||
|
||||
@@ -163,7 +163,7 @@ class PrintWebViewHelper
|
||||
|
||||
// Get final print settings from the user.
|
||||
// Return false if the user cancels or on error.
|
||||
bool GetPrintSettingsFromUser(blink::WebFrame* frame,
|
||||
bool GetPrintSettingsFromUser(blink::WebLocalFrame* frame,
|
||||
const blink::WebNode& node,
|
||||
int expected_pages_count);
|
||||
|
||||
@@ -171,23 +171,23 @@ class PrintWebViewHelper
|
||||
|
||||
void OnFramePreparedForPrintPages();
|
||||
void PrintPages();
|
||||
bool PrintPagesNative(blink::WebFrame* frame, int page_count);
|
||||
bool PrintPagesNative(blink::WebLocalFrame* frame, int page_count);
|
||||
void FinishFramePrinting();
|
||||
|
||||
// Prints the page listed in |params|.
|
||||
#if defined(OS_LINUX) || defined(OS_ANDROID)
|
||||
void PrintPageInternal(const PrintMsg_PrintPage_Params& params,
|
||||
blink::WebFrame* frame,
|
||||
blink::WebLocalFrame* frame,
|
||||
PdfMetafileSkia* metafile);
|
||||
#elif defined(OS_WIN)
|
||||
void PrintPageInternal(const PrintMsg_PrintPage_Params& params,
|
||||
blink::WebFrame* frame,
|
||||
blink::WebLocalFrame* frame,
|
||||
PdfMetafileSkia* metafile,
|
||||
gfx::Size* page_size_in_dpi,
|
||||
gfx::Rect* content_area_in_dpi);
|
||||
#else
|
||||
void PrintPageInternal(const PrintMsg_PrintPage_Params& params,
|
||||
blink::WebFrame* frame);
|
||||
blink::WebLocalFrame* frame);
|
||||
#endif
|
||||
|
||||
// Render the frame for printing.
|
||||
@@ -198,7 +198,7 @@ class PrintWebViewHelper
|
||||
#if defined(OS_MACOSX)
|
||||
void RenderPage(const PrintMsg_Print_Params& params,
|
||||
int page_number,
|
||||
blink::WebFrame* frame,
|
||||
blink::WebLocalFrame* frame,
|
||||
bool is_preview,
|
||||
PdfMetafileSkia* metafile,
|
||||
gfx::Size* page_size,
|
||||
@@ -223,15 +223,13 @@ class PrintWebViewHelper
|
||||
|
||||
// Helper method to get page layout in points and fit to page if needed.
|
||||
static void ComputePageLayoutInPointsForCss(
|
||||
blink::WebFrame* frame,
|
||||
blink::WebLocalFrame* frame,
|
||||
int page_index,
|
||||
const PrintMsg_Print_Params& default_params,
|
||||
bool ignore_css_margins,
|
||||
double* scale_factor,
|
||||
PageSizeMargins* page_layout_in_points);
|
||||
|
||||
bool GetPrintFrame(blink::WebLocalFrame** frame);
|
||||
|
||||
// Script Initiated Printing ------------------------------------------------
|
||||
|
||||
// Notifies the browser a print preview page has been rendered.
|
||||
@@ -373,6 +371,7 @@ class PrintWebViewHelper
|
||||
bool print_node_in_progress_;
|
||||
bool is_loading_;
|
||||
bool is_scripted_preview_delayed_;
|
||||
int ipc_nesting_level_;
|
||||
|
||||
PrintPreviewContext print_preview_context_;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
namespace printing {
|
||||
|
||||
using blink::WebFrame;
|
||||
using blink::WebLocalFrame;
|
||||
|
||||
bool PrintWebViewHelper::RenderPreviewPage(
|
||||
int page_number,
|
||||
@@ -56,7 +56,7 @@ bool PrintWebViewHelper::RenderPreviewPage(
|
||||
return PreviewPageRendered(page_number, draft_metafile.get());
|
||||
}
|
||||
|
||||
bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame,
|
||||
bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame,
|
||||
int page_count) {
|
||||
PdfMetafileSkia metafile(PDF_SKIA_DOCUMENT_TYPE);
|
||||
if (!metafile.Init())
|
||||
@@ -113,7 +113,7 @@ bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame,
|
||||
|
||||
void PrintWebViewHelper::PrintPageInternal(
|
||||
const PrintMsg_PrintPage_Params& params,
|
||||
WebFrame* frame,
|
||||
WebLocalFrame* frame,
|
||||
PdfMetafileSkia* metafile) {
|
||||
PageSizeMargins page_layout_in_points;
|
||||
double scale_factor = 1.0f;
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
|
||||
namespace printing {
|
||||
|
||||
using blink::WebFrame;
|
||||
using blink::WebLocalFrame;
|
||||
|
||||
void PrintWebViewHelper::PrintPageInternal(
|
||||
const PrintMsg_PrintPage_Params& params,
|
||||
WebFrame* frame) {
|
||||
WebLocalFrame* frame) {
|
||||
PdfMetafileSkia metafile(PDF_SKIA_DOCUMENT_TYPE);
|
||||
CHECK(metafile.Init());
|
||||
|
||||
@@ -89,7 +89,7 @@ bool PrintWebViewHelper::RenderPreviewPage(
|
||||
|
||||
void PrintWebViewHelper::RenderPage(const PrintMsg_Print_Params& params,
|
||||
int page_number,
|
||||
WebFrame* frame,
|
||||
WebLocalFrame* frame,
|
||||
bool is_preview,
|
||||
PdfMetafileSkia* metafile,
|
||||
gfx::Size* page_size,
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
namespace printing {
|
||||
|
||||
using blink::WebFrame;
|
||||
using blink::WebLocalFrame;
|
||||
|
||||
bool PrintWebViewHelper::RenderPreviewPage(
|
||||
int page_number,
|
||||
@@ -55,7 +55,7 @@ bool PrintWebViewHelper::RenderPreviewPage(
|
||||
return PreviewPageRendered(page_number, draft_metafile.get());
|
||||
}
|
||||
|
||||
bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame,
|
||||
bool PrintWebViewHelper::PrintPagesNative(blink::WebLocalFrame* frame,
|
||||
int page_count) {
|
||||
PdfMetafileSkia metafile(PDF_SKIA_DOCUMENT_TYPE);
|
||||
if (!metafile.Init())
|
||||
@@ -122,7 +122,7 @@ bool PrintWebViewHelper::PrintPagesNative(blink::WebFrame* frame,
|
||||
|
||||
void PrintWebViewHelper::PrintPageInternal(
|
||||
const PrintMsg_PrintPage_Params& params,
|
||||
WebFrame* frame,
|
||||
WebLocalFrame* frame,
|
||||
PdfMetafileSkia* metafile,
|
||||
gfx::Size* page_size_in_dpi,
|
||||
gfx::Rect* content_area_in_dpi) {
|
||||
|
||||
11
common.gypi
11
common.gypi
@@ -119,6 +119,7 @@
|
||||
'-Wno-deprecated-declarations',
|
||||
'-Wno-return-type',
|
||||
'-Wno-shift-negative-value',
|
||||
'-Wno-format',
|
||||
'-Wno-varargs', # https://git.io/v6Olj
|
||||
# Required when building as shared library.
|
||||
'-fPIC',
|
||||
@@ -147,8 +148,13 @@
|
||||
'include_dirs': [
|
||||
'<(DEPTH)/atom/node',
|
||||
],
|
||||
# Node is using networking API but linking with this itself.
|
||||
'libraries': [ '-lwinmm.lib' ],
|
||||
'libraries': [
|
||||
# Node is using networking API but linking with this itself.
|
||||
'-lwinmm.lib',
|
||||
# Needed by V8.
|
||||
'-ldbghelp.lib',
|
||||
'-lshlwapi.lib',
|
||||
],
|
||||
# Fix the linking error with icu.
|
||||
'conditions': [
|
||||
['libchromiumcontent_component==0', {
|
||||
@@ -235,6 +241,7 @@
|
||||
'xcode_settings': {
|
||||
'WARNING_CFLAGS': [
|
||||
'-Wno-unused-private-field',
|
||||
'-Wno-address-of-packed-member',
|
||||
],
|
||||
},
|
||||
}], # OS=="mac"
|
||||
|
||||
@@ -86,6 +86,9 @@ app.once('ready', () => {
|
||||
{
|
||||
role: 'reload'
|
||||
},
|
||||
{
|
||||
role: 'forcereload'
|
||||
},
|
||||
{
|
||||
role: 'toggledevtools'
|
||||
},
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
> どうやってNode.jsとElectronのAPIを使うか。
|
||||
|
||||
Electron では全ての [Node.js のビルトインモジュール](http://nodejs.org/api/) 利用可能です。また、サードパーティの Node モジュール ([ネイティブモジュール](../tutorial/using-native-node-modules.md)も含む) も完全にサポートされています。
|
||||
Electron では全ての [Node.js のビルトインモジュール](http://nodejs.org/api/) が利用可能です。また、サードパーティの Node モジュール ([ネイティブモジュール](../tutorial/using-native-node-modules.md)も含む) も完全にサポートされています。
|
||||
|
||||
Electron はネイティブのデスクトップアプリケーション開発のための幾つかの追加のビルトインモジュールも提供しています。メインプロセスでだけ使えるモジュールもあれば、レンダラプロセス(ウェブページ)でだけ使えるモジュール、あるいはメインプロセス、レンダラプロセスどちらでも使えるモジュールもあります。
|
||||
|
||||
@@ -39,7 +39,7 @@ app.on('ready', () => {
|
||||
|
||||
## 分割代入
|
||||
|
||||
0.37の時点で、 、[分割代入][desctructuring-assignment]でビルトインモジュールの使用をより簡単にできます:
|
||||
0.37の時点で、[分割代入][desctructuring-assignment]でビルトインモジュールの使用をより簡単にできます:
|
||||
|
||||
```javascript
|
||||
const {app, BrowserWindow} = require('electron')
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user