Merge pull request #12648 from electron/clang-format-atom
clang-format atom files
This commit is contained in:
commit
47826a1262
309 changed files with 4870 additions and 5005 deletions
|
@ -1 +0,0 @@
|
||||||
filter=+build/include_alpha
|
|
|
@ -61,15 +61,14 @@ content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path,
|
||||||
flash_version_numbers.push_back("999");
|
flash_version_numbers.push_back("999");
|
||||||
// E.g., "Shockwave Flash 10.2 r154":
|
// E.g., "Shockwave Flash 10.2 r154":
|
||||||
plugin.description = plugin.name + " " + flash_version_numbers[0] + "." +
|
plugin.description = plugin.name + " " + flash_version_numbers[0] + "." +
|
||||||
flash_version_numbers[1] + " r" + flash_version_numbers[2];
|
flash_version_numbers[1] + " r" +
|
||||||
|
flash_version_numbers[2];
|
||||||
plugin.version = base::JoinString(flash_version_numbers, ".");
|
plugin.version = base::JoinString(flash_version_numbers, ".");
|
||||||
content::WebPluginMimeType swf_mime_type(
|
content::WebPluginMimeType swf_mime_type(content::kFlashPluginSwfMimeType,
|
||||||
content::kFlashPluginSwfMimeType,
|
|
||||||
content::kFlashPluginSwfExtension,
|
content::kFlashPluginSwfExtension,
|
||||||
content::kFlashPluginSwfDescription);
|
content::kFlashPluginSwfDescription);
|
||||||
plugin.mime_types.push_back(swf_mime_type);
|
plugin.mime_types.push_back(swf_mime_type);
|
||||||
content::WebPluginMimeType spl_mime_type(
|
content::WebPluginMimeType spl_mime_type(content::kFlashPluginSplMimeType,
|
||||||
content::kFlashPluginSplMimeType,
|
|
||||||
content::kFlashPluginSplExtension,
|
content::kFlashPluginSplExtension,
|
||||||
content::kFlashPluginSplDescription);
|
content::kFlashPluginSplDescription);
|
||||||
plugin.mime_types.push_back(spl_mime_type);
|
plugin.mime_types.push_back(spl_mime_type);
|
||||||
|
@ -84,13 +83,11 @@ content::PepperPluginInfo CreateWidevineCdmInfo(const base::FilePath& path,
|
||||||
widevine_cdm.is_out_of_process = true;
|
widevine_cdm.is_out_of_process = true;
|
||||||
widevine_cdm.path = path;
|
widevine_cdm.path = path;
|
||||||
widevine_cdm.name = kWidevineCdmDisplayName;
|
widevine_cdm.name = kWidevineCdmDisplayName;
|
||||||
widevine_cdm.description = kWidevineCdmDescription +
|
widevine_cdm.description =
|
||||||
std::string(" (version: ") +
|
kWidevineCdmDescription + std::string(" (version: ") + version + ")";
|
||||||
version + ")";
|
|
||||||
widevine_cdm.version = version;
|
widevine_cdm.version = version;
|
||||||
content::WebPluginMimeType widevine_cdm_mime_type(
|
content::WebPluginMimeType widevine_cdm_mime_type(
|
||||||
kWidevineCdmPluginMimeType,
|
kWidevineCdmPluginMimeType, kWidevineCdmPluginExtension,
|
||||||
kWidevineCdmPluginExtension,
|
|
||||||
kWidevineCdmPluginMimeTypeDescription);
|
kWidevineCdmPluginMimeTypeDescription);
|
||||||
|
|
||||||
// Add the supported codecs as if they came from the component manifest.
|
// Add the supported codecs as if they came from the component manifest.
|
||||||
|
@ -142,8 +139,7 @@ void ConvertStringWithSeparatorToVector(std::vector<std::string>* vec,
|
||||||
auto string_with_separator = command_line->GetSwitchValueASCII(cmd_switch);
|
auto string_with_separator = command_line->GetSwitchValueASCII(cmd_switch);
|
||||||
if (!string_with_separator.empty())
|
if (!string_with_separator.empty())
|
||||||
*vec = base::SplitString(string_with_separator, separator,
|
*vec = base::SplitString(string_with_separator, separator,
|
||||||
base::TRIM_WHITESPACE,
|
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
||||||
base::SPLIT_WANT_NONEMPTY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -151,13 +147,13 @@ void ConvertStringWithSeparatorToVector(std::vector<std::string>* vec,
|
||||||
void AddPepperFlashFromCommandLine(
|
void AddPepperFlashFromCommandLine(
|
||||||
std::vector<content::PepperPluginInfo>* plugins) {
|
std::vector<content::PepperPluginInfo>* plugins) {
|
||||||
auto command_line = base::CommandLine::ForCurrentProcess();
|
auto command_line = base::CommandLine::ForCurrentProcess();
|
||||||
base::FilePath flash_path = command_line->GetSwitchValuePath(
|
base::FilePath flash_path =
|
||||||
switches::kPpapiFlashPath);
|
command_line->GetSwitchValuePath(switches::kPpapiFlashPath);
|
||||||
if (flash_path.empty())
|
if (flash_path.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto flash_version = command_line->GetSwitchValueASCII(
|
auto flash_version =
|
||||||
switches::kPpapiFlashVersion);
|
command_line->GetSwitchValueASCII(switches::kPpapiFlashVersion);
|
||||||
|
|
||||||
plugins->push_back(CreatePepperFlashInfo(flash_path, flash_version));
|
plugins->push_back(CreatePepperFlashInfo(flash_path, flash_version));
|
||||||
}
|
}
|
||||||
|
@ -166,38 +162,36 @@ void AddPepperFlashFromCommandLine(
|
||||||
void AddWidevineCdmFromCommandLine(
|
void AddWidevineCdmFromCommandLine(
|
||||||
std::vector<content::PepperPluginInfo>* plugins) {
|
std::vector<content::PepperPluginInfo>* plugins) {
|
||||||
auto command_line = base::CommandLine::ForCurrentProcess();
|
auto command_line = base::CommandLine::ForCurrentProcess();
|
||||||
base::FilePath widevine_cdm_path = command_line->GetSwitchValuePath(
|
base::FilePath widevine_cdm_path =
|
||||||
switches::kWidevineCdmPath);
|
command_line->GetSwitchValuePath(switches::kWidevineCdmPath);
|
||||||
if (widevine_cdm_path.empty())
|
if (widevine_cdm_path.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!base::PathExists(widevine_cdm_path))
|
if (!base::PathExists(widevine_cdm_path))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto widevine_cdm_version = command_line->GetSwitchValueASCII(
|
auto widevine_cdm_version =
|
||||||
switches::kWidevineCdmVersion);
|
command_line->GetSwitchValueASCII(switches::kWidevineCdmVersion);
|
||||||
if (widevine_cdm_version.empty())
|
if (widevine_cdm_version.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
plugins->push_back(CreateWidevineCdmInfo(widevine_cdm_path,
|
plugins->push_back(
|
||||||
widevine_cdm_version));
|
CreateWidevineCdmInfo(widevine_cdm_path, widevine_cdm_version));
|
||||||
}
|
}
|
||||||
#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
|
||||||
|
|
||||||
AtomContentClient::AtomContentClient() {
|
AtomContentClient::AtomContentClient() {}
|
||||||
}
|
|
||||||
|
|
||||||
AtomContentClient::~AtomContentClient() {
|
AtomContentClient::~AtomContentClient() {}
|
||||||
}
|
|
||||||
|
|
||||||
std::string AtomContentClient::GetProduct() const {
|
std::string AtomContentClient::GetProduct() const {
|
||||||
return "Chrome/" CHROME_VERSION_STRING;
|
return "Chrome/" CHROME_VERSION_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string AtomContentClient::GetUserAgent() const {
|
std::string AtomContentClient::GetUserAgent() const {
|
||||||
return content::BuildUserAgentFromProduct(
|
return content::BuildUserAgentFromProduct("Chrome/" CHROME_VERSION_STRING
|
||||||
"Chrome/" CHROME_VERSION_STRING " "
|
" " ATOM_PRODUCT_NAME
|
||||||
ATOM_PRODUCT_NAME "/" ATOM_VERSION_STRING);
|
"/" ATOM_VERSION_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
base::string16 AtomContentClient::GetLocalizedString(int message_id) const {
|
base::string16 AtomContentClient::GetLocalizedString(int message_id) const {
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
__attribute__((visibility("default")))
|
__attribute__((visibility("default"))) int AtomMain(int argc, char* argv[]);
|
||||||
int AtomMain(int argc, char* argv[]);
|
|
||||||
|
|
||||||
#ifdef ENABLE_RUN_AS_NODE
|
#ifdef ENABLE_RUN_AS_NODE
|
||||||
__attribute__((visibility("default")))
|
__attribute__((visibility("default"))) int AtomInitializeICUandStartNode(
|
||||||
int AtomInitializeICUandStartNode(int argc, char *argv[]);
|
int argc,
|
||||||
|
char* argv[]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif // OS_MACOSX
|
#endif // OS_MACOSX
|
||||||
|
|
|
@ -117,9 +117,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
|
||||||
// from within the CRT's atexit facility, ensuring the heap functions are
|
// from within the CRT's atexit facility, ensuring the heap functions are
|
||||||
// still active. The second invocation from the OS loader will be a no-op.
|
// still active. The second invocation from the OS loader will be a no-op.
|
||||||
extern void NTAPI OnThreadExit(PVOID module, DWORD reason, PVOID reserved);
|
extern void NTAPI OnThreadExit(PVOID module, DWORD reason, PVOID reserved);
|
||||||
atexit([]() {
|
atexit([]() { OnThreadExit(nullptr, DLL_THREAD_DETACH, nullptr); });
|
||||||
OnThreadExit(nullptr, DLL_THREAD_DETACH, nullptr);
|
|
||||||
});
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_RUN_AS_NODE
|
#ifdef ENABLE_RUN_AS_NODE
|
||||||
|
|
|
@ -45,19 +45,20 @@ bool IsBrowserProcess(base::CommandLine* cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
void InvalidParameterHandler(const wchar_t*, const wchar_t*, const wchar_t*,
|
void InvalidParameterHandler(const wchar_t*,
|
||||||
unsigned int, uintptr_t) {
|
const wchar_t*,
|
||||||
|
const wchar_t*,
|
||||||
|
unsigned int,
|
||||||
|
uintptr_t) {
|
||||||
// noop.
|
// noop.
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
AtomMainDelegate::AtomMainDelegate() {
|
AtomMainDelegate::AtomMainDelegate() {}
|
||||||
}
|
|
||||||
|
|
||||||
AtomMainDelegate::~AtomMainDelegate() {
|
AtomMainDelegate::~AtomMainDelegate() {}
|
||||||
}
|
|
||||||
|
|
||||||
bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
|
bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
|
||||||
auto command_line = base::CommandLine::ForCurrentProcess();
|
auto command_line = base::CommandLine::ForCurrentProcess();
|
||||||
|
@ -129,8 +130,8 @@ void AtomMainDelegate::PreSandboxStartup() {
|
||||||
brightray::MainDelegate::PreSandboxStartup();
|
brightray::MainDelegate::PreSandboxStartup();
|
||||||
|
|
||||||
auto command_line = base::CommandLine::ForCurrentProcess();
|
auto command_line = base::CommandLine::ForCurrentProcess();
|
||||||
std::string process_type = command_line->GetSwitchValueASCII(
|
std::string process_type =
|
||||||
::switches::kProcessType);
|
command_line->GetSwitchValueASCII(::switches::kProcessType);
|
||||||
|
|
||||||
// Only append arguments for browser process.
|
// Only append arguments for browser process.
|
||||||
if (!IsBrowserProcess(command_line))
|
if (!IsBrowserProcess(command_line))
|
||||||
|
|
|
@ -14,4 +14,3 @@ bool CheckCommandLineArguments(int argc, base::CommandLine::CharType** argv);
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
||||||
#endif // ATOM_APP_COMMAND_LINE_ARGS_H_
|
#endif // ATOM_APP_COMMAND_LINE_ARGS_H_
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,7 @@
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
UvTaskRunner::UvTaskRunner(uv_loop_t* loop) : loop_(loop) {
|
UvTaskRunner::UvTaskRunner(uv_loop_t* loop) : loop_(loop) {}
|
||||||
}
|
|
||||||
|
|
||||||
UvTaskRunner::~UvTaskRunner() {
|
UvTaskRunner::~UvTaskRunner() {
|
||||||
for (auto& iter : tasks_) {
|
for (auto& iter : tasks_) {
|
||||||
|
@ -35,8 +34,7 @@ bool UvTaskRunner::RunsTasksInCurrentSequence() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UvTaskRunner::PostNonNestableDelayedTask(
|
bool UvTaskRunner::PostNonNestableDelayedTask(const base::Location& from_here,
|
||||||
const base::Location& from_here,
|
|
||||||
base::OnceClosure task,
|
base::OnceClosure task,
|
||||||
base::TimeDelta delay) {
|
base::TimeDelta delay) {
|
||||||
return PostDelayedTask(from_here, std::move(task), delay);
|
return PostDelayedTask(from_here, std::move(task), delay);
|
||||||
|
|
|
@ -25,8 +25,7 @@ class UvTaskRunner : public base::SingleThreadTaskRunner {
|
||||||
base::OnceClosure task,
|
base::OnceClosure task,
|
||||||
base::TimeDelta delay) override;
|
base::TimeDelta delay) override;
|
||||||
bool RunsTasksInCurrentSequence() const override;
|
bool RunsTasksInCurrentSequence() const override;
|
||||||
bool PostNonNestableDelayedTask(
|
bool PostNonNestableDelayedTask(const base::Location& from_here,
|
||||||
const base::Location& from_here,
|
|
||||||
base::OnceClosure task,
|
base::OnceClosure task,
|
||||||
base::TimeDelta delay) override;
|
base::TimeDelta delay) override;
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,8 @@ namespace mate {
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
template <>
|
template <>
|
||||||
struct Converter<Browser::UserTask> {
|
struct Converter<Browser::UserTask> {
|
||||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Value> val,
|
||||||
Browser::UserTask* out) {
|
Browser::UserTask* out) {
|
||||||
mate::Dictionary dict;
|
mate::Dictionary dict;
|
||||||
if (!ConvertFromV8(isolate, val, &dict))
|
if (!ConvertFromV8(isolate, val, &dict))
|
||||||
|
@ -83,13 +84,14 @@ struct Converter<Browser::UserTask> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
using atom::JumpListItem;
|
|
||||||
using atom::JumpListCategory;
|
using atom::JumpListCategory;
|
||||||
|
using atom::JumpListItem;
|
||||||
using atom::JumpListResult;
|
using atom::JumpListResult;
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Converter<JumpListItem::Type> {
|
struct Converter<JumpListItem::Type> {
|
||||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Value> val,
|
||||||
JumpListItem::Type* out) {
|
JumpListItem::Type* out) {
|
||||||
std::string item_type;
|
std::string item_type;
|
||||||
if (!ConvertFromV8(isolate, val, &item_type))
|
if (!ConvertFromV8(isolate, val, &item_type))
|
||||||
|
@ -129,7 +131,8 @@ struct Converter<JumpListItem::Type> {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Converter<JumpListItem> {
|
struct Converter<JumpListItem> {
|
||||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Value> val,
|
||||||
JumpListItem* out) {
|
JumpListItem* out) {
|
||||||
mate::Dictionary dict;
|
mate::Dictionary dict;
|
||||||
if (!ConvertFromV8(isolate, val, &dict))
|
if (!ConvertFromV8(isolate, val, &dict))
|
||||||
|
@ -191,7 +194,8 @@ struct Converter<JumpListItem> {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Converter<JumpListCategory::Type> {
|
struct Converter<JumpListCategory::Type> {
|
||||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Value> val,
|
||||||
JumpListCategory::Type* out) {
|
JumpListCategory::Type* out) {
|
||||||
std::string category_type;
|
std::string category_type;
|
||||||
if (!ConvertFromV8(isolate, val, &category_type))
|
if (!ConvertFromV8(isolate, val, &category_type))
|
||||||
|
@ -237,7 +241,8 @@ struct Converter<JumpListCategory::Type> {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Converter<JumpListCategory> {
|
struct Converter<JumpListCategory> {
|
||||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Value> val,
|
||||||
JumpListCategory* out) {
|
JumpListCategory* out) {
|
||||||
mate::Dictionary dict;
|
mate::Dictionary dict;
|
||||||
if (!ConvertFromV8(isolate, val, &dict))
|
if (!ConvertFromV8(isolate, val, &dict))
|
||||||
|
@ -300,7 +305,8 @@ struct Converter<JumpListResult> {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Converter<Browser::LoginItemSettings> {
|
struct Converter<Browser::LoginItemSettings> {
|
||||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Value> val,
|
||||||
Browser::LoginItemSettings* out) {
|
Browser::LoginItemSettings* out) {
|
||||||
mate::Dictionary dict;
|
mate::Dictionary dict;
|
||||||
if (!ConvertFromV8(isolate, val, &dict))
|
if (!ConvertFromV8(isolate, val, &dict))
|
||||||
|
@ -327,13 +333,14 @@ struct Converter<Browser::LoginItemSettings> {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Converter<content::CertificateRequestResultType> {
|
struct Converter<content::CertificateRequestResultType> {
|
||||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Value> val,
|
||||||
content::CertificateRequestResultType* out) {
|
content::CertificateRequestResultType* out) {
|
||||||
bool b;
|
bool b;
|
||||||
if (!ConvertFromV8(isolate, val, &b))
|
if (!ConvertFromV8(isolate, val, &b))
|
||||||
return false;
|
return false;
|
||||||
*out = b ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE :
|
*out = b ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE
|
||||||
content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL;
|
: content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -414,8 +421,8 @@ bool NotificationCallbackWrapper(
|
||||||
} else {
|
} else {
|
||||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner(
|
scoped_refptr<base::SingleThreadTaskRunner> task_runner(
|
||||||
base::ThreadTaskRunnerHandle::Get());
|
base::ThreadTaskRunnerHandle::Get());
|
||||||
task_runner->PostTask(
|
task_runner->PostTask(FROM_HERE,
|
||||||
FROM_HERE, base::Bind(base::IgnoreResult(callback), cmd, cwd));
|
base::Bind(base::IgnoreResult(callback), cmd, cwd));
|
||||||
}
|
}
|
||||||
// ProcessSingleton needs to know whether current process is quiting.
|
// ProcessSingleton needs to know whether current process is quiting.
|
||||||
return !Browser::Get()->is_shutting_down();
|
return !Browser::Get()->is_shutting_down();
|
||||||
|
@ -479,8 +486,7 @@ void PassLoginInformation(scoped_refptr<LoginHandler> login_handler,
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(USE_NSS_CERTS)
|
#if defined(USE_NSS_CERTS)
|
||||||
int ImportIntoCertStore(
|
int ImportIntoCertStore(CertificateManagerModel* model,
|
||||||
CertificateManagerModel* model,
|
|
||||||
const base::DictionaryValue& options) {
|
const base::DictionaryValue& options) {
|
||||||
std::string file_data, cert_path;
|
std::string file_data, cert_path;
|
||||||
base::string16 password;
|
base::string16 password;
|
||||||
|
@ -492,17 +498,13 @@ int ImportIntoCertStore(
|
||||||
if (!cert_path.empty()) {
|
if (!cert_path.empty()) {
|
||||||
if (base::ReadFileToString(base::FilePath(cert_path), &file_data)) {
|
if (base::ReadFileToString(base::FilePath(cert_path), &file_data)) {
|
||||||
auto module = model->cert_db()->GetPrivateSlot();
|
auto module = model->cert_db()->GetPrivateSlot();
|
||||||
rv = model->ImportFromPKCS12(module.get(),
|
rv = model->ImportFromPKCS12(module.get(), file_data, password, true,
|
||||||
file_data,
|
|
||||||
password,
|
|
||||||
true,
|
|
||||||
&imported_certs);
|
&imported_certs);
|
||||||
if (imported_certs.size() > 1) {
|
if (imported_certs.size() > 1) {
|
||||||
auto it = imported_certs.begin();
|
auto it = imported_certs.begin();
|
||||||
++it; // skip first which would be the client certificate.
|
++it; // skip first which would be the client certificate.
|
||||||
for (; it != imported_certs.end(); ++it)
|
for (; it != imported_certs.end(); ++it)
|
||||||
rv &= model->SetCertTrust(it->get(),
|
rv &= model->SetCertTrust(it->get(), net::CA_CERT,
|
||||||
net::CA_CERT,
|
|
||||||
net::NSSCertDatabase::TRUSTED_SSL);
|
net::NSSCertDatabase::TRUSTED_SSL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -533,18 +535,16 @@ App::App(v8::Isolate* isolate) {
|
||||||
Browser::Get()->AddObserver(this);
|
Browser::Get()->AddObserver(this);
|
||||||
content::GpuDataManager::GetInstance()->AddObserver(this);
|
content::GpuDataManager::GetInstance()->AddObserver(this);
|
||||||
base::ProcessId pid = base::GetCurrentProcId();
|
base::ProcessId pid = base::GetCurrentProcId();
|
||||||
std::unique_ptr<atom::ProcessMetric> process_metric(
|
std::unique_ptr<atom::ProcessMetric> process_metric(new atom::ProcessMetric(
|
||||||
new atom::ProcessMetric(
|
content::PROCESS_TYPE_BROWSER, pid,
|
||||||
content::PROCESS_TYPE_BROWSER,
|
|
||||||
pid,
|
|
||||||
base::ProcessMetrics::CreateCurrentProcessMetrics()));
|
base::ProcessMetrics::CreateCurrentProcessMetrics()));
|
||||||
app_metrics_[pid] = std::move(process_metric);
|
app_metrics_[pid] = std::move(process_metric);
|
||||||
Init(isolate);
|
Init(isolate);
|
||||||
}
|
}
|
||||||
|
|
||||||
App::~App() {
|
App::~App() {
|
||||||
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())->set_delegate(
|
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())
|
||||||
nullptr);
|
->set_delegate(nullptr);
|
||||||
Browser::Get()->RemoveObserver(this);
|
Browser::Get()->RemoveObserver(this);
|
||||||
content::GpuDataManager::GetInstance()->RemoveObserver(this);
|
content::GpuDataManager::GetInstance()->RemoveObserver(this);
|
||||||
content::BrowserChildProcessObserver::Remove(this);
|
content::BrowserChildProcessObserver::Remove(this);
|
||||||
|
@ -609,33 +609,28 @@ void App::OnAccessibilitySupportChanged() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
void App::OnWillContinueUserActivity(
|
void App::OnWillContinueUserActivity(bool* prevent_default,
|
||||||
bool* prevent_default,
|
|
||||||
const std::string& type) {
|
const std::string& type) {
|
||||||
*prevent_default = Emit("will-continue-activity", type);
|
*prevent_default = Emit("will-continue-activity", type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::OnDidFailToContinueUserActivity(
|
void App::OnDidFailToContinueUserActivity(const std::string& type,
|
||||||
const std::string& type,
|
|
||||||
const std::string& error) {
|
const std::string& error) {
|
||||||
Emit("continue-activity-error", type, error);
|
Emit("continue-activity-error", type, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::OnContinueUserActivity(
|
void App::OnContinueUserActivity(bool* prevent_default,
|
||||||
bool* prevent_default,
|
|
||||||
const std::string& type,
|
const std::string& type,
|
||||||
const base::DictionaryValue& user_info) {
|
const base::DictionaryValue& user_info) {
|
||||||
*prevent_default = Emit("continue-activity", type, user_info);
|
*prevent_default = Emit("continue-activity", type, user_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::OnUserActivityWasContinued(
|
void App::OnUserActivityWasContinued(const std::string& type,
|
||||||
const std::string& type,
|
|
||||||
const base::DictionaryValue& user_info) {
|
const base::DictionaryValue& user_info) {
|
||||||
Emit("activity-was-continued", type, user_info);
|
Emit("activity-was-continued", type, user_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::OnUpdateUserActivityState(
|
void App::OnUpdateUserActivityState(bool* prevent_default,
|
||||||
bool* prevent_default,
|
|
||||||
const std::string& type,
|
const std::string& type,
|
||||||
const base::DictionaryValue& user_info) {
|
const base::DictionaryValue& user_info) {
|
||||||
*prevent_default = Emit("update-activity-state", type, user_info);
|
*prevent_default = Emit("update-activity-state", type, user_info);
|
||||||
|
@ -654,12 +649,9 @@ void App::OnLogin(LoginHandler* login_handler,
|
||||||
content::WebContents* web_contents = login_handler->GetWebContents();
|
content::WebContents* web_contents = login_handler->GetWebContents();
|
||||||
if (web_contents) {
|
if (web_contents) {
|
||||||
prevent_default =
|
prevent_default =
|
||||||
Emit("login",
|
Emit("login", WebContents::CreateFrom(isolate(), web_contents),
|
||||||
WebContents::CreateFrom(isolate(), web_contents),
|
request_details, login_handler->auth_info(),
|
||||||
request_details,
|
base::Bind(&PassLoginInformation, WrapRefCounted(login_handler)));
|
||||||
login_handler->auth_info(),
|
|
||||||
base::Bind(&PassLoginInformation,
|
|
||||||
WrapRefCounted(login_handler)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default behavior is to always cancel the auth.
|
// Default behavior is to always cancel the auth.
|
||||||
|
@ -708,12 +700,9 @@ void App::AllowCertificateError(
|
||||||
callback) {
|
callback) {
|
||||||
v8::Locker locker(isolate());
|
v8::Locker locker(isolate());
|
||||||
v8::HandleScope handle_scope(isolate());
|
v8::HandleScope handle_scope(isolate());
|
||||||
bool prevent_default = Emit("certificate-error",
|
bool prevent_default = Emit(
|
||||||
WebContents::CreateFrom(isolate(), web_contents),
|
"certificate-error", WebContents::CreateFrom(isolate(), web_contents),
|
||||||
request_url,
|
request_url, net::ErrorToString(cert_error), ssl_info.cert, callback);
|
||||||
net::ErrorToString(cert_error),
|
|
||||||
ssl_info.cert,
|
|
||||||
callback);
|
|
||||||
|
|
||||||
// Deny the certificate by default.
|
// Deny the certificate by default.
|
||||||
if (!prevent_default)
|
if (!prevent_default)
|
||||||
|
@ -725,8 +714,8 @@ void App::SelectClientCertificate(
|
||||||
net::SSLCertRequestInfo* cert_request_info,
|
net::SSLCertRequestInfo* cert_request_info,
|
||||||
net::ClientCertIdentityList identities,
|
net::ClientCertIdentityList identities,
|
||||||
std::unique_ptr<content::ClientCertificateDelegate> delegate) {
|
std::unique_ptr<content::ClientCertificateDelegate> delegate) {
|
||||||
std::shared_ptr<content::ClientCertificateDelegate>
|
std::shared_ptr<content::ClientCertificateDelegate> shared_delegate(
|
||||||
shared_delegate(delegate.release());
|
delegate.release());
|
||||||
|
|
||||||
// Convert the ClientCertIdentityList to a CertificateList
|
// Convert the ClientCertIdentityList to a CertificateList
|
||||||
// to avoid changes in the API.
|
// to avoid changes in the API.
|
||||||
|
@ -918,7 +907,8 @@ bool App::Relaunch(mate::Arguments* js_args) {
|
||||||
|
|
||||||
void App::DisableHardwareAcceleration(mate::Arguments* args) {
|
void App::DisableHardwareAcceleration(mate::Arguments* args) {
|
||||||
if (Browser::Get()->is_ready()) {
|
if (Browser::Get()->is_ready()) {
|
||||||
args->ThrowError("app.disableHardwareAcceleration() can only be called "
|
args->ThrowError(
|
||||||
|
"app.disableHardwareAcceleration() can only be called "
|
||||||
"before app is ready");
|
"before app is ready");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -958,8 +948,7 @@ Browser::LoginItemSettings App::GetLoginItemSettings(mate::Arguments* args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(USE_NSS_CERTS)
|
#if defined(USE_NSS_CERTS)
|
||||||
void App::ImportCertificate(
|
void App::ImportCertificate(const base::DictionaryValue& options,
|
||||||
const base::DictionaryValue& options,
|
|
||||||
const net::CompletionCallback& callback) {
|
const net::CompletionCallback& callback) {
|
||||||
auto browser_context = AtomBrowserContext::From("", false);
|
auto browser_context = AtomBrowserContext::From("", false);
|
||||||
if (!certificate_manager_model_) {
|
if (!certificate_manager_model_) {
|
||||||
|
@ -967,9 +956,7 @@ void App::ImportCertificate(
|
||||||
CertificateManagerModel::Create(
|
CertificateManagerModel::Create(
|
||||||
browser_context.get(),
|
browser_context.get(),
|
||||||
base::Bind(&App::OnCertificateManagerModelCreated,
|
base::Bind(&App::OnCertificateManagerModelCreated,
|
||||||
base::Unretained(this),
|
base::Unretained(this), base::Passed(©), callback));
|
||||||
base::Passed(©),
|
|
||||||
callback));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -982,8 +969,8 @@ void App::OnCertificateManagerModelCreated(
|
||||||
const net::CompletionCallback& callback,
|
const net::CompletionCallback& callback,
|
||||||
std::unique_ptr<CertificateManagerModel> model) {
|
std::unique_ptr<CertificateManagerModel> model) {
|
||||||
certificate_manager_model_ = std::move(model);
|
certificate_manager_model_ = std::move(model);
|
||||||
int rv = ImportIntoCertStore(certificate_manager_model_.get(),
|
int rv =
|
||||||
*(options.get()));
|
ImportIntoCertStore(certificate_manager_model_.get(), *(options.get()));
|
||||||
callback.Run(rv);
|
callback.Run(rv);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1020,8 +1007,7 @@ JumpListResult App::SetJumpList(v8::Local<v8::Value> val,
|
||||||
JumpList jump_list(Browser::Get()->GetAppUserModelID());
|
JumpList jump_list(Browser::Get()->GetAppUserModelID());
|
||||||
|
|
||||||
if (delete_jump_list) {
|
if (delete_jump_list) {
|
||||||
return jump_list.Delete()
|
return jump_list.Delete() ? JumpListResult::SUCCESS
|
||||||
? JumpListResult::SUCCESS
|
|
||||||
: JumpListResult::GENERIC_ERROR;
|
: JumpListResult::GENERIC_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1045,8 +1031,7 @@ JumpListResult App::SetJumpList(v8::Local<v8::Value> val,
|
||||||
}
|
}
|
||||||
#endif // defined(OS_WIN)
|
#endif // defined(OS_WIN)
|
||||||
|
|
||||||
void App::GetFileIcon(const base::FilePath& path,
|
void App::GetFileIcon(const base::FilePath& path, mate::Arguments* args) {
|
||||||
mate::Arguments* args) {
|
|
||||||
mate::Dictionary options;
|
mate::Dictionary options;
|
||||||
IconLoader::IconSize icon_size;
|
IconLoader::IconSize icon_size;
|
||||||
FileIconCallback callback;
|
FileIconCallback callback;
|
||||||
|
@ -1091,10 +1076,12 @@ std::vector<mate::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
|
||||||
mate::Dictionary memory_dict = mate::Dictionary::CreateEmpty(isolate);
|
mate::Dictionary memory_dict = mate::Dictionary::CreateEmpty(isolate);
|
||||||
mate::Dictionary cpu_dict = mate::Dictionary::CreateEmpty(isolate);
|
mate::Dictionary cpu_dict = mate::Dictionary::CreateEmpty(isolate);
|
||||||
|
|
||||||
memory_dict.Set("workingSetSize",
|
memory_dict.Set(
|
||||||
|
"workingSetSize",
|
||||||
static_cast<double>(
|
static_cast<double>(
|
||||||
process_metric.second->metrics->GetWorkingSetSize() >> 10));
|
process_metric.second->metrics->GetWorkingSetSize() >> 10));
|
||||||
memory_dict.Set("peakWorkingSetSize",
|
memory_dict.Set(
|
||||||
|
"peakWorkingSetSize",
|
||||||
static_cast<double>(
|
static_cast<double>(
|
||||||
process_metric.second->metrics->GetPeakWorkingSetSize() >> 10));
|
process_metric.second->metrics->GetPeakWorkingSetSize() >> 10));
|
||||||
|
|
||||||
|
@ -1106,9 +1093,10 @@ std::vector<mate::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_dict.Set("memory", memory_dict);
|
pid_dict.Set("memory", memory_dict);
|
||||||
cpu_dict.Set("percentCPUUsage",
|
cpu_dict.Set(
|
||||||
process_metric.second->metrics->GetPlatformIndependentCPUUsage()
|
"percentCPUUsage",
|
||||||
/ processor_count);
|
process_metric.second->metrics->GetPlatformIndependentCPUUsage() /
|
||||||
|
processor_count);
|
||||||
|
|
||||||
#if !defined(OS_WIN)
|
#if !defined(OS_WIN)
|
||||||
cpu_dict.Set("idleWakeupsPerSecond",
|
cpu_dict.Set("idleWakeupsPerSecond",
|
||||||
|
@ -1122,8 +1110,8 @@ std::vector<mate::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
|
||||||
|
|
||||||
pid_dict.Set("cpu", cpu_dict);
|
pid_dict.Set("cpu", cpu_dict);
|
||||||
pid_dict.Set("pid", process_metric.second->pid);
|
pid_dict.Set("pid", process_metric.second->pid);
|
||||||
pid_dict.Set("type",
|
pid_dict.Set("type", content::GetProcessTypeNameInEnglish(
|
||||||
content::GetProcessTypeNameInEnglish(process_metric.second->type));
|
process_metric.second->type));
|
||||||
result.push_back(pid_dict);
|
result.push_back(pid_dict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1138,7 +1126,8 @@ v8::Local<v8::Value> App::GetGPUFeatureStatus(v8::Isolate* isolate) {
|
||||||
|
|
||||||
void App::EnableMixedSandbox(mate::Arguments* args) {
|
void App::EnableMixedSandbox(mate::Arguments* args) {
|
||||||
if (Browser::Get()->is_ready()) {
|
if (Browser::Get()->is_ready()) {
|
||||||
args->ThrowError("app.enableMixedSandbox() can only be called "
|
args->ThrowError(
|
||||||
|
"app.enableMixedSandbox() can only be called "
|
||||||
"before app is ready");
|
"before app is ready");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1179,8 +1168,8 @@ mate::Handle<App> App::Create(v8::Isolate* isolate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void App::BuildPrototype(
|
void App::BuildPrototype(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
|
v8::Local<v8::FunctionTemplate> prototype) {
|
||||||
prototype->SetClassName(mate::StringToV8(isolate, "App"));
|
prototype->SetClassName(mate::StringToV8(isolate, "App"));
|
||||||
auto browser = base::Unretained(Browser::Get());
|
auto browser = base::Unretained(Browser::Get());
|
||||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||||
|
@ -1271,7 +1260,6 @@ void App::BuildPrototype(
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void AppendSwitch(const std::string& switch_string, mate::Arguments* args) {
|
void AppendSwitch(const std::string& switch_string, mate::Arguments* args) {
|
||||||
|
@ -1308,8 +1296,10 @@ void DockSetMenu(atom::api::Menu* menu) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
auto command_line = base::CommandLine::ForCurrentProcess();
|
auto command_line = base::CommandLine::ForCurrentProcess();
|
||||||
|
|
||||||
|
@ -1317,8 +1307,7 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||||
dict.Set("App", atom::api::App::GetConstructor(isolate)->GetFunction());
|
dict.Set("App", atom::api::App::GetConstructor(isolate)->GetFunction());
|
||||||
dict.Set("app", atom::api::App::Create(isolate));
|
dict.Set("app", atom::api::App::Create(isolate));
|
||||||
dict.SetMethod("appendSwitch", &AppendSwitch);
|
dict.SetMethod("appendSwitch", &AppendSwitch);
|
||||||
dict.SetMethod("appendArgument",
|
dict.SetMethod("appendArgument", base::Bind(&base::CommandLine::AppendArg,
|
||||||
base::Bind(&base::CommandLine::AppendArg,
|
|
||||||
base::Unretained(command_line)));
|
base::Unretained(command_line)));
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
auto browser = base::Unretained(Browser::Get());
|
auto browser = base::Unretained(Browser::Get());
|
||||||
|
|
|
@ -67,8 +67,8 @@ class App : public AtomBrowserClient::Delegate,
|
||||||
public content::GpuDataManagerObserver,
|
public content::GpuDataManagerObserver,
|
||||||
public content::BrowserChildProcessObserver {
|
public content::BrowserChildProcessObserver {
|
||||||
public:
|
public:
|
||||||
using FileIconCallback = base::Callback<void(v8::Local<v8::Value>,
|
using FileIconCallback =
|
||||||
const gfx::Image&)>;
|
base::Callback<void(v8::Local<v8::Value>, const gfx::Image&)>;
|
||||||
|
|
||||||
static mate::Handle<App> Create(v8::Isolate* isolate);
|
static mate::Handle<App> Create(v8::Isolate* isolate);
|
||||||
|
|
||||||
|
@ -106,14 +106,11 @@ class App : public AtomBrowserClient::Delegate,
|
||||||
void OnAccessibilitySupportChanged() override;
|
void OnAccessibilitySupportChanged() override;
|
||||||
void OnPreMainMessageLoopRun() override;
|
void OnPreMainMessageLoopRun() override;
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
void OnWillContinueUserActivity(
|
void OnWillContinueUserActivity(bool* prevent_default,
|
||||||
bool* prevent_default,
|
|
||||||
const std::string& type) override;
|
const std::string& type) override;
|
||||||
void OnDidFailToContinueUserActivity(
|
void OnDidFailToContinueUserActivity(const std::string& type,
|
||||||
const std::string& type,
|
|
||||||
const std::string& error) override;
|
const std::string& error) override;
|
||||||
void OnContinueUserActivity(
|
void OnContinueUserActivity(bool* prevent_default,
|
||||||
bool* prevent_default,
|
|
||||||
const std::string& type,
|
const std::string& type,
|
||||||
const base::DictionaryValue& user_info) override;
|
const base::DictionaryValue& user_info) override;
|
||||||
void OnUserActivityWasContinued(
|
void OnUserActivityWasContinued(
|
||||||
|
@ -166,10 +163,10 @@ class App : public AtomBrowserClient::Delegate,
|
||||||
const content::ChildProcessData& data) override;
|
const content::ChildProcessData& data) override;
|
||||||
void BrowserChildProcessHostDisconnected(
|
void BrowserChildProcessHostDisconnected(
|
||||||
const content::ChildProcessData& data) override;
|
const content::ChildProcessData& data) override;
|
||||||
void BrowserChildProcessCrashed(
|
void BrowserChildProcessCrashed(const content::ChildProcessData& data,
|
||||||
const content::ChildProcessData& data, int exit_code) override;
|
int exit_code) override;
|
||||||
void BrowserChildProcessKilled(
|
void BrowserChildProcessKilled(const content::ChildProcessData& data,
|
||||||
const content::ChildProcessData& data, int exit_code) override;
|
int exit_code) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetAppPath(const base::FilePath& app_path);
|
void SetAppPath(const base::FilePath& app_path);
|
||||||
|
@ -197,8 +194,7 @@ class App : public AtomBrowserClient::Delegate,
|
||||||
void ImportCertificate(const base::DictionaryValue& options,
|
void ImportCertificate(const base::DictionaryValue& options,
|
||||||
const net::CompletionCallback& callback);
|
const net::CompletionCallback& callback);
|
||||||
#endif
|
#endif
|
||||||
void GetFileIcon(const base::FilePath& path,
|
void GetFileIcon(const base::FilePath& path, mate::Arguments* args);
|
||||||
mate::Arguments* args);
|
|
||||||
|
|
||||||
std::vector<mate::Dictionary> GetAppMetrics(v8::Isolate* isolate);
|
std::vector<mate::Dictionary> GetAppMetrics(v8::Isolate* isolate);
|
||||||
v8::Local<v8::Value> GetGPUFeatureStatus(v8::Isolate* isolate);
|
v8::Local<v8::Value> GetGPUFeatureStatus(v8::Isolate* isolate);
|
||||||
|
@ -233,8 +229,7 @@ class App : public AtomBrowserClient::Delegate,
|
||||||
base::FilePath app_path_;
|
base::FilePath app_path_;
|
||||||
|
|
||||||
using ProcessMetricMap =
|
using ProcessMetricMap =
|
||||||
std::unordered_map<base::ProcessId,
|
std::unordered_map<base::ProcessId, std::unique_ptr<atom::ProcessMetric>>;
|
||||||
std::unique_ptr<atom::ProcessMetric>>;
|
|
||||||
ProcessMetricMap app_metrics_;
|
ProcessMetricMap app_metrics_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(App);
|
DISALLOW_COPY_AND_ASSIGN(App);
|
||||||
|
|
|
@ -20,8 +20,8 @@ template<>
|
||||||
struct Converter<base::Time> {
|
struct Converter<base::Time> {
|
||||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||||
const base::Time& val) {
|
const base::Time& val) {
|
||||||
v8::MaybeLocal<v8::Value> date = v8::Date::New(
|
v8::MaybeLocal<v8::Value> date =
|
||||||
isolate->GetCurrentContext(), val.ToJsTime());
|
v8::Date::New(isolate->GetCurrentContext(), val.ToJsTime());
|
||||||
if (date.IsEmpty())
|
if (date.IsEmpty())
|
||||||
return v8::Null(isolate);
|
return v8::Null(isolate);
|
||||||
else
|
else
|
||||||
|
@ -49,21 +49,20 @@ void AutoUpdater::OnError(const std::string& message) {
|
||||||
v8::HandleScope handle_scope(isolate());
|
v8::HandleScope handle_scope(isolate());
|
||||||
auto error = v8::Exception::Error(mate::StringToV8(isolate(), message));
|
auto error = v8::Exception::Error(mate::StringToV8(isolate(), message));
|
||||||
mate::EmitEvent(
|
mate::EmitEvent(
|
||||||
isolate(),
|
isolate(), GetWrapper(), "error",
|
||||||
GetWrapper(),
|
|
||||||
"error",
|
|
||||||
error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked(),
|
error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked(),
|
||||||
// Message is also emitted to keep compatibility with old code.
|
// Message is also emitted to keep compatibility with old code.
|
||||||
message);
|
message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoUpdater::OnError(const std::string& message,
|
void AutoUpdater::OnError(const std::string& message,
|
||||||
const int code, const std::string& domain) {
|
const int code,
|
||||||
|
const std::string& domain) {
|
||||||
v8::Locker locker(isolate());
|
v8::Locker locker(isolate());
|
||||||
v8::HandleScope handle_scope(isolate());
|
v8::HandleScope handle_scope(isolate());
|
||||||
auto error = v8::Exception::Error(mate::StringToV8(isolate(), message));
|
auto error = v8::Exception::Error(mate::StringToV8(isolate(), message));
|
||||||
auto errorObject = error->ToObject(
|
auto errorObject =
|
||||||
isolate()->GetCurrentContext()).ToLocalChecked();
|
error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked();
|
||||||
|
|
||||||
// add two new params for better error handling
|
// add two new params for better error handling
|
||||||
errorObject->Set(mate::StringToV8(isolate(), "code"),
|
errorObject->Set(mate::StringToV8(isolate(), "code"),
|
||||||
|
@ -123,8 +122,8 @@ mate::Handle<AutoUpdater> AutoUpdater::Create(v8::Isolate* isolate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void AutoUpdater::BuildPrototype(
|
void AutoUpdater::BuildPrototype(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
|
v8::Local<v8::FunctionTemplate> prototype) {
|
||||||
prototype->SetClassName(mate::StringToV8(isolate, "AutoUpdater"));
|
prototype->SetClassName(mate::StringToV8(isolate, "AutoUpdater"));
|
||||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||||
.SetMethod("checkForUpdates", &auto_updater::AutoUpdater::CheckForUpdates)
|
.SetMethod("checkForUpdates", &auto_updater::AutoUpdater::CheckForUpdates)
|
||||||
|
@ -137,13 +136,14 @@ void AutoUpdater::BuildPrototype(
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using atom::api::AutoUpdater;
|
using atom::api::AutoUpdater;
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
dict.Set("autoUpdater", AutoUpdater::Create(isolate));
|
dict.Set("autoUpdater", AutoUpdater::Create(isolate));
|
||||||
|
|
|
@ -32,7 +32,8 @@ class AutoUpdater : public mate::EventEmitter<AutoUpdater>,
|
||||||
|
|
||||||
// Delegate implementations.
|
// Delegate implementations.
|
||||||
void OnError(const std::string& error) override;
|
void OnError(const std::string& error) override;
|
||||||
void OnError(const std::string& message, const int code,
|
void OnError(const std::string& message,
|
||||||
|
const int code,
|
||||||
const std::string& domain);
|
const std::string& domain);
|
||||||
void OnCheckingForUpdate() override;
|
void OnCheckingForUpdate() override;
|
||||||
void OnUpdateAvailable() override;
|
void OnUpdateAvailable() override;
|
||||||
|
|
|
@ -29,8 +29,7 @@ namespace api {
|
||||||
BrowserWindow::BrowserWindow(v8::Isolate* isolate,
|
BrowserWindow::BrowserWindow(v8::Isolate* isolate,
|
||||||
v8::Local<v8::Object> wrapper,
|
v8::Local<v8::Object> wrapper,
|
||||||
const mate::Dictionary& options)
|
const mate::Dictionary& options)
|
||||||
: TopLevelWindow(isolate, wrapper, options),
|
: TopLevelWindow(isolate, wrapper, options), weak_factory_(this) {
|
||||||
weak_factory_(this) {
|
|
||||||
mate::Handle<class WebContents> web_contents;
|
mate::Handle<class WebContents> web_contents;
|
||||||
|
|
||||||
// Use options.webPreferences in WebContents.
|
// Use options.webPreferences in WebContents.
|
||||||
|
@ -69,8 +68,8 @@ BrowserWindow::BrowserWindow(v8::Isolate* isolate,
|
||||||
Observe(api_web_contents_->web_contents());
|
Observe(api_web_contents_->web_contents());
|
||||||
|
|
||||||
// Keep a copy of the options for later use.
|
// Keep a copy of the options for later use.
|
||||||
mate::Dictionary(isolate, web_contents->GetWrapper()).Set(
|
mate::Dictionary(isolate, web_contents->GetWrapper())
|
||||||
"browserWindowOptions", options);
|
.Set("browserWindowOptions", options);
|
||||||
|
|
||||||
// Tell the content module to initialize renderer widget with transparent
|
// Tell the content module to initialize renderer widget with transparent
|
||||||
// mode.
|
// mode.
|
||||||
|
@ -142,11 +141,12 @@ void BrowserWindow::DidFirstVisuallyNonEmptyPaint() {
|
||||||
|
|
||||||
// Emit the ReadyToShow event in next tick in case of pending drawing work.
|
// Emit the ReadyToShow event in next tick in case of pending drawing work.
|
||||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||||
FROM_HERE,
|
FROM_HERE, base::Bind(
|
||||||
base::Bind([](base::WeakPtr<BrowserWindow> self) {
|
[](base::WeakPtr<BrowserWindow> self) {
|
||||||
if (self)
|
if (self)
|
||||||
self->Emit("ready-to-show");
|
self->Emit("ready-to-show");
|
||||||
}, GetWeakPtr()));
|
},
|
||||||
|
GetWeakPtr()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWindow::BeforeUnloadDialogCancelled() {
|
void BrowserWindow::BeforeUnloadDialogCancelled() {
|
||||||
|
@ -339,9 +339,7 @@ std::unique_ptr<SkRegion> BrowserWindow::DraggableRegionsToSkRegion(
|
||||||
std::unique_ptr<SkRegion> sk_region(new SkRegion);
|
std::unique_ptr<SkRegion> sk_region(new SkRegion);
|
||||||
for (const DraggableRegion& region : regions) {
|
for (const DraggableRegion& region : regions) {
|
||||||
sk_region->op(
|
sk_region->op(
|
||||||
region.bounds.x(),
|
region.bounds.x(), region.bounds.y(), region.bounds.right(),
|
||||||
region.bounds.y(),
|
|
||||||
region.bounds.right(),
|
|
||||||
region.bounds.bottom(),
|
region.bounds.bottom(),
|
||||||
region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
|
region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
|
||||||
}
|
}
|
||||||
|
@ -355,8 +353,7 @@ void BrowserWindow::ScheduleUnresponsiveEvent(int ms) {
|
||||||
window_unresponsive_closure_.Reset(
|
window_unresponsive_closure_.Reset(
|
||||||
base::Bind(&BrowserWindow::NotifyWindowUnresponsive, GetWeakPtr()));
|
base::Bind(&BrowserWindow::NotifyWindowUnresponsive, GetWeakPtr()));
|
||||||
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
|
||||||
FROM_HERE,
|
FROM_HERE, window_unresponsive_closure_.callback(),
|
||||||
window_unresponsive_closure_.callback(),
|
|
||||||
base::TimeDelta::FromMilliseconds(ms));
|
base::TimeDelta::FromMilliseconds(ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,7 +394,6 @@ mate::WrappableBase* BrowserWindow::New(mate::Arguments* args) {
|
||||||
return new BrowserWindow(args->isolate(), args->GetThis(), options);
|
return new BrowserWindow(args->isolate(), args->GetThis(), options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void BrowserWindow::BuildPrototype(v8::Isolate* isolate,
|
void BrowserWindow::BuildPrototype(v8::Isolate* isolate,
|
||||||
v8::Local<v8::FunctionTemplate> prototype) {
|
v8::Local<v8::FunctionTemplate> prototype) {
|
||||||
|
@ -429,8 +425,10 @@ namespace {
|
||||||
using atom::api::BrowserWindow;
|
using atom::api::BrowserWindow;
|
||||||
using atom::api::TopLevelWindow;
|
using atom::api::TopLevelWindow;
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
// Calling SetConstructor would only use TopLevelWindow's prototype.
|
// Calling SetConstructor would only use TopLevelWindow's prototype.
|
||||||
v8::Local<v8::FunctionTemplate> templ = CreateFunctionTemplate(
|
v8::Local<v8::FunctionTemplate> templ = CreateFunctionTemplate(
|
||||||
|
@ -443,10 +441,8 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
||||||
|
|
||||||
mate::Dictionary browser_window(isolate, templ->GetFunction());
|
mate::Dictionary browser_window(isolate, templ->GetFunction());
|
||||||
browser_window.SetMethod(
|
browser_window.SetMethod(
|
||||||
"fromId",
|
"fromId", &mate::TrackableObject<TopLevelWindow>::FromWeakMapID);
|
||||||
&mate::TrackableObject<TopLevelWindow>::FromWeakMapID);
|
browser_window.SetMethod("getAllWindows",
|
||||||
browser_window.SetMethod(
|
|
||||||
"getAllWindows",
|
|
||||||
&mate::TrackableObject<TopLevelWindow>::GetAll);
|
&mate::TrackableObject<TopLevelWindow>::GetAll);
|
||||||
|
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
|
|
|
@ -82,8 +82,7 @@ class BrowserWindow : public TopLevelWindow,
|
||||||
// Helpers.
|
// Helpers.
|
||||||
|
|
||||||
// Called when the window needs to update its draggable region.
|
// Called when the window needs to update its draggable region.
|
||||||
void UpdateDraggableRegions(
|
void UpdateDraggableRegions(content::RenderFrameHost* rfh,
|
||||||
content::RenderFrameHost* rfh,
|
|
||||||
const std::vector<DraggableRegion>& regions);
|
const std::vector<DraggableRegion>& regions);
|
||||||
|
|
||||||
// Convert draggable regions in raw format to SkRegion format.
|
// Convert draggable regions in raw format to SkRegion format.
|
||||||
|
@ -123,7 +122,8 @@ namespace mate {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Converter<atom::NativeWindow*> {
|
struct Converter<atom::NativeWindow*> {
|
||||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Value> val,
|
||||||
atom::NativeWindow** out) {
|
atom::NativeWindow** out) {
|
||||||
// null would be tranfered to NULL.
|
// null would be tranfered to NULL.
|
||||||
if (val->IsNull()) {
|
if (val->IsNull()) {
|
||||||
|
|
|
@ -15,8 +15,8 @@ void BrowserWindow::UpdateDraggableRegions(
|
||||||
const std::vector<DraggableRegion>& regions) {
|
const std::vector<DraggableRegion>& regions) {
|
||||||
if (window_->has_frame())
|
if (window_->has_frame())
|
||||||
return;
|
return;
|
||||||
static_cast<NativeWindowViews*>(window_.get())->UpdateDraggableRegions(
|
static_cast<NativeWindowViews*>(window_.get())
|
||||||
DraggableRegionsToSkRegion(regions));
|
->UpdateDraggableRegions(DraggableRegionsToSkRegion(regions));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace api
|
} // namespace api
|
||||||
|
|
|
@ -42,14 +42,14 @@ namespace {
|
||||||
using CompletionCallback = base::Callback<void(const base::FilePath&)>;
|
using CompletionCallback = base::Callback<void(const base::FilePath&)>;
|
||||||
|
|
||||||
scoped_refptr<TracingController::TraceDataEndpoint> GetTraceDataEndpoint(
|
scoped_refptr<TracingController::TraceDataEndpoint> GetTraceDataEndpoint(
|
||||||
const base::FilePath& path, const CompletionCallback& callback) {
|
const base::FilePath& path,
|
||||||
|
const CompletionCallback& callback) {
|
||||||
base::FilePath result_file_path = path;
|
base::FilePath result_file_path = path;
|
||||||
if (result_file_path.empty() && !base::CreateTemporaryFile(&result_file_path))
|
if (result_file_path.empty() && !base::CreateTemporaryFile(&result_file_path))
|
||||||
LOG(ERROR) << "Creating temporary file failed";
|
LOG(ERROR) << "Creating temporary file failed";
|
||||||
|
|
||||||
return TracingController::CreateFileEndpoint(result_file_path,
|
return TracingController::CreateFileEndpoint(
|
||||||
base::Bind(callback,
|
result_file_path, base::Bind(callback, result_file_path));
|
||||||
result_file_path));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StopRecording(const base::FilePath& path,
|
void StopRecording(const base::FilePath& path,
|
||||||
|
@ -58,17 +58,20 @@ void StopRecording(const base::FilePath& path,
|
||||||
GetTraceDataEndpoint(path, callback));
|
GetTraceDataEndpoint(path, callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
auto controller = base::Unretained(TracingController::GetInstance());
|
auto controller = base::Unretained(TracingController::GetInstance());
|
||||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||||
dict.SetMethod("getCategories", base::Bind(
|
dict.SetMethod("getCategories",
|
||||||
&TracingController::GetCategories, controller));
|
base::Bind(&TracingController::GetCategories, controller));
|
||||||
dict.SetMethod("startRecording", base::Bind(
|
dict.SetMethod("startRecording",
|
||||||
&TracingController::StartTracing, controller));
|
base::Bind(&TracingController::StartTracing, controller));
|
||||||
dict.SetMethod("stopRecording", &StopRecording);
|
dict.SetMethod("stopRecording", &StopRecording);
|
||||||
dict.SetMethod("getTraceBufferUsage", base::Bind(
|
dict.SetMethod(
|
||||||
&TracingController::GetTraceBufferUsage, controller));
|
"getTraceBufferUsage",
|
||||||
|
base::Bind(&TracingController::GetTraceBufferUsage, controller));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -170,7 +170,8 @@ void GetCookiesOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||||
|
|
||||||
// Removes cookie with |url| and |name| in IO thread.
|
// Removes cookie with |url| and |name| in IO thread.
|
||||||
void RemoveCookieOnIOThread(scoped_refptr<net::URLRequestContextGetter> getter,
|
void RemoveCookieOnIOThread(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||||
const GURL& url, const std::string& name,
|
const GURL& url,
|
||||||
|
const std::string& name,
|
||||||
const base::Closure& callback) {
|
const base::Closure& callback) {
|
||||||
GetCookieStore(getter)->DeleteCookieAsync(
|
GetCookieStore(getter)->DeleteCookieAsync(
|
||||||
url, name, base::Bind(RunCallbackInUI, callback));
|
url, name, base::Bind(RunCallbackInUI, callback));
|
||||||
|
@ -209,30 +210,29 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||||
|
|
||||||
base::Time creation_time;
|
base::Time creation_time;
|
||||||
if (details->GetDouble("creationDate", &creation_date)) {
|
if (details->GetDouble("creationDate", &creation_date)) {
|
||||||
creation_time = (creation_date == 0) ?
|
creation_time = (creation_date == 0)
|
||||||
base::Time::UnixEpoch() :
|
? base::Time::UnixEpoch()
|
||||||
base::Time::FromDoubleT(creation_date);
|
: base::Time::FromDoubleT(creation_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
base::Time expiration_time;
|
base::Time expiration_time;
|
||||||
if (details->GetDouble("expirationDate", &expiration_date)) {
|
if (details->GetDouble("expirationDate", &expiration_date)) {
|
||||||
expiration_time = (expiration_date == 0) ?
|
expiration_time = (expiration_date == 0)
|
||||||
base::Time::UnixEpoch() :
|
? base::Time::UnixEpoch()
|
||||||
base::Time::FromDoubleT(expiration_date);
|
: base::Time::FromDoubleT(expiration_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
base::Time last_access_time;
|
base::Time last_access_time;
|
||||||
if (details->GetDouble("lastAccessDate", &last_access_date)) {
|
if (details->GetDouble("lastAccessDate", &last_access_date)) {
|
||||||
last_access_time = (last_access_date == 0) ?
|
last_access_time = (last_access_date == 0)
|
||||||
base::Time::UnixEpoch() :
|
? base::Time::UnixEpoch()
|
||||||
base::Time::FromDoubleT(last_access_date);
|
: base::Time::FromDoubleT(last_access_date);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetCookieStore(getter)->SetCookieWithDetailsAsync(
|
GetCookieStore(getter)->SetCookieWithDetailsAsync(
|
||||||
GURL(url), name, value, domain, path, creation_time,
|
GURL(url), name, value, domain, path, creation_time, expiration_time,
|
||||||
expiration_time, last_access_time, secure, http_only,
|
last_access_time, secure, http_only, net::CookieSameSite::DEFAULT_MODE,
|
||||||
net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT,
|
net::COOKIE_PRIORITY_DEFAULT, base::Bind(OnSetCookie, callback));
|
||||||
base::Bind(OnSetCookie, callback));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -257,7 +257,8 @@ void Cookies::Get(const base::DictionaryValue& filter,
|
||||||
callback));
|
callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cookies::Remove(const GURL& url, const std::string& name,
|
void Cookies::Remove(const GURL& url,
|
||||||
|
const std::string& name,
|
||||||
const base::Closure& callback) {
|
const base::Closure& callback) {
|
||||||
auto getter = browser_context_->GetRequestContext();
|
auto getter = browser_context_->GetRequestContext();
|
||||||
content::BrowserThread::PostTask(
|
content::BrowserThread::PostTask(
|
||||||
|
@ -288,10 +289,8 @@ void Cookies::OnCookieChanged(const CookieDetails* details) {
|
||||||
Emit("changed", *(details->cookie), details->cause, details->removed);
|
Emit("changed", *(details->cookie), details->cause, details->removed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
mate::Handle<Cookies> Cookies::Create(
|
mate::Handle<Cookies> Cookies::Create(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate,
|
|
||||||
AtomBrowserContext* browser_context) {
|
AtomBrowserContext* browser_context) {
|
||||||
return mate::CreateHandle(isolate, new Cookies(isolate, browser_context));
|
return mate::CreateHandle(isolate, new Cookies(isolate, browser_context));
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,8 @@ class Cookies : public mate::TrackableObject<Cookies> {
|
||||||
~Cookies() override;
|
~Cookies() override;
|
||||||
|
|
||||||
void Get(const base::DictionaryValue& filter, const GetCallback& callback);
|
void Get(const base::DictionaryValue& filter, const GetCallback& callback);
|
||||||
void Remove(const GURL& url, const std::string& name,
|
void Remove(const GURL& url,
|
||||||
|
const std::string& name,
|
||||||
const base::Closure& callback);
|
const base::Closure& callback);
|
||||||
void Set(const base::DictionaryValue& details, const SetCallback& callback);
|
void Set(const base::DictionaryValue& details, const SetCallback& callback);
|
||||||
void FlushStore(const base::Closure& callback);
|
void FlushStore(const base::Closure& callback);
|
||||||
|
|
|
@ -26,13 +26,11 @@ namespace atom {
|
||||||
namespace api {
|
namespace api {
|
||||||
|
|
||||||
Debugger::Debugger(v8::Isolate* isolate, content::WebContents* web_contents)
|
Debugger::Debugger(v8::Isolate* isolate, content::WebContents* web_contents)
|
||||||
: web_contents_(web_contents),
|
: web_contents_(web_contents), previous_request_id_(0) {
|
||||||
previous_request_id_(0) {
|
|
||||||
Init(isolate);
|
Init(isolate);
|
||||||
}
|
}
|
||||||
|
|
||||||
Debugger::~Debugger() {
|
Debugger::~Debugger() {}
|
||||||
}
|
|
||||||
|
|
||||||
void Debugger::AgentHostClosed(DevToolsAgentHost* agent_host,
|
void Debugger::AgentHostClosed(DevToolsAgentHost* agent_host,
|
||||||
bool replaced_with_another_client) {
|
bool replaced_with_another_client) {
|
||||||
|
@ -144,8 +142,7 @@ void Debugger::SendCommand(mate::Arguments* args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
mate::Handle<Debugger> Debugger::Create(
|
mate::Handle<Debugger> Debugger::Create(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate,
|
|
||||||
content::WebContents* web_contents) {
|
content::WebContents* web_contents) {
|
||||||
return mate::CreateHandle(isolate, new Debugger(isolate, web_contents));
|
return mate::CreateHandle(isolate, new Debugger(isolate, web_contents));
|
||||||
}
|
}
|
||||||
|
@ -169,8 +166,10 @@ namespace {
|
||||||
|
|
||||||
using atom::api::Debugger;
|
using atom::api::Debugger;
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
mate::Dictionary(isolate, exports)
|
mate::Dictionary(isolate, exports)
|
||||||
.Set("Debugger", Debugger::GetConstructor(isolate)->GetFunction());
|
.Set("Debugger", Debugger::GetConstructor(isolate)->GetFunction());
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
namespace content {
|
namespace content {
|
||||||
class DevToolsAgentHost;
|
class DevToolsAgentHost;
|
||||||
class WebContents;
|
class WebContents;
|
||||||
}
|
} // namespace content
|
||||||
|
|
||||||
namespace mate {
|
namespace mate {
|
||||||
class Arguments;
|
class Arguments;
|
||||||
|
@ -34,8 +34,8 @@ class Debugger: public mate::TrackableObject<Debugger>,
|
||||||
base::Callback<void(const base::DictionaryValue&,
|
base::Callback<void(const base::DictionaryValue&,
|
||||||
const base::DictionaryValue&)>;
|
const base::DictionaryValue&)>;
|
||||||
|
|
||||||
static mate::Handle<Debugger> Create(
|
static mate::Handle<Debugger> Create(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate, content::WebContents* web_contents);
|
content::WebContents* web_contents);
|
||||||
|
|
||||||
// mate::TrackableObject:
|
// mate::TrackableObject:
|
||||||
static void BuildPrototype(v8::Isolate* isolate,
|
static void BuildPrototype(v8::Isolate* isolate,
|
||||||
|
|
|
@ -53,8 +53,7 @@ DesktopCapturer::DesktopCapturer(v8::Isolate* isolate) {
|
||||||
Init(isolate);
|
Init(isolate);
|
||||||
}
|
}
|
||||||
|
|
||||||
DesktopCapturer::~DesktopCapturer() {
|
DesktopCapturer::~DesktopCapturer() {}
|
||||||
}
|
|
||||||
|
|
||||||
void DesktopCapturer::StartHandling(bool capture_window,
|
void DesktopCapturer::StartHandling(bool capture_window,
|
||||||
bool capture_screen,
|
bool capture_screen,
|
||||||
|
@ -71,27 +70,22 @@ void DesktopCapturer::StartHandling(bool capture_window,
|
||||||
std::unique_ptr<webrtc::DesktopCapturer> window_capturer(
|
std::unique_ptr<webrtc::DesktopCapturer> window_capturer(
|
||||||
capture_window ? webrtc::DesktopCapturer::CreateWindowCapturer(options)
|
capture_window ? webrtc::DesktopCapturer::CreateWindowCapturer(options)
|
||||||
: nullptr);
|
: nullptr);
|
||||||
media_list_.reset(new NativeDesktopMediaList(
|
media_list_.reset(new NativeDesktopMediaList(std::move(screen_capturer),
|
||||||
std::move(screen_capturer), std::move(window_capturer)));
|
std::move(window_capturer)));
|
||||||
|
|
||||||
media_list_->SetThumbnailSize(thumbnail_size);
|
media_list_->SetThumbnailSize(thumbnail_size);
|
||||||
media_list_->StartUpdating(this);
|
media_list_->StartUpdating(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesktopCapturer::OnSourceAdded(int index) {
|
void DesktopCapturer::OnSourceAdded(int index) {}
|
||||||
}
|
|
||||||
|
|
||||||
void DesktopCapturer::OnSourceRemoved(int index) {
|
void DesktopCapturer::OnSourceRemoved(int index) {}
|
||||||
}
|
|
||||||
|
|
||||||
void DesktopCapturer::OnSourceMoved(int old_index, int new_index) {
|
void DesktopCapturer::OnSourceMoved(int old_index, int new_index) {}
|
||||||
}
|
|
||||||
|
|
||||||
void DesktopCapturer::OnSourceNameChanged(int index) {
|
void DesktopCapturer::OnSourceNameChanged(int index) {}
|
||||||
}
|
|
||||||
|
|
||||||
void DesktopCapturer::OnSourceThumbnailChanged(int index) {
|
void DesktopCapturer::OnSourceThumbnailChanged(int index) {}
|
||||||
}
|
|
||||||
|
|
||||||
bool DesktopCapturer::OnRefreshFinished() {
|
bool DesktopCapturer::OnRefreshFinished() {
|
||||||
const auto media_list_sources = media_list_->GetSources();
|
const auto media_list_sources = media_list_->GetSources();
|
||||||
|
@ -131,8 +125,7 @@ bool DesktopCapturer::OnRefreshFinished() {
|
||||||
for (auto& source : sources) {
|
for (auto& source : sources) {
|
||||||
if (source.media_list_source.id.type ==
|
if (source.media_list_source.id.type ==
|
||||||
content::DesktopMediaID::TYPE_SCREEN) {
|
content::DesktopMediaID::TYPE_SCREEN) {
|
||||||
source.display_id =
|
source.display_id = base::Int64ToString(source.media_list_source.id.id);
|
||||||
base::Int64ToString(source.media_list_source.id.id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // defined(OS_WIN)
|
#endif // defined(OS_WIN)
|
||||||
|
@ -151,7 +144,8 @@ mate::Handle<DesktopCapturer> DesktopCapturer::Create(v8::Isolate* isolate) {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void DesktopCapturer::BuildPrototype(
|
void DesktopCapturer::BuildPrototype(
|
||||||
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
|
v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::FunctionTemplate> prototype) {
|
||||||
prototype->SetClassName(mate::StringToV8(isolate, "DesktopCapturer"));
|
prototype->SetClassName(mate::StringToV8(isolate, "DesktopCapturer"));
|
||||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||||
.SetMethod("startHandling", &DesktopCapturer::StartHandling);
|
.SetMethod("startHandling", &DesktopCapturer::StartHandling);
|
||||||
|
@ -163,8 +157,10 @@ void DesktopCapturer::BuildPrototype(
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
dict.Set("desktopCapturer", atom::api::DesktopCapturer::Create(isolate));
|
dict.Set("desktopCapturer", atom::api::DesktopCapturer::Create(isolate));
|
||||||
|
|
|
@ -80,8 +80,7 @@ void ShowMessageBox(int type,
|
||||||
mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
v8::Local<v8::Value> peek = args->PeekNext();
|
v8::Local<v8::Value> peek = args->PeekNext();
|
||||||
atom::MessageBoxCallback callback;
|
atom::MessageBoxCallback callback;
|
||||||
if (mate::Converter<atom::MessageBoxCallback>::FromV8(args->isolate(),
|
if (mate::Converter<atom::MessageBoxCallback>::FromV8(args->isolate(), peek,
|
||||||
peek,
|
|
||||||
&callback)) {
|
&callback)) {
|
||||||
atom::ShowMessageBox(window, static_cast<atom::MessageBoxType>(type),
|
atom::ShowMessageBox(window, static_cast<atom::MessageBoxType>(type),
|
||||||
buttons, default_id, cancel_id, options, title,
|
buttons, default_id, cancel_id, options, title,
|
||||||
|
@ -99,9 +98,8 @@ void ShowOpenDialog(const file_dialog::DialogSettings& settings,
|
||||||
mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
v8::Local<v8::Value> peek = args->PeekNext();
|
v8::Local<v8::Value> peek = args->PeekNext();
|
||||||
file_dialog::OpenDialogCallback callback;
|
file_dialog::OpenDialogCallback callback;
|
||||||
if (mate::Converter<file_dialog::OpenDialogCallback>::FromV8(args->isolate(),
|
if (mate::Converter<file_dialog::OpenDialogCallback>::FromV8(
|
||||||
peek,
|
args->isolate(), peek, &callback)) {
|
||||||
&callback)) {
|
|
||||||
file_dialog::ShowOpenDialog(settings, callback);
|
file_dialog::ShowOpenDialog(settings, callback);
|
||||||
} else {
|
} else {
|
||||||
std::vector<base::FilePath> paths;
|
std::vector<base::FilePath> paths;
|
||||||
|
@ -114,9 +112,8 @@ void ShowSaveDialog(const file_dialog::DialogSettings& settings,
|
||||||
mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
v8::Local<v8::Value> peek = args->PeekNext();
|
v8::Local<v8::Value> peek = args->PeekNext();
|
||||||
file_dialog::SaveDialogCallback callback;
|
file_dialog::SaveDialogCallback callback;
|
||||||
if (mate::Converter<file_dialog::SaveDialogCallback>::FromV8(args->isolate(),
|
if (mate::Converter<file_dialog::SaveDialogCallback>::FromV8(
|
||||||
peek,
|
args->isolate(), peek, &callback)) {
|
||||||
&callback)) {
|
|
||||||
file_dialog::ShowSaveDialog(settings, callback);
|
file_dialog::ShowSaveDialog(settings, callback);
|
||||||
} else {
|
} else {
|
||||||
base::FilePath path;
|
base::FilePath path;
|
||||||
|
@ -125,8 +122,10 @@ void ShowSaveDialog(const file_dialog::DialogSettings& settings,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||||
dict.SetMethod("showMessageBox", &ShowMessageBox);
|
dict.SetMethod("showMessageBox", &ShowMessageBox);
|
||||||
dict.SetMethod("showErrorBox", &atom::ShowErrorBox);
|
dict.SetMethod("showErrorBox", &atom::ShowErrorBox);
|
||||||
|
|
|
@ -79,8 +79,8 @@ void DownloadItem::OnDownloadUpdated(content::DownloadItem* item) {
|
||||||
if (download_item_->IsDone()) {
|
if (download_item_->IsDone()) {
|
||||||
Emit("done", item->GetState());
|
Emit("done", item->GetState());
|
||||||
// Destroy the item once item is downloaded.
|
// Destroy the item once item is downloaded.
|
||||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
|
||||||
FROM_HERE, GetDestroyClosure());
|
GetDestroyClosure());
|
||||||
} else {
|
} else {
|
||||||
Emit("updated", item->GetState());
|
Emit("updated", item->GetState());
|
||||||
}
|
}
|
||||||
|
@ -129,12 +129,11 @@ bool DownloadItem::HasUserGesture() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DownloadItem::GetFilename() const {
|
std::string DownloadItem::GetFilename() const {
|
||||||
return base::UTF16ToUTF8(net::GenerateFileName(GetURL(),
|
return base::UTF16ToUTF8(
|
||||||
GetContentDisposition(),
|
net::GenerateFileName(GetURL(), GetContentDisposition(), std::string(),
|
||||||
std::string(),
|
|
||||||
download_item_->GetSuggestedFilename(),
|
download_item_->GetSuggestedFilename(),
|
||||||
GetMimeType(),
|
GetMimeType(), "download")
|
||||||
"download").LossyDisplayName());
|
.LossyDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DownloadItem::GetContentDisposition() const {
|
std::string DownloadItem::GetContentDisposition() const {
|
||||||
|
@ -206,8 +205,8 @@ void DownloadItem::BuildPrototype(v8::Isolate* isolate,
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
mate::Handle<DownloadItem> DownloadItem::Create(
|
mate::Handle<DownloadItem> DownloadItem::Create(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate, content::DownloadItem* item) {
|
content::DownloadItem* item) {
|
||||||
auto existing = TrackableObject::FromWrappedClass(isolate, item);
|
auto existing = TrackableObject::FromWrappedClass(isolate, item);
|
||||||
if (existing)
|
if (existing)
|
||||||
return mate::CreateHandle(isolate, static_cast<DownloadItem*>(existing));
|
return mate::CreateHandle(isolate, static_cast<DownloadItem*>(existing));
|
||||||
|
@ -226,8 +225,10 @@ mate::Handle<DownloadItem> DownloadItem::Create(
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
mate::Dictionary(isolate, exports)
|
mate::Dictionary(isolate, exports)
|
||||||
.Set("DownloadItem",
|
.Set("DownloadItem",
|
||||||
|
|
|
@ -40,8 +40,8 @@ void GlobalShortcut::OnKeyPressed(const ui::Accelerator& accelerator) {
|
||||||
|
|
||||||
bool GlobalShortcut::Register(const ui::Accelerator& accelerator,
|
bool GlobalShortcut::Register(const ui::Accelerator& accelerator,
|
||||||
const base::Closure& callback) {
|
const base::Closure& callback) {
|
||||||
if (!GlobalShortcutListener::GetInstance()->RegisterAccelerator(
|
if (!GlobalShortcutListener::GetInstance()->RegisterAccelerator(accelerator,
|
||||||
accelerator, this)) {
|
this)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,8 +54,8 @@ void GlobalShortcut::Unregister(const ui::Accelerator& accelerator) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
accelerator_callback_map_.erase(accelerator);
|
accelerator_callback_map_.erase(accelerator);
|
||||||
GlobalShortcutListener::GetInstance()->UnregisterAccelerator(
|
GlobalShortcutListener::GetInstance()->UnregisterAccelerator(accelerator,
|
||||||
accelerator, this);
|
this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GlobalShortcut::IsRegistered(const ui::Accelerator& accelerator) {
|
bool GlobalShortcut::IsRegistered(const ui::Accelerator& accelerator) {
|
||||||
|
@ -73,8 +73,8 @@ mate::Handle<GlobalShortcut> GlobalShortcut::Create(v8::Isolate* isolate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void GlobalShortcut::BuildPrototype(
|
void GlobalShortcut::BuildPrototype(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
|
v8::Local<v8::FunctionTemplate> prototype) {
|
||||||
prototype->SetClassName(mate::StringToV8(isolate, "GlobalShortcut"));
|
prototype->SetClassName(mate::StringToV8(isolate, "GlobalShortcut"));
|
||||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||||
.SetMethod("register", &GlobalShortcut::Register)
|
.SetMethod("register", &GlobalShortcut::Register)
|
||||||
|
@ -89,8 +89,10 @@ void GlobalShortcut::BuildPrototype(
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
dict.Set("globalShortcut", atom::api::GlobalShortcut::Create(isolate));
|
dict.Set("globalShortcut", atom::api::GlobalShortcut::Create(isolate));
|
||||||
|
|
|
@ -99,8 +99,7 @@ InAppPurchase::InAppPurchase(v8::Isolate* isolate) {
|
||||||
Init(isolate);
|
Init(isolate);
|
||||||
}
|
}
|
||||||
|
|
||||||
InAppPurchase::~InAppPurchase() {
|
InAppPurchase::~InAppPurchase() {}
|
||||||
}
|
|
||||||
|
|
||||||
void InAppPurchase::PurchaseProduct(const std::string& product_id,
|
void InAppPurchase::PurchaseProduct(const std::string& product_id,
|
||||||
mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
|
|
|
@ -20,8 +20,7 @@ namespace atom {
|
||||||
namespace api {
|
namespace api {
|
||||||
|
|
||||||
Menu::Menu(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
|
Menu::Menu(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
|
||||||
: model_(new AtomMenuModel(this)),
|
: model_(new AtomMenuModel(this)), parent_(nullptr) {
|
||||||
parent_(nullptr) {
|
|
||||||
InitWith(isolate, wrapper);
|
InitWith(isolate, wrapper);
|
||||||
model_->AddObserver(this);
|
model_->AddObserver(this);
|
||||||
}
|
}
|
||||||
|
@ -70,16 +69,15 @@ bool Menu::GetAcceleratorForCommandIdWithParams(
|
||||||
ui::Accelerator* accelerator) const {
|
ui::Accelerator* accelerator) const {
|
||||||
v8::Locker locker(isolate());
|
v8::Locker locker(isolate());
|
||||||
v8::HandleScope handle_scope(isolate());
|
v8::HandleScope handle_scope(isolate());
|
||||||
v8::Local<v8::Value> val = get_accelerator_.Run(
|
v8::Local<v8::Value> val =
|
||||||
GetWrapper(), command_id, use_default_accelerator);
|
get_accelerator_.Run(GetWrapper(), command_id, use_default_accelerator);
|
||||||
return mate::ConvertFromV8(isolate(), val, accelerator);
|
return mate::ConvertFromV8(isolate(), val, accelerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::ExecuteCommand(int command_id, int flags) {
|
void Menu::ExecuteCommand(int command_id, int flags) {
|
||||||
v8::Locker locker(isolate());
|
v8::Locker locker(isolate());
|
||||||
v8::HandleScope handle_scope(isolate());
|
v8::HandleScope handle_scope(isolate());
|
||||||
execute_command_.Run(
|
execute_command_.Run(GetWrapper(),
|
||||||
GetWrapper(),
|
|
||||||
mate::internal::CreateEventFromFlags(isolate(), flags),
|
mate::internal::CreateEventFromFlags(isolate(), flags),
|
||||||
command_id);
|
command_id);
|
||||||
}
|
}
|
||||||
|
@ -90,8 +88,9 @@ void Menu::MenuWillShow(ui::SimpleMenuModel* source) {
|
||||||
menu_will_show_.Run(GetWrapper());
|
menu_will_show_.Run(GetWrapper());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::InsertItemAt(
|
void Menu::InsertItemAt(int index,
|
||||||
int index, int command_id, const base::string16& label) {
|
int command_id,
|
||||||
|
const base::string16& label) {
|
||||||
model_->InsertItemAt(index, command_id, label);
|
model_->InsertItemAt(index, command_id, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,13 +206,14 @@ void Menu::BuildPrototype(v8::Isolate* isolate,
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using atom::api::Menu;
|
using atom::api::Menu;
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
Menu::SetConstructor(isolate, base::Bind(&Menu::New));
|
Menu::SetConstructor(isolate, base::Bind(&Menu::New));
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,9 @@ class Menu : public mate::TrackableObject<Menu>,
|
||||||
void MenuWillShow(ui::SimpleMenuModel* source) override;
|
void MenuWillShow(ui::SimpleMenuModel* source) override;
|
||||||
|
|
||||||
virtual void PopupAt(BrowserWindow* window,
|
virtual void PopupAt(BrowserWindow* window,
|
||||||
int x, int y, int positioning_item,
|
int x,
|
||||||
|
int y,
|
||||||
|
int positioning_item,
|
||||||
const base::Closure& callback) = 0;
|
const base::Closure& callback) = 0;
|
||||||
virtual void ClosePopupAt(int32_t window_id) = 0;
|
virtual void ClosePopupAt(int32_t window_id) = 0;
|
||||||
|
|
||||||
|
@ -110,12 +112,12 @@ class Menu : public mate::TrackableObject<Menu>,
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
||||||
|
|
||||||
namespace mate {
|
namespace mate {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Converter<atom::AtomMenuModel*> {
|
struct Converter<atom::AtomMenuModel*> {
|
||||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Value> val,
|
||||||
atom::AtomMenuModel** out) {
|
atom::AtomMenuModel** out) {
|
||||||
// null would be tranfered to NULL.
|
// null would be tranfered to NULL.
|
||||||
if (val->IsNull()) {
|
if (val->IsNull()) {
|
||||||
|
|
|
@ -23,7 +23,9 @@ class MenuMac : public Menu {
|
||||||
MenuMac(v8::Isolate* isolate, v8::Local<v8::Object> wrapper);
|
MenuMac(v8::Isolate* isolate, v8::Local<v8::Object> wrapper);
|
||||||
|
|
||||||
void PopupAt(BrowserWindow* window,
|
void PopupAt(BrowserWindow* window,
|
||||||
int x, int y, int positioning_item,
|
int x,
|
||||||
|
int y,
|
||||||
|
int positioning_item,
|
||||||
const base::Closure& callback) override;
|
const base::Closure& callback) override;
|
||||||
void PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
void PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
|
||||||
int32_t window_id,
|
int32_t window_id,
|
||||||
|
|
|
@ -17,12 +17,12 @@ namespace atom {
|
||||||
namespace api {
|
namespace api {
|
||||||
|
|
||||||
MenuViews::MenuViews(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
|
MenuViews::MenuViews(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
|
||||||
: Menu(isolate, wrapper),
|
: Menu(isolate, wrapper), weak_factory_(this) {}
|
||||||
weak_factory_(this) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void MenuViews::PopupAt(BrowserWindow* window,
|
void MenuViews::PopupAt(BrowserWindow* window,
|
||||||
int x, int y, int positioning_item,
|
int x,
|
||||||
|
int y,
|
||||||
|
int positioning_item,
|
||||||
const base::Closure& callback) {
|
const base::Closure& callback) {
|
||||||
auto* native_window = static_cast<NativeWindowViews*>(window->window());
|
auto* native_window = static_cast<NativeWindowViews*>(window->window());
|
||||||
if (!native_window)
|
if (!native_window)
|
||||||
|
@ -46,14 +46,11 @@ void MenuViews::PopupAt(BrowserWindow* window,
|
||||||
int32_t window_id = window->weak_map_id();
|
int32_t window_id = window->weak_map_id();
|
||||||
auto close_callback = base::Bind(
|
auto close_callback = base::Bind(
|
||||||
&MenuViews::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback);
|
&MenuViews::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback);
|
||||||
menu_runners_[window_id] = std::unique_ptr<MenuRunner>(new MenuRunner(
|
menu_runners_[window_id] = std::unique_ptr<MenuRunner>(
|
||||||
model(), flags, close_callback));
|
new MenuRunner(model(), flags, close_callback));
|
||||||
menu_runners_[window_id]->RunMenuAt(
|
menu_runners_[window_id]->RunMenuAt(
|
||||||
native_window->widget(),
|
native_window->widget(), NULL, gfx::Rect(location, gfx::Size()),
|
||||||
NULL,
|
views::MENU_ANCHOR_TOPLEFT, ui::MENU_SOURCE_MOUSE);
|
||||||
gfx::Rect(location, gfx::Size()),
|
|
||||||
views::MENU_ANCHOR_TOPLEFT,
|
|
||||||
ui::MENU_SOURCE_MOUSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuViews::ClosePopupAt(int32_t window_id) {
|
void MenuViews::ClosePopupAt(int32_t window_id) {
|
||||||
|
|
|
@ -22,7 +22,9 @@ class MenuViews : public Menu {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void PopupAt(BrowserWindow* window,
|
void PopupAt(BrowserWindow* window,
|
||||||
int x, int y, int positioning_item,
|
int x,
|
||||||
|
int y,
|
||||||
|
int positioning_item,
|
||||||
const base::Closure& callback) override;
|
const base::Closure& callback) override;
|
||||||
void ClosePopupAt(int32_t window_id) override;
|
void ClosePopupAt(int32_t window_id) override;
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
namespace mate {
|
namespace mate {
|
||||||
template <>
|
template <>
|
||||||
struct Converter<brightray::NotificationAction> {
|
struct Converter<brightray::NotificationAction> {
|
||||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Value> val,
|
||||||
brightray::NotificationAction* out) {
|
brightray::NotificationAction* out) {
|
||||||
mate::Dictionary dict;
|
mate::Dictionary dict;
|
||||||
if (!ConvertFromV8(isolate, val, &dict))
|
if (!ConvertFromV8(isolate, val, &dict))
|
||||||
|
@ -179,8 +180,7 @@ void Notification::NotificationDisplayed() {
|
||||||
Emit("show");
|
Emit("show");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notification::NotificationDestroyed() {
|
void Notification::NotificationDestroyed() {}
|
||||||
}
|
|
||||||
|
|
||||||
void Notification::NotificationClosed() {
|
void Notification::NotificationClosed() {
|
||||||
Emit("close");
|
Emit("close");
|
||||||
|
@ -232,14 +232,12 @@ void Notification::BuildPrototype(v8::Isolate* isolate,
|
||||||
.SetProperty("subtitle", &Notification::GetSubtitle,
|
.SetProperty("subtitle", &Notification::GetSubtitle,
|
||||||
&Notification::SetSubtitle)
|
&Notification::SetSubtitle)
|
||||||
.SetProperty("body", &Notification::GetBody, &Notification::SetBody)
|
.SetProperty("body", &Notification::GetBody, &Notification::SetBody)
|
||||||
.SetProperty("silent", &Notification::GetSilent,
|
.SetProperty("silent", &Notification::GetSilent, &Notification::SetSilent)
|
||||||
&Notification::SetSilent)
|
|
||||||
.SetProperty("hasReply", &Notification::GetHasReply,
|
.SetProperty("hasReply", &Notification::GetHasReply,
|
||||||
&Notification::SetHasReply)
|
&Notification::SetHasReply)
|
||||||
.SetProperty("replyPlaceholder", &Notification::GetReplyPlaceholder,
|
.SetProperty("replyPlaceholder", &Notification::GetReplyPlaceholder,
|
||||||
&Notification::SetReplyPlaceholder)
|
&Notification::SetReplyPlaceholder)
|
||||||
.SetProperty("sound", &Notification::GetSound,
|
.SetProperty("sound", &Notification::GetSound, &Notification::SetSound)
|
||||||
&Notification::SetSound)
|
|
||||||
.SetProperty("actions", &Notification::GetActions,
|
.SetProperty("actions", &Notification::GetActions,
|
||||||
&Notification::SetActions)
|
&Notification::SetActions)
|
||||||
.SetProperty("closeButtonText", &Notification::GetCloseButtonText,
|
.SetProperty("closeButtonText", &Notification::GetCloseButtonText,
|
||||||
|
|
|
@ -38,11 +38,11 @@ namespace api {
|
||||||
|
|
||||||
PowerMonitor::PowerMonitor(v8::Isolate* isolate) {
|
PowerMonitor::PowerMonitor(v8::Isolate* isolate) {
|
||||||
#if defined(OS_LINUX)
|
#if defined(OS_LINUX)
|
||||||
SetShutdownHandler(base::Bind(&PowerMonitor::ShouldShutdown,
|
SetShutdownHandler(
|
||||||
base::Unretained(this)));
|
base::Bind(&PowerMonitor::ShouldShutdown, base::Unretained(this)));
|
||||||
#elif defined(OS_MACOSX)
|
#elif defined(OS_MACOSX)
|
||||||
Browser::Get()->SetShutdownHandler(base::Bind(&PowerMonitor::ShouldShutdown,
|
Browser::Get()->SetShutdownHandler(
|
||||||
base::Unretained(this)));
|
base::Bind(&PowerMonitor::ShouldShutdown, base::Unretained(this)));
|
||||||
#endif
|
#endif
|
||||||
base::PowerMonitor::Get()->AddObserver(this);
|
base::PowerMonitor::Get()->AddObserver(this);
|
||||||
Init(isolate);
|
Init(isolate);
|
||||||
|
@ -87,9 +87,8 @@ void PowerMonitor::QuerySystemIdleState(v8::Isolate* isolate,
|
||||||
if (idle_threshold > 0) {
|
if (idle_threshold > 0) {
|
||||||
ui::CalculateIdleState(idle_threshold, callback);
|
ui::CalculateIdleState(idle_threshold, callback);
|
||||||
} else {
|
} else {
|
||||||
isolate->ThrowException(v8::Exception::TypeError(
|
isolate->ThrowException(v8::Exception::TypeError(mate::StringToV8(
|
||||||
mate::StringToV8(isolate,
|
isolate, "Invalid idle threshold, must be greater than 0")));
|
||||||
"Invalid idle threshold, must be greater than 0")));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,8 +109,8 @@ v8::Local<v8::Value> PowerMonitor::Create(v8::Isolate* isolate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void PowerMonitor::BuildPrototype(
|
void PowerMonitor::BuildPrototype(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
|
v8::Local<v8::FunctionTemplate> prototype) {
|
||||||
prototype->SetClassName(mate::StringToV8(isolate, "PowerMonitor"));
|
prototype->SetClassName(mate::StringToV8(isolate, "PowerMonitor"));
|
||||||
|
|
||||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||||
|
@ -128,13 +127,14 @@ void PowerMonitor::BuildPrototype(
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using atom::api::PowerMonitor;
|
using atom::api::PowerMonitor;
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
dict.Set("powerMonitor", PowerMonitor::Create(isolate));
|
dict.Set("powerMonitor", PowerMonitor::Create(isolate));
|
||||||
|
|
|
@ -46,8 +46,7 @@ PowerSaveBlocker::PowerSaveBlocker(v8::Isolate* isolate)
|
||||||
Init(isolate);
|
Init(isolate);
|
||||||
}
|
}
|
||||||
|
|
||||||
PowerSaveBlocker::~PowerSaveBlocker() {
|
PowerSaveBlocker::~PowerSaveBlocker() {}
|
||||||
}
|
|
||||||
|
|
||||||
void PowerSaveBlocker::UpdatePowerSaveBlocker() {
|
void PowerSaveBlocker::UpdatePowerSaveBlocker() {
|
||||||
if (power_save_blocker_types_.empty()) {
|
if (power_save_blocker_types_.empty()) {
|
||||||
|
@ -75,8 +74,7 @@ void PowerSaveBlocker::UpdatePowerSaveBlocker() {
|
||||||
if (!power_save_blocker_ || new_blocker_type != current_blocker_type_) {
|
if (!power_save_blocker_ || new_blocker_type != current_blocker_type_) {
|
||||||
std::unique_ptr<device::PowerSaveBlocker> new_blocker(
|
std::unique_ptr<device::PowerSaveBlocker> new_blocker(
|
||||||
new device::PowerSaveBlocker(
|
new device::PowerSaveBlocker(
|
||||||
new_blocker_type,
|
new_blocker_type, device::PowerSaveBlocker::kReasonOther,
|
||||||
device::PowerSaveBlocker::kReasonOther,
|
|
||||||
ATOM_PRODUCT_NAME,
|
ATOM_PRODUCT_NAME,
|
||||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
|
BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
|
||||||
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)));
|
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)));
|
||||||
|
@ -110,7 +108,8 @@ mate::Handle<PowerSaveBlocker> PowerSaveBlocker::Create(v8::Isolate* isolate) {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void PowerSaveBlocker::BuildPrototype(
|
void PowerSaveBlocker::BuildPrototype(
|
||||||
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
|
v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::FunctionTemplate> prototype) {
|
||||||
prototype->SetClassName(mate::StringToV8(isolate, "PowerSaveBlocker"));
|
prototype->SetClassName(mate::StringToV8(isolate, "PowerSaveBlocker"));
|
||||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||||
.SetMethod("start", &PowerSaveBlocker::Start)
|
.SetMethod("start", &PowerSaveBlocker::Start)
|
||||||
|
@ -124,8 +123,10 @@ void PowerSaveBlocker::BuildPrototype(
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
dict.Set("powerSaveBlocker", atom::api::PowerSaveBlocker::Create(isolate));
|
dict.Set("powerSaveBlocker", atom::api::PowerSaveBlocker::Create(isolate));
|
||||||
|
|
|
@ -72,16 +72,15 @@ Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||||
Init(isolate);
|
Init(isolate);
|
||||||
}
|
}
|
||||||
|
|
||||||
Protocol::~Protocol() {
|
Protocol::~Protocol() {}
|
||||||
}
|
|
||||||
|
|
||||||
void Protocol::RegisterServiceWorkerSchemes(
|
void Protocol::RegisterServiceWorkerSchemes(
|
||||||
const std::vector<std::string>& schemes) {
|
const std::vector<std::string>& schemes) {
|
||||||
atom::AtomBrowserClient::SetCustomServiceWorkerSchemes(schemes);
|
atom::AtomBrowserClient::SetCustomServiceWorkerSchemes(schemes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Protocol::UnregisterProtocol(
|
void Protocol::UnregisterProtocol(const std::string& scheme,
|
||||||
const std::string& scheme, mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
CompletionCallback callback;
|
CompletionCallback callback;
|
||||||
args->GetNext(&callback);
|
args->GetNext(&callback);
|
||||||
auto getter = browser_context_->GetRequestContext();
|
auto getter = browser_context_->GetRequestContext();
|
||||||
|
@ -121,8 +120,8 @@ bool Protocol::IsProtocolHandledInIO(
|
||||||
return request_context_getter->job_factory()->IsHandledProtocol(scheme);
|
return request_context_getter->job_factory()->IsHandledProtocol(scheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Protocol::UninterceptProtocol(
|
void Protocol::UninterceptProtocol(const std::string& scheme,
|
||||||
const std::string& scheme, mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
CompletionCallback callback;
|
CompletionCallback callback;
|
||||||
args->GetNext(&callback);
|
args->GetNext(&callback);
|
||||||
auto getter = browser_context_->GetRequestContext();
|
auto getter = browser_context_->GetRequestContext();
|
||||||
|
@ -138,12 +137,14 @@ Protocol::ProtocolError Protocol::UninterceptProtocolInIO(
|
||||||
scoped_refptr<brightray::URLRequestContextGetter> request_context_getter,
|
scoped_refptr<brightray::URLRequestContextGetter> request_context_getter,
|
||||||
const std::string& scheme) {
|
const std::string& scheme) {
|
||||||
return static_cast<AtomURLRequestJobFactory*>(
|
return static_cast<AtomURLRequestJobFactory*>(
|
||||||
request_context_getter->job_factory())->UninterceptProtocol(scheme) ?
|
request_context_getter->job_factory())
|
||||||
PROTOCOL_OK : PROTOCOL_NOT_INTERCEPTED;
|
->UninterceptProtocol(scheme)
|
||||||
|
? PROTOCOL_OK
|
||||||
|
: PROTOCOL_NOT_INTERCEPTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Protocol::OnIOCompleted(
|
void Protocol::OnIOCompleted(const CompletionCallback& callback,
|
||||||
const CompletionCallback& callback, ProtocolError error) {
|
ProtocolError error) {
|
||||||
// The completion callback is optional.
|
// The completion callback is optional.
|
||||||
if (callback.is_null())
|
if (callback.is_null())
|
||||||
return;
|
return;
|
||||||
|
@ -161,24 +162,30 @@ void Protocol::OnIOCompleted(
|
||||||
|
|
||||||
std::string Protocol::ErrorCodeToString(ProtocolError error) {
|
std::string Protocol::ErrorCodeToString(ProtocolError error) {
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case PROTOCOL_FAIL: return "Failed to manipulate protocol factory";
|
case PROTOCOL_FAIL:
|
||||||
case PROTOCOL_REGISTERED: return "The scheme has been registered";
|
return "Failed to manipulate protocol factory";
|
||||||
case PROTOCOL_NOT_REGISTERED: return "The scheme has not been registered";
|
case PROTOCOL_REGISTERED:
|
||||||
case PROTOCOL_INTERCEPTED: return "The scheme has been intercepted";
|
return "The scheme has been registered";
|
||||||
case PROTOCOL_NOT_INTERCEPTED: return "The scheme has not been intercepted";
|
case PROTOCOL_NOT_REGISTERED:
|
||||||
default: return "Unexpected error";
|
return "The scheme has not been registered";
|
||||||
|
case PROTOCOL_INTERCEPTED:
|
||||||
|
return "The scheme has been intercepted";
|
||||||
|
case PROTOCOL_NOT_INTERCEPTED:
|
||||||
|
return "The scheme has not been intercepted";
|
||||||
|
default:
|
||||||
|
return "Unexpected error";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
mate::Handle<Protocol> Protocol::Create(
|
mate::Handle<Protocol> Protocol::Create(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate, AtomBrowserContext* browser_context) {
|
AtomBrowserContext* browser_context) {
|
||||||
return mate::CreateHandle(isolate, new Protocol(isolate, browser_context));
|
return mate::CreateHandle(isolate, new Protocol(isolate, browser_context));
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void Protocol::BuildPrototype(
|
void Protocol::BuildPrototype(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
|
v8::Local<v8::FunctionTemplate> prototype) {
|
||||||
prototype->SetClassName(mate::StringToV8(isolate, "Protocol"));
|
prototype->SetClassName(mate::StringToV8(isolate, "Protocol"));
|
||||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||||
.SetMethod("registerServiceWorkerSchemes",
|
.SetMethod("registerServiceWorkerSchemes",
|
||||||
|
@ -214,10 +221,11 @@ void Protocol::BuildPrototype(
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void RegisterStandardSchemes(
|
void RegisterStandardSchemes(const std::vector<std::string>& schemes,
|
||||||
const std::vector<std::string>& schemes, mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
if (atom::Browser::Get()->is_ready()) {
|
if (atom::Browser::Get()->is_ready()) {
|
||||||
args->ThrowError("protocol.registerStandardSchemes should be called before "
|
args->ThrowError(
|
||||||
|
"protocol.registerStandardSchemes should be called before "
|
||||||
"app is ready");
|
"app is ready");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -225,8 +233,10 @@ void RegisterStandardSchemes(
|
||||||
atom::api::RegisterStandardSchemes(schemes, args);
|
atom::api::RegisterStandardSchemes(schemes, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
dict.SetMethod("registerStandardSchemes", &RegisterStandardSchemes);
|
dict.SetMethod("registerStandardSchemes", &RegisterStandardSchemes);
|
||||||
|
|
|
@ -39,8 +39,8 @@ class Protocol : public mate::TrackableObject<Protocol> {
|
||||||
using CompletionCallback = base::Callback<void(v8::Local<v8::Value>)>;
|
using CompletionCallback = base::Callback<void(v8::Local<v8::Value>)>;
|
||||||
using BooleanCallback = base::Callback<void(bool)>;
|
using BooleanCallback = base::Callback<void(bool)>;
|
||||||
|
|
||||||
static mate::Handle<Protocol> Create(
|
static mate::Handle<Protocol> Create(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate, AtomBrowserContext* browser_context);
|
AtomBrowserContext* browser_context);
|
||||||
|
|
||||||
static void BuildPrototype(v8::Isolate* isolate,
|
static void BuildPrototype(v8::Isolate* isolate,
|
||||||
v8::Local<v8::FunctionTemplate> prototype);
|
v8::Local<v8::FunctionTemplate> prototype);
|
||||||
|
@ -66,8 +66,7 @@ class Protocol : public mate::TrackableObject<Protocol> {
|
||||||
class CustomProtocolHandler
|
class CustomProtocolHandler
|
||||||
: public net::URLRequestJobFactory::ProtocolHandler {
|
: public net::URLRequestJobFactory::ProtocolHandler {
|
||||||
public:
|
public:
|
||||||
CustomProtocolHandler(
|
CustomProtocolHandler(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate,
|
|
||||||
net::URLRequestContextGetter* request_context,
|
net::URLRequestContextGetter* request_context,
|
||||||
const Handler& handler)
|
const Handler& handler)
|
||||||
: isolate_(isolate),
|
: isolate_(isolate),
|
||||||
|
@ -187,9 +186,7 @@ class Protocol : public mate::TrackableObject<Protocol> {
|
||||||
// Convert error code to string.
|
// Convert error code to string.
|
||||||
std::string ErrorCodeToString(ProtocolError error);
|
std::string ErrorCodeToString(ProtocolError error);
|
||||||
|
|
||||||
base::WeakPtr<Protocol> GetWeakPtr() {
|
base::WeakPtr<Protocol> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
|
||||||
return weak_factory_.GetWeakPtr();
|
|
||||||
}
|
|
||||||
|
|
||||||
scoped_refptr<AtomBrowserContext> browser_context_;
|
scoped_refptr<AtomBrowserContext> browser_context_;
|
||||||
base::WeakPtrFactory<Protocol> weak_factory_;
|
base::WeakPtrFactory<Protocol> weak_factory_;
|
||||||
|
|
|
@ -21,8 +21,8 @@ namespace {
|
||||||
|
|
||||||
bool IsWebContents(v8::Isolate* isolate, content::RenderProcessHost* process) {
|
bool IsWebContents(v8::Isolate* isolate, content::RenderProcessHost* process) {
|
||||||
content::WebContents* web_contents =
|
content::WebContents* web_contents =
|
||||||
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())->
|
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())
|
||||||
GetWebContentsFromProcessID(process->GetID());
|
->GetWebContentsFromProcessID(process->GetID());
|
||||||
if (!web_contents)
|
if (!web_contents)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -41,8 +41,7 @@ RenderProcessPreferences::RenderProcessPreferences(
|
||||||
Init(isolate);
|
Init(isolate);
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderProcessPreferences::~RenderProcessPreferences() {
|
RenderProcessPreferences::~RenderProcessPreferences() {}
|
||||||
}
|
|
||||||
|
|
||||||
int RenderProcessPreferences::AddEntry(const base::DictionaryValue& entry) {
|
int RenderProcessPreferences::AddEntry(const base::DictionaryValue& entry) {
|
||||||
return preferences_.AddEntry(entry);
|
return preferences_.AddEntry(entry);
|
||||||
|
@ -54,7 +53,8 @@ void RenderProcessPreferences::RemoveEntry(int id) {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void RenderProcessPreferences::BuildPrototype(
|
void RenderProcessPreferences::BuildPrototype(
|
||||||
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
|
v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::FunctionTemplate> prototype) {
|
||||||
prototype->SetClassName(
|
prototype->SetClassName(
|
||||||
mate::StringToV8(isolate, "RenderProcessPreferences"));
|
mate::StringToV8(isolate, "RenderProcessPreferences"));
|
||||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||||
|
@ -65,10 +65,9 @@ void RenderProcessPreferences::BuildPrototype(
|
||||||
// static
|
// static
|
||||||
mate::Handle<RenderProcessPreferences>
|
mate::Handle<RenderProcessPreferences>
|
||||||
RenderProcessPreferences::ForAllWebContents(v8::Isolate* isolate) {
|
RenderProcessPreferences::ForAllWebContents(v8::Isolate* isolate) {
|
||||||
return mate::CreateHandle(
|
return mate::CreateHandle(isolate,
|
||||||
isolate,
|
new RenderProcessPreferences(
|
||||||
new RenderProcessPreferences(isolate,
|
isolate, base::Bind(&IsWebContents, isolate)));
|
||||||
base::Bind(&IsWebContents, isolate)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace api
|
} // namespace api
|
||||||
|
@ -77,8 +76,10 @@ RenderProcessPreferences::ForAllWebContents(v8::Isolate* isolate) {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||||
dict.SetMethod("forAllWebContents",
|
dict.SetMethod("forAllWebContents",
|
||||||
&atom::api::RenderProcessPreferences::ForAllWebContents);
|
&atom::api::RenderProcessPreferences::ForAllWebContents);
|
||||||
|
|
|
@ -16,8 +16,8 @@ namespace api {
|
||||||
class RenderProcessPreferences
|
class RenderProcessPreferences
|
||||||
: public mate::Wrappable<RenderProcessPreferences> {
|
: public mate::Wrappable<RenderProcessPreferences> {
|
||||||
public:
|
public:
|
||||||
static mate::Handle<RenderProcessPreferences>
|
static mate::Handle<RenderProcessPreferences> ForAllWebContents(
|
||||||
ForAllWebContents(v8::Isolate* isolate);
|
v8::Isolate* isolate);
|
||||||
|
|
||||||
static void BuildPrototype(v8::Isolate* isolate,
|
static void BuildPrototype(v8::Isolate* isolate,
|
||||||
v8::Local<v8::FunctionTemplate> prototype);
|
v8::Local<v8::FunctionTemplate> prototype);
|
||||||
|
|
|
@ -96,15 +96,14 @@ void Screen::OnDisplayMetricsChanged(const display::Display& display,
|
||||||
v8::Local<v8::Value> Screen::Create(v8::Isolate* isolate) {
|
v8::Local<v8::Value> Screen::Create(v8::Isolate* isolate) {
|
||||||
if (!Browser::Get()->is_ready()) {
|
if (!Browser::Get()->is_ready()) {
|
||||||
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
|
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
|
||||||
isolate,
|
isolate, "Cannot require \"screen\" module before app is ready")));
|
||||||
"Cannot require \"screen\" module before app is ready")));
|
|
||||||
return v8::Null(isolate);
|
return v8::Null(isolate);
|
||||||
}
|
}
|
||||||
|
|
||||||
display::Screen* screen = display::Screen::GetScreen();
|
display::Screen* screen = display::Screen::GetScreen();
|
||||||
if (!screen) {
|
if (!screen) {
|
||||||
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
|
isolate->ThrowException(v8::Exception::Error(
|
||||||
isolate, "Failed to get screen information")));
|
mate::StringToV8(isolate, "Failed to get screen information")));
|
||||||
return v8::Null(isolate);
|
return v8::Null(isolate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,8 +111,8 @@ v8::Local<v8::Value> Screen::Create(v8::Isolate* isolate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void Screen::BuildPrototype(
|
void Screen::BuildPrototype(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
|
v8::Local<v8::FunctionTemplate> prototype) {
|
||||||
prototype->SetClassName(mate::StringToV8(isolate, "Screen"));
|
prototype->SetClassName(mate::StringToV8(isolate, "Screen"));
|
||||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||||
.SetMethod("getCursorScreenPoint", &Screen::GetCursorScreenPoint)
|
.SetMethod("getCursorScreenPoint", &Screen::GetCursorScreenPoint)
|
||||||
|
@ -134,8 +133,10 @@ namespace {
|
||||||
|
|
||||||
using atom::api::Screen;
|
using atom::api::Screen;
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
dict.Set("screen", Screen::Create(isolate));
|
dict.Set("screen", Screen::Create(isolate));
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace gfx {
|
||||||
class Point;
|
class Point;
|
||||||
class Rect;
|
class Rect;
|
||||||
class Screen;
|
class Screen;
|
||||||
}
|
} // namespace gfx
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
|
|
@ -244,8 +244,7 @@ class ResolveProxyHelper {
|
||||||
scoped_refptr<net::URLRequestContextGetter> context_getter =
|
scoped_refptr<net::URLRequestContextGetter> context_getter =
|
||||||
browser_context->url_request_context_getter();
|
browser_context->url_request_context_getter();
|
||||||
context_getter->GetNetworkTaskRunner()->PostTask(
|
context_getter->GetNetworkTaskRunner()->PostTask(
|
||||||
FROM_HERE,
|
FROM_HERE, base::Bind(&ResolveProxyHelper::ResolveProxy,
|
||||||
base::Bind(&ResolveProxyHelper::ResolveProxy,
|
|
||||||
base::Unretained(this), context_getter, url));
|
base::Unretained(this), context_getter, url));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,8 +252,7 @@ class ResolveProxyHelper {
|
||||||
std::string proxy;
|
std::string proxy;
|
||||||
if (result == net::OK)
|
if (result == net::OK)
|
||||||
proxy = proxy_info_.ToPacString();
|
proxy = proxy_info_.ToPacString();
|
||||||
original_thread_->PostTask(FROM_HERE,
|
original_thread_->PostTask(FROM_HERE, base::Bind(callback_, proxy));
|
||||||
base::Bind(callback_, proxy));
|
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,14 +263,13 @@ class ResolveProxyHelper {
|
||||||
|
|
||||||
net::ProxyService* proxy_service =
|
net::ProxyService* proxy_service =
|
||||||
context_getter->GetURLRequestContext()->proxy_service();
|
context_getter->GetURLRequestContext()->proxy_service();
|
||||||
net::CompletionCallback completion_callback =
|
net::CompletionCallback completion_callback = base::Bind(
|
||||||
base::Bind(&ResolveProxyHelper::OnResolveProxyCompleted,
|
&ResolveProxyHelper::OnResolveProxyCompleted, base::Unretained(this));
|
||||||
base::Unretained(this));
|
|
||||||
|
|
||||||
// Start the request.
|
// Start the request.
|
||||||
int result = proxy_service->ResolveProxy(
|
int result = proxy_service->ResolveProxy(url, "GET", &proxy_info_,
|
||||||
url, "GET", &proxy_info_, completion_callback, &pac_req_, nullptr,
|
completion_callback, &pac_req_,
|
||||||
net::NetLogWithSource());
|
nullptr, net::NetLogWithSource());
|
||||||
|
|
||||||
// Completed synchronously.
|
// Completed synchronously.
|
||||||
if (result != net::ERR_IO_PENDING)
|
if (result != net::ERR_IO_PENDING)
|
||||||
|
@ -293,8 +290,8 @@ void RunCallbackInUI(const base::Callback<void()>& callback) {
|
||||||
}
|
}
|
||||||
template <typename... T>
|
template <typename... T>
|
||||||
void RunCallbackInUI(const base::Callback<void(T...)>& callback, T... result) {
|
void RunCallbackInUI(const base::Callback<void(T...)>& callback, T... result) {
|
||||||
BrowserThread::PostTask(
|
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
||||||
BrowserThread::UI, FROM_HERE, base::Bind(callback, result...));
|
base::Bind(callback, result...));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback of HttpCache::GetBackend.
|
// Callback of HttpCache::GetBackend.
|
||||||
|
@ -306,8 +303,8 @@ void OnGetBackend(disk_cache::Backend** backend_ptr,
|
||||||
RunCallbackInUI(callback, result);
|
RunCallbackInUI(callback, result);
|
||||||
} else if (backend_ptr && *backend_ptr) {
|
} else if (backend_ptr && *backend_ptr) {
|
||||||
if (action == Session::CacheAction::CLEAR) {
|
if (action == Session::CacheAction::CLEAR) {
|
||||||
(*backend_ptr)->DoomAllEntries(base::Bind(&RunCallbackInUI<int>,
|
(*backend_ptr)
|
||||||
callback));
|
->DoomAllEntries(base::Bind(&RunCallbackInUI<int>, callback));
|
||||||
} else if (action == Session::CacheAction::STATS) {
|
} else if (action == Session::CacheAction::STATS) {
|
||||||
base::StringPairs stats;
|
base::StringPairs stats;
|
||||||
(*backend_ptr)->GetStats(&stats);
|
(*backend_ptr)->GetStats(&stats);
|
||||||
|
@ -348,8 +345,8 @@ void SetProxyInIO(scoped_refptr<net::URLRequestContextGetter> getter,
|
||||||
const net::ProxyConfig& config,
|
const net::ProxyConfig& config,
|
||||||
const base::Closure& callback) {
|
const base::Closure& callback) {
|
||||||
auto proxy_service = getter->GetURLRequestContext()->proxy_service();
|
auto proxy_service = getter->GetURLRequestContext()->proxy_service();
|
||||||
proxy_service->ResetConfigService(base::WrapUnique(
|
proxy_service->ResetConfigService(
|
||||||
new net::ProxyConfigServiceFixed(config)));
|
base::WrapUnique(new net::ProxyConfigServiceFixed(config)));
|
||||||
// Refetches and applies the new pac script if provided.
|
// Refetches and applies the new pac script if provided.
|
||||||
proxy_service->ForceReloadProxyConfig();
|
proxy_service->ForceReloadProxyConfig();
|
||||||
RunCallbackInUI(callback);
|
RunCallbackInUI(callback);
|
||||||
|
@ -359,8 +356,8 @@ void SetCertVerifyProcInIO(
|
||||||
const scoped_refptr<net::URLRequestContextGetter>& context_getter,
|
const scoped_refptr<net::URLRequestContextGetter>& context_getter,
|
||||||
const AtomCertVerifier::VerifyProc& proc) {
|
const AtomCertVerifier::VerifyProc& proc) {
|
||||||
auto request_context = context_getter->GetURLRequestContext();
|
auto request_context = context_getter->GetURLRequestContext();
|
||||||
static_cast<AtomCertVerifier*>(request_context->cert_verifier())->
|
static_cast<AtomCertVerifier*>(request_context->cert_verifier())
|
||||||
SetVerifyProc(proc);
|
->SetVerifyProc(proc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearHostResolverCacheInIO(
|
void ClearHostResolverCacheInIO(
|
||||||
|
@ -437,9 +434,8 @@ void DownloadIdCallback(content::DownloadManager* download_manager,
|
||||||
last_modified, offset, length, std::string(),
|
last_modified, offset, length, std::string(),
|
||||||
content::DownloadItem::INTERRUPTED,
|
content::DownloadItem::INTERRUPTED,
|
||||||
content::DownloadDangerType::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
|
content::DownloadDangerType::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
|
||||||
content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT, false,
|
content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT, false, base::Time(),
|
||||||
base::Time(), false,
|
false, std::vector<content::DownloadItem::ReceivedSlice>());
|
||||||
std::vector<content::DownloadItem::ReceivedSlice>());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetDevToolsNetworkEmulationClientIdInIO(
|
void SetDevToolsNetworkEmulationClientIdInIO(
|
||||||
|
@ -486,8 +482,8 @@ Session::Session(v8::Isolate* isolate, AtomBrowserContext* browser_context)
|
||||||
: devtools_network_emulation_client_id_(base::GenerateGUID()),
|
: devtools_network_emulation_client_id_(base::GenerateGUID()),
|
||||||
browser_context_(browser_context) {
|
browser_context_(browser_context) {
|
||||||
// Observe DownloadManager to get download notifications.
|
// Observe DownloadManager to get download notifications.
|
||||||
content::BrowserContext::GetDownloadManager(browser_context)->
|
content::BrowserContext::GetDownloadManager(browser_context)
|
||||||
AddObserver(this);
|
->AddObserver(this);
|
||||||
|
|
||||||
new SessionPreferences(browser_context);
|
new SessionPreferences(browser_context);
|
||||||
|
|
||||||
|
@ -500,8 +496,8 @@ Session::~Session() {
|
||||||
content::BrowserThread::PostTask(
|
content::BrowserThread::PostTask(
|
||||||
content::BrowserThread::IO, FROM_HERE,
|
content::BrowserThread::IO, FROM_HERE,
|
||||||
base::BindOnce(ClearJobFactoryInIO, base::RetainedRef(getter)));
|
base::BindOnce(ClearJobFactoryInIO, base::RetainedRef(getter)));
|
||||||
content::BrowserContext::GetDownloadManager(browser_context())->
|
content::BrowserContext::GetDownloadManager(browser_context())
|
||||||
RemoveObserver(this);
|
->RemoveObserver(this);
|
||||||
DestroyGlobalHandle(isolate(), cookies_);
|
DestroyGlobalHandle(isolate(), cookies_);
|
||||||
DestroyGlobalHandle(isolate(), web_request_);
|
DestroyGlobalHandle(isolate(), web_request_);
|
||||||
DestroyGlobalHandle(isolate(), protocol_);
|
DestroyGlobalHandle(isolate(), protocol_);
|
||||||
|
@ -531,10 +527,10 @@ void Session::ResolveProxy(const GURL& url, ResolveProxyCallback callback) {
|
||||||
|
|
||||||
template <Session::CacheAction action>
|
template <Session::CacheAction action>
|
||||||
void Session::DoCacheAction(const net::CompletionCallback& callback) {
|
void Session::DoCacheAction(const net::CompletionCallback& callback) {
|
||||||
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
BrowserThread::PostTask(
|
||||||
|
BrowserThread::IO, FROM_HERE,
|
||||||
base::Bind(&DoCacheActionInIO,
|
base::Bind(&DoCacheActionInIO,
|
||||||
WrapRefCounted(browser_context_->GetRequestContext()),
|
WrapRefCounted(browser_context_->GetRequestContext()), action,
|
||||||
action,
|
|
||||||
callback));
|
callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -554,9 +550,8 @@ void Session::ClearStorageData(mate::Arguments* args) {
|
||||||
}
|
}
|
||||||
storage_partition->ClearData(
|
storage_partition->ClearData(
|
||||||
options.storage_types, options.quota_types, options.origin,
|
options.storage_types, options.quota_types, options.origin,
|
||||||
content::StoragePartition::OriginMatcherFunction(),
|
content::StoragePartition::OriginMatcherFunction(), base::Time(),
|
||||||
base::Time(), base::Time::Max(),
|
base::Time::Max(), base::Bind(&OnClearStorageDataDone, callback));
|
||||||
base::Bind(&OnClearStorageDataDone, callback));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::FlushStorageData() {
|
void Session::FlushStorageData() {
|
||||||
|
@ -575,8 +570,8 @@ void Session::SetProxy(const net::ProxyConfig& config,
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::SetDownloadPath(const base::FilePath& path) {
|
void Session::SetDownloadPath(const base::FilePath& path) {
|
||||||
browser_context_->prefs()->SetFilePath(
|
browser_context_->prefs()->SetFilePath(prefs::kDownloadDefaultDirectory,
|
||||||
prefs::kDownloadDefaultDirectory, path);
|
path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::EnableNetworkEmulation(const mate::Dictionary& options) {
|
void Session::EnableNetworkEmulation(const mate::Dictionary& options) {
|
||||||
|
@ -623,10 +618,10 @@ void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
BrowserThread::PostTask(
|
||||||
|
BrowserThread::IO, FROM_HERE,
|
||||||
base::Bind(&SetCertVerifyProcInIO,
|
base::Bind(&SetCertVerifyProcInIO,
|
||||||
WrapRefCounted(browser_context_->GetRequestContext()),
|
WrapRefCounted(browser_context_->GetRequestContext()), proc));
|
||||||
proc));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::SetPermissionRequestHandler(v8::Local<v8::Value> val,
|
void Session::SetPermissionRequestHandler(v8::Local<v8::Value> val,
|
||||||
|
@ -645,7 +640,8 @@ void Session::ClearHostResolverCache(mate::Arguments* args) {
|
||||||
base::Closure callback;
|
base::Closure callback;
|
||||||
args->GetNext(&callback);
|
args->GetNext(&callback);
|
||||||
|
|
||||||
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
BrowserThread::PostTask(
|
||||||
|
BrowserThread::IO, FROM_HERE,
|
||||||
base::Bind(&ClearHostResolverCacheInIO,
|
base::Bind(&ClearHostResolverCacheInIO,
|
||||||
WrapRefCounted(browser_context_->GetRequestContext()),
|
WrapRefCounted(browser_context_->GetRequestContext()),
|
||||||
callback));
|
callback));
|
||||||
|
@ -663,12 +659,13 @@ void Session::ClearAuthCache(mate::Arguments* args) {
|
||||||
BrowserThread::PostTask(
|
BrowserThread::PostTask(
|
||||||
BrowserThread::IO, FROM_HERE,
|
BrowserThread::IO, FROM_HERE,
|
||||||
base::Bind(&ClearAuthCacheInIO,
|
base::Bind(&ClearAuthCacheInIO,
|
||||||
WrapRefCounted(browser_context_->GetRequestContext()),
|
WrapRefCounted(browser_context_->GetRequestContext()), options,
|
||||||
options, callback));
|
callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::AllowNTLMCredentialsForDomains(const std::string& domains) {
|
void Session::AllowNTLMCredentialsForDomains(const std::string& domains) {
|
||||||
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
BrowserThread::PostTask(
|
||||||
|
BrowserThread::IO, FROM_HERE,
|
||||||
base::Bind(&AllowNTLMCredentialsForDomainsInIO,
|
base::Bind(&AllowNTLMCredentialsForDomainsInIO,
|
||||||
WrapRefCounted(browser_context_->GetRequestContext()),
|
WrapRefCounted(browser_context_->GetRequestContext()),
|
||||||
domains));
|
domains));
|
||||||
|
@ -692,19 +689,16 @@ std::string Session::GetUserAgent() {
|
||||||
return browser_context_->GetUserAgent();
|
return browser_context_->GetUserAgent();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::GetBlobData(
|
void Session::GetBlobData(const std::string& uuid,
|
||||||
const std::string& uuid,
|
|
||||||
const AtomBlobReader::CompletionCallback& callback) {
|
const AtomBlobReader::CompletionCallback& callback) {
|
||||||
if (callback.is_null())
|
if (callback.is_null())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AtomBlobReader* blob_reader =
|
AtomBlobReader* blob_reader = browser_context()->GetBlobReader();
|
||||||
browser_context()->GetBlobReader();
|
BrowserThread::PostTask(
|
||||||
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
|
BrowserThread::IO, FROM_HERE,
|
||||||
base::Bind(&AtomBlobReader::StartReading,
|
base::Bind(&AtomBlobReader::StartReading, base::Unretained(blob_reader),
|
||||||
base::Unretained(blob_reader),
|
uuid, callback));
|
||||||
uuid,
|
|
||||||
callback));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Session::CreateInterruptedDownload(const mate::Dictionary& options) {
|
void Session::CreateInterruptedDownload(const mate::Dictionary& options) {
|
||||||
|
@ -776,14 +770,14 @@ v8::Local<v8::Value> Session::WebRequest(v8::Isolate* isolate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
mate::Handle<Session> Session::CreateFrom(
|
mate::Handle<Session> Session::CreateFrom(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate, AtomBrowserContext* browser_context) {
|
AtomBrowserContext* browser_context) {
|
||||||
auto existing = TrackableObject::FromWrappedClass(isolate, browser_context);
|
auto existing = TrackableObject::FromWrappedClass(isolate, browser_context);
|
||||||
if (existing)
|
if (existing)
|
||||||
return mate::CreateHandle(isolate, static_cast<Session*>(existing));
|
return mate::CreateHandle(isolate, static_cast<Session*>(existing));
|
||||||
|
|
||||||
auto handle = mate::CreateHandle(
|
auto handle =
|
||||||
isolate, new Session(isolate, browser_context));
|
mate::CreateHandle(isolate, new Session(isolate, browser_context));
|
||||||
|
|
||||||
// The Sessions should never be garbage collected, since the common pattern is
|
// The Sessions should never be garbage collected, since the common pattern is
|
||||||
// to use partition strings, instead of using the Session object directly.
|
// to use partition strings, instead of using the Session object directly.
|
||||||
|
@ -795,7 +789,8 @@ mate::Handle<Session> Session::CreateFrom(
|
||||||
|
|
||||||
// static
|
// static
|
||||||
mate::Handle<Session> Session::FromPartition(
|
mate::Handle<Session> Session::FromPartition(
|
||||||
v8::Isolate* isolate, const std::string& partition,
|
v8::Isolate* isolate,
|
||||||
|
const std::string& partition,
|
||||||
const base::DictionaryValue& options) {
|
const base::DictionaryValue& options) {
|
||||||
scoped_refptr<AtomBrowserContext> browser_context;
|
scoped_refptr<AtomBrowserContext> browser_context;
|
||||||
if (partition.empty()) {
|
if (partition.empty()) {
|
||||||
|
@ -852,8 +847,8 @@ namespace {
|
||||||
|
|
||||||
using atom::api::Session;
|
using atom::api::Session;
|
||||||
|
|
||||||
v8::Local<v8::Value> FromPartition(
|
v8::Local<v8::Value> FromPartition(const std::string& partition,
|
||||||
const std::string& partition, mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
if (!atom::Browser::Get()->is_ready()) {
|
if (!atom::Browser::Get()->is_ready()) {
|
||||||
args->ThrowError("Session can only be received when app is ready");
|
args->ThrowError("Session can only be received when app is ready");
|
||||||
return v8::Null(args->isolate());
|
return v8::Null(args->isolate());
|
||||||
|
@ -863,8 +858,10 @@ v8::Local<v8::Value> FromPartition(
|
||||||
return Session::FromPartition(args->isolate(), partition, options).ToV8();
|
return Session::FromPartition(args->isolate(), partition, options).ToV8();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
dict.Set("Session", Session::GetConstructor(isolate)->GetFunction());
|
dict.Set("Session", Session::GetConstructor(isolate)->GetFunction());
|
||||||
|
|
|
@ -24,7 +24,7 @@ class FilePath;
|
||||||
namespace mate {
|
namespace mate {
|
||||||
class Arguments;
|
class Arguments;
|
||||||
class Dictionary;
|
class Dictionary;
|
||||||
}
|
} // namespace mate
|
||||||
|
|
||||||
namespace net {
|
namespace net {
|
||||||
class ProxyConfig;
|
class ProxyConfig;
|
||||||
|
@ -47,12 +47,13 @@ class Session: public mate::TrackableObject<Session>,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Gets or creates Session from the |browser_context|.
|
// Gets or creates Session from the |browser_context|.
|
||||||
static mate::Handle<Session> CreateFrom(
|
static mate::Handle<Session> CreateFrom(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate, AtomBrowserContext* browser_context);
|
AtomBrowserContext* browser_context);
|
||||||
|
|
||||||
// Gets the Session of |partition|.
|
// Gets the Session of |partition|.
|
||||||
static mate::Handle<Session> FromPartition(
|
static mate::Handle<Session> FromPartition(
|
||||||
v8::Isolate* isolate, const std::string& partition,
|
v8::Isolate* isolate,
|
||||||
|
const std::string& partition,
|
||||||
const base::DictionaryValue& options = base::DictionaryValue());
|
const base::DictionaryValue& options = base::DictionaryValue());
|
||||||
|
|
||||||
AtomBrowserContext* browser_context() const { return browser_context_.get(); }
|
AtomBrowserContext* browser_context() const { return browser_context_.get(); }
|
||||||
|
|
|
@ -45,7 +45,8 @@ mate::Handle<SystemPreferences> SystemPreferences::Create(
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void SystemPreferences::BuildPrototype(
|
void SystemPreferences::BuildPrototype(
|
||||||
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
|
v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::FunctionTemplate> prototype) {
|
||||||
prototype->SetClassName(mate::StringToV8(isolate, "SystemPreferences"));
|
prototype->SetClassName(mate::StringToV8(isolate, "SystemPreferences"));
|
||||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
|
@ -53,8 +54,7 @@ void SystemPreferences::BuildPrototype(
|
||||||
.SetMethod("isAeroGlassEnabled", &SystemPreferences::IsAeroGlassEnabled)
|
.SetMethod("isAeroGlassEnabled", &SystemPreferences::IsAeroGlassEnabled)
|
||||||
.SetMethod("getColor", &SystemPreferences::GetColor)
|
.SetMethod("getColor", &SystemPreferences::GetColor)
|
||||||
#elif defined(OS_MACOSX)
|
#elif defined(OS_MACOSX)
|
||||||
.SetMethod("postNotification",
|
.SetMethod("postNotification", &SystemPreferences::PostNotification)
|
||||||
&SystemPreferences::PostNotification)
|
|
||||||
.SetMethod("subscribeNotification",
|
.SetMethod("subscribeNotification",
|
||||||
&SystemPreferences::SubscribeNotification)
|
&SystemPreferences::SubscribeNotification)
|
||||||
.SetMethod("unsubscribeNotification",
|
.SetMethod("unsubscribeNotification",
|
||||||
|
@ -91,8 +91,10 @@ namespace {
|
||||||
|
|
||||||
using atom::api::SystemPreferences;
|
using atom::api::SystemPreferences;
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
dict.Set("systemPreferences", SystemPreferences::Create(isolate));
|
dict.Set("systemPreferences", SystemPreferences::Create(isolate));
|
||||||
|
|
|
@ -36,8 +36,9 @@ enum NotificationCenterKind {
|
||||||
|
|
||||||
class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
, public BrowserObserver
|
,
|
||||||
, public gfx::SysColorChangeListener
|
public BrowserObserver,
|
||||||
|
public gfx::SysColorChangeListener
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -66,8 +67,8 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||||
void OnFinishLaunching(const base::DictionaryValue& launch_info) override;
|
void OnFinishLaunching(const base::DictionaryValue& launch_info) override;
|
||||||
|
|
||||||
#elif defined(OS_MACOSX)
|
#elif defined(OS_MACOSX)
|
||||||
using NotificationCallback = base::Callback<
|
using NotificationCallback =
|
||||||
void(const std::string&, const base::DictionaryValue&)>;
|
base::Callback<void(const std::string&, const base::DictionaryValue&)>;
|
||||||
|
|
||||||
void PostNotification(const std::string& name,
|
void PostNotification(const std::string& name,
|
||||||
const base::DictionaryValue& user_info);
|
const base::DictionaryValue& user_info);
|
||||||
|
@ -113,11 +114,15 @@ class SystemPreferences : public mate::EventEmitter<SystemPreferences>
|
||||||
private:
|
private:
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
// Static callback invoked when a message comes in to our messaging window.
|
// Static callback invoked when a message comes in to our messaging window.
|
||||||
static LRESULT CALLBACK
|
static LRESULT CALLBACK WndProcStatic(HWND hwnd,
|
||||||
WndProcStatic(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
|
UINT message,
|
||||||
|
WPARAM wparam,
|
||||||
|
LPARAM lparam);
|
||||||
|
|
||||||
LRESULT CALLBACK
|
LRESULT CALLBACK WndProc(HWND hwnd,
|
||||||
WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
|
UINT message,
|
||||||
|
WPARAM wparam,
|
||||||
|
LPARAM lparam);
|
||||||
|
|
||||||
// The window class of |window_|.
|
// The window class of |window_|.
|
||||||
ATOM atom_;
|
ATOM atom_;
|
||||||
|
|
|
@ -130,9 +130,8 @@ void SystemPreferences::InitializeWindow() {
|
||||||
WNDCLASSEX window_class;
|
WNDCLASSEX window_class;
|
||||||
base::win::InitializeWindowClass(
|
base::win::InitializeWindowClass(
|
||||||
kSystemPreferencesWindowClass,
|
kSystemPreferencesWindowClass,
|
||||||
&base::win::WrappedWindowProc<SystemPreferences::WndProcStatic>,
|
&base::win::WrappedWindowProc<SystemPreferences::WndProcStatic>, 0, 0, 0,
|
||||||
0, 0, 0, NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL, &window_class);
|
||||||
&window_class);
|
|
||||||
instance_ = window_class.hInstance;
|
instance_ = window_class.hInstance;
|
||||||
atom_ = RegisterClassEx(&window_class);
|
atom_ = RegisterClassEx(&window_class);
|
||||||
|
|
||||||
|
@ -140,8 +139,8 @@ void SystemPreferences::InitializeWindow() {
|
||||||
// colorization color. Create a hidden WS_POPUP window instead of an
|
// colorization color. Create a hidden WS_POPUP window instead of an
|
||||||
// HWND_MESSAGE window, because only top-level windows such as popups can
|
// HWND_MESSAGE window, because only top-level windows such as popups can
|
||||||
// receive broadcast messages like "WM_DWMCOLORIZATIONCOLORCHANGED".
|
// receive broadcast messages like "WM_DWMCOLORIZATIONCOLORCHANGED".
|
||||||
window_ = CreateWindow(MAKEINTATOM(atom_),
|
window_ = CreateWindow(MAKEINTATOM(atom_), 0, WS_POPUP, 0, 0, 0, 0, 0, 0,
|
||||||
0, WS_POPUP, 0, 0, 0, 0, 0, 0, instance_, 0);
|
instance_, 0);
|
||||||
gfx::CheckWindowCreated(window_);
|
gfx::CheckWindowCreated(window_);
|
||||||
gfx::SetWindowUserData(window_, this);
|
gfx::SetWindowUserData(window_, this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,8 @@ namespace mate {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Converter<atom::TaskbarHost::ThumbarButton> {
|
struct Converter<atom::TaskbarHost::ThumbarButton> {
|
||||||
static bool FromV8(v8::Isolate* isolate, v8::Handle<v8::Value> val,
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
|
v8::Handle<v8::Value> val,
|
||||||
atom::TaskbarHost::ThumbarButton* out) {
|
atom::TaskbarHost::ThumbarButton* out) {
|
||||||
mate::Dictionary dict;
|
mate::Dictionary dict;
|
||||||
if (!ConvertFromV8(isolate, val, &dict))
|
if (!ConvertFromV8(isolate, val, &dict))
|
||||||
|
@ -82,16 +83,14 @@ TopLevelWindow::TopLevelWindow(v8::Isolate* isolate,
|
||||||
mate::Dictionary web_preferences;
|
mate::Dictionary web_preferences;
|
||||||
bool offscreen;
|
bool offscreen;
|
||||||
if (options.Get(options::kWebPreferences, &web_preferences) &&
|
if (options.Get(options::kWebPreferences, &web_preferences) &&
|
||||||
web_preferences.Get("offscreen", &offscreen) &&
|
web_preferences.Get("offscreen", &offscreen) && offscreen) {
|
||||||
offscreen) {
|
|
||||||
const_cast<mate::Dictionary&>(options).Set(options::kFrame, false);
|
const_cast<mate::Dictionary&>(options).Set(options::kFrame, false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Creates NativeWindow.
|
// Creates NativeWindow.
|
||||||
window_.reset(NativeWindow::Create(
|
window_.reset(NativeWindow::Create(
|
||||||
options,
|
options, parent.IsEmpty() ? nullptr : parent->window_.get()));
|
||||||
parent.IsEmpty() ? nullptr : parent->window_.get()));
|
|
||||||
window_->AddObserver(this);
|
window_->AddObserver(this);
|
||||||
|
|
||||||
#if defined(TOOLKIT_VIEWS)
|
#if defined(TOOLKIT_VIEWS)
|
||||||
|
@ -227,7 +226,8 @@ void TopLevelWindow::OnExecuteWindowsCommand(const std::string& command_name) {
|
||||||
Emit("app-command", command_name);
|
Emit("app-command", command_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TopLevelWindow::OnTouchBarItemResult(const std::string& item_id,
|
void TopLevelWindow::OnTouchBarItemResult(
|
||||||
|
const std::string& item_id,
|
||||||
const base::DictionaryValue& details) {
|
const base::DictionaryValue& details) {
|
||||||
Emit("-touch-bar-interaction", item_id, details);
|
Emit("-touch-bar-interaction", item_id, details);
|
||||||
}
|
}
|
||||||
|
@ -358,7 +358,8 @@ std::vector<int> TopLevelWindow::GetSize() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TopLevelWindow::SetContentSize(int width, int height,
|
void TopLevelWindow::SetContentSize(int width,
|
||||||
|
int height,
|
||||||
mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
bool animate = false;
|
bool animate = false;
|
||||||
args->GetNext(&animate);
|
args->GetNext(&animate);
|
||||||
|
@ -580,16 +581,15 @@ void TopLevelWindow::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) {
|
||||||
mate::Handle<Menu> menu;
|
mate::Handle<Menu> menu;
|
||||||
if (value->IsObject() &&
|
if (value->IsObject() &&
|
||||||
mate::V8ToString(value->ToObject()->GetConstructorName()) == "Menu" &&
|
mate::V8ToString(value->ToObject()->GetConstructorName()) == "Menu" &&
|
||||||
mate::ConvertFromV8(isolate, value, &menu) &&
|
mate::ConvertFromV8(isolate, value, &menu) && !menu.IsEmpty()) {
|
||||||
!menu.IsEmpty()) {
|
|
||||||
menu_.Reset(isolate, menu.ToV8());
|
menu_.Reset(isolate, menu.ToV8());
|
||||||
window_->SetMenu(menu->model());
|
window_->SetMenu(menu->model());
|
||||||
} else if (value->IsNull()) {
|
} else if (value->IsNull()) {
|
||||||
menu_.Reset();
|
menu_.Reset();
|
||||||
window_->SetMenu(nullptr);
|
window_->SetMenu(nullptr);
|
||||||
} else {
|
} else {
|
||||||
isolate->ThrowException(v8::Exception::TypeError(
|
isolate->ThrowException(
|
||||||
mate::StringToV8(isolate, "Invalid Menu")));
|
v8::Exception::TypeError(mate::StringToV8(isolate, "Invalid Menu")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -789,12 +789,12 @@ bool TopLevelWindow::SetThumbarButtons(mate::Arguments* args) {
|
||||||
#if defined(TOOLKIT_VIEWS)
|
#if defined(TOOLKIT_VIEWS)
|
||||||
void TopLevelWindow::SetIcon(mate::Handle<NativeImage> icon) {
|
void TopLevelWindow::SetIcon(mate::Handle<NativeImage> icon) {
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
static_cast<NativeWindowViews*>(window_.get())->SetIcon(
|
static_cast<NativeWindowViews*>(window_.get())
|
||||||
icon->GetHICON(GetSystemMetrics(SM_CXSMICON)),
|
->SetIcon(icon->GetHICON(GetSystemMetrics(SM_CXSMICON)),
|
||||||
icon->GetHICON(GetSystemMetrics(SM_CXICON)));
|
icon->GetHICON(GetSystemMetrics(SM_CXICON)));
|
||||||
#elif defined(USE_X11)
|
#elif defined(USE_X11)
|
||||||
static_cast<NativeWindowViews*>(window_.get())->SetIcon(
|
static_cast<NativeWindowViews*>(window_.get())
|
||||||
icon->image().AsImageSkia());
|
->SetIcon(icon->image().AsImageSkia());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -846,8 +846,7 @@ void TopLevelWindow::SetAppDetails(const mate::Dictionary& options) {
|
||||||
options.Get("relaunchCommand", &relaunch_command);
|
options.Get("relaunchCommand", &relaunch_command);
|
||||||
options.Get("relaunchDisplayName", &relaunch_display_name);
|
options.Get("relaunchDisplayName", &relaunch_display_name);
|
||||||
|
|
||||||
ui::win::SetAppDetailsForWindow(
|
ui::win::SetAppDetailsForWindow(app_id, app_icon_path, app_icon_index,
|
||||||
app_id, app_icon_path, app_icon_index,
|
|
||||||
relaunch_command, relaunch_display_name,
|
relaunch_command, relaunch_display_name,
|
||||||
window_->GetAcceleratedWidget());
|
window_->GetAcceleratedWidget());
|
||||||
}
|
}
|
||||||
|
@ -1036,8 +1035,10 @@ namespace {
|
||||||
|
|
||||||
using atom::api::TopLevelWindow;
|
using atom::api::TopLevelWindow;
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
TopLevelWindow::SetConstructor(isolate, base::Bind(&TopLevelWindow::New));
|
TopLevelWindow::SetConstructor(isolate, base::Bind(&TopLevelWindow::New));
|
||||||
|
|
||||||
|
|
|
@ -184,8 +184,8 @@ class TopLevelWindow : public mate::TrackableObject<TopLevelWindow>,
|
||||||
void SetIcon(mate::Handle<NativeImage> icon);
|
void SetIcon(mate::Handle<NativeImage> icon);
|
||||||
#endif
|
#endif
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
typedef base::Callback<void(v8::Local<v8::Value>,
|
typedef base::Callback<void(v8::Local<v8::Value>, v8::Local<v8::Value>)>
|
||||||
v8::Local<v8::Value>)> MessageCallback;
|
MessageCallback;
|
||||||
bool HookWindowMessage(UINT message, const MessageCallback& callback);
|
bool HookWindowMessage(UINT message, const MessageCallback& callback);
|
||||||
bool IsWindowMessageHooked(UINT message);
|
bool IsWindowMessageHooked(UINT message);
|
||||||
void UnhookWindowMessage(UINT message);
|
void UnhookWindowMessage(UINT message);
|
||||||
|
|
|
@ -22,7 +22,8 @@ namespace mate {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Converter<atom::TrayIcon::HighlightMode> {
|
struct Converter<atom::TrayIcon::HighlightMode> {
|
||||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Value> val,
|
||||||
atom::TrayIcon::HighlightMode* out) {
|
atom::TrayIcon::HighlightMode* out) {
|
||||||
std::string mode;
|
std::string mode;
|
||||||
if (ConvertFromV8(isolate, val, &mode)) {
|
if (ConvertFromV8(isolate, val, &mode)) {
|
||||||
|
@ -54,12 +55,12 @@ struct Converter<atom::TrayIcon::HighlightMode> {
|
||||||
};
|
};
|
||||||
} // namespace mate
|
} // namespace mate
|
||||||
|
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace api {
|
namespace api {
|
||||||
|
|
||||||
Tray::Tray(v8::Isolate* isolate, v8::Local<v8::Object> wrapper,
|
Tray::Tray(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Object> wrapper,
|
||||||
mate::Handle<NativeImage> image)
|
mate::Handle<NativeImage> image)
|
||||||
: tray_icon_(TrayIcon::Create()) {
|
: tray_icon_(TrayIcon::Create()) {
|
||||||
SetImage(isolate, image);
|
SetImage(isolate, image);
|
||||||
|
@ -70,8 +71,8 @@ Tray::Tray(v8::Isolate* isolate, v8::Local<v8::Object> wrapper,
|
||||||
|
|
||||||
Tray::~Tray() {
|
Tray::~Tray() {
|
||||||
// Destroy the native tray in next tick.
|
// Destroy the native tray in next tick.
|
||||||
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(
|
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE,
|
||||||
FROM_HERE, tray_icon_.release());
|
tray_icon_.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
@ -180,8 +181,7 @@ void Tray::DisplayBalloon(mate::Arguments* args,
|
||||||
mate::Handle<NativeImage> icon;
|
mate::Handle<NativeImage> icon;
|
||||||
options.Get("icon", &icon);
|
options.Get("icon", &icon);
|
||||||
base::string16 title, content;
|
base::string16 title, content;
|
||||||
if (!options.Get("title", &title) ||
|
if (!options.Get("title", &title) || !options.Get("content", &content)) {
|
||||||
!options.Get("content", &content)) {
|
|
||||||
args->ThrowError("'title' and 'content' must be defined");
|
args->ThrowError("'title' and 'content' must be defined");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -191,8 +191,8 @@ void Tray::DisplayBalloon(mate::Arguments* args,
|
||||||
icon.IsEmpty() ? NULL : icon->GetHICON(GetSystemMetrics(SM_CXSMICON)),
|
icon.IsEmpty() ? NULL : icon->GetHICON(GetSystemMetrics(SM_CXSMICON)),
|
||||||
title, content);
|
title, content);
|
||||||
#else
|
#else
|
||||||
tray_icon_->DisplayBalloon(
|
tray_icon_->DisplayBalloon(icon.IsEmpty() ? gfx::Image() : icon->image(),
|
||||||
icon.IsEmpty() ? gfx::Image() : icon->image(), title, content);
|
title, content);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,13 +234,14 @@ void Tray::BuildPrototype(v8::Isolate* isolate,
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using atom::api::Tray;
|
using atom::api::Tray;
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
Tray::SetConstructor(isolate, base::Bind(&Tray::New));
|
Tray::SetConstructor(isolate, base::Bind(&Tray::New));
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Image;
|
||||||
namespace mate {
|
namespace mate {
|
||||||
class Arguments;
|
class Arguments;
|
||||||
class Dictionary;
|
class Dictionary;
|
||||||
}
|
} // namespace mate
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
@ -32,8 +32,7 @@ namespace api {
|
||||||
class Menu;
|
class Menu;
|
||||||
class NativeImage;
|
class NativeImage;
|
||||||
|
|
||||||
class Tray : public mate::TrackableObject<Tray>,
|
class Tray : public mate::TrackableObject<Tray>, public TrayIconObserver {
|
||||||
public TrayIconObserver {
|
|
||||||
public:
|
public:
|
||||||
static mate::WrappableBase* New(mate::Handle<NativeImage> image,
|
static mate::WrappableBase* New(mate::Handle<NativeImage> image,
|
||||||
mate::Arguments* args);
|
mate::Arguments* args);
|
||||||
|
@ -42,7 +41,8 @@ class Tray : public mate::TrackableObject<Tray>,
|
||||||
v8::Local<v8::FunctionTemplate> prototype);
|
v8::Local<v8::FunctionTemplate> prototype);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Tray(v8::Isolate* isolate, v8::Local<v8::Object> wrapper,
|
Tray(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Object> wrapper,
|
||||||
mate::Handle<NativeImage> image);
|
mate::Handle<NativeImage> image);
|
||||||
~Tray() override;
|
~Tray() override;
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,8 @@ struct Converter<atom::SetSizeParams> {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Converter<PrintSettings> {
|
struct Converter<PrintSettings> {
|
||||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Value> val,
|
||||||
PrintSettings* out) {
|
PrintSettings* out) {
|
||||||
mate::Dictionary dict;
|
mate::Dictionary dict;
|
||||||
if (!ConvertFromV8(isolate, val, &dict))
|
if (!ConvertFromV8(isolate, val, &dict))
|
||||||
|
@ -189,7 +190,8 @@ struct Converter<WindowOpenDisposition> {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Converter<content::SavePageType> {
|
struct Converter<content::SavePageType> {
|
||||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Value> val,
|
||||||
content::SavePageType* out) {
|
content::SavePageType* out) {
|
||||||
std::string save_type;
|
std::string save_type;
|
||||||
if (!ConvertFromV8(isolate, val, &save_type))
|
if (!ConvertFromV8(isolate, val, &save_type))
|
||||||
|
@ -215,18 +217,32 @@ struct Converter<atom::api::WebContents::Type> {
|
||||||
using Type = atom::api::WebContents::Type;
|
using Type = atom::api::WebContents::Type;
|
||||||
std::string type = "";
|
std::string type = "";
|
||||||
switch (val) {
|
switch (val) {
|
||||||
case Type::BACKGROUND_PAGE: type = "backgroundPage"; break;
|
case Type::BACKGROUND_PAGE:
|
||||||
case Type::BROWSER_WINDOW: type = "window"; break;
|
type = "backgroundPage";
|
||||||
case Type::BROWSER_VIEW: type = "browserView"; break;
|
break;
|
||||||
case Type::REMOTE: type = "remote"; break;
|
case Type::BROWSER_WINDOW:
|
||||||
case Type::WEB_VIEW: type = "webview"; break;
|
type = "window";
|
||||||
case Type::OFF_SCREEN: type = "offscreen"; break;
|
break;
|
||||||
default: break;
|
case Type::BROWSER_VIEW:
|
||||||
|
type = "browserView";
|
||||||
|
break;
|
||||||
|
case Type::REMOTE:
|
||||||
|
type = "remote";
|
||||||
|
break;
|
||||||
|
case Type::WEB_VIEW:
|
||||||
|
type = "webview";
|
||||||
|
break;
|
||||||
|
case Type::OFF_SCREEN:
|
||||||
|
type = "offscreen";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return mate::ConvertToV8(isolate, type);
|
return mate::ConvertToV8(isolate, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Value> val,
|
||||||
atom::api::WebContents::Type* out) {
|
atom::api::WebContents::Type* out) {
|
||||||
using Type = atom::api::WebContents::Type;
|
using Type = atom::api::WebContents::Type;
|
||||||
std::string type;
|
std::string type;
|
||||||
|
@ -251,7 +267,6 @@ struct Converter<atom::api::WebContents::Type> {
|
||||||
|
|
||||||
} // namespace mate
|
} // namespace mate
|
||||||
|
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace api {
|
namespace api {
|
||||||
|
@ -377,17 +392,17 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
|
||||||
content::WebContents* web_contents;
|
content::WebContents* web_contents;
|
||||||
if (IsGuest()) {
|
if (IsGuest()) {
|
||||||
scoped_refptr<content::SiteInstance> site_instance =
|
scoped_refptr<content::SiteInstance> site_instance =
|
||||||
content::SiteInstance::CreateForURL(
|
content::SiteInstance::CreateForURL(session->browser_context(),
|
||||||
session->browser_context(), GURL("chrome-guest://fake-host"));
|
GURL("chrome-guest://fake-host"));
|
||||||
content::WebContents::CreateParams params(
|
content::WebContents::CreateParams params(session->browser_context(),
|
||||||
session->browser_context(), site_instance);
|
site_instance);
|
||||||
guest_delegate_.reset(new WebViewGuestDelegate);
|
guest_delegate_.reset(new WebViewGuestDelegate);
|
||||||
params.guest_delegate = guest_delegate_.get();
|
params.guest_delegate = guest_delegate_.get();
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
#if defined(ENABLE_OSR)
|
||||||
if (embedder_ && embedder_->IsOffScreen()) {
|
if (embedder_ && embedder_->IsOffScreen()) {
|
||||||
auto* view = new OffScreenWebContentsView(false,
|
auto* view = new OffScreenWebContentsView(
|
||||||
base::Bind(&WebContents::OnPaint, base::Unretained(this)));
|
false, base::Bind(&WebContents::OnPaint, base::Unretained(this)));
|
||||||
params.view = view;
|
params.view = view;
|
||||||
params.delegate_view = view;
|
params.delegate_view = view;
|
||||||
|
|
||||||
|
@ -403,8 +418,8 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
|
||||||
options.Get("transparent", &transparent);
|
options.Get("transparent", &transparent);
|
||||||
|
|
||||||
content::WebContents::CreateParams params(session->browser_context());
|
content::WebContents::CreateParams params(session->browser_context());
|
||||||
auto* view = new OffScreenWebContentsView(transparent,
|
auto* view = new OffScreenWebContentsView(
|
||||||
base::Bind(&WebContents::OnPaint, base::Unretained(this)));
|
transparent, base::Bind(&WebContents::OnPaint, base::Unretained(this)));
|
||||||
params.view = view;
|
params.view = view;
|
||||||
params.delegate_view = view;
|
params.delegate_view = view;
|
||||||
|
|
||||||
|
@ -442,7 +457,8 @@ void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
|
||||||
|
|
||||||
#if defined(OS_LINUX) || defined(OS_WIN)
|
#if defined(OS_LINUX) || defined(OS_WIN)
|
||||||
// Update font settings.
|
// Update font settings.
|
||||||
CR_DEFINE_STATIC_LOCAL(const gfx::FontRenderParams, params,
|
CR_DEFINE_STATIC_LOCAL(
|
||||||
|
const gfx::FontRenderParams, params,
|
||||||
(gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr)));
|
(gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr)));
|
||||||
prefs->should_antialias_text = params.antialiasing;
|
prefs->should_antialias_text = params.antialiasing;
|
||||||
prefs->use_subpixel_positioning = params.subpixel_positioning;
|
prefs->use_subpixel_positioning = params.subpixel_positioning;
|
||||||
|
@ -541,8 +557,7 @@ void WebContents::OnCreateWindow(
|
||||||
Emit("new-window", target_url, frame_name, disposition, features);
|
Emit("new-window", target_url, frame_name, disposition, features);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::WebContentsCreated(
|
void WebContents::WebContentsCreated(content::WebContents* source_contents,
|
||||||
content::WebContents* source_contents,
|
|
||||||
int opener_render_process_id,
|
int opener_render_process_id,
|
||||||
int opener_render_frame_id,
|
int opener_render_frame_id,
|
||||||
const std::string& frame_name,
|
const std::string& frame_name,
|
||||||
|
@ -660,8 +675,7 @@ content::KeyboardEventProcessingResult WebContents::PreHandleKeyboardEvent(
|
||||||
|
|
||||||
void WebContents::EnterFullscreenModeForTab(content::WebContents* source,
|
void WebContents::EnterFullscreenModeForTab(content::WebContents* source,
|
||||||
const GURL& origin) {
|
const GURL& origin) {
|
||||||
auto permission_helper =
|
auto permission_helper = WebContentsPermissionHelper::FromWebContents(source);
|
||||||
WebContentsPermissionHelper::FromWebContents(source);
|
|
||||||
auto callback = base::Bind(&WebContents::OnEnterFullscreenModeForTab,
|
auto callback = base::Bind(&WebContents::OnEnterFullscreenModeForTab,
|
||||||
base::Unretained(this), source, origin);
|
base::Unretained(this), source, origin);
|
||||||
permission_helper->RequestFullscreenPermission(callback);
|
permission_helper->RequestFullscreenPermission(callback);
|
||||||
|
@ -695,8 +709,7 @@ void WebContents::RendererResponsive(content::WebContents* source) {
|
||||||
|
|
||||||
bool WebContents::HandleContextMenu(const content::ContextMenuParams& params) {
|
bool WebContents::HandleContextMenu(const content::ContextMenuParams& params) {
|
||||||
if (params.custom_context.is_pepper_menu) {
|
if (params.custom_context.is_pepper_menu) {
|
||||||
Emit("pepper-context-menu",
|
Emit("pepper-context-menu", std::make_pair(params, web_contents()),
|
||||||
std::make_pair(params, web_contents()),
|
|
||||||
base::Bind(&content::WebContents::NotifyContextMenuClosed,
|
base::Bind(&content::WebContents::NotifyContextMenuClosed,
|
||||||
base::Unretained(web_contents()), params.custom_context));
|
base::Unretained(web_contents()), params.custom_context));
|
||||||
} else {
|
} else {
|
||||||
|
@ -731,8 +744,7 @@ void WebContents::FindReply(content::WebContents* web_contents,
|
||||||
Emit("found-in-page", result);
|
Emit("found-in-page", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebContents::CheckMediaAccessPermission(
|
bool WebContents::CheckMediaAccessPermission(content::WebContents* web_contents,
|
||||||
content::WebContents* web_contents,
|
|
||||||
const GURL& security_origin,
|
const GURL& security_origin,
|
||||||
content::MediaStreamType type) {
|
content::MediaStreamType type) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -747,8 +759,7 @@ void WebContents::RequestMediaAccessPermission(
|
||||||
permission_helper->RequestMediaAccessPermission(request, callback);
|
permission_helper->RequestMediaAccessPermission(request, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::RequestToLockMouse(
|
void WebContents::RequestToLockMouse(content::WebContents* web_contents,
|
||||||
content::WebContents* web_contents,
|
|
||||||
bool user_gesture,
|
bool user_gesture,
|
||||||
bool last_unlocked_by_target) {
|
bool last_unlocked_by_target) {
|
||||||
auto permission_helper =
|
auto permission_helper =
|
||||||
|
@ -764,8 +775,7 @@ std::unique_ptr<content::BluetoothChooser> WebContents::RunBluetoothChooser(
|
||||||
return std::move(bluetooth_chooser);
|
return std::move(bluetooth_chooser);
|
||||||
}
|
}
|
||||||
|
|
||||||
content::JavaScriptDialogManager*
|
content::JavaScriptDialogManager* WebContents::GetJavaScriptDialogManager(
|
||||||
WebContents::GetJavaScriptDialogManager(
|
|
||||||
content::WebContents* source) {
|
content::WebContents* source) {
|
||||||
if (!dialog_manager_)
|
if (!dialog_manager_)
|
||||||
dialog_manager_.reset(new AtomJavaScriptDialogManager(this));
|
dialog_manager_.reset(new AtomJavaScriptDialogManager(this));
|
||||||
|
@ -861,26 +871,17 @@ void WebContents::DidGetResourceResponseStart(
|
||||||
(details.resource_type == content::RESOURCE_TYPE_MAIN_FRAME ||
|
(details.resource_type == content::RESOURCE_TYPE_MAIN_FRAME ||
|
||||||
details.resource_type == content::RESOURCE_TYPE_SUB_FRAME))
|
details.resource_type == content::RESOURCE_TYPE_SUB_FRAME))
|
||||||
return;
|
return;
|
||||||
Emit("did-get-response-details",
|
Emit("did-get-response-details", details.socket_address.IsEmpty(),
|
||||||
details.socket_address.IsEmpty(),
|
details.url, details.original_url, details.http_response_code,
|
||||||
details.url,
|
details.method, details.referrer, details.headers.get(),
|
||||||
details.original_url,
|
|
||||||
details.http_response_code,
|
|
||||||
details.method,
|
|
||||||
details.referrer,
|
|
||||||
details.headers.get(),
|
|
||||||
ResourceTypeToString(details.resource_type));
|
ResourceTypeToString(details.resource_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::DidGetRedirectForResourceRequest(
|
void WebContents::DidGetRedirectForResourceRequest(
|
||||||
const content::ResourceRedirectDetails& details) {
|
const content::ResourceRedirectDetails& details) {
|
||||||
Emit("did-get-redirect-request",
|
Emit("did-get-redirect-request", details.url, details.new_url,
|
||||||
details.url,
|
|
||||||
details.new_url,
|
|
||||||
(details.resource_type == content::RESOURCE_TYPE_MAIN_FRAME),
|
(details.resource_type == content::RESOURCE_TYPE_MAIN_FRAME),
|
||||||
details.http_response_code,
|
details.http_response_code, details.method, details.referrer,
|
||||||
details.method,
|
|
||||||
details.referrer,
|
|
||||||
details.headers.get());
|
details.headers.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -953,8 +954,8 @@ void WebContents::DevToolsOpened() {
|
||||||
|
|
||||||
// Set inspected tabID.
|
// Set inspected tabID.
|
||||||
base::Value tab_id(ID());
|
base::Value tab_id(ID());
|
||||||
managed_web_contents()->CallClientFunction(
|
managed_web_contents()->CallClientFunction("DevToolsAPI.setInspectedTabId",
|
||||||
"DevToolsAPI.setInspectedTabId", &tab_id, nullptr, nullptr);
|
&tab_id, nullptr, nullptr);
|
||||||
|
|
||||||
// Inherit owner window in devtools when it doesn't have one.
|
// Inherit owner window in devtools when it doesn't have one.
|
||||||
auto* devtools = managed_web_contents()->GetDevToolsWebContents();
|
auto* devtools = managed_web_contents()->GetDevToolsWebContents();
|
||||||
|
@ -979,8 +980,8 @@ void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host,
|
||||||
const std::vector<base::string16>& values,
|
const std::vector<base::string16>& values,
|
||||||
const std::vector<base::string16>& labels) {
|
const std::vector<base::string16>& labels) {
|
||||||
bool offscreen = IsOffScreen() || (embedder_ && embedder_->IsOffScreen());
|
bool offscreen = IsOffScreen() || (embedder_ && embedder_->IsOffScreen());
|
||||||
CommonWebContentsDelegate::ShowAutofillPopup(
|
CommonWebContentsDelegate::ShowAutofillPopup(offscreen, frame_host, bounds,
|
||||||
offscreen, frame_host, bounds, values, labels);
|
values, labels);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1041,8 +1042,7 @@ void WebContents::WebContentsDestroyed() {
|
||||||
Emit("destroyed");
|
Emit("destroyed");
|
||||||
|
|
||||||
// Destroy the native class in next tick.
|
// Destroy the native class in next tick.
|
||||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, GetDestroyClosure());
|
||||||
FROM_HERE, GetDestroyClosure());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::NavigationEntryCommitted(
|
void WebContents::NavigationEntryCommitted(
|
||||||
|
@ -1082,11 +1082,9 @@ bool WebContents::Equal(const WebContents* web_contents) const {
|
||||||
|
|
||||||
void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
|
void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
|
||||||
if (!url.is_valid() || url.spec().size() > url::kMaxURLChars) {
|
if (!url.is_valid() || url.spec().size() > url::kMaxURLChars) {
|
||||||
Emit("did-fail-load",
|
Emit("did-fail-load", static_cast<int>(net::ERR_INVALID_URL),
|
||||||
static_cast<int>(net::ERR_INVALID_URL),
|
|
||||||
net::ErrorToShortString(net::ERR_INVALID_URL),
|
net::ErrorToShortString(net::ERR_INVALID_URL),
|
||||||
url.possibly_invalid_spec(),
|
url.possibly_invalid_spec(), true);
|
||||||
true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1194,8 +1192,7 @@ void WebContents::GoToOffset(int offset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string WebContents::GetWebRTCIPHandlingPolicy() const {
|
const std::string WebContents::GetWebRTCIPHandlingPolicy() const {
|
||||||
return web_contents()->
|
return web_contents()->GetMutableRendererPrefs()->webrtc_ip_handling_policy;
|
||||||
GetMutableRendererPrefs()->webrtc_ip_handling_policy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::SetWebRTCIPHandlingPolicy(
|
void WebContents::SetWebRTCIPHandlingPolicy(
|
||||||
|
@ -1345,8 +1342,7 @@ void WebContents::InspectServiceWorker() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::HasServiceWorker(
|
void WebContents::HasServiceWorker(const base::Callback<void(bool)>& callback) {
|
||||||
const base::Callback<void(bool)>& callback) {
|
|
||||||
auto context = GetServiceWorkerContext(web_contents());
|
auto context = GetServiceWorkerContext(web_contents());
|
||||||
if (!context)
|
if (!context)
|
||||||
return;
|
return;
|
||||||
|
@ -1407,10 +1403,9 @@ void WebContents::Print(mate::Arguments* args) {
|
||||||
}
|
}
|
||||||
print_view_manager_basic_ptr->SetCallback(callback);
|
print_view_manager_basic_ptr->SetCallback(callback);
|
||||||
}
|
}
|
||||||
print_view_manager_basic_ptr->PrintNow(web_contents()->GetMainFrame(),
|
print_view_manager_basic_ptr->PrintNow(
|
||||||
settings.silent,
|
web_contents()->GetMainFrame(), settings.silent,
|
||||||
settings.print_background,
|
settings.print_background, settings.device_name);
|
||||||
settings.device_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<printing::PrinterBasicInfo> WebContents::GetPrinterList() {
|
std::vector<printing::PrinterBasicInfo> WebContents::GetPrinterList() {
|
||||||
|
@ -1423,8 +1418,8 @@ std::vector<printing::PrinterBasicInfo> WebContents::GetPrinterList() {
|
||||||
|
|
||||||
void WebContents::PrintToPDF(const base::DictionaryValue& setting,
|
void WebContents::PrintToPDF(const base::DictionaryValue& setting,
|
||||||
const PrintToPDFCallback& callback) {
|
const PrintToPDFCallback& callback) {
|
||||||
printing::PrintPreviewMessageHandler::FromWebContents(web_contents())->
|
printing::PrintPreviewMessageHandler::FromWebContents(web_contents())
|
||||||
PrintToPDF(setting, callback);
|
->PrintToPDF(setting, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::AddWorkSpace(mate::Arguments* args,
|
void WebContents::AddWorkSpace(mate::Arguments* args,
|
||||||
|
@ -1529,7 +1524,8 @@ void WebContents::Focus() {
|
||||||
#if !defined(OS_MACOSX)
|
#if !defined(OS_MACOSX)
|
||||||
bool WebContents::IsFocused() const {
|
bool WebContents::IsFocused() const {
|
||||||
auto view = web_contents()->GetRenderWidgetHostView();
|
auto view = web_contents()->GetRenderWidgetHostView();
|
||||||
if (!view) return false;
|
if (!view)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (GetType() != BACKGROUND_PAGE) {
|
if (GetType() != BACKGROUND_PAGE) {
|
||||||
auto window = web_contents()->GetNativeView()->GetToplevelWindow();
|
auto window = web_contents()->GetNativeView()->GetToplevelWindow();
|
||||||
|
@ -1563,8 +1559,8 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
|
||||||
if (!view)
|
if (!view)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
blink::WebInputEvent::Type type = mate::GetWebInputEventType(isolate,
|
blink::WebInputEvent::Type type =
|
||||||
input_event);
|
mate::GetWebInputEventType(isolate, input_event);
|
||||||
if (blink::WebInputEvent::IsMouseEventType(type)) {
|
if (blink::WebInputEvent::IsMouseEventType(type)) {
|
||||||
blink::WebMouseEvent mouse_event;
|
blink::WebMouseEvent mouse_event;
|
||||||
if (mate::ConvertFromV8(isolate, input_event, &mouse_event)) {
|
if (mate::ConvertFromV8(isolate, input_event, &mouse_event)) {
|
||||||
|
@ -1574,8 +1570,7 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
|
||||||
} else if (blink::WebInputEvent::IsKeyboardEventType(type)) {
|
} else if (blink::WebInputEvent::IsKeyboardEventType(type)) {
|
||||||
content::NativeWebKeyboardEvent keyboard_event(
|
content::NativeWebKeyboardEvent keyboard_event(
|
||||||
blink::WebKeyboardEvent::kRawKeyDown,
|
blink::WebKeyboardEvent::kRawKeyDown,
|
||||||
blink::WebInputEvent::kNoModifiers,
|
blink::WebInputEvent::kNoModifiers, ui::EventTimeForNow());
|
||||||
ui::EventTimeForNow());
|
|
||||||
if (mate::ConvertFromV8(isolate, input_event, &keyboard_event)) {
|
if (mate::ConvertFromV8(isolate, input_event, &keyboard_event)) {
|
||||||
view->ProcessKeyboardEvent(keyboard_event, ui::LatencyInfo());
|
view->ProcessKeyboardEvent(keyboard_event, ui::LatencyInfo());
|
||||||
return;
|
return;
|
||||||
|
@ -1588,8 +1583,8 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
|
isolate->ThrowException(
|
||||||
isolate, "Invalid event object")));
|
v8::Exception::Error(mate::StringToV8(isolate, "Invalid event object")));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebContents::BeginFrameSubscription(mate::Arguments* args) {
|
void WebContents::BeginFrameSubscription(mate::Arguments* args) {
|
||||||
|
@ -1604,8 +1599,8 @@ void WebContents::BeginFrameSubscription(mate::Arguments* args) {
|
||||||
|
|
||||||
const auto view = web_contents()->GetRenderWidgetHostView();
|
const auto view = web_contents()->GetRenderWidgetHostView();
|
||||||
if (view) {
|
if (view) {
|
||||||
std::unique_ptr<FrameSubscriber> frame_subscriber(new FrameSubscriber(
|
std::unique_ptr<FrameSubscriber> frame_subscriber(
|
||||||
isolate(), view, callback, only_dirty));
|
new FrameSubscriber(isolate(), view, callback, only_dirty));
|
||||||
view->BeginFrameSubscription(std::move(frame_subscriber));
|
view->BeginFrameSubscription(std::move(frame_subscriber));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1658,8 +1653,8 @@ void WebContents::CapturePage(mate::Arguments* args) {
|
||||||
base::Callback<void(const gfx::Image&)> callback;
|
base::Callback<void(const gfx::Image&)> callback;
|
||||||
|
|
||||||
if (!(args->Length() == 1 && args->GetNext(&callback)) &&
|
if (!(args->Length() == 1 && args->GetNext(&callback)) &&
|
||||||
!(args->Length() == 2 && args->GetNext(&rect)
|
!(args->Length() == 2 && args->GetNext(&rect) &&
|
||||||
&& args->GetNext(&callback))) {
|
args->GetNext(&callback))) {
|
||||||
args->ThrowError();
|
args->ThrowError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1671,22 +1666,21 @@ void WebContents::CapturePage(mate::Arguments* args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Capture full page if user doesn't specify a |rect|.
|
// Capture full page if user doesn't specify a |rect|.
|
||||||
const gfx::Size view_size = rect.IsEmpty() ? view->GetViewBounds().size() :
|
const gfx::Size view_size =
|
||||||
rect.size();
|
rect.IsEmpty() ? view->GetViewBounds().size() : rect.size();
|
||||||
|
|
||||||
// By default, the requested bitmap size is the view size in screen
|
// By default, the requested bitmap size is the view size in screen
|
||||||
// coordinates. However, if there's more pixel detail available on the
|
// coordinates. However, if there's more pixel detail available on the
|
||||||
// current system, increase the requested bitmap size to capture it all.
|
// current system, increase the requested bitmap size to capture it all.
|
||||||
gfx::Size bitmap_size = view_size;
|
gfx::Size bitmap_size = view_size;
|
||||||
const gfx::NativeView native_view = view->GetNativeView();
|
const gfx::NativeView native_view = view->GetNativeView();
|
||||||
const float scale =
|
const float scale = display::Screen::GetScreen()
|
||||||
display::Screen::GetScreen()->GetDisplayNearestView(native_view)
|
->GetDisplayNearestView(native_view)
|
||||||
.device_scale_factor();
|
.device_scale_factor();
|
||||||
if (scale > 1.0f)
|
if (scale > 1.0f)
|
||||||
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
|
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
|
||||||
|
|
||||||
view->CopyFromSurface(gfx::Rect(rect.origin(), view_size),
|
view->CopyFromSurface(gfx::Rect(rect.origin(), view_size), bitmap_size,
|
||||||
bitmap_size,
|
|
||||||
base::Bind(&OnCapturePageDone, callback),
|
base::Bind(&OnCapturePageDone, callback),
|
||||||
kBGRA_8888_SkColorType);
|
kBGRA_8888_SkColorType);
|
||||||
}
|
}
|
||||||
|
@ -1799,8 +1793,7 @@ void WebContents::Invalidate() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Size WebContents::GetSizeForNewRenderView(
|
gfx::Size WebContents::GetSizeForNewRenderView(content::WebContents* wc) const {
|
||||||
content::WebContents* wc) const {
|
|
||||||
if (IsOffScreen() && wc == web_contents()) {
|
if (IsOffScreen() && wc == web_contents()) {
|
||||||
auto relay = NativeWindowRelay::FromWebContents(web_contents());
|
auto relay = NativeWindowRelay::FromWebContents(web_contents());
|
||||||
if (relay) {
|
if (relay) {
|
||||||
|
@ -1907,8 +1900,8 @@ void WebContents::SetDevToolsWebContents(const WebContents* devtools) {
|
||||||
|
|
||||||
v8::Local<v8::Value> WebContents::GetNativeView() const {
|
v8::Local<v8::Value> WebContents::GetNativeView() const {
|
||||||
gfx::NativeView ptr = web_contents()->GetNativeView();
|
gfx::NativeView ptr = web_contents()->GetNativeView();
|
||||||
auto buffer = node::Buffer::Copy(
|
auto buffer = node::Buffer::Copy(isolate(), reinterpret_cast<char*>(&ptr),
|
||||||
isolate(), reinterpret_cast<char*>(&ptr), sizeof(gfx::NativeView));
|
sizeof(gfx::NativeView));
|
||||||
if (buffer.IsEmpty())
|
if (buffer.IsEmpty())
|
||||||
return v8::Null(isolate());
|
return v8::Null(isolate());
|
||||||
else
|
else
|
||||||
|
@ -1932,8 +1925,7 @@ v8::Local<v8::Value> WebContents::Debugger(v8::Isolate* isolate) {
|
||||||
|
|
||||||
void WebContents::GrantOriginAccess(const GURL& url) {
|
void WebContents::GrantOriginAccess(const GURL& url) {
|
||||||
content::ChildProcessSecurityPolicy::GetInstance()->GrantOrigin(
|
content::ChildProcessSecurityPolicy::GetInstance()->GrantOrigin(
|
||||||
web_contents()->GetMainFrame()->GetProcess()->GetID(),
|
web_contents()->GetMainFrame()->GetProcess()->GetID(), url::Origin(url));
|
||||||
url::Origin(url));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
@ -1969,8 +1961,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
||||||
.SetMethod("disableDeviceEmulation", &WebContents::DisableDeviceEmulation)
|
.SetMethod("disableDeviceEmulation", &WebContents::DisableDeviceEmulation)
|
||||||
.SetMethod("toggleDevTools", &WebContents::ToggleDevTools)
|
.SetMethod("toggleDevTools", &WebContents::ToggleDevTools)
|
||||||
.SetMethod("inspectElement", &WebContents::InspectElement)
|
.SetMethod("inspectElement", &WebContents::InspectElement)
|
||||||
.SetMethod("setIgnoreMenuShortcuts",
|
.SetMethod("setIgnoreMenuShortcuts", &WebContents::SetIgnoreMenuShortcuts)
|
||||||
&WebContents::SetIgnoreMenuShortcuts)
|
|
||||||
.SetMethod("setAudioMuted", &WebContents::SetAudioMuted)
|
.SetMethod("setAudioMuted", &WebContents::SetAudioMuted)
|
||||||
.SetMethod("isAudioMuted", &WebContents::IsAudioMuted)
|
.SetMethod("isAudioMuted", &WebContents::IsAudioMuted)
|
||||||
.SetMethod("undo", &WebContents::Undo)
|
.SetMethod("undo", &WebContents::Undo)
|
||||||
|
@ -2060,27 +2051,30 @@ void WebContents::OnRendererMessageSync(content::RenderFrameHost* frame_host,
|
||||||
|
|
||||||
// static
|
// static
|
||||||
mate::Handle<WebContents> WebContents::CreateFrom(
|
mate::Handle<WebContents> WebContents::CreateFrom(
|
||||||
v8::Isolate* isolate, content::WebContents* web_contents) {
|
v8::Isolate* isolate,
|
||||||
|
content::WebContents* web_contents) {
|
||||||
// We have an existing WebContents object in JS.
|
// We have an existing WebContents object in JS.
|
||||||
auto existing = TrackableObject::FromWrappedClass(isolate, web_contents);
|
auto existing = TrackableObject::FromWrappedClass(isolate, web_contents);
|
||||||
if (existing)
|
if (existing)
|
||||||
return mate::CreateHandle(isolate, static_cast<WebContents*>(existing));
|
return mate::CreateHandle(isolate, static_cast<WebContents*>(existing));
|
||||||
|
|
||||||
// Otherwise create a new WebContents wrapper object.
|
// Otherwise create a new WebContents wrapper object.
|
||||||
return mate::CreateHandle(isolate, new WebContents(isolate, web_contents,
|
return mate::CreateHandle(isolate,
|
||||||
REMOTE));
|
new WebContents(isolate, web_contents, REMOTE));
|
||||||
}
|
}
|
||||||
|
|
||||||
mate::Handle<WebContents> WebContents::CreateFrom(
|
mate::Handle<WebContents> WebContents::CreateFrom(
|
||||||
v8::Isolate* isolate, content::WebContents* web_contents, Type type) {
|
v8::Isolate* isolate,
|
||||||
|
content::WebContents* web_contents,
|
||||||
|
Type type) {
|
||||||
// Otherwise create a new WebContents wrapper object.
|
// Otherwise create a new WebContents wrapper object.
|
||||||
return mate::CreateHandle(isolate, new WebContents(isolate, web_contents,
|
return mate::CreateHandle(isolate,
|
||||||
type));
|
new WebContents(isolate, web_contents, type));
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
mate::Handle<WebContents> WebContents::Create(
|
mate::Handle<WebContents> WebContents::Create(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate, const mate::Dictionary& options) {
|
const mate::Dictionary& options) {
|
||||||
return mate::CreateHandle(isolate, new WebContents(isolate, options));
|
return mate::CreateHandle(isolate, new WebContents(isolate, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2092,8 +2086,10 @@ namespace {
|
||||||
|
|
||||||
using atom::api::WebContents;
|
using atom::api::WebContents;
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
dict.Set("WebContents", WebContents::GetConstructor(isolate)->GetFunction());
|
dict.Set("WebContents", WebContents::GetConstructor(isolate)->GetFunction());
|
||||||
|
|
|
@ -38,7 +38,7 @@ class ResourceRequestBody;
|
||||||
namespace mate {
|
namespace mate {
|
||||||
class Arguments;
|
class Arguments;
|
||||||
class Dictionary;
|
class Dictionary;
|
||||||
}
|
} // namespace mate
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
@ -82,13 +82,16 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
|
|
||||||
// Create from an existing WebContents.
|
// Create from an existing WebContents.
|
||||||
static mate::Handle<WebContents> CreateFrom(
|
static mate::Handle<WebContents> CreateFrom(
|
||||||
v8::Isolate* isolate, content::WebContents* web_contents);
|
v8::Isolate* isolate,
|
||||||
|
content::WebContents* web_contents);
|
||||||
static mate::Handle<WebContents> CreateFrom(
|
static mate::Handle<WebContents> CreateFrom(
|
||||||
v8::Isolate* isolate, content::WebContents* web_contents, Type type);
|
v8::Isolate* isolate,
|
||||||
|
content::WebContents* web_contents,
|
||||||
|
Type type);
|
||||||
|
|
||||||
// Create a new WebContents.
|
// Create a new WebContents.
|
||||||
static mate::Handle<WebContents> Create(
|
static mate::Handle<WebContents> Create(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate, const mate::Dictionary& options);
|
const mate::Dictionary& options);
|
||||||
|
|
||||||
static void BuildPrototype(v8::Isolate* isolate,
|
static void BuildPrototype(v8::Isolate* isolate,
|
||||||
v8::Local<v8::FunctionTemplate> prototype);
|
v8::Local<v8::FunctionTemplate> prototype);
|
||||||
|
@ -133,8 +136,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
void DisableDeviceEmulation();
|
void DisableDeviceEmulation();
|
||||||
void InspectElement(int x, int y);
|
void InspectElement(int x, int y);
|
||||||
void InspectServiceWorker();
|
void InspectServiceWorker();
|
||||||
void HasServiceWorker(
|
void HasServiceWorker(const base::Callback<void(bool)>&);
|
||||||
const base::Callback<void(bool)>&);
|
|
||||||
void UnregisterServiceWorker(const base::Callback<void(bool)>&);
|
void UnregisterServiceWorker(const base::Callback<void(bool)>&);
|
||||||
void SetIgnoreMenuShortcuts(bool ignore);
|
void SetIgnoreMenuShortcuts(bool ignore);
|
||||||
void SetAudioMuted(bool muted);
|
void SetAudioMuted(bool muted);
|
||||||
|
@ -221,8 +223,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
bool allowed);
|
bool allowed);
|
||||||
|
|
||||||
// Create window with the given disposition.
|
// Create window with the given disposition.
|
||||||
void OnCreateWindow(
|
void OnCreateWindow(const GURL& target_url,
|
||||||
const GURL& target_url,
|
|
||||||
const content::Referrer& referrer,
|
const content::Referrer& referrer,
|
||||||
const std::string& frame_name,
|
const std::string& frame_name,
|
||||||
WindowOpenDisposition disposition,
|
WindowOpenDisposition disposition,
|
||||||
|
@ -274,14 +275,12 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
const base::string16& message,
|
const base::string16& message,
|
||||||
int32_t line_no,
|
int32_t line_no,
|
||||||
const base::string16& source_id) override;
|
const base::string16& source_id) override;
|
||||||
void WebContentsCreated(
|
void WebContentsCreated(content::WebContents* source_contents,
|
||||||
content::WebContents* source_contents,
|
|
||||||
int opener_render_process_id,
|
int opener_render_process_id,
|
||||||
int opener_render_frame_id,
|
int opener_render_frame_id,
|
||||||
const std::string& frame_name,
|
const std::string& frame_name,
|
||||||
const GURL& target_url,
|
const GURL& target_url,
|
||||||
content::WebContents* new_contents)
|
content::WebContents* new_contents) override;
|
||||||
override;
|
|
||||||
void AddNewContents(content::WebContents* source,
|
void AddNewContents(content::WebContents* source,
|
||||||
content::WebContents* new_contents,
|
content::WebContents* new_contents,
|
||||||
WindowOpenDisposition disposition,
|
WindowOpenDisposition disposition,
|
||||||
|
@ -321,16 +320,14 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
const gfx::Rect& selection_rect,
|
const gfx::Rect& selection_rect,
|
||||||
int active_match_ordinal,
|
int active_match_ordinal,
|
||||||
bool final_update) override;
|
bool final_update) override;
|
||||||
bool CheckMediaAccessPermission(
|
bool CheckMediaAccessPermission(content::WebContents* web_contents,
|
||||||
content::WebContents* web_contents,
|
|
||||||
const GURL& security_origin,
|
const GURL& security_origin,
|
||||||
content::MediaStreamType type) override;
|
content::MediaStreamType type) override;
|
||||||
void RequestMediaAccessPermission(
|
void RequestMediaAccessPermission(
|
||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
const content::MediaStreamRequest& request,
|
const content::MediaStreamRequest& request,
|
||||||
const content::MediaResponseCallback& callback) override;
|
const content::MediaResponseCallback& callback) override;
|
||||||
void RequestToLockMouse(
|
void RequestToLockMouse(content::WebContents* web_contents,
|
||||||
content::WebContents* web_contents,
|
|
||||||
bool user_gesture,
|
bool user_gesture,
|
||||||
bool last_unlocked_by_target) override;
|
bool last_unlocked_by_target) override;
|
||||||
std::unique_ptr<content::BluetoothChooser> RunBluetoothChooser(
|
std::unique_ptr<content::BluetoothChooser> RunBluetoothChooser(
|
||||||
|
@ -396,9 +393,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
struct FrameDispatchHelper;
|
struct FrameDispatchHelper;
|
||||||
AtomBrowserContext* GetBrowserContext() const;
|
AtomBrowserContext* GetBrowserContext() const;
|
||||||
|
|
||||||
uint32_t GetNextRequestId() {
|
uint32_t GetNextRequestId() { return ++request_id_; }
|
||||||
return ++request_id_;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(ENABLE_OSR)
|
#if defined(ENABLE_OSR)
|
||||||
OffScreenWebContentsView* GetOffScreenWebContentsView() const;
|
OffScreenWebContentsView* GetOffScreenWebContentsView() const;
|
||||||
|
|
|
@ -21,7 +21,8 @@ namespace mate {
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Converter<URLPattern> {
|
struct Converter<URLPattern> {
|
||||||
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
|
v8::Local<v8::Value> val,
|
||||||
URLPattern* out) {
|
URLPattern* out) {
|
||||||
std::string pattern;
|
std::string pattern;
|
||||||
if (!ConvertFromV8(isolate, val, &pattern))
|
if (!ConvertFromV8(isolate, val, &pattern))
|
||||||
|
@ -63,8 +64,7 @@ WebRequest::WebRequest(v8::Isolate* isolate,
|
||||||
Init(isolate);
|
Init(isolate);
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRequest::~WebRequest() {
|
WebRequest::~WebRequest() {}
|
||||||
}
|
|
||||||
|
|
||||||
template <AtomNetworkDelegate::SimpleEvent type>
|
template <AtomNetworkDelegate::SimpleEvent type>
|
||||||
void WebRequest::SetSimpleListener(mate::Arguments* args) {
|
void WebRequest::SetSimpleListener(mate::Arguments* args) {
|
||||||
|
@ -101,8 +101,8 @@ void WebRequest::SetListener(Method method, Event type, mate::Arguments* args) {
|
||||||
BrowserThread::PostTask(
|
BrowserThread::PostTask(
|
||||||
BrowserThread::IO, FROM_HERE,
|
BrowserThread::IO, FROM_HERE,
|
||||||
base::Bind(&CallNetworkDelegateMethod<Method, Event, Listener>,
|
base::Bind(&CallNetworkDelegateMethod<Method, Event, Listener>,
|
||||||
base::RetainedRef(url_request_context_getter),
|
base::RetainedRef(url_request_context_getter), method, type,
|
||||||
method, type, std::move(patterns), std::move(listener)));
|
std::move(patterns), std::move(listener)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
@ -117,8 +117,7 @@ void WebRequest::BuildPrototype(v8::Isolate* isolate,
|
||||||
v8::Local<v8::FunctionTemplate> prototype) {
|
v8::Local<v8::FunctionTemplate> prototype) {
|
||||||
prototype->SetClassName(mate::StringToV8(isolate, "WebRequest"));
|
prototype->SetClassName(mate::StringToV8(isolate, "WebRequest"));
|
||||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||||
.SetMethod("onBeforeRequest",
|
.SetMethod("onBeforeRequest", &WebRequest::SetResponseListener<
|
||||||
&WebRequest::SetResponseListener<
|
|
||||||
AtomNetworkDelegate::kOnBeforeRequest>)
|
AtomNetworkDelegate::kOnBeforeRequest>)
|
||||||
.SetMethod("onBeforeSendHeaders",
|
.SetMethod("onBeforeSendHeaders",
|
||||||
&WebRequest::SetResponseListener<
|
&WebRequest::SetResponseListener<
|
||||||
|
@ -126,20 +125,19 @@ void WebRequest::BuildPrototype(v8::Isolate* isolate,
|
||||||
.SetMethod("onHeadersReceived",
|
.SetMethod("onHeadersReceived",
|
||||||
&WebRequest::SetResponseListener<
|
&WebRequest::SetResponseListener<
|
||||||
AtomNetworkDelegate::kOnHeadersReceived>)
|
AtomNetworkDelegate::kOnHeadersReceived>)
|
||||||
.SetMethod("onSendHeaders",
|
.SetMethod(
|
||||||
&WebRequest::SetSimpleListener<
|
"onSendHeaders",
|
||||||
AtomNetworkDelegate::kOnSendHeaders>)
|
&WebRequest::SetSimpleListener<AtomNetworkDelegate::kOnSendHeaders>)
|
||||||
.SetMethod("onBeforeRedirect",
|
.SetMethod("onBeforeRedirect",
|
||||||
&WebRequest::SetSimpleListener<
|
&WebRequest::SetSimpleListener<
|
||||||
AtomNetworkDelegate::kOnBeforeRedirect>)
|
AtomNetworkDelegate::kOnBeforeRedirect>)
|
||||||
.SetMethod("onResponseStarted",
|
.SetMethod("onResponseStarted",
|
||||||
&WebRequest::SetSimpleListener<
|
&WebRequest::SetSimpleListener<
|
||||||
AtomNetworkDelegate::kOnResponseStarted>)
|
AtomNetworkDelegate::kOnResponseStarted>)
|
||||||
.SetMethod("onCompleted",
|
.SetMethod(
|
||||||
&WebRequest::SetSimpleListener<
|
"onCompleted",
|
||||||
AtomNetworkDelegate::kOnCompleted>)
|
&WebRequest::SetSimpleListener<AtomNetworkDelegate::kOnCompleted>)
|
||||||
.SetMethod("onErrorOccurred",
|
.SetMethod("onErrorOccurred", &WebRequest::SetSimpleListener<
|
||||||
&WebRequest::SetSimpleListener<
|
|
||||||
AtomNetworkDelegate::kOnErrorOccurred>);
|
AtomNetworkDelegate::kOnErrorOccurred>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,10 @@ void RemoveGuest(content::WebContents* embedder, int guest_instance_id) {
|
||||||
manager->RemoveGuest(guest_instance_id);
|
manager->RemoveGuest(guest_instance_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
|
void Initialize(v8::Local<v8::Object> exports,
|
||||||
v8::Local<v8::Context> context, void* priv) {
|
v8::Local<v8::Value> unused,
|
||||||
|
v8::Local<v8::Context> context,
|
||||||
|
void* priv) {
|
||||||
mate::Dictionary dict(context->GetIsolate(), exports);
|
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||||
dict.SetMethod("addGuest", &AddGuest);
|
dict.SetMethod("addGuest", &AddGuest);
|
||||||
dict.SetMethod("removeGuest", &RemoveGuest);
|
dict.SetMethod("removeGuest", &RemoveGuest);
|
||||||
|
|
|
@ -12,14 +12,11 @@
|
||||||
|
|
||||||
namespace mate {
|
namespace mate {
|
||||||
|
|
||||||
Event::Event(v8::Isolate* isolate)
|
Event::Event(v8::Isolate* isolate) : sender_(nullptr), message_(nullptr) {
|
||||||
: sender_(nullptr),
|
|
||||||
message_(nullptr) {
|
|
||||||
Init(isolate);
|
Init(isolate);
|
||||||
}
|
}
|
||||||
|
|
||||||
Event::~Event() {
|
Event::~Event() {}
|
||||||
}
|
|
||||||
|
|
||||||
void Event::SetSenderAndMessage(content::RenderFrameHost* sender,
|
void Event::SetSenderAndMessage(content::RenderFrameHost* sender,
|
||||||
IPC::Message* message) {
|
IPC::Message* message) {
|
||||||
|
@ -52,8 +49,7 @@ void Event::FrameDeleted(content::RenderFrameHost* rfh) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Event::PreventDefault(v8::Isolate* isolate) {
|
void Event::PreventDefault(v8::Isolate* isolate) {
|
||||||
GetWrapper()->Set(StringToV8(isolate, "defaultPrevented"),
|
GetWrapper()->Set(StringToV8(isolate, "defaultPrevented"), v8::True(isolate));
|
||||||
v8::True(isolate));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Event::SendReply(const base::string16& json) {
|
bool Event::SendReply(const base::string16& json) {
|
||||||
|
@ -73,8 +69,8 @@ Handle<Event> Event::Create(v8::Isolate* isolate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void Event::BuildPrototype(
|
void Event::BuildPrototype(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
|
v8::Local<v8::FunctionTemplate> prototype) {
|
||||||
prototype->SetClassName(mate::StringToV8(isolate, "Event"));
|
prototype->SetClassName(mate::StringToV8(isolate, "Event"));
|
||||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||||
.SetMethod("preventDefault", &Event::PreventDefault)
|
.SetMethod("preventDefault", &Event::PreventDefault)
|
||||||
|
|
|
@ -15,8 +15,7 @@ class Message;
|
||||||
|
|
||||||
namespace mate {
|
namespace mate {
|
||||||
|
|
||||||
class Event : public Wrappable<Event>,
|
class Event : public Wrappable<Event>, public content::WebContentsObserver {
|
||||||
public content::WebContentsObserver {
|
|
||||||
public:
|
public:
|
||||||
static Handle<Event> Create(v8::Isolate* isolate);
|
static Handle<Event> Create(v8::Isolate* isolate);
|
||||||
|
|
||||||
|
|
|
@ -26,13 +26,14 @@ void PreventDefault(mate::Arguments* args) {
|
||||||
// Create a pure JavaScript Event object.
|
// Create a pure JavaScript Event object.
|
||||||
v8::Local<v8::Object> CreateEventObject(v8::Isolate* isolate) {
|
v8::Local<v8::Object> CreateEventObject(v8::Isolate* isolate) {
|
||||||
if (event_template.IsEmpty()) {
|
if (event_template.IsEmpty()) {
|
||||||
event_template.Reset(isolate, ObjectTemplateBuilder(isolate)
|
event_template.Reset(isolate,
|
||||||
|
ObjectTemplateBuilder(isolate)
|
||||||
.SetMethod("preventDefault", &PreventDefault)
|
.SetMethod("preventDefault", &PreventDefault)
|
||||||
.Build());
|
.Build());
|
||||||
}
|
}
|
||||||
|
|
||||||
return v8::Local<v8::ObjectTemplate>::New(
|
return v8::Local<v8::ObjectTemplate>::New(isolate, event_template)
|
||||||
isolate, event_template)->NewInstance();
|
->NewInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -57,8 +58,7 @@ v8::Local<v8::Object> CreateJSEvent(v8::Isolate* isolate,
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
v8::Local<v8::Object> CreateCustomEvent(
|
v8::Local<v8::Object> CreateCustomEvent(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate,
|
|
||||||
v8::Local<v8::Object> object,
|
v8::Local<v8::Object> object,
|
||||||
v8::Local<v8::Object> custom_event) {
|
v8::Local<v8::Object> custom_event) {
|
||||||
v8::Local<v8::Object> event = CreateEventObject(isolate);
|
v8::Local<v8::Object> event = CreateEventObject(isolate);
|
||||||
|
|
|
@ -26,8 +26,7 @@ v8::Local<v8::Object> CreateJSEvent(v8::Isolate* isolate,
|
||||||
v8::Local<v8::Object> object,
|
v8::Local<v8::Object> object,
|
||||||
content::RenderFrameHost* sender,
|
content::RenderFrameHost* sender,
|
||||||
IPC::Message* message);
|
IPC::Message* message);
|
||||||
v8::Local<v8::Object> CreateCustomEvent(
|
v8::Local<v8::Object> CreateCustomEvent(v8::Isolate* isolate,
|
||||||
v8::Isolate* isolate,
|
|
||||||
v8::Local<v8::Object> object,
|
v8::Local<v8::Object> object,
|
||||||
v8::Local<v8::Object> event);
|
v8::Local<v8::Object> event);
|
||||||
v8::Local<v8::Object> CreateEventFromFlags(v8::Isolate* isolate, int flags);
|
v8::Local<v8::Object> CreateEventFromFlags(v8::Isolate* isolate, int flags);
|
||||||
|
@ -53,8 +52,8 @@ class EventEmitter : public Wrappable<T> {
|
||||||
v8::Local<v8::Object> event,
|
v8::Local<v8::Object> event,
|
||||||
const Args&... args) {
|
const Args&... args) {
|
||||||
return EmitWithEvent(
|
return EmitWithEvent(
|
||||||
name,
|
name, internal::CreateCustomEvent(isolate(), GetWrapper(), event),
|
||||||
internal::CreateCustomEvent(isolate(), GetWrapper(), event), args...);
|
args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.emit(name, new Event(flags), args...);
|
// this.emit(name, new Event(flags), args...);
|
||||||
|
@ -63,8 +62,7 @@ class EventEmitter : public Wrappable<T> {
|
||||||
int flags,
|
int flags,
|
||||||
const Args&... args) {
|
const Args&... args) {
|
||||||
return EmitCustomEvent(
|
return EmitCustomEvent(
|
||||||
name,
|
name, internal::CreateEventFromFlags(isolate(), flags), args...);
|
||||||
internal::CreateEventFromFlags(isolate(), flags), args...);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.emit(name, new Event(), args...);
|
// this.emit(name, new Event(), args...);
|
||||||
|
@ -85,8 +83,8 @@ class EventEmitter : public Wrappable<T> {
|
||||||
if (wrapper.IsEmpty()) {
|
if (wrapper.IsEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
v8::Local<v8::Object> event = internal::CreateJSEvent(
|
v8::Local<v8::Object> event =
|
||||||
isolate(), wrapper, sender, message);
|
internal::CreateJSEvent(isolate(), wrapper, sender, message);
|
||||||
return EmitWithEvent(name, event, args...);
|
return EmitWithEvent(name, event, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,8 +100,8 @@ class EventEmitter : public Wrappable<T> {
|
||||||
v8::Locker locker(isolate());
|
v8::Locker locker(isolate());
|
||||||
v8::HandleScope handle_scope(isolate());
|
v8::HandleScope handle_scope(isolate());
|
||||||
EmitEvent(isolate(), GetWrapper(), name, event, args...);
|
EmitEvent(isolate(), GetWrapper(), name, event, args...);
|
||||||
return event->Get(
|
return event->Get(StringToV8(isolate(), "defaultPrevented"))
|
||||||
StringToV8(isolate(), "defaultPrevented"))->BooleanValue();
|
->BooleanValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(EventEmitter);
|
DISALLOW_COPY_AND_ASSIGN(EventEmitter);
|
||||||
|
|
|
@ -25,8 +25,7 @@ FrameSubscriber::FrameSubscriber(v8::Isolate* isolate,
|
||||||
callback_(callback),
|
callback_(callback),
|
||||||
only_dirty_(only_dirty),
|
only_dirty_(only_dirty),
|
||||||
source_id_for_copy_request_(base::UnguessableToken::Create()),
|
source_id_for_copy_request_(base::UnguessableToken::Create()),
|
||||||
weak_factory_(this) {
|
weak_factory_(this) {}
|
||||||
}
|
|
||||||
|
|
||||||
bool FrameSubscriber::ShouldCaptureFrame(
|
bool FrameSubscriber::ShouldCaptureFrame(
|
||||||
const gfx::Rect& dirty_rect,
|
const gfx::Rect& dirty_rect,
|
||||||
|
@ -46,8 +45,8 @@ bool FrameSubscriber::ShouldCaptureFrame(
|
||||||
gfx::Size view_size = rect.size();
|
gfx::Size view_size = rect.size();
|
||||||
gfx::Size bitmap_size = view_size;
|
gfx::Size bitmap_size = view_size;
|
||||||
gfx::NativeView native_view = view_->GetNativeView();
|
gfx::NativeView native_view = view_->GetNativeView();
|
||||||
const float scale =
|
const float scale = display::Screen::GetScreen()
|
||||||
display::Screen::GetScreen()->GetDisplayNearestView(native_view)
|
->GetDisplayNearestView(native_view)
|
||||||
.device_scale_factor();
|
.device_scale_factor();
|
||||||
if (scale > 1.0f)
|
if (scale > 1.0f)
|
||||||
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
|
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
|
||||||
|
@ -55,10 +54,9 @@ bool FrameSubscriber::ShouldCaptureFrame(
|
||||||
rect = gfx::Rect(rect.origin(), bitmap_size);
|
rect = gfx::Rect(rect.origin(), bitmap_size);
|
||||||
|
|
||||||
view_->CopyFromSurface(
|
view_->CopyFromSurface(
|
||||||
rect,
|
rect, rect.size(),
|
||||||
rect.size(),
|
base::Bind(&FrameSubscriber::OnFrameDelivered, weak_factory_.GetWeakPtr(),
|
||||||
base::Bind(&FrameSubscriber::OnFrameDelivered,
|
callback_, rect),
|
||||||
weak_factory_.GetWeakPtr(), callback_, rect),
|
|
||||||
kBGRA_8888_SkColorType);
|
kBGRA_8888_SkColorType);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -17,12 +17,9 @@ namespace api {
|
||||||
|
|
||||||
SavePageHandler::SavePageHandler(content::WebContents* web_contents,
|
SavePageHandler::SavePageHandler(content::WebContents* web_contents,
|
||||||
const SavePageCallback& callback)
|
const SavePageCallback& callback)
|
||||||
: web_contents_(web_contents),
|
: web_contents_(web_contents), callback_(callback) {}
|
||||||
callback_(callback) {
|
|
||||||
}
|
|
||||||
|
|
||||||
SavePageHandler::~SavePageHandler() {
|
SavePageHandler::~SavePageHandler() {}
|
||||||
}
|
|
||||||
|
|
||||||
void SavePageHandler::OnDownloadCreated(content::DownloadManager* manager,
|
void SavePageHandler::OnDownloadCreated(content::DownloadManager* manager,
|
||||||
content::DownloadItem* item) {
|
content::DownloadItem* item) {
|
||||||
|
@ -41,9 +38,8 @@ bool SavePageHandler::Handle(const base::FilePath& full_path,
|
||||||
base::FilePath saved_main_directory_path = full_path.DirName().Append(
|
base::FilePath saved_main_directory_path = full_path.DirName().Append(
|
||||||
full_path.RemoveExtension().BaseName().value() +
|
full_path.RemoveExtension().BaseName().value() +
|
||||||
FILE_PATH_LITERAL("_files"));
|
FILE_PATH_LITERAL("_files"));
|
||||||
bool result = web_contents_->SavePage(full_path,
|
bool result =
|
||||||
saved_main_directory_path,
|
web_contents_->SavePage(full_path, saved_main_directory_path, save_type);
|
||||||
save_type);
|
|
||||||
download_manager->RemoveObserver(this);
|
download_manager->RemoveObserver(this);
|
||||||
// If initialization fails which means fail to create |DownloadItem|, we need
|
// If initialization fails which means fail to create |DownloadItem|, we need
|
||||||
// to delete the |SavePageHandler| instance to avoid memory-leak.
|
// to delete the |SavePageHandler| instance to avoid memory-leak.
|
||||||
|
@ -60,8 +56,8 @@ void SavePageHandler::OnDownloadUpdated(content::DownloadItem* item) {
|
||||||
if (item->GetState() == content::DownloadItem::COMPLETE) {
|
if (item->GetState() == content::DownloadItem::COMPLETE) {
|
||||||
callback_.Run(v8::Null(isolate));
|
callback_.Run(v8::Null(isolate));
|
||||||
} else {
|
} else {
|
||||||
v8::Local<v8::String> error_message = v8::String::NewFromUtf8(
|
v8::Local<v8::String> error_message =
|
||||||
isolate, "Fail to save page");
|
v8::String::NewFromUtf8(isolate, "Fail to save page");
|
||||||
callback_.Run(v8::Exception::Error(error_message));
|
callback_.Run(v8::Exception::Error(error_message));
|
||||||
}
|
}
|
||||||
Destroy(item);
|
Destroy(item);
|
||||||
|
|
|
@ -34,8 +34,7 @@ TrackableObjectBase::TrackableObjectBase()
|
||||||
GetDestroyClosure());
|
GetDestroyClosure());
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackableObjectBase::~TrackableObjectBase() {
|
TrackableObjectBase::~TrackableObjectBase() {}
|
||||||
}
|
|
||||||
|
|
||||||
base::OnceClosure TrackableObjectBase::GetDestroyClosure() {
|
base::OnceClosure TrackableObjectBase::GetDestroyClosure() {
|
||||||
return base::BindOnce(&TrackableObjectBase::Destroy,
|
return base::BindOnce(&TrackableObjectBase::Destroy,
|
||||||
|
|
|
@ -107,13 +107,9 @@ class TrackableObject : public TrackableObjectBase,
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TrackableObject() {
|
TrackableObject() { weak_map_id_ = ++next_id_; }
|
||||||
weak_map_id_ = ++next_id_;
|
|
||||||
}
|
|
||||||
|
|
||||||
~TrackableObject() override {
|
~TrackableObject() override { RemoveFromWeakMap(); }
|
||||||
RemoveFromWeakMap();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitWith(v8::Isolate* isolate, v8::Local<v8::Object> wrapper) override {
|
void InitWith(v8::Isolate* isolate, v8::Local<v8::Object> wrapper) override {
|
||||||
WrappableBase::InitWith(isolate, wrapper);
|
WrappableBase::InitWith(isolate, wrapper);
|
||||||
|
|
|
@ -25,8 +25,7 @@ void FreeNodeBufferData(char* data, void* hint) {
|
||||||
delete[] data;
|
delete[] data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunCallbackInUI(
|
void RunCallbackInUI(const AtomBlobReader::CompletionCallback& callback,
|
||||||
const AtomBlobReader::CompletionCallback& callback,
|
|
||||||
char* blob_data,
|
char* blob_data,
|
||||||
int size) {
|
int size) {
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||||
|
@ -35,8 +34,9 @@ void RunCallbackInUI(
|
||||||
v8::Locker locker(isolate);
|
v8::Locker locker(isolate);
|
||||||
v8::HandleScope handle_scope(isolate);
|
v8::HandleScope handle_scope(isolate);
|
||||||
if (blob_data) {
|
if (blob_data) {
|
||||||
v8::Local<v8::Value> buffer = node::Buffer::New(isolate,
|
v8::Local<v8::Value> buffer =
|
||||||
blob_data, static_cast<size_t>(size), &FreeNodeBufferData, nullptr)
|
node::Buffer::New(isolate, blob_data, static_cast<size_t>(size),
|
||||||
|
&FreeNodeBufferData, nullptr)
|
||||||
.ToLocalChecked();
|
.ToLocalChecked();
|
||||||
callback.Run(buffer);
|
callback.Run(buffer);
|
||||||
} else {
|
} else {
|
||||||
|
@ -46,33 +46,26 @@ void RunCallbackInUI(
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
AtomBlobReader::AtomBlobReader(
|
AtomBlobReader::AtomBlobReader(content::ChromeBlobStorageContext* blob_context,
|
||||||
content::ChromeBlobStorageContext* blob_context,
|
|
||||||
storage::FileSystemContext* file_system_context)
|
storage::FileSystemContext* file_system_context)
|
||||||
: blob_context_(blob_context),
|
: blob_context_(blob_context), file_system_context_(file_system_context) {}
|
||||||
file_system_context_(file_system_context) {
|
|
||||||
}
|
|
||||||
|
|
||||||
AtomBlobReader::~AtomBlobReader() {
|
AtomBlobReader::~AtomBlobReader() {}
|
||||||
}
|
|
||||||
|
|
||||||
void AtomBlobReader::StartReading(
|
void AtomBlobReader::StartReading(
|
||||||
const std::string& uuid,
|
const std::string& uuid,
|
||||||
const AtomBlobReader::CompletionCallback& completion_callback) {
|
const AtomBlobReader::CompletionCallback& completion_callback) {
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||||
|
|
||||||
auto blob_data_handle =
|
auto blob_data_handle = blob_context_->context()->GetBlobDataFromUUID(uuid);
|
||||||
blob_context_->context()->GetBlobDataFromUUID(uuid);
|
auto callback = base::Bind(&RunCallbackInUI, completion_callback);
|
||||||
auto callback = base::Bind(&RunCallbackInUI,
|
|
||||||
completion_callback);
|
|
||||||
if (!blob_data_handle) {
|
if (!blob_data_handle) {
|
||||||
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
|
||||||
base::Bind(callback, nullptr, 0));
|
base::Bind(callback, nullptr, 0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto blob_reader = blob_data_handle->CreateReader(
|
auto blob_reader = blob_data_handle->CreateReader(file_system_context_.get());
|
||||||
file_system_context_.get());
|
|
||||||
BlobReadHelper* blob_read_helper =
|
BlobReadHelper* blob_read_helper =
|
||||||
new BlobReadHelper(std::move(blob_reader), callback);
|
new BlobReadHelper(std::move(blob_reader), callback);
|
||||||
blob_read_helper->Read();
|
blob_read_helper->Read();
|
||||||
|
@ -81,12 +74,9 @@ void AtomBlobReader::StartReading(
|
||||||
AtomBlobReader::BlobReadHelper::BlobReadHelper(
|
AtomBlobReader::BlobReadHelper::BlobReadHelper(
|
||||||
std::unique_ptr<storage::BlobReader> blob_reader,
|
std::unique_ptr<storage::BlobReader> blob_reader,
|
||||||
const BlobReadHelper::CompletionCallback& callback)
|
const BlobReadHelper::CompletionCallback& callback)
|
||||||
: blob_reader_(std::move(blob_reader)),
|
: blob_reader_(std::move(blob_reader)), completion_callback_(callback) {}
|
||||||
completion_callback_(callback) {
|
|
||||||
}
|
|
||||||
|
|
||||||
AtomBlobReader::BlobReadHelper::~BlobReadHelper() {
|
AtomBlobReader::BlobReadHelper::~BlobReadHelper() {}
|
||||||
}
|
|
||||||
|
|
||||||
void AtomBlobReader::BlobReadHelper::Read() {
|
void AtomBlobReader::BlobReadHelper::Read() {
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||||
|
@ -110,14 +100,11 @@ void AtomBlobReader::BlobReadHelper::DidCalculateSize(int result) {
|
||||||
int bytes_read = 0;
|
int bytes_read = 0;
|
||||||
scoped_refptr<net::IOBuffer> blob_data =
|
scoped_refptr<net::IOBuffer> blob_data =
|
||||||
new net::IOBuffer(static_cast<size_t>(total_size));
|
new net::IOBuffer(static_cast<size_t>(total_size));
|
||||||
auto callback = base::Bind(&AtomBlobReader::BlobReadHelper::DidReadBlobData,
|
auto callback =
|
||||||
base::Unretained(this),
|
base::Bind(&AtomBlobReader::BlobReadHelper::DidReadBlobData,
|
||||||
base::RetainedRef(blob_data));
|
base::Unretained(this), base::RetainedRef(blob_data));
|
||||||
storage::BlobReader::Status read_status = blob_reader_->Read(
|
storage::BlobReader::Status read_status =
|
||||||
blob_data.get(),
|
blob_reader_->Read(blob_data.get(), total_size, &bytes_read, callback);
|
||||||
total_size,
|
|
||||||
&bytes_read,
|
|
||||||
callback);
|
|
||||||
if (read_status != storage::BlobReader::Status::IO_PENDING)
|
if (read_status != storage::BlobReader::Status::IO_PENDING)
|
||||||
callback.Run(bytes_read);
|
callback.Run(bytes_read);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,13 +21,13 @@ namespace storage {
|
||||||
class BlobDataHandle;
|
class BlobDataHandle;
|
||||||
class BlobReader;
|
class BlobReader;
|
||||||
class FileSystemContext;
|
class FileSystemContext;
|
||||||
}
|
} // namespace storage
|
||||||
|
|
||||||
namespace v8 {
|
namespace v8 {
|
||||||
template <class T>
|
template <class T>
|
||||||
class Local;
|
class Local;
|
||||||
class Value;
|
class Value;
|
||||||
}
|
} // namespace v8
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
@ -41,8 +41,7 @@ class AtomBlobReader {
|
||||||
storage::FileSystemContext* file_system_context);
|
storage::FileSystemContext* file_system_context);
|
||||||
~AtomBlobReader();
|
~AtomBlobReader();
|
||||||
|
|
||||||
void StartReading(
|
void StartReading(const std::string& uuid,
|
||||||
const std::string& uuid,
|
|
||||||
const AtomBlobReader::CompletionCallback& callback);
|
const AtomBlobReader::CompletionCallback& callback);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -90,8 +90,7 @@ void AtomBrowserClient::SetCustomServiceWorkerSchemes(
|
||||||
|
|
||||||
AtomBrowserClient::AtomBrowserClient() : delegate_(nullptr) {}
|
AtomBrowserClient::AtomBrowserClient() : delegate_(nullptr) {}
|
||||||
|
|
||||||
AtomBrowserClient::~AtomBrowserClient() {
|
AtomBrowserClient::~AtomBrowserClient() {}
|
||||||
}
|
|
||||||
|
|
||||||
content::WebContents* AtomBrowserClient::GetWebContentsFromProcessID(
|
content::WebContents* AtomBrowserClient::GetWebContentsFromProcessID(
|
||||||
int process_id) {
|
int process_id) {
|
||||||
|
@ -138,7 +137,8 @@ bool AtomBrowserClient::ShouldCreateNewSiteInstance(
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomBrowserClient::AddProcessPreferences(
|
void AtomBrowserClient::AddProcessPreferences(
|
||||||
int process_id, AtomBrowserClient::ProcessPreferences prefs) {
|
int process_id,
|
||||||
|
AtomBrowserClient::ProcessPreferences prefs) {
|
||||||
process_preferences_[process_id] = prefs;
|
process_preferences_[process_id] = prefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,8 +178,8 @@ void AtomBrowserClient::RenderProcessWillLaunch(
|
||||||
new WidevineCdmMessageFilter(process_id, host->GetBrowserContext()));
|
new WidevineCdmMessageFilter(process_id, host->GetBrowserContext()));
|
||||||
|
|
||||||
ProcessPreferences prefs;
|
ProcessPreferences prefs;
|
||||||
auto* web_preferences = WebContentsPreferences::From(
|
auto* web_preferences =
|
||||||
GetWebContentsFromProcessID(process_id));
|
WebContentsPreferences::From(GetWebContentsFromProcessID(process_id));
|
||||||
if (web_preferences) {
|
if (web_preferences) {
|
||||||
prefs.sandbox = web_preferences->IsEnabled("sandbox");
|
prefs.sandbox = web_preferences->IsEnabled("sandbox");
|
||||||
prefs.native_window_open = web_preferences->IsEnabled("nativeWindowOpen");
|
prefs.native_window_open = web_preferences->IsEnabled("nativeWindowOpen");
|
||||||
|
@ -195,8 +195,8 @@ content::SpeechRecognitionManagerDelegate*
|
||||||
return new AtomSpeechRecognitionManagerDelegate;
|
return new AtomSpeechRecognitionManagerDelegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomBrowserClient::OverrideWebkitPrefs(
|
void AtomBrowserClient::OverrideWebkitPrefs(content::RenderViewHost* host,
|
||||||
content::RenderViewHost* host, content::WebPreferences* prefs) {
|
content::WebPreferences* prefs) {
|
||||||
prefs->javascript_enabled = true;
|
prefs->javascript_enabled = true;
|
||||||
prefs->web_security_enabled = true;
|
prefs->web_security_enabled = true;
|
||||||
prefs->plugins_enabled = true;
|
prefs->plugins_enabled = true;
|
||||||
|
@ -295,14 +295,12 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Copy following switches to child process.
|
// Copy following switches to child process.
|
||||||
static const char* const kCommonSwitchNames[] = {
|
static const char* const kCommonSwitchNames[] = {switches::kStandardSchemes,
|
||||||
switches::kStandardSchemes,
|
|
||||||
switches::kEnableSandbox,
|
switches::kEnableSandbox,
|
||||||
switches::kSecureSchemes
|
switches::kSecureSchemes};
|
||||||
};
|
command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
|
||||||
command_line->CopySwitchesFrom(
|
kCommonSwitchNames,
|
||||||
*base::CommandLine::ForCurrentProcess(),
|
arraysize(kCommonSwitchNames));
|
||||||
kCommonSwitchNames, arraysize(kCommonSwitchNames));
|
|
||||||
|
|
||||||
// The registered service worker schemes.
|
// The registered service worker schemes.
|
||||||
if (!g_custom_service_worker_schemes.empty())
|
if (!g_custom_service_worker_schemes.empty())
|
||||||
|
@ -331,15 +329,13 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
||||||
SessionPreferences::AppendExtraCommandLineSwitches(
|
SessionPreferences::AppendExtraCommandLineSwitches(
|
||||||
web_contents->GetBrowserContext(), command_line);
|
web_contents->GetBrowserContext(), command_line);
|
||||||
|
|
||||||
auto context_id = atom::api::WebContents::GetIDForContents(
|
auto context_id = atom::api::WebContents::GetIDForContents(web_contents);
|
||||||
web_contents);
|
|
||||||
command_line->AppendSwitchASCII(switches::kContextId,
|
command_line->AppendSwitchASCII(switches::kContextId,
|
||||||
base::IntToString(context_id));
|
base::IntToString(context_id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomBrowserClient::DidCreatePpapiPlugin(
|
void AtomBrowserClient::DidCreatePpapiPlugin(content::BrowserPpapiHost* host) {
|
||||||
content::BrowserPpapiHost* host) {
|
|
||||||
host->GetPpapiHost()->AddHostFactoryFilter(
|
host->GetPpapiHost()->AddHostFactoryFilter(
|
||||||
base::WrapUnique(new chrome::ChromeBrowserPepperHostFactory(host)));
|
base::WrapUnique(new chrome::ChromeBrowserPepperHostFactory(host)));
|
||||||
}
|
}
|
||||||
|
@ -379,9 +375,8 @@ void AtomBrowserClient::AllowCertificateError(
|
||||||
callback) {
|
callback) {
|
||||||
if (delegate_) {
|
if (delegate_) {
|
||||||
delegate_->AllowCertificateError(
|
delegate_->AllowCertificateError(
|
||||||
web_contents, cert_error, ssl_info, request_url,
|
web_contents, cert_error, ssl_info, request_url, resource_type,
|
||||||
resource_type, strict_enforcement,
|
strict_enforcement, expired_previous_decision, callback);
|
||||||
expired_previous_decision, callback);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,8 +450,7 @@ void AtomBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
|
||||||
std::vector<std::string>* additional_schemes) {
|
std::vector<std::string>* additional_schemes) {
|
||||||
auto schemes_list = api::GetStandardSchemes();
|
auto schemes_list = api::GetStandardSchemes();
|
||||||
if (!schemes_list.empty())
|
if (!schemes_list.empty())
|
||||||
additional_schemes->insert(additional_schemes->end(),
|
additional_schemes->insert(additional_schemes->end(), schemes_list.begin(),
|
||||||
schemes_list.begin(),
|
|
||||||
schemes_list.end());
|
schemes_list.end());
|
||||||
additional_schemes->push_back(content::kChromeDevToolsScheme);
|
additional_schemes->push_back(content::kChromeDevToolsScheme);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
namespace content {
|
namespace content {
|
||||||
class QuotaPermissionContext;
|
class QuotaPermissionContext;
|
||||||
class ClientCertificateDelegate;
|
class ClientCertificateDelegate;
|
||||||
}
|
} // namespace content
|
||||||
|
|
||||||
namespace net {
|
namespace net {
|
||||||
class SSLCertRequestInfo;
|
class SSLCertRequestInfo;
|
||||||
|
@ -84,8 +84,7 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||||
net::ClientCertIdentityList client_certs,
|
net::ClientCertIdentityList client_certs,
|
||||||
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
|
std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
|
||||||
void ResourceDispatcherHostCreated() override;
|
void ResourceDispatcherHostCreated() override;
|
||||||
bool CanCreateWindow(
|
bool CanCreateWindow(content::RenderFrameHost* opener,
|
||||||
content::RenderFrameHost* opener,
|
|
||||||
const GURL& opener_url,
|
const GURL& opener_url,
|
||||||
const GURL& opener_top_level_frame_url,
|
const GURL& opener_top_level_frame_url,
|
||||||
const GURL& source_origin,
|
const GURL& source_origin,
|
||||||
|
|
|
@ -77,14 +77,12 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition,
|
||||||
std::string name = RemoveWhitespace(browser->GetName());
|
std::string name = RemoveWhitespace(browser->GetName());
|
||||||
std::string user_agent;
|
std::string user_agent;
|
||||||
if (name == ATOM_PRODUCT_NAME) {
|
if (name == ATOM_PRODUCT_NAME) {
|
||||||
user_agent = "Chrome/" CHROME_VERSION_STRING " "
|
user_agent = "Chrome/" CHROME_VERSION_STRING " " ATOM_PRODUCT_NAME
|
||||||
ATOM_PRODUCT_NAME "/" ATOM_VERSION_STRING;
|
"/" ATOM_VERSION_STRING;
|
||||||
} else {
|
} else {
|
||||||
user_agent = base::StringPrintf(
|
user_agent = base::StringPrintf(
|
||||||
"%s/%s Chrome/%s " ATOM_PRODUCT_NAME "/" ATOM_VERSION_STRING,
|
"%s/%s Chrome/%s " ATOM_PRODUCT_NAME "/" ATOM_VERSION_STRING,
|
||||||
name.c_str(),
|
name.c_str(), browser->GetVersion().c_str(), CHROME_VERSION_STRING);
|
||||||
browser->GetVersion().c_str(),
|
|
||||||
CHROME_VERSION_STRING);
|
|
||||||
}
|
}
|
||||||
user_agent_ = content::BuildUserAgentFromProduct(user_agent);
|
user_agent_ = content::BuildUserAgentFromProduct(user_agent);
|
||||||
|
|
||||||
|
@ -96,8 +94,7 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition,
|
||||||
InitPrefs();
|
InitPrefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomBrowserContext::~AtomBrowserContext() {
|
AtomBrowserContext::~AtomBrowserContext() {}
|
||||||
}
|
|
||||||
|
|
||||||
void AtomBrowserContext::SetUserAgent(const std::string& user_agent) {
|
void AtomBrowserContext::SetUserAgent(const std::string& user_agent) {
|
||||||
user_agent_ = user_agent;
|
user_agent_ = user_agent;
|
||||||
|
@ -156,8 +153,7 @@ AtomBrowserContext::CreateURLRequestJobFactory(
|
||||||
auto host_resolver =
|
auto host_resolver =
|
||||||
url_request_context_getter()->GetURLRequestContext()->host_resolver();
|
url_request_context_getter()->GetURLRequestContext()->host_resolver();
|
||||||
job_factory->SetProtocolHandler(
|
job_factory->SetProtocolHandler(
|
||||||
url::kFtpScheme,
|
url::kFtpScheme, net::FtpProtocolHandler::Create(host_resolver));
|
||||||
net::FtpProtocolHandler::Create(host_resolver));
|
|
||||||
|
|
||||||
return std::move(job_factory);
|
return std::move(job_factory);
|
||||||
}
|
}
|
||||||
|
@ -202,8 +198,8 @@ std::unique_ptr<net::CertVerifier> AtomBrowserContext::CreateCertVerifier(
|
||||||
std::vector<std::string> AtomBrowserContext::GetCookieableSchemes() {
|
std::vector<std::string> AtomBrowserContext::GetCookieableSchemes() {
|
||||||
auto default_schemes = brightray::BrowserContext::GetCookieableSchemes();
|
auto default_schemes = brightray::BrowserContext::GetCookieableSchemes();
|
||||||
const auto& standard_schemes = atom::api::GetStandardSchemes();
|
const auto& standard_schemes = atom::api::GetStandardSchemes();
|
||||||
default_schemes.insert(default_schemes.end(),
|
default_schemes.insert(default_schemes.end(), standard_schemes.begin(),
|
||||||
standard_schemes.begin(), standard_schemes.end());
|
standard_schemes.end());
|
||||||
return default_schemes;
|
return default_schemes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,17 +226,17 @@ AtomBlobReader* AtomBrowserContext::GetBlobReader() {
|
||||||
content::ChromeBlobStorageContext* blob_context =
|
content::ChromeBlobStorageContext* blob_context =
|
||||||
content::ChromeBlobStorageContext::GetFor(this);
|
content::ChromeBlobStorageContext::GetFor(this);
|
||||||
storage::FileSystemContext* file_system_context =
|
storage::FileSystemContext* file_system_context =
|
||||||
content::BrowserContext::GetStoragePartition(
|
content::BrowserContext::GetStoragePartition(this, nullptr)
|
||||||
this, nullptr)->GetFileSystemContext();
|
->GetFileSystemContext();
|
||||||
blob_reader_.reset(new AtomBlobReader(blob_context,
|
blob_reader_.reset(new AtomBlobReader(blob_context, file_system_context));
|
||||||
file_system_context));
|
|
||||||
}
|
}
|
||||||
return blob_reader_.get();
|
return blob_reader_.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
scoped_refptr<AtomBrowserContext> AtomBrowserContext::From(
|
scoped_refptr<AtomBrowserContext> AtomBrowserContext::From(
|
||||||
const std::string& partition, bool in_memory,
|
const std::string& partition,
|
||||||
|
bool in_memory,
|
||||||
const base::DictionaryValue& options) {
|
const base::DictionaryValue& options) {
|
||||||
auto browser_context = brightray::BrowserContext::Get(partition, in_memory);
|
auto browser_context = brightray::BrowserContext::Get(partition, in_memory);
|
||||||
if (browser_context)
|
if (browser_context)
|
||||||
|
|
|
@ -26,7 +26,8 @@ class AtomBrowserContext : public brightray::BrowserContext {
|
||||||
// |in_memory|. The |options| will be passed to constructor when there is no
|
// |in_memory|. The |options| will be passed to constructor when there is no
|
||||||
// existing BrowserContext.
|
// existing BrowserContext.
|
||||||
static scoped_refptr<AtomBrowserContext> From(
|
static scoped_refptr<AtomBrowserContext> From(
|
||||||
const std::string& partition, bool in_memory,
|
const std::string& partition,
|
||||||
|
bool in_memory,
|
||||||
const base::DictionaryValue& options = base::DictionaryValue());
|
const base::DictionaryValue& options = base::DictionaryValue());
|
||||||
|
|
||||||
void SetUserAgent(const std::string& user_agent);
|
void SetUserAgent(const std::string& user_agent);
|
||||||
|
@ -67,7 +68,8 @@ class AtomBrowserContext : public brightray::BrowserContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
AtomBrowserContext(const std::string& partition, bool in_memory,
|
AtomBrowserContext(const std::string& partition,
|
||||||
|
bool in_memory,
|
||||||
const base::DictionaryValue& options);
|
const base::DictionaryValue& options);
|
||||||
~AtomBrowserContext() override;
|
~AtomBrowserContext() override;
|
||||||
|
|
||||||
|
|
|
@ -76,8 +76,8 @@ AtomBrowserMainParts::AtomBrowserMainParts()
|
||||||
DCHECK(!self_) << "Cannot have two AtomBrowserMainParts";
|
DCHECK(!self_) << "Cannot have two AtomBrowserMainParts";
|
||||||
self_ = this;
|
self_ = this;
|
||||||
// Register extension scheme as web safe scheme.
|
// Register extension scheme as web safe scheme.
|
||||||
content::ChildProcessSecurityPolicy::GetInstance()->
|
content::ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme(
|
||||||
RegisterWebSafeScheme("chrome-extension");
|
"chrome-extension");
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomBrowserMainParts::~AtomBrowserMainParts() {
|
AtomBrowserMainParts::~AtomBrowserMainParts() {
|
||||||
|
@ -85,10 +85,11 @@ AtomBrowserMainParts::~AtomBrowserMainParts() {
|
||||||
// Leak the JavascriptEnvironment on exit.
|
// Leak the JavascriptEnvironment on exit.
|
||||||
// This is to work around the bug that V8 would be waiting for background
|
// This is to work around the bug that V8 would be waiting for background
|
||||||
// tasks to finish on exit, while somehow it waits forever in Electron, more
|
// tasks to finish on exit, while somehow it waits forever in Electron, more
|
||||||
// about this can be found at https://github.com/electron/electron/issues/4767.
|
// about this can be found at
|
||||||
// On the other handle there is actually no need to gracefully shutdown V8
|
// https://github.com/electron/electron/issues/4767. On the other handle there
|
||||||
// on exit in the main process, we already ensured all necessary resources get
|
// is actually no need to gracefully shutdown V8 on exit in the main process,
|
||||||
// cleaned up, and it would make quitting faster.
|
// we already ensured all necessary resources get cleaned up, and it would
|
||||||
|
// make quitting faster.
|
||||||
ignore_result(js_env_.release());
|
ignore_result(js_env_.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,8 +184,7 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Start idle gc.
|
// Start idle gc.
|
||||||
gc_timer_.Start(
|
gc_timer_.Start(FROM_HERE, base::TimeDelta::FromMinutes(1),
|
||||||
FROM_HERE, base::TimeDelta::FromMinutes(1),
|
|
||||||
base::Bind(&v8::Isolate::LowMemoryNotification,
|
base::Bind(&v8::Isolate::LowMemoryNotification,
|
||||||
base::Unretained(js_env_->isolate())));
|
base::Unretained(js_env_->isolate())));
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,7 @@ namespace atom {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// See comment in |PreEarlyInitialization()|, where sigaction is called.
|
// See comment in |PreEarlyInitialization()|, where sigaction is called.
|
||||||
void SIGCHLDHandler(int signal) {
|
void SIGCHLDHandler(int signal) {}
|
||||||
}
|
|
||||||
|
|
||||||
// The OSX fork() implementation can crash in the child process before
|
// The OSX fork() implementation can crash in the child process before
|
||||||
// fork() returns. In that case, the shutdown pipe will still be
|
// fork() returns. In that case, the shutdown pipe will still be
|
||||||
|
@ -121,8 +120,7 @@ void ShutdownDetector::ThreadMain() {
|
||||||
size_t bytes_read = 0;
|
size_t bytes_read = 0;
|
||||||
do {
|
do {
|
||||||
ssize_t ret = HANDLE_EINTR(
|
ssize_t ret = HANDLE_EINTR(
|
||||||
read(shutdown_fd_,
|
read(shutdown_fd_, reinterpret_cast<char*>(&signal) + bytes_read,
|
||||||
reinterpret_cast<char*>(&signal) + bytes_read,
|
|
||||||
sizeof(signal) - bytes_read));
|
sizeof(signal) - bytes_read));
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
NOTREACHED() << "Unexpected error: " << strerror(errno);
|
NOTREACHED() << "Unexpected error: " << strerror(errno);
|
||||||
|
|
|
@ -50,8 +50,7 @@ void CreateDownloadPath(
|
||||||
|
|
||||||
AtomDownloadManagerDelegate::AtomDownloadManagerDelegate(
|
AtomDownloadManagerDelegate::AtomDownloadManagerDelegate(
|
||||||
content::DownloadManager* manager)
|
content::DownloadManager* manager)
|
||||||
: download_manager_(manager),
|
: download_manager_(manager), weak_ptr_factory_(this) {}
|
||||||
weak_ptr_factory_(this) {}
|
|
||||||
|
|
||||||
AtomDownloadManagerDelegate::~AtomDownloadManagerDelegate() {
|
AtomDownloadManagerDelegate::~AtomDownloadManagerDelegate() {
|
||||||
if (download_manager_) {
|
if (download_manager_) {
|
||||||
|
@ -67,8 +66,8 @@ void AtomDownloadManagerDelegate::GetItemSavePath(content::DownloadItem* item,
|
||||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||||
v8::Locker locker(isolate);
|
v8::Locker locker(isolate);
|
||||||
v8::HandleScope handle_scope(isolate);
|
v8::HandleScope handle_scope(isolate);
|
||||||
api::DownloadItem* download = api::DownloadItem::FromWrappedClass(isolate,
|
api::DownloadItem* download =
|
||||||
item);
|
api::DownloadItem::FromWrappedClass(isolate, item);
|
||||||
if (download)
|
if (download)
|
||||||
*path = download->GetSavePath();
|
*path = download->GetSavePath();
|
||||||
}
|
}
|
||||||
|
@ -85,8 +84,8 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
|
||||||
|
|
||||||
NativeWindow* window = nullptr;
|
NativeWindow* window = nullptr;
|
||||||
content::WebContents* web_contents = item->GetWebContents();
|
content::WebContents* web_contents = item->GetWebContents();
|
||||||
auto relay = web_contents ? NativeWindowRelay::FromWebContents(web_contents)
|
auto relay =
|
||||||
: nullptr;
|
web_contents ? NativeWindowRelay::FromWebContents(web_contents) : nullptr;
|
||||||
if (relay)
|
if (relay)
|
||||||
window = relay->window.get();
|
window = relay->window.get();
|
||||||
|
|
||||||
|
@ -111,8 +110,8 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
|
||||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||||
v8::Locker locker(isolate);
|
v8::Locker locker(isolate);
|
||||||
v8::HandleScope handle_scope(isolate);
|
v8::HandleScope handle_scope(isolate);
|
||||||
api::DownloadItem* download_item = api::DownloadItem::FromWrappedClass(
|
api::DownloadItem* download_item =
|
||||||
isolate, item);
|
api::DownloadItem::FromWrappedClass(isolate, item);
|
||||||
if (download_item)
|
if (download_item)
|
||||||
download_item->SetSavePath(path);
|
download_item->SetSavePath(path);
|
||||||
}
|
}
|
||||||
|
@ -120,12 +119,10 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
|
||||||
// Running the DownloadTargetCallback with an empty FilePath signals that the
|
// Running the DownloadTargetCallback with an empty FilePath signals that the
|
||||||
// download should be cancelled.
|
// download should be cancelled.
|
||||||
// If user cancels the file save dialog, run the callback with empty FilePath.
|
// If user cancels the file save dialog, run the callback with empty FilePath.
|
||||||
callback.Run(path,
|
callback.Run(path, content::DownloadItem::TARGET_DISPOSITION_PROMPT,
|
||||||
content::DownloadItem::TARGET_DISPOSITION_PROMPT,
|
|
||||||
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path,
|
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path,
|
||||||
path.empty() ?
|
path.empty() ? content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED
|
||||||
content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED :
|
: content::DOWNLOAD_INTERRUPT_REASON_NONE);
|
||||||
content::DOWNLOAD_INTERRUPT_REASON_NONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomDownloadManagerDelegate::Shutdown() {
|
void AtomDownloadManagerDelegate::Shutdown() {
|
||||||
|
@ -151,22 +148,20 @@ bool AtomDownloadManagerDelegate::DetermineDownloadTarget(
|
||||||
base::FilePath save_path;
|
base::FilePath save_path;
|
||||||
GetItemSavePath(download, &save_path);
|
GetItemSavePath(download, &save_path);
|
||||||
if (!save_path.empty()) {
|
if (!save_path.empty()) {
|
||||||
callback.Run(save_path,
|
callback.Run(save_path, content::DownloadItem::TARGET_DISPOSITION_OVERWRITE,
|
||||||
content::DownloadItem::TARGET_DISPOSITION_OVERWRITE,
|
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, save_path,
|
||||||
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
|
content::DOWNLOAD_INTERRUPT_REASON_NONE);
|
||||||
save_path, content::DOWNLOAD_INTERRUPT_REASON_NONE);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
AtomBrowserContext* browser_context = static_cast<AtomBrowserContext*>(
|
AtomBrowserContext* browser_context =
|
||||||
download_manager_->GetBrowserContext());
|
static_cast<AtomBrowserContext*>(download_manager_->GetBrowserContext());
|
||||||
base::FilePath default_download_path = browser_context->prefs()->GetFilePath(
|
base::FilePath default_download_path =
|
||||||
prefs::kDownloadDefaultDirectory);
|
browser_context->prefs()->GetFilePath(prefs::kDownloadDefaultDirectory);
|
||||||
|
|
||||||
CreateDownloadPathCallback download_path_callback =
|
CreateDownloadPathCallback download_path_callback =
|
||||||
base::Bind(&AtomDownloadManagerDelegate::OnDownloadPathGenerated,
|
base::Bind(&AtomDownloadManagerDelegate::OnDownloadPathGenerated,
|
||||||
weak_ptr_factory_.GetWeakPtr(),
|
weak_ptr_factory_.GetWeakPtr(), download->GetId(), callback);
|
||||||
download->GetId(), callback);
|
|
||||||
|
|
||||||
content::BrowserThread::PostTask(
|
content::BrowserThread::PostTask(
|
||||||
content::BrowserThread::FILE, FROM_HERE,
|
content::BrowserThread::FILE, FROM_HERE,
|
||||||
|
|
|
@ -57,8 +57,7 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
|
||||||
|
|
||||||
auto* web_preferences = WebContentsPreferences::From(web_contents);
|
auto* web_preferences = WebContentsPreferences::From(web_contents);
|
||||||
std::string checkbox;
|
std::string checkbox;
|
||||||
if (origin_counts_[origin] > 1 &&
|
if (origin_counts_[origin] > 1 && web_preferences &&
|
||||||
web_preferences &&
|
|
||||||
web_preferences->IsEnabled("safeDialogs") &&
|
web_preferences->IsEnabled("safeDialogs") &&
|
||||||
!web_preferences->dict()->GetString("safeDialogsMessage", &checkbox)) {
|
!web_preferences->dict()->GetString("safeDialogsMessage", &checkbox)) {
|
||||||
checkbox = "Prevent this app from creating additional dialogs";
|
checkbox = "Prevent this app from creating additional dialogs";
|
||||||
|
@ -73,14 +72,11 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
|
||||||
}
|
}
|
||||||
|
|
||||||
atom::ShowMessageBox(
|
atom::ShowMessageBox(
|
||||||
window,
|
window, atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, -1, 0,
|
||||||
atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, -1, 0,
|
|
||||||
atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
|
atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
|
||||||
base::UTF16ToUTF8(message_text), "", checkbox,
|
base::UTF16ToUTF8(message_text), "", checkbox, false, gfx::ImageSkia(),
|
||||||
false, gfx::ImageSkia(),
|
|
||||||
base::Bind(&AtomJavaScriptDialogManager::OnMessageBoxCallback,
|
base::Bind(&AtomJavaScriptDialogManager::OnMessageBoxCallback,
|
||||||
base::Unretained(this),
|
base::Unretained(this), base::Passed(std::move(callback)),
|
||||||
base::Passed(std::move(callback)),
|
|
||||||
origin));
|
origin));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,8 +91,7 @@ void AtomJavaScriptDialogManager::RunBeforeUnloadDialog(
|
||||||
|
|
||||||
void AtomJavaScriptDialogManager::CancelDialogs(
|
void AtomJavaScriptDialogManager::CancelDialogs(
|
||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
bool reset_state) {
|
bool reset_state) {}
|
||||||
}
|
|
||||||
|
|
||||||
void AtomJavaScriptDialogManager::OnMessageBoxCallback(
|
void AtomJavaScriptDialogManager::OnMessageBoxCallback(
|
||||||
DialogClosedCallback callback,
|
DialogClosedCallback callback,
|
||||||
|
|
|
@ -21,16 +21,14 @@ class AtomJavaScriptDialogManager : public content::JavaScriptDialogManager {
|
||||||
explicit AtomJavaScriptDialogManager(api::WebContents* api_web_contents);
|
explicit AtomJavaScriptDialogManager(api::WebContents* api_web_contents);
|
||||||
|
|
||||||
// content::JavaScriptDialogManager implementations.
|
// content::JavaScriptDialogManager implementations.
|
||||||
void RunJavaScriptDialog(
|
void RunJavaScriptDialog(content::WebContents* web_contents,
|
||||||
content::WebContents* web_contents,
|
|
||||||
const GURL& origin_url,
|
const GURL& origin_url,
|
||||||
content::JavaScriptDialogType dialog_type,
|
content::JavaScriptDialogType dialog_type,
|
||||||
const base::string16& message_text,
|
const base::string16& message_text,
|
||||||
const base::string16& default_prompt_text,
|
const base::string16& default_prompt_text,
|
||||||
DialogClosedCallback callback,
|
DialogClosedCallback callback,
|
||||||
bool* did_suppress_message) override;
|
bool* did_suppress_message) override;
|
||||||
void RunBeforeUnloadDialog(
|
void RunBeforeUnloadDialog(content::WebContents* web_contents,
|
||||||
content::WebContents* web_contents,
|
|
||||||
bool is_reload,
|
bool is_reload,
|
||||||
DialogClosedCallback callback) override;
|
DialogClosedCallback callback) override;
|
||||||
void CancelDialogs(content::WebContents* web_contents,
|
void CancelDialogs(content::WebContents* web_contents,
|
||||||
|
|
|
@ -21,8 +21,8 @@ namespace {
|
||||||
|
|
||||||
bool WebContentsDestroyed(int process_id) {
|
bool WebContentsDestroyed(int process_id) {
|
||||||
content::WebContents* web_contents =
|
content::WebContents* web_contents =
|
||||||
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())->
|
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())
|
||||||
GetWebContentsFromProcessID(process_id);
|
->GetWebContentsFromProcessID(process_id);
|
||||||
if (!web_contents)
|
if (!web_contents)
|
||||||
return true;
|
return true;
|
||||||
return web_contents->IsBeingDestroyed();
|
return web_contents->IsBeingDestroyed();
|
||||||
|
@ -54,17 +54,11 @@ class AtomPermissionManager::PendingRequest {
|
||||||
--remaining_results_;
|
--remaining_results_;
|
||||||
}
|
}
|
||||||
|
|
||||||
int render_process_id() const {
|
int render_process_id() const { return render_process_id_; }
|
||||||
return render_process_id_;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsComplete() const {
|
bool IsComplete() const { return remaining_results_ == 0; }
|
||||||
return remaining_results_ == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunCallback() const {
|
void RunCallback() const { callback_.Run(results_); }
|
||||||
callback_.Run(results_);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int render_process_id_;
|
int render_process_id_;
|
||||||
|
@ -73,11 +67,9 @@ class AtomPermissionManager::PendingRequest {
|
||||||
size_t remaining_results_;
|
size_t remaining_results_;
|
||||||
};
|
};
|
||||||
|
|
||||||
AtomPermissionManager::AtomPermissionManager() {
|
AtomPermissionManager::AtomPermissionManager() {}
|
||||||
}
|
|
||||||
|
|
||||||
AtomPermissionManager::~AtomPermissionManager() {
|
AtomPermissionManager::~AtomPermissionManager() {}
|
||||||
}
|
|
||||||
|
|
||||||
void AtomPermissionManager::SetPermissionRequestHandler(
|
void AtomPermissionManager::SetPermissionRequestHandler(
|
||||||
const RequestHandler& handler) {
|
const RequestHandler& handler) {
|
||||||
|
@ -99,12 +91,8 @@ int AtomPermissionManager::RequestPermission(
|
||||||
const GURL& requesting_origin,
|
const GURL& requesting_origin,
|
||||||
bool user_gesture,
|
bool user_gesture,
|
||||||
const StatusCallback& response_callback) {
|
const StatusCallback& response_callback) {
|
||||||
return RequestPermissionWithDetails(
|
return RequestPermissionWithDetails(permission, render_frame_host,
|
||||||
permission,
|
requesting_origin, user_gesture, nullptr,
|
||||||
render_frame_host,
|
|
||||||
requesting_origin,
|
|
||||||
user_gesture,
|
|
||||||
nullptr,
|
|
||||||
response_callback);
|
response_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,11 +104,8 @@ int AtomPermissionManager::RequestPermissionWithDetails(
|
||||||
const base::DictionaryValue* details,
|
const base::DictionaryValue* details,
|
||||||
const StatusCallback& response_callback) {
|
const StatusCallback& response_callback) {
|
||||||
return RequestPermissionsWithDetails(
|
return RequestPermissionsWithDetails(
|
||||||
std::vector<content::PermissionType>(1, permission),
|
std::vector<content::PermissionType>(1, permission), render_frame_host,
|
||||||
render_frame_host,
|
requesting_origin, user_gesture, details,
|
||||||
requesting_origin,
|
|
||||||
user_gesture,
|
|
||||||
details,
|
|
||||||
base::Bind(&PermissionRequestResponseCallbackWrapper, response_callback));
|
base::Bind(&PermissionRequestResponseCallbackWrapper, response_callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,9 +115,9 @@ int AtomPermissionManager::RequestPermissions(
|
||||||
const GURL& requesting_origin,
|
const GURL& requesting_origin,
|
||||||
bool user_gesture,
|
bool user_gesture,
|
||||||
const StatusesCallback& response_callback) {
|
const StatusesCallback& response_callback) {
|
||||||
return RequestPermissionsWithDetails(
|
return RequestPermissionsWithDetails(permissions, render_frame_host,
|
||||||
permissions, render_frame_host, requesting_origin,
|
requesting_origin, user_gesture, nullptr,
|
||||||
user_gesture, nullptr, response_callback);
|
response_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
int AtomPermissionManager::RequestPermissionsWithDetails(
|
int AtomPermissionManager::RequestPermissionsWithDetails(
|
||||||
|
@ -151,8 +136,9 @@ int AtomPermissionManager::RequestPermissionsWithDetails(
|
||||||
std::vector<blink::mojom::PermissionStatus> statuses;
|
std::vector<blink::mojom::PermissionStatus> statuses;
|
||||||
for (auto permission : permissions) {
|
for (auto permission : permissions) {
|
||||||
if (permission == content::PermissionType::MIDI_SYSEX) {
|
if (permission == content::PermissionType::MIDI_SYSEX) {
|
||||||
content::ChildProcessSecurityPolicy::GetInstance()->
|
content::ChildProcessSecurityPolicy::GetInstance()
|
||||||
GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
|
->GrantSendMidiSysExMessage(
|
||||||
|
render_frame_host->GetProcess()->GetID());
|
||||||
}
|
}
|
||||||
statuses.push_back(blink::mojom::PermissionStatus::GRANTED);
|
statuses.push_back(blink::mojom::PermissionStatus::GRANTED);
|
||||||
}
|
}
|
||||||
|
@ -168,8 +154,8 @@ int AtomPermissionManager::RequestPermissionsWithDetails(
|
||||||
for (size_t i = 0; i < permissions.size(); ++i) {
|
for (size_t i = 0; i < permissions.size(); ++i) {
|
||||||
auto permission = permissions[i];
|
auto permission = permissions[i];
|
||||||
if (permission == content::PermissionType::MIDI_SYSEX) {
|
if (permission == content::PermissionType::MIDI_SYSEX) {
|
||||||
content::ChildProcessSecurityPolicy::GetInstance()->
|
content::ChildProcessSecurityPolicy::GetInstance()
|
||||||
GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
|
->GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
|
||||||
}
|
}
|
||||||
const auto callback =
|
const auto callback =
|
||||||
base::Bind(&AtomPermissionManager::OnPermissionResponse,
|
base::Bind(&AtomPermissionManager::OnPermissionResponse,
|
||||||
|
@ -210,11 +196,9 @@ void AtomPermissionManager::CancelPermissionRequest(int request_id) {
|
||||||
pending_requests_.Remove(request_id);
|
pending_requests_.Remove(request_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomPermissionManager::ResetPermission(
|
void AtomPermissionManager::ResetPermission(content::PermissionType permission,
|
||||||
content::PermissionType permission,
|
|
||||||
const GURL& requesting_origin,
|
const GURL& requesting_origin,
|
||||||
const GURL& embedding_origin) {
|
const GURL& embedding_origin) {}
|
||||||
}
|
|
||||||
|
|
||||||
blink::mojom::PermissionStatus AtomPermissionManager::GetPermissionStatus(
|
blink::mojom::PermissionStatus AtomPermissionManager::GetPermissionStatus(
|
||||||
content::PermissionType permission,
|
content::PermissionType permission,
|
||||||
|
@ -232,7 +216,6 @@ int AtomPermissionManager::SubscribePermissionStatusChange(
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomPermissionManager::UnsubscribePermissionStatusChange(
|
void AtomPermissionManager::UnsubscribePermissionStatusChange(
|
||||||
int subscription_id) {
|
int subscription_id) {}
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -24,12 +24,10 @@ class AtomPermissionManager : public content::PermissionManager {
|
||||||
AtomPermissionManager();
|
AtomPermissionManager();
|
||||||
~AtomPermissionManager() override;
|
~AtomPermissionManager() override;
|
||||||
|
|
||||||
using StatusCallback =
|
using StatusCallback = base::Callback<void(blink::mojom::PermissionStatus)>;
|
||||||
base::Callback<void(blink::mojom::PermissionStatus)>;
|
|
||||||
using StatusesCallback =
|
using StatusesCallback =
|
||||||
base::Callback<void(const std::vector<blink::mojom::PermissionStatus>&)>;
|
base::Callback<void(const std::vector<blink::mojom::PermissionStatus>&)>;
|
||||||
using RequestHandler =
|
using RequestHandler = base::Callback<void(content::WebContents*,
|
||||||
base::Callback<void(content::WebContents*,
|
|
||||||
content::PermissionType,
|
content::PermissionType,
|
||||||
const StatusCallback&,
|
const StatusCallback&,
|
||||||
const base::DictionaryValue&)>;
|
const base::DictionaryValue&)>;
|
||||||
|
@ -57,8 +55,8 @@ class AtomPermissionManager : public content::PermissionManager {
|
||||||
content::RenderFrameHost* render_frame_host,
|
content::RenderFrameHost* render_frame_host,
|
||||||
const GURL& requesting_origin,
|
const GURL& requesting_origin,
|
||||||
bool user_gesture,
|
bool user_gesture,
|
||||||
const base::Callback<void(
|
const base::Callback<
|
||||||
const std::vector<blink::mojom::PermissionStatus>&)>& callback)
|
void(const std::vector<blink::mojom::PermissionStatus>&)>& callback)
|
||||||
override;
|
override;
|
||||||
int RequestPermissionsWithDetails(
|
int RequestPermissionsWithDetails(
|
||||||
const std::vector<content::PermissionType>& permissions,
|
const std::vector<content::PermissionType>& permissions,
|
||||||
|
@ -66,8 +64,8 @@ class AtomPermissionManager : public content::PermissionManager {
|
||||||
const GURL& requesting_origin,
|
const GURL& requesting_origin,
|
||||||
bool user_gesture,
|
bool user_gesture,
|
||||||
const base::DictionaryValue* details,
|
const base::DictionaryValue* details,
|
||||||
const base::Callback<void(
|
const base::Callback<
|
||||||
const std::vector<blink::mojom::PermissionStatus>&)>& callback);
|
void(const std::vector<blink::mojom::PermissionStatus>&)>& callback);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void OnPermissionResponse(int request_id,
|
void OnPermissionResponse(int request_id,
|
||||||
|
|
|
@ -8,11 +8,9 @@
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
AtomQuotaPermissionContext::AtomQuotaPermissionContext() {
|
AtomQuotaPermissionContext::AtomQuotaPermissionContext() {}
|
||||||
}
|
|
||||||
|
|
||||||
AtomQuotaPermissionContext::~AtomQuotaPermissionContext() {
|
AtomQuotaPermissionContext::~AtomQuotaPermissionContext() {}
|
||||||
}
|
|
||||||
|
|
||||||
void AtomQuotaPermissionContext::RequestQuotaPermission(
|
void AtomQuotaPermissionContext::RequestQuotaPermission(
|
||||||
const content::StorageQuotaParams& params,
|
const content::StorageQuotaParams& params,
|
||||||
|
|
|
@ -17,8 +17,7 @@ class AtomQuotaPermissionContext : public content::QuotaPermissionContext {
|
||||||
virtual ~AtomQuotaPermissionContext();
|
virtual ~AtomQuotaPermissionContext();
|
||||||
|
|
||||||
// content::QuotaPermissionContext:
|
// content::QuotaPermissionContext:
|
||||||
void RequestQuotaPermission(
|
void RequestQuotaPermission(const content::StorageQuotaParams& params,
|
||||||
const content::StorageQuotaParams& params,
|
|
||||||
int render_process_id,
|
int render_process_id,
|
||||||
const PermissionCallback& callback) override;
|
const PermissionCallback& callback) override;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include "net/url_request/url_request.h"
|
#include "net/url_request/url_request.h"
|
||||||
#endif // defined(ENABLE_PDF_VIEWER)
|
#endif // defined(ENABLE_PDF_VIEWER)
|
||||||
|
|
||||||
|
|
||||||
using content::BrowserThread;
|
using content::BrowserThread;
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
|
@ -10,45 +10,37 @@
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
AtomSpeechRecognitionManagerDelegate::AtomSpeechRecognitionManagerDelegate() {
|
AtomSpeechRecognitionManagerDelegate::AtomSpeechRecognitionManagerDelegate() {}
|
||||||
}
|
|
||||||
|
|
||||||
AtomSpeechRecognitionManagerDelegate::~AtomSpeechRecognitionManagerDelegate() {
|
AtomSpeechRecognitionManagerDelegate::~AtomSpeechRecognitionManagerDelegate() {}
|
||||||
}
|
|
||||||
|
|
||||||
void AtomSpeechRecognitionManagerDelegate::OnRecognitionStart(int session_id) {
|
void AtomSpeechRecognitionManagerDelegate::OnRecognitionStart(int session_id) {}
|
||||||
}
|
|
||||||
|
|
||||||
void AtomSpeechRecognitionManagerDelegate::OnAudioStart(int session_id) {
|
void AtomSpeechRecognitionManagerDelegate::OnAudioStart(int session_id) {}
|
||||||
}
|
|
||||||
|
|
||||||
void AtomSpeechRecognitionManagerDelegate::OnEnvironmentEstimationComplete(
|
void AtomSpeechRecognitionManagerDelegate::OnEnvironmentEstimationComplete(
|
||||||
int session_id) {
|
int session_id) {}
|
||||||
}
|
|
||||||
|
|
||||||
void AtomSpeechRecognitionManagerDelegate::OnSoundStart(int session_id) {
|
void AtomSpeechRecognitionManagerDelegate::OnSoundStart(int session_id) {}
|
||||||
}
|
|
||||||
|
|
||||||
void AtomSpeechRecognitionManagerDelegate::OnSoundEnd(int session_id) {
|
void AtomSpeechRecognitionManagerDelegate::OnSoundEnd(int session_id) {}
|
||||||
}
|
|
||||||
|
|
||||||
void AtomSpeechRecognitionManagerDelegate::OnAudioEnd(int session_id) {
|
void AtomSpeechRecognitionManagerDelegate::OnAudioEnd(int session_id) {}
|
||||||
}
|
|
||||||
|
|
||||||
void AtomSpeechRecognitionManagerDelegate::OnRecognitionEnd(int session_id) {
|
void AtomSpeechRecognitionManagerDelegate::OnRecognitionEnd(int session_id) {}
|
||||||
}
|
|
||||||
|
|
||||||
void AtomSpeechRecognitionManagerDelegate::OnRecognitionResults(
|
void AtomSpeechRecognitionManagerDelegate::OnRecognitionResults(
|
||||||
int session_id, const content::SpeechRecognitionResults& result) {
|
int session_id,
|
||||||
}
|
const content::SpeechRecognitionResults& result) {}
|
||||||
|
|
||||||
void AtomSpeechRecognitionManagerDelegate::OnRecognitionError(
|
void AtomSpeechRecognitionManagerDelegate::OnRecognitionError(
|
||||||
int session_id, const content::SpeechRecognitionError& error) {
|
int session_id,
|
||||||
}
|
const content::SpeechRecognitionError& error) {}
|
||||||
|
|
||||||
void AtomSpeechRecognitionManagerDelegate::OnAudioLevelsChange(
|
void AtomSpeechRecognitionManagerDelegate::OnAudioLevelsChange(
|
||||||
int session_id, float volume, float noise_volume) {
|
int session_id,
|
||||||
}
|
float volume,
|
||||||
|
float noise_volume) {}
|
||||||
|
|
||||||
void AtomSpeechRecognitionManagerDelegate::CheckRecognitionIsAllowed(
|
void AtomSpeechRecognitionManagerDelegate::CheckRecognitionIsAllowed(
|
||||||
int session_id,
|
int session_id,
|
||||||
|
|
|
@ -29,10 +29,13 @@ class AtomSpeechRecognitionManagerDelegate
|
||||||
void OnAudioEnd(int session_id) override;
|
void OnAudioEnd(int session_id) override;
|
||||||
void OnRecognitionEnd(int session_id) override;
|
void OnRecognitionEnd(int session_id) override;
|
||||||
void OnRecognitionResults(
|
void OnRecognitionResults(
|
||||||
int session_id, const content::SpeechRecognitionResults& result) override;
|
int session_id,
|
||||||
|
const content::SpeechRecognitionResults& result) override;
|
||||||
void OnRecognitionError(
|
void OnRecognitionError(
|
||||||
int session_id, const content::SpeechRecognitionError& error) override;
|
int session_id,
|
||||||
void OnAudioLevelsChange(int session_id, float volume,
|
const content::SpeechRecognitionError& error) override;
|
||||||
|
void OnAudioLevelsChange(int session_id,
|
||||||
|
float volume,
|
||||||
float noise_volume) override;
|
float noise_volume) override;
|
||||||
|
|
||||||
// content::SpeechRecognitionManagerDelegate:
|
// content::SpeechRecognitionManagerDelegate:
|
||||||
|
|
|
@ -21,14 +21,11 @@ std::string AutoUpdater::GetFeedURL() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoUpdater::SetFeedURL(mate::Arguments* args) {
|
void AutoUpdater::SetFeedURL(mate::Arguments* args) {}
|
||||||
}
|
|
||||||
|
|
||||||
void AutoUpdater::CheckForUpdates() {
|
void AutoUpdater::CheckForUpdates() {}
|
||||||
}
|
|
||||||
|
|
||||||
void AutoUpdater::QuitAndInstall() {
|
void AutoUpdater::QuitAndInstall() {}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace auto_updater
|
} // namespace auto_updater
|
||||||
|
|
|
@ -23,7 +23,8 @@ class Delegate {
|
||||||
// An error happened.
|
// An error happened.
|
||||||
virtual void OnError(const std::string& error) {}
|
virtual void OnError(const std::string& error) {}
|
||||||
|
|
||||||
virtual void OnError(const std::string& error, const int code,
|
virtual void OnError(const std::string& error,
|
||||||
|
const int code,
|
||||||
const std::string& domain) {}
|
const std::string& domain) {}
|
||||||
|
|
||||||
// Checking to see if there is an update
|
// Checking to see if there is an update
|
||||||
|
|
|
@ -21,8 +21,7 @@ void BridgeTaskRunner::MessageLoopIsReady() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BridgeTaskRunner::PostDelayedTask(
|
bool BridgeTaskRunner::PostDelayedTask(const base::Location& from_here,
|
||||||
const base::Location& from_here,
|
|
||||||
base::OnceClosure task,
|
base::OnceClosure task,
|
||||||
base::TimeDelta delay) {
|
base::TimeDelta delay) {
|
||||||
auto message_loop = base::MessageLoop::current();
|
auto message_loop = base::MessageLoop::current();
|
||||||
|
@ -31,8 +30,8 @@ bool BridgeTaskRunner::PostDelayedTask(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return message_loop->task_runner()->PostDelayedTask(
|
return message_loop->task_runner()->PostDelayedTask(from_here,
|
||||||
from_here, std::move(task), delay);
|
std::move(task), delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BridgeTaskRunner::RunsTasksInCurrentSequence() const {
|
bool BridgeTaskRunner::RunsTasksInCurrentSequence() const {
|
||||||
|
@ -49,8 +48,8 @@ bool BridgeTaskRunner::PostNonNestableDelayedTask(
|
||||||
base::TimeDelta delay) {
|
base::TimeDelta delay) {
|
||||||
auto message_loop = base::MessageLoop::current();
|
auto message_loop = base::MessageLoop::current();
|
||||||
if (!message_loop) {
|
if (!message_loop) {
|
||||||
non_nestable_tasks_.push_back(std::make_tuple(
|
non_nestable_tasks_.push_back(
|
||||||
from_here, std::move(task), delay));
|
std::make_tuple(from_here, std::move(task), delay));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,14 +29,13 @@ class BridgeTaskRunner : public base::SingleThreadTaskRunner {
|
||||||
base::OnceClosure task,
|
base::OnceClosure task,
|
||||||
base::TimeDelta delay) override;
|
base::TimeDelta delay) override;
|
||||||
bool RunsTasksInCurrentSequence() const override;
|
bool RunsTasksInCurrentSequence() const override;
|
||||||
bool PostNonNestableDelayedTask(
|
bool PostNonNestableDelayedTask(const base::Location& from_here,
|
||||||
const base::Location& from_here,
|
|
||||||
base::OnceClosure task,
|
base::OnceClosure task,
|
||||||
base::TimeDelta delay) override;
|
base::TimeDelta delay) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using TaskPair = std::tuple<
|
using TaskPair =
|
||||||
base::Location, base::OnceClosure, base::TimeDelta>;
|
std::tuple<base::Location, base::OnceClosure, base::TimeDelta>;
|
||||||
std::vector<TaskPair> tasks_;
|
std::vector<TaskPair> tasks_;
|
||||||
std::vector<TaskPair> non_nestable_tasks_;
|
std::vector<TaskPair> non_nestable_tasks_;
|
||||||
|
|
||||||
|
|
|
@ -229,13 +229,9 @@ class Browser : public WindowListObserver {
|
||||||
|
|
||||||
void PreMainMessageLoopRun();
|
void PreMainMessageLoopRun();
|
||||||
|
|
||||||
void AddObserver(BrowserObserver* obs) {
|
void AddObserver(BrowserObserver* obs) { observers_.AddObserver(obs); }
|
||||||
observers_.AddObserver(obs);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RemoveObserver(BrowserObserver* obs) {
|
void RemoveObserver(BrowserObserver* obs) { observers_.RemoveObserver(obs); }
|
||||||
observers_.RemoveObserver(obs);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_shutting_down() const { return is_shutdown_; }
|
bool is_shutting_down() const { return is_shutdown_; }
|
||||||
bool is_quiting() const { return is_quiting_; }
|
bool is_quiting() const { return is_quiting_; }
|
||||||
|
|
|
@ -28,7 +28,8 @@ const char kXdgSettingsDefaultSchemeHandler[] = "default-url-scheme-handler";
|
||||||
bool LaunchXdgUtility(const std::vector<std::string>& argv, int* exit_code) {
|
bool LaunchXdgUtility(const std::vector<std::string>& argv, int* exit_code) {
|
||||||
*exit_code = EXIT_FAILURE;
|
*exit_code = EXIT_FAILURE;
|
||||||
int devnull = open("/dev/null", O_RDONLY);
|
int devnull = open("/dev/null", O_RDONLY);
|
||||||
if (devnull < 0) return false;
|
if (devnull < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
base::LaunchOptions options;
|
base::LaunchOptions options;
|
||||||
options.fds_to_remap.push_back(std::make_pair(devnull, STDIN_FILENO));
|
options.fds_to_remap.push_back(std::make_pair(devnull, STDIN_FILENO));
|
||||||
|
@ -36,7 +37,8 @@ bool LaunchXdgUtility(const std::vector<std::string>& argv, int* exit_code) {
|
||||||
base::Process process = base::LaunchProcess(argv, options);
|
base::Process process = base::LaunchProcess(argv, options);
|
||||||
close(devnull);
|
close(devnull);
|
||||||
|
|
||||||
if (!process.IsValid()) return false;
|
if (!process.IsValid())
|
||||||
|
return false;
|
||||||
return process.WaitForExit(exit_code);
|
return process.WaitForExit(exit_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,14 +69,11 @@ void Browser::Focus() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::AddRecentDocument(const base::FilePath& path) {
|
void Browser::AddRecentDocument(const base::FilePath& path) {}
|
||||||
}
|
|
||||||
|
|
||||||
void Browser::ClearRecentDocuments() {
|
void Browser::ClearRecentDocuments() {}
|
||||||
}
|
|
||||||
|
|
||||||
void Browser::SetAppUserModelID(const base::string16& name) {
|
void Browser::SetAppUserModelID(const base::string16& name) {}
|
||||||
}
|
|
||||||
|
|
||||||
bool Browser::SetAsDefaultProtocolClient(const std::string& protocol,
|
bool Browser::SetAsDefaultProtocolClient(const std::string& protocol,
|
||||||
mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
|
@ -85,7 +84,8 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol,
|
||||||
mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
||||||
|
|
||||||
if (protocol.empty()) return false;
|
if (protocol.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
std::vector<std::string> argv;
|
std::vector<std::string> argv;
|
||||||
argv.push_back(kXdgSettings);
|
argv.push_back(kXdgSettings);
|
||||||
|
@ -96,14 +96,14 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol,
|
||||||
|
|
||||||
std::string reply;
|
std::string reply;
|
||||||
int success_code;
|
int success_code;
|
||||||
bool ran_ok = base::GetAppOutputWithExitCode(base::CommandLine(argv),
|
bool ran_ok = base::GetAppOutputWithExitCode(base::CommandLine(argv), &reply,
|
||||||
&reply, &success_code);
|
&success_code);
|
||||||
|
|
||||||
if (!ran_ok || success_code != EXIT_SUCCESS) return false;
|
if (!ran_ok || success_code != EXIT_SUCCESS)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Allow any reply that starts with "yes".
|
// Allow any reply that starts with "yes".
|
||||||
return base::StartsWith(reply, "yes", base::CompareCase::SENSITIVE)
|
return base::StartsWith(reply, "yes", base::CompareCase::SENSITIVE) ? true
|
||||||
? true
|
|
||||||
: false;
|
: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,8 +123,7 @@ bool Browser::SetBadgeCount(int count) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Browser::SetLoginItemSettings(LoginItemSettings settings) {
|
void Browser::SetLoginItemSettings(LoginItemSettings settings) {}
|
||||||
}
|
|
||||||
|
|
||||||
Browser::LoginItemSettings Browser::GetLoginItemSettings(
|
Browser::LoginItemSettings Browser::GetLoginItemSettings(
|
||||||
const LoginItemSettings& options) {
|
const LoginItemSettings& options) {
|
||||||
|
|
|
@ -34,8 +34,8 @@ class BrowserObserver {
|
||||||
|
|
||||||
// The browser has opened a file by double clicking in Finder or dragging the
|
// The browser has opened a file by double clicking in Finder or dragging the
|
||||||
// file to the Dock icon. (macOS only)
|
// file to the Dock icon. (macOS only)
|
||||||
virtual void OnOpenFile(bool* prevent_default,
|
virtual void OnOpenFile(bool* prevent_default, const std::string& file_path) {
|
||||||
const std::string& file_path) {}
|
}
|
||||||
|
|
||||||
// Browser is used to open a url.
|
// Browser is used to open a url.
|
||||||
virtual void OnOpenURL(const std::string& url) {}
|
virtual void OnOpenURL(const std::string& url) {}
|
||||||
|
@ -60,16 +60,13 @@ class BrowserObserver {
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
// The browser wants to report that an user activity will resume. (macOS only)
|
// The browser wants to report that an user activity will resume. (macOS only)
|
||||||
virtual void OnWillContinueUserActivity(
|
virtual void OnWillContinueUserActivity(bool* prevent_default,
|
||||||
bool* prevent_default,
|
|
||||||
const std::string& type) {}
|
const std::string& type) {}
|
||||||
// The browser wants to report an user activity resuming error. (macOS only)
|
// The browser wants to report an user activity resuming error. (macOS only)
|
||||||
virtual void OnDidFailToContinueUserActivity(
|
virtual void OnDidFailToContinueUserActivity(const std::string& type,
|
||||||
const std::string& type,
|
|
||||||
const std::string& error) {}
|
const std::string& error) {}
|
||||||
// The browser wants to resume a user activity via handoff. (macOS only)
|
// The browser wants to resume a user activity via handoff. (macOS only)
|
||||||
virtual void OnContinueUserActivity(
|
virtual void OnContinueUserActivity(bool* prevent_default,
|
||||||
bool* prevent_default,
|
|
||||||
const std::string& type,
|
const std::string& type,
|
||||||
const base::DictionaryValue& user_info) {}
|
const base::DictionaryValue& user_info) {}
|
||||||
// The browser wants to notify that an user activity was resumed. (macOS only)
|
// The browser wants to notify that an user activity was resumed. (macOS only)
|
||||||
|
|
|
@ -61,8 +61,7 @@ bool GetProtocolLaunchPath(mate::Arguments* args, base::string16* exe) {
|
||||||
// Read in optional args arg
|
// Read in optional args arg
|
||||||
std::vector<base::string16> launch_args;
|
std::vector<base::string16> launch_args;
|
||||||
if (args->GetNext(&launch_args) && !launch_args.empty())
|
if (args->GetNext(&launch_args) && !launch_args.empty())
|
||||||
*exe = base::StringPrintf(L"\"%ls\" %ls \"%%1\"",
|
*exe = base::StringPrintf(L"\"%ls\" %ls \"%%1\"", exe->c_str(),
|
||||||
exe->c_str(),
|
|
||||||
base::JoinString(launch_args, L" ").c_str());
|
base::JoinString(launch_args, L" ").c_str());
|
||||||
else
|
else
|
||||||
*exe = base::StringPrintf(L"\"%ls\" \"%%1\"", exe->c_str());
|
*exe = base::StringPrintf(L"\"%ls\" \"%%1\"", exe->c_str());
|
||||||
|
@ -76,8 +75,7 @@ bool FormatCommandLineString(base::string16* exe,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!launch_args.empty()) {
|
if (!launch_args.empty()) {
|
||||||
*exe = base::StringPrintf(L"%ls %ls",
|
*exe = base::StringPrintf(L"%ls %ls", exe->c_str(),
|
||||||
exe->c_str(),
|
|
||||||
base::JoinString(launch_args, L" ").c_str());
|
base::JoinString(launch_args, L" ").c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,8 +95,8 @@ void Browser::AddRecentDocument(const base::FilePath& path) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CComPtr<IShellItem> item;
|
CComPtr<IShellItem> item;
|
||||||
HRESULT hr = SHCreateItemFromParsingName(
|
HRESULT hr = SHCreateItemFromParsingName(path.value().c_str(), NULL,
|
||||||
path.value().c_str(), NULL, IID_PPV_ARGS(&item));
|
IID_PPV_ARGS(&item));
|
||||||
if (SUCCEEDED(hr)) {
|
if (SUCCEEDED(hr)) {
|
||||||
SHARDAPPIDINFO info;
|
SHARDAPPIDINFO info;
|
||||||
info.psi = item;
|
info.psi = item;
|
||||||
|
@ -109,8 +107,8 @@ void Browser::AddRecentDocument(const base::FilePath& path) {
|
||||||
|
|
||||||
void Browser::ClearRecentDocuments() {
|
void Browser::ClearRecentDocuments() {
|
||||||
CComPtr<IApplicationDestinations> destinations;
|
CComPtr<IApplicationDestinations> destinations;
|
||||||
if (FAILED(destinations.CoCreateInstance(CLSID_ApplicationDestinations,
|
if (FAILED(destinations.CoCreateInstance(CLSID_ApplicationDestinations, NULL,
|
||||||
NULL, CLSCTX_INPROC_SERVER)))
|
CLSCTX_INPROC_SERVER)))
|
||||||
return;
|
return;
|
||||||
if (FAILED(destinations->SetAppID(GetAppUserModelID())))
|
if (FAILED(destinations->SetAppID(GetAppUserModelID())))
|
||||||
return;
|
return;
|
||||||
|
@ -189,8 +187,8 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
|
||||||
base::win::RegKey protocolKey;
|
base::win::RegKey protocolKey;
|
||||||
base::string16 protocolPath = keyPath + wprotocol;
|
base::string16 protocolPath = keyPath + wprotocol;
|
||||||
|
|
||||||
if (SUCCEEDED(protocolKey
|
if (SUCCEEDED(
|
||||||
.Open(root, protocolPath.c_str(), KEY_ALL_ACCESS))) {
|
protocolKey.Open(root, protocolPath.c_str(), KEY_ALL_ACCESS))) {
|
||||||
protocolKey.DeleteValue(L"URL Protocol");
|
protocolKey.DeleteValue(L"URL Protocol");
|
||||||
|
|
||||||
// Overwrite the default value to be empty, we can't delete it right away
|
// Overwrite the default value to be empty, we can't delete it right away
|
||||||
|
|
|
@ -42,15 +42,13 @@ namespace {
|
||||||
const char kRootName[] = "<root>";
|
const char kRootName[] = "<root>";
|
||||||
|
|
||||||
struct FileSystem {
|
struct FileSystem {
|
||||||
FileSystem() {
|
FileSystem() {}
|
||||||
}
|
|
||||||
FileSystem(const std::string& file_system_name,
|
FileSystem(const std::string& file_system_name,
|
||||||
const std::string& root_url,
|
const std::string& root_url,
|
||||||
const std::string& file_system_path)
|
const std::string& file_system_path)
|
||||||
: file_system_name(file_system_name),
|
: file_system_name(file_system_name),
|
||||||
root_url(root_url),
|
root_url(root_url),
|
||||||
file_system_path(file_system_path) {
|
file_system_path(file_system_path) {}
|
||||||
}
|
|
||||||
|
|
||||||
std::string file_system_name;
|
std::string file_system_name;
|
||||||
std::string root_url;
|
std::string root_url;
|
||||||
|
@ -62,10 +60,7 @@ std::string RegisterFileSystem(content::WebContents* web_contents,
|
||||||
auto isolated_context = storage::IsolatedContext::GetInstance();
|
auto isolated_context = storage::IsolatedContext::GetInstance();
|
||||||
std::string root_name(kRootName);
|
std::string root_name(kRootName);
|
||||||
std::string file_system_id = isolated_context->RegisterFileSystemForPath(
|
std::string file_system_id = isolated_context->RegisterFileSystemForPath(
|
||||||
storage::kFileSystemTypeNativeLocal,
|
storage::kFileSystemTypeNativeLocal, std::string(), path, &root_name);
|
||||||
std::string(),
|
|
||||||
path,
|
|
||||||
&root_name);
|
|
||||||
|
|
||||||
content::ChildProcessSecurityPolicy* policy =
|
content::ChildProcessSecurityPolicy* policy =
|
||||||
content::ChildProcessSecurityPolicy::GetInstance();
|
content::ChildProcessSecurityPolicy::GetInstance();
|
||||||
|
@ -82,8 +77,7 @@ std::string RegisterFileSystem(content::WebContents* web_contents,
|
||||||
return file_system_id;
|
return file_system_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSystem CreateFileSystemStruct(
|
FileSystem CreateFileSystemStruct(content::WebContents* web_contents,
|
||||||
content::WebContents* web_contents,
|
|
||||||
const std::string& file_system_id,
|
const std::string& file_system_id,
|
||||||
const std::string& file_system_path) {
|
const std::string& file_system_path) {
|
||||||
const GURL origin = web_contents->GetURL().GetOrigin();
|
const GURL origin = web_contents->GetURL().GetOrigin();
|
||||||
|
@ -104,16 +98,14 @@ std::unique_ptr<base::DictionaryValue> CreateFileSystemValue(
|
||||||
return file_system_value;
|
return file_system_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteToFile(const base::FilePath& path,
|
void WriteToFile(const base::FilePath& path, const std::string& content) {
|
||||||
const std::string& content) {
|
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
|
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
|
||||||
DCHECK(!path.empty());
|
DCHECK(!path.empty());
|
||||||
|
|
||||||
base::WriteFile(path, content.data(), content.size());
|
base::WriteFile(path, content.data(), content.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppendToFile(const base::FilePath& path,
|
void AppendToFile(const base::FilePath& path, const std::string& content) {
|
||||||
const std::string& content) {
|
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
|
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
|
||||||
DCHECK(!path.empty());
|
DCHECK(!path.empty());
|
||||||
|
|
||||||
|
@ -140,8 +132,7 @@ std::set<std::string> GetAddedFileSystemPaths(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsDevToolsFileSystemAdded(
|
bool IsDevToolsFileSystemAdded(content::WebContents* web_contents,
|
||||||
content::WebContents* web_contents,
|
|
||||||
const std::string& file_system_path) {
|
const std::string& file_system_path) {
|
||||||
auto file_system_paths = GetAddedFileSystemPaths(web_contents);
|
auto file_system_paths = GetAddedFileSystemPaths(web_contents);
|
||||||
return file_system_paths.find(file_system_path) != file_system_paths.end();
|
return file_system_paths.find(file_system_path) != file_system_paths.end();
|
||||||
|
@ -154,11 +145,9 @@ CommonWebContentsDelegate::CommonWebContentsDelegate()
|
||||||
ignore_menu_shortcuts_(false),
|
ignore_menu_shortcuts_(false),
|
||||||
html_fullscreen_(false),
|
html_fullscreen_(false),
|
||||||
native_fullscreen_(false),
|
native_fullscreen_(false),
|
||||||
devtools_file_system_indexer_(new DevToolsFileSystemIndexer) {
|
devtools_file_system_indexer_(new DevToolsFileSystemIndexer) {}
|
||||||
}
|
|
||||||
|
|
||||||
CommonWebContentsDelegate::~CommonWebContentsDelegate() {
|
CommonWebContentsDelegate::~CommonWebContentsDelegate() {}
|
||||||
}
|
|
||||||
|
|
||||||
void CommonWebContentsDelegate::InitWithWebContents(
|
void CommonWebContentsDelegate::InitWithWebContents(
|
||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
|
@ -183,7 +172,8 @@ void CommonWebContentsDelegate::SetOwnerWindow(NativeWindow* owner_window) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonWebContentsDelegate::SetOwnerWindow(
|
void CommonWebContentsDelegate::SetOwnerWindow(
|
||||||
content::WebContents* web_contents, NativeWindow* owner_window) {
|
content::WebContents* web_contents,
|
||||||
|
NativeWindow* owner_window) {
|
||||||
owner_window_ = owner_window ? owner_window->GetWeakPtr() : nullptr;
|
owner_window_ = owner_window ? owner_window->GetWeakPtr() : nullptr;
|
||||||
auto relay = std::make_unique<NativeWindowRelay>(owner_window_);
|
auto relay = std::make_unique<NativeWindowRelay>(owner_window_);
|
||||||
auto relay_key = relay->key;
|
auto relay_key = relay->key;
|
||||||
|
@ -213,8 +203,8 @@ content::WebContents* CommonWebContentsDelegate::GetWebContents() const {
|
||||||
return web_contents_->GetWebContents();
|
return web_contents_->GetWebContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
content::WebContents*
|
content::WebContents* CommonWebContentsDelegate::GetDevToolsWebContents()
|
||||||
CommonWebContentsDelegate::GetDevToolsWebContents() const {
|
const {
|
||||||
if (!web_contents_)
|
if (!web_contents_)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
return web_contents_->GetDevToolsWebContents();
|
return web_contents_->GetDevToolsWebContents();
|
||||||
|
@ -264,7 +254,8 @@ void CommonWebContentsDelegate::EnumerateDirectory(content::WebContents* guest,
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonWebContentsDelegate::EnterFullscreenModeForTab(
|
void CommonWebContentsDelegate::EnterFullscreenModeForTab(
|
||||||
content::WebContents* source, const GURL& origin) {
|
content::WebContents* source,
|
||||||
|
const GURL& origin) {
|
||||||
if (!owner_window_)
|
if (!owner_window_)
|
||||||
return;
|
return;
|
||||||
SetHtmlApiFullscreen(true);
|
SetHtmlApiFullscreen(true);
|
||||||
|
@ -298,8 +289,9 @@ blink::WebSecurityStyle CommonWebContentsDelegate::GetSecurityStyle(
|
||||||
security_style_explanations);
|
security_style_explanations);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonWebContentsDelegate::DevToolsSaveToFile(
|
void CommonWebContentsDelegate::DevToolsSaveToFile(const std::string& url,
|
||||||
const std::string& url, const std::string& content, bool save_as) {
|
const std::string& content,
|
||||||
|
bool save_as) {
|
||||||
base::FilePath path;
|
base::FilePath path;
|
||||||
auto it = saved_files_.find(url);
|
auto it = saved_files_.find(url);
|
||||||
if (it != saved_files_.end() && !save_as) {
|
if (it != saved_files_.end() && !save_as) {
|
||||||
|
@ -312,22 +304,22 @@ void CommonWebContentsDelegate::DevToolsSaveToFile(
|
||||||
settings.default_path = base::FilePath::FromUTF8Unsafe(url);
|
settings.default_path = base::FilePath::FromUTF8Unsafe(url);
|
||||||
if (!file_dialog::ShowSaveDialog(settings, &path)) {
|
if (!file_dialog::ShowSaveDialog(settings, &path)) {
|
||||||
base::Value url_value(url);
|
base::Value url_value(url);
|
||||||
web_contents_->CallClientFunction(
|
web_contents_->CallClientFunction("DevToolsAPI.canceledSaveURL",
|
||||||
"DevToolsAPI.canceledSaveURL", &url_value, nullptr, nullptr);
|
&url_value, nullptr, nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
saved_files_[url] = path;
|
saved_files_[url] = path;
|
||||||
BrowserThread::PostTaskAndReply(
|
BrowserThread::PostTaskAndReply(
|
||||||
BrowserThread::FILE, FROM_HERE,
|
BrowserThread::FILE, FROM_HERE, base::Bind(&WriteToFile, path, content),
|
||||||
base::Bind(&WriteToFile, path, content),
|
|
||||||
base::Bind(&CommonWebContentsDelegate::OnDevToolsSaveToFile,
|
base::Bind(&CommonWebContentsDelegate::OnDevToolsSaveToFile,
|
||||||
base::Unretained(this), url));
|
base::Unretained(this), url));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonWebContentsDelegate::DevToolsAppendToFile(
|
void CommonWebContentsDelegate::DevToolsAppendToFile(
|
||||||
const std::string& url, const std::string& content) {
|
const std::string& url,
|
||||||
|
const std::string& content) {
|
||||||
auto it = saved_files_.find(url);
|
auto it = saved_files_.find(url);
|
||||||
if (it == saved_files_.end())
|
if (it == saved_files_.end())
|
||||||
return;
|
return;
|
||||||
|
@ -344,19 +336,18 @@ void CommonWebContentsDelegate::DevToolsRequestFileSystems() {
|
||||||
if (file_system_paths.empty()) {
|
if (file_system_paths.empty()) {
|
||||||
base::ListValue empty_file_system_value;
|
base::ListValue empty_file_system_value;
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.fileSystemsLoaded",
|
web_contents_->CallClientFunction("DevToolsAPI.fileSystemsLoaded",
|
||||||
&empty_file_system_value,
|
&empty_file_system_value, nullptr,
|
||||||
nullptr, nullptr);
|
nullptr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<FileSystem> file_systems;
|
std::vector<FileSystem> file_systems;
|
||||||
for (const auto& file_system_path : file_system_paths) {
|
for (const auto& file_system_path : file_system_paths) {
|
||||||
base::FilePath path = base::FilePath::FromUTF8Unsafe(file_system_path);
|
base::FilePath path = base::FilePath::FromUTF8Unsafe(file_system_path);
|
||||||
std::string file_system_id = RegisterFileSystem(GetDevToolsWebContents(),
|
std::string file_system_id =
|
||||||
path);
|
RegisterFileSystem(GetDevToolsWebContents(), path);
|
||||||
FileSystem file_system = CreateFileSystemStruct(GetDevToolsWebContents(),
|
FileSystem file_system = CreateFileSystemStruct(
|
||||||
file_system_id,
|
GetDevToolsWebContents(), file_system_id, file_system_path);
|
||||||
file_system_path);
|
|
||||||
file_systems.push_back(file_system);
|
file_systems.push_back(file_system);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,25 +373,23 @@ void CommonWebContentsDelegate::DevToolsAddFileSystem(
|
||||||
path = paths[0];
|
path = paths[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string file_system_id = RegisterFileSystem(GetDevToolsWebContents(),
|
std::string file_system_id =
|
||||||
path);
|
RegisterFileSystem(GetDevToolsWebContents(), path);
|
||||||
if (IsDevToolsFileSystemAdded(GetDevToolsWebContents(), path.AsUTF8Unsafe()))
|
if (IsDevToolsFileSystemAdded(GetDevToolsWebContents(), path.AsUTF8Unsafe()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FileSystem file_system = CreateFileSystemStruct(GetDevToolsWebContents(),
|
FileSystem file_system = CreateFileSystemStruct(
|
||||||
file_system_id,
|
GetDevToolsWebContents(), file_system_id, path.AsUTF8Unsafe());
|
||||||
path.AsUTF8Unsafe());
|
|
||||||
std::unique_ptr<base::DictionaryValue> file_system_value(
|
std::unique_ptr<base::DictionaryValue> file_system_value(
|
||||||
CreateFileSystemValue(file_system));
|
CreateFileSystemValue(file_system));
|
||||||
|
|
||||||
auto pref_service = GetPrefService(GetDevToolsWebContents());
|
auto pref_service = GetPrefService(GetDevToolsWebContents());
|
||||||
DictionaryPrefUpdate update(pref_service, prefs::kDevToolsFileSystemPaths);
|
DictionaryPrefUpdate update(pref_service, prefs::kDevToolsFileSystemPaths);
|
||||||
update.Get()->SetWithoutPathExpansion(
|
update.Get()->SetWithoutPathExpansion(path.AsUTF8Unsafe(),
|
||||||
path.AsUTF8Unsafe(), std::make_unique<base::Value>());
|
std::make_unique<base::Value>());
|
||||||
|
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.fileSystemAdded",
|
web_contents_->CallClientFunction("DevToolsAPI.fileSystemAdded",
|
||||||
file_system_value.get(),
|
file_system_value.get(), nullptr, nullptr);
|
||||||
nullptr, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonWebContentsDelegate::DevToolsRemoveFileSystem(
|
void CommonWebContentsDelegate::DevToolsRemoveFileSystem(
|
||||||
|
@ -409,8 +398,8 @@ void CommonWebContentsDelegate::DevToolsRemoveFileSystem(
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string path = file_system_path.AsUTF8Unsafe();
|
std::string path = file_system_path.AsUTF8Unsafe();
|
||||||
storage::IsolatedContext::GetInstance()->
|
storage::IsolatedContext::GetInstance()->RevokeFileSystemByPath(
|
||||||
RevokeFileSystemByPath(file_system_path);
|
file_system_path);
|
||||||
|
|
||||||
auto pref_service = GetPrefService(GetDevToolsWebContents());
|
auto pref_service = GetPrefService(GetDevToolsWebContents());
|
||||||
DictionaryPrefUpdate update(pref_service, prefs::kDevToolsFileSystemPaths);
|
DictionaryPrefUpdate update(pref_service, prefs::kDevToolsFileSystemPaths);
|
||||||
|
@ -418,8 +407,7 @@ void CommonWebContentsDelegate::DevToolsRemoveFileSystem(
|
||||||
|
|
||||||
base::Value file_system_path_value(path);
|
base::Value file_system_path_value(path);
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.fileSystemRemoved",
|
web_contents_->CallClientFunction("DevToolsAPI.fileSystemRemoved",
|
||||||
&file_system_path_value,
|
&file_system_path_value, nullptr, nullptr);
|
||||||
nullptr, nullptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonWebContentsDelegate::DevToolsIndexPath(
|
void CommonWebContentsDelegate::DevToolsIndexPath(
|
||||||
|
@ -437,16 +425,11 @@ void CommonWebContentsDelegate::DevToolsIndexPath(
|
||||||
file_system_path,
|
file_system_path,
|
||||||
base::Bind(
|
base::Bind(
|
||||||
&CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated,
|
&CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated,
|
||||||
base::Unretained(this),
|
base::Unretained(this), request_id, file_system_path),
|
||||||
request_id,
|
|
||||||
file_system_path),
|
|
||||||
base::Bind(&CommonWebContentsDelegate::OnDevToolsIndexingWorked,
|
base::Bind(&CommonWebContentsDelegate::OnDevToolsIndexingWorked,
|
||||||
base::Unretained(this),
|
base::Unretained(this), request_id, file_system_path),
|
||||||
request_id,
|
|
||||||
file_system_path),
|
|
||||||
base::Bind(&CommonWebContentsDelegate::OnDevToolsIndexingDone,
|
base::Bind(&CommonWebContentsDelegate::OnDevToolsIndexingDone,
|
||||||
base::Unretained(this),
|
base::Unretained(this), request_id,
|
||||||
request_id,
|
|
||||||
file_system_path)));
|
file_system_path)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,34 +446,28 @@ void CommonWebContentsDelegate::DevToolsSearchInPath(
|
||||||
const std::string& file_system_path,
|
const std::string& file_system_path,
|
||||||
const std::string& query) {
|
const std::string& query) {
|
||||||
if (!IsDevToolsFileSystemAdded(GetDevToolsWebContents(), file_system_path)) {
|
if (!IsDevToolsFileSystemAdded(GetDevToolsWebContents(), file_system_path)) {
|
||||||
OnDevToolsSearchCompleted(request_id,
|
OnDevToolsSearchCompleted(request_id, file_system_path,
|
||||||
file_system_path,
|
|
||||||
std::vector<std::string>());
|
std::vector<std::string>());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
devtools_file_system_indexer_->SearchInPath(
|
devtools_file_system_indexer_->SearchInPath(
|
||||||
file_system_path,
|
file_system_path, query,
|
||||||
query,
|
|
||||||
base::Bind(&CommonWebContentsDelegate::OnDevToolsSearchCompleted,
|
base::Bind(&CommonWebContentsDelegate::OnDevToolsSearchCompleted,
|
||||||
base::Unretained(this),
|
base::Unretained(this), request_id, file_system_path));
|
||||||
request_id,
|
|
||||||
file_system_path));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonWebContentsDelegate::OnDevToolsSaveToFile(
|
void CommonWebContentsDelegate::OnDevToolsSaveToFile(const std::string& url) {
|
||||||
const std::string& url) {
|
|
||||||
// Notify DevTools.
|
// Notify DevTools.
|
||||||
base::Value url_value(url);
|
base::Value url_value(url);
|
||||||
web_contents_->CallClientFunction(
|
web_contents_->CallClientFunction("DevToolsAPI.savedURL", &url_value, nullptr,
|
||||||
"DevToolsAPI.savedURL", &url_value, nullptr, nullptr);
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonWebContentsDelegate::OnDevToolsAppendToFile(
|
void CommonWebContentsDelegate::OnDevToolsAppendToFile(const std::string& url) {
|
||||||
const std::string& url) {
|
|
||||||
// Notify DevTools.
|
// Notify DevTools.
|
||||||
base::Value url_value(url);
|
base::Value url_value(url);
|
||||||
web_contents_->CallClientFunction(
|
web_contents_->CallClientFunction("DevToolsAPI.appendedToURL", &url_value,
|
||||||
"DevToolsAPI.appendedToURL", &url_value, nullptr, nullptr);
|
nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated(
|
void CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated(
|
||||||
|
@ -501,8 +478,7 @@ void CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated(
|
||||||
base::Value file_system_path_value(file_system_path);
|
base::Value file_system_path_value(file_system_path);
|
||||||
base::Value total_work_value(total_work);
|
base::Value total_work_value(total_work);
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.indexingTotalWorkCalculated",
|
web_contents_->CallClientFunction("DevToolsAPI.indexingTotalWorkCalculated",
|
||||||
&request_id_value,
|
&request_id_value, &file_system_path_value,
|
||||||
&file_system_path_value,
|
|
||||||
&total_work_value);
|
&total_work_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,8 +490,7 @@ void CommonWebContentsDelegate::OnDevToolsIndexingWorked(
|
||||||
base::Value file_system_path_value(file_system_path);
|
base::Value file_system_path_value(file_system_path);
|
||||||
base::Value worked_value(worked);
|
base::Value worked_value(worked);
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.indexingWorked",
|
web_contents_->CallClientFunction("DevToolsAPI.indexingWorked",
|
||||||
&request_id_value,
|
&request_id_value, &file_system_path_value,
|
||||||
&file_system_path_value,
|
|
||||||
&worked_value);
|
&worked_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,8 +501,7 @@ void CommonWebContentsDelegate::OnDevToolsIndexingDone(
|
||||||
base::Value request_id_value(request_id);
|
base::Value request_id_value(request_id);
|
||||||
base::Value file_system_path_value(file_system_path);
|
base::Value file_system_path_value(file_system_path);
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.indexingDone",
|
web_contents_->CallClientFunction("DevToolsAPI.indexingDone",
|
||||||
&request_id_value,
|
&request_id_value, &file_system_path_value,
|
||||||
&file_system_path_value,
|
|
||||||
nullptr);
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,8 +516,7 @@ void CommonWebContentsDelegate::OnDevToolsSearchCompleted(
|
||||||
base::Value request_id_value(request_id);
|
base::Value request_id_value(request_id);
|
||||||
base::Value file_system_path_value(file_system_path);
|
base::Value file_system_path_value(file_system_path);
|
||||||
web_contents_->CallClientFunction("DevToolsAPI.searchCompleted",
|
web_contents_->CallClientFunction("DevToolsAPI.searchCompleted",
|
||||||
&request_id_value,
|
&request_id_value, &file_system_path_value,
|
||||||
&file_system_path_value,
|
|
||||||
&file_paths_value);
|
&file_paths_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,8 +92,7 @@ class CommonWebContentsDelegate
|
||||||
|
|
||||||
// Autofill related events.
|
// Autofill related events.
|
||||||
#if defined(TOOLKIT_VIEWS)
|
#if defined(TOOLKIT_VIEWS)
|
||||||
void ShowAutofillPopup(
|
void ShowAutofillPopup(bool offscreen,
|
||||||
bool offscreen,
|
|
||||||
content::RenderFrameHost* frame_host,
|
content::RenderFrameHost* frame_host,
|
||||||
const gfx::RectF& bounds,
|
const gfx::RectF& bounds,
|
||||||
const std::vector<base::string16>& values,
|
const std::vector<base::string16>& values,
|
||||||
|
@ -123,8 +122,8 @@ class CommonWebContentsDelegate
|
||||||
gfx::ImageSkia GetDevToolsWindowIcon() override;
|
gfx::ImageSkia GetDevToolsWindowIcon() override;
|
||||||
#endif
|
#endif
|
||||||
#if defined(USE_X11)
|
#if defined(USE_X11)
|
||||||
void GetDevToolsWindowWMClass(
|
void GetDevToolsWindowWMClass(std::string* name,
|
||||||
std::string* name, std::string* class_name) override;
|
std::string* class_name) override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Destroy the managed InspectableWebContents object.
|
// Destroy the managed InspectableWebContents object.
|
||||||
|
@ -187,9 +186,8 @@ class CommonWebContentsDelegate
|
||||||
PathsMap saved_files_;
|
PathsMap saved_files_;
|
||||||
|
|
||||||
// Map id to index job, used for file system indexing requests from devtools.
|
// Map id to index job, used for file system indexing requests from devtools.
|
||||||
typedef std::map<
|
typedef std::
|
||||||
int,
|
map<int, scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob>>
|
||||||
scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob>>
|
|
||||||
DevToolsIndexingJobsMap;
|
DevToolsIndexingJobsMap;
|
||||||
DevToolsIndexingJobsMap devtools_indexing_jobs_;
|
DevToolsIndexingJobsMap devtools_indexing_jobs_;
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,8 @@ void CommonWebContentsDelegate::ShowAutofillPopup(
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto* window = static_cast<NativeWindowViews*>(owner_window());
|
auto* window = static_cast<NativeWindowViews*>(owner_window());
|
||||||
autofill_popup_->CreateView(
|
autofill_popup_->CreateView(frame_host, offscreen, window->content_view(),
|
||||||
frame_host, offscreen, window->content_view(), bounds);
|
bounds);
|
||||||
autofill_popup_->SetItems(values, labels);
|
autofill_popup_->SetItems(values, labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,13 +50,15 @@ void CommonWebContentsDelegate::HideAutofillPopup() {
|
||||||
gfx::ImageSkia CommonWebContentsDelegate::GetDevToolsWindowIcon() {
|
gfx::ImageSkia CommonWebContentsDelegate::GetDevToolsWindowIcon() {
|
||||||
if (!owner_window())
|
if (!owner_window())
|
||||||
return gfx::ImageSkia();
|
return gfx::ImageSkia();
|
||||||
return static_cast<views::WidgetDelegate*>(static_cast<NativeWindowViews*>(
|
return static_cast<views::WidgetDelegate*>(
|
||||||
owner_window()))->GetWindowAppIcon();
|
static_cast<NativeWindowViews*>(owner_window()))
|
||||||
|
->GetWindowAppIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(USE_X11)
|
#if defined(USE_X11)
|
||||||
void CommonWebContentsDelegate::GetDevToolsWindowWMClass(
|
void CommonWebContentsDelegate::GetDevToolsWindowWMClass(
|
||||||
std::string* name, std::string* class_name) {
|
std::string* name,
|
||||||
|
std::string* class_name) {
|
||||||
*class_name = Browser::Get()->GetName();
|
*class_name = Browser::Get()->GetName();
|
||||||
*name = base::ToLowerASCII(*class_name);
|
*name = base::ToLowerASCII(*class_name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,7 @@ JavascriptEnvironment::JavascriptEnvironment()
|
||||||
locker_(isolate_),
|
locker_(isolate_),
|
||||||
handle_scope_(isolate_),
|
handle_scope_(isolate_),
|
||||||
context_(isolate_, v8::Context::New(isolate_)),
|
context_(isolate_, v8::Context::New(isolate_)),
|
||||||
context_scope_(v8::Local<v8::Context>::New(isolate_, context_)) {
|
context_scope_(v8::Local<v8::Context>::New(isolate_, context_)) {}
|
||||||
}
|
|
||||||
|
|
||||||
void JavascriptEnvironment::OnMessageLoopCreated() {
|
void JavascriptEnvironment::OnMessageLoopCreated() {
|
||||||
isolate_holder_.AddRunMicrotasksObserver();
|
isolate_holder_.AddRunMicrotasksObserver();
|
||||||
|
@ -53,15 +52,13 @@ bool JavascriptEnvironment::Initialize() {
|
||||||
v8::V8::InitializePlatform(platform_);
|
v8::V8::InitializePlatform(platform_);
|
||||||
node::tracing::TraceEventHelper::SetTracingController(
|
node::tracing::TraceEventHelper::SetTracingController(
|
||||||
new v8::TracingController());
|
new v8::TracingController());
|
||||||
gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
|
gin::IsolateHolder::Initialize(
|
||||||
gin::IsolateHolder::kStableV8Extras,
|
gin::IsolateHolder::kNonStrictMode, gin::IsolateHolder::kStableV8Extras,
|
||||||
gin::ArrayBufferAllocator::SharedInstance(),
|
gin::ArrayBufferAllocator::SharedInstance(), false);
|
||||||
false);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeEnvironment::NodeEnvironment(node::Environment* env) : env_(env) {
|
NodeEnvironment::NodeEnvironment(node::Environment* env) : env_(env) {}
|
||||||
}
|
|
||||||
|
|
||||||
NodeEnvironment::~NodeEnvironment() {
|
NodeEnvironment::~NodeEnvironment() {
|
||||||
node::FreeEnvironment(env_);
|
node::FreeEnvironment(env_);
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
namespace node {
|
namespace node {
|
||||||
class Environment;
|
class Environment;
|
||||||
class MultiIsolatePlatform;
|
class MultiIsolatePlatform;
|
||||||
}
|
} // namespace node
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,8 @@ namespace mate {
|
||||||
template <>
|
template <>
|
||||||
struct Converter<atom::BluetoothChooser::DeviceInfo> {
|
struct Converter<atom::BluetoothChooser::DeviceInfo> {
|
||||||
static v8::Local<v8::Value> ToV8(
|
static v8::Local<v8::Value> ToV8(
|
||||||
v8::Isolate* isolate, const atom::BluetoothChooser::DeviceInfo& val) {
|
v8::Isolate* isolate,
|
||||||
|
const atom::BluetoothChooser::DeviceInfo& val) {
|
||||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||||
dict.Set("deviceName", val.device_name);
|
dict.Set("deviceName", val.device_name);
|
||||||
dict.Set("deviceId", val.device_id);
|
dict.Set("deviceId", val.device_id);
|
||||||
|
@ -28,8 +29,7 @@ namespace {
|
||||||
|
|
||||||
const int kMaxScanRetries = 5;
|
const int kMaxScanRetries = 5;
|
||||||
|
|
||||||
void OnDeviceChosen(
|
void OnDeviceChosen(const content::BluetoothChooser::EventHandler& handler,
|
||||||
const content::BluetoothChooser::EventHandler& handler,
|
|
||||||
const std::string& device_id) {
|
const std::string& device_id) {
|
||||||
if (device_id.empty()) {
|
if (device_id.empty()) {
|
||||||
handler.Run(content::BluetoothChooser::Event::CANCELLED, device_id);
|
handler.Run(content::BluetoothChooser::Event::CANCELLED, device_id);
|
||||||
|
@ -40,16 +40,13 @@ void OnDeviceChosen(
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
BluetoothChooser::BluetoothChooser(
|
BluetoothChooser::BluetoothChooser(api::WebContents* contents,
|
||||||
api::WebContents* contents,
|
|
||||||
const EventHandler& event_handler)
|
const EventHandler& event_handler)
|
||||||
: api_web_contents_(contents),
|
: api_web_contents_(contents),
|
||||||
event_handler_(event_handler),
|
event_handler_(event_handler),
|
||||||
num_retries_(0) {
|
num_retries_(0) {}
|
||||||
}
|
|
||||||
|
|
||||||
BluetoothChooser::~BluetoothChooser() {
|
BluetoothChooser::~BluetoothChooser() {}
|
||||||
}
|
|
||||||
|
|
||||||
void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) {
|
void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) {
|
||||||
switch (presence) {
|
switch (presence) {
|
||||||
|
@ -69,15 +66,13 @@ void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) {
|
||||||
break;
|
break;
|
||||||
case DiscoveryState::IDLE:
|
case DiscoveryState::IDLE:
|
||||||
if (device_list_.empty()) {
|
if (device_list_.empty()) {
|
||||||
auto event = ++num_retries_ > kMaxScanRetries ? Event::CANCELLED
|
auto event =
|
||||||
: Event::RESCAN;
|
++num_retries_ > kMaxScanRetries ? Event::CANCELLED : Event::RESCAN;
|
||||||
event_handler_.Run(event, "");
|
event_handler_.Run(event, "");
|
||||||
} else {
|
} else {
|
||||||
bool prevent_default =
|
bool prevent_default = api_web_contents_->Emit(
|
||||||
api_web_contents_->Emit("select-bluetooth-device",
|
"select-bluetooth-device", device_list_,
|
||||||
device_list_,
|
base::Bind(&OnDeviceChosen, event_handler_));
|
||||||
base::Bind(&OnDeviceChosen,
|
|
||||||
event_handler_));
|
|
||||||
if (!prevent_default) {
|
if (!prevent_default) {
|
||||||
auto device_id = device_list_[0].device_id;
|
auto device_id = device_list_[0].device_id;
|
||||||
event_handler_.Run(Event::SELECTED, device_id);
|
event_handler_.Run(Event::SELECTED, device_id);
|
||||||
|
@ -100,8 +95,9 @@ void BluetoothChooser::AddOrUpdateDevice(const std::string& device_id,
|
||||||
|
|
||||||
// Emit a select-bluetooth-device handler to allow for user to listen for
|
// Emit a select-bluetooth-device handler to allow for user to listen for
|
||||||
// bluetooth device found.
|
// bluetooth device found.
|
||||||
bool prevent_default = api_web_contents_->Emit("select-bluetooth-device",
|
bool prevent_default =
|
||||||
device_list_, base::Bind(&OnDeviceChosen, event_handler_));
|
api_web_contents_->Emit("select-bluetooth-device", device_list_,
|
||||||
|
base::Bind(&OnDeviceChosen, event_handler_));
|
||||||
|
|
||||||
// If emit not implimented select first device that matches the filters
|
// If emit not implimented select first device that matches the filters
|
||||||
// provided.
|
// provided.
|
||||||
|
|
|
@ -47,14 +47,12 @@ LoginHandler::LoginHandler(net::AuthChallengeInfo* auth_info,
|
||||||
|
|
||||||
BrowserThread::PostTask(
|
BrowserThread::PostTask(
|
||||||
BrowserThread::UI, FROM_HERE,
|
BrowserThread::UI, FROM_HERE,
|
||||||
base::Bind(&Browser::RequestLogin,
|
base::Bind(&Browser::RequestLogin, base::Unretained(Browser::Get()),
|
||||||
base::Unretained(Browser::Get()),
|
|
||||||
base::RetainedRef(WrapRefCounted(this)),
|
base::RetainedRef(WrapRefCounted(this)),
|
||||||
base::Passed(&request_details)));
|
base::Passed(&request_details)));
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginHandler::~LoginHandler() {
|
LoginHandler::~LoginHandler() {}
|
||||||
}
|
|
||||||
|
|
||||||
content::WebContents* LoginHandler::GetWebContents() const {
|
content::WebContents* LoginHandler::GetWebContents() const {
|
||||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||||
|
|
|
@ -16,7 +16,7 @@ class WebContents;
|
||||||
namespace net {
|
namespace net {
|
||||||
class AuthChallengeInfo;
|
class AuthChallengeInfo;
|
||||||
class URLRequest;
|
class URLRequest;
|
||||||
}
|
} // namespace net
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "base/callback.h"
|
#include "base/callback.h"
|
||||||
#include "base/mac/scoped_sending_event.h"
|
|
||||||
#include "base/mac/scoped_nsobject.h"
|
#include "base/mac/scoped_nsobject.h"
|
||||||
|
#include "base/mac/scoped_sending_event.h"
|
||||||
|
|
||||||
@interface AtomApplication : NSApplication <CrAppProtocol,
|
@interface AtomApplication : NSApplication <CrAppProtocol,
|
||||||
CrAppControlProtocol,
|
CrAppControlProtocol,
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
class InspectableWebContents;
|
class InspectableWebContents;
|
||||||
class InspectableWebContentsView;
|
class InspectableWebContentsView;
|
||||||
}
|
} // namespace brightray
|
||||||
|
|
||||||
namespace gfx {
|
namespace gfx {
|
||||||
class Rect;
|
class Rect;
|
||||||
|
|
|
@ -261,75 +261,59 @@ double NativeWindow::GetSheetOffsetY() {
|
||||||
return sheet_offset_y_;
|
return sheet_offset_y_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::SetRepresentedFilename(const std::string& filename) {
|
void NativeWindow::SetRepresentedFilename(const std::string& filename) {}
|
||||||
}
|
|
||||||
|
|
||||||
std::string NativeWindow::GetRepresentedFilename() {
|
std::string NativeWindow::GetRepresentedFilename() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::SetDocumentEdited(bool edited) {
|
void NativeWindow::SetDocumentEdited(bool edited) {}
|
||||||
}
|
|
||||||
|
|
||||||
bool NativeWindow::IsDocumentEdited() {
|
bool NativeWindow::IsDocumentEdited() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::SetFocusable(bool focusable) {
|
void NativeWindow::SetFocusable(bool focusable) {}
|
||||||
}
|
|
||||||
|
|
||||||
void NativeWindow::SetMenu(AtomMenuModel* menu) {
|
void NativeWindow::SetMenu(AtomMenuModel* menu) {}
|
||||||
}
|
|
||||||
|
|
||||||
void NativeWindow::SetParentWindow(NativeWindow* parent) {
|
void NativeWindow::SetParentWindow(NativeWindow* parent) {
|
||||||
parent_ = parent;
|
parent_ = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::SetAutoHideCursor(bool auto_hide) {
|
void NativeWindow::SetAutoHideCursor(bool auto_hide) {}
|
||||||
}
|
|
||||||
|
|
||||||
void NativeWindow::SelectPreviousTab() {
|
void NativeWindow::SelectPreviousTab() {}
|
||||||
}
|
|
||||||
|
|
||||||
void NativeWindow::SelectNextTab() {
|
void NativeWindow::SelectNextTab() {}
|
||||||
}
|
|
||||||
|
|
||||||
void NativeWindow::MergeAllWindows() {
|
void NativeWindow::MergeAllWindows() {}
|
||||||
}
|
|
||||||
|
|
||||||
void NativeWindow::MoveTabToNewWindow() {
|
void NativeWindow::MoveTabToNewWindow() {}
|
||||||
}
|
|
||||||
|
|
||||||
void NativeWindow::ToggleTabBar() {
|
void NativeWindow::ToggleTabBar() {}
|
||||||
}
|
|
||||||
|
|
||||||
bool NativeWindow::AddTabbedWindow(NativeWindow* window) {
|
bool NativeWindow::AddTabbedWindow(NativeWindow* window) {
|
||||||
return true; // for non-Mac platforms
|
return true; // for non-Mac platforms
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::SetVibrancy(const std::string& filename) {
|
void NativeWindow::SetVibrancy(const std::string& filename) {}
|
||||||
}
|
|
||||||
|
|
||||||
void NativeWindow::SetTouchBar(
|
void NativeWindow::SetTouchBar(
|
||||||
const std::vector<mate::PersistentDictionary>& items) {
|
const std::vector<mate::PersistentDictionary>& items) {}
|
||||||
}
|
|
||||||
|
|
||||||
void NativeWindow::RefreshTouchBarItem(const std::string& item_id) {
|
void NativeWindow::RefreshTouchBarItem(const std::string& item_id) {}
|
||||||
}
|
|
||||||
|
|
||||||
void NativeWindow::SetEscapeTouchBarItem(
|
void NativeWindow::SetEscapeTouchBarItem(
|
||||||
const mate::PersistentDictionary& item) {
|
const mate::PersistentDictionary& item) {}
|
||||||
}
|
|
||||||
|
|
||||||
void NativeWindow::SetAutoHideMenuBar(bool auto_hide) {
|
void NativeWindow::SetAutoHideMenuBar(bool auto_hide) {}
|
||||||
}
|
|
||||||
|
|
||||||
bool NativeWindow::IsMenuBarAutoHide() {
|
bool NativeWindow::IsMenuBarAutoHide() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::SetMenuBarVisibility(bool visible) {
|
void NativeWindow::SetMenuBarVisibility(bool visible) {}
|
||||||
}
|
|
||||||
|
|
||||||
bool NativeWindow::IsMenuBarVisible() {
|
bool NativeWindow::IsMenuBarVisible() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -350,11 +334,9 @@ void NativeWindow::SetAspectRatio(double aspect_ratio,
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::PreviewFile(const std::string& path,
|
void NativeWindow::PreviewFile(const std::string& path,
|
||||||
const std::string& display_name) {
|
const std::string& display_name) {}
|
||||||
}
|
|
||||||
|
|
||||||
void NativeWindow::CloseFilePreview() {
|
void NativeWindow::CloseFilePreview() {}
|
||||||
}
|
|
||||||
|
|
||||||
void NativeWindow::NotifyWindowRequestPreferredWith(int* width) {
|
void NativeWindow::NotifyWindowRequestPreferredWith(int* width) {
|
||||||
for (NativeWindowObserver& observer : observers_)
|
for (NativeWindowObserver& observer : observers_)
|
||||||
|
@ -515,8 +497,9 @@ void NativeWindow::NotifyNewWindowForTab() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
void NativeWindow::NotifyWindowMessage(
|
void NativeWindow::NotifyWindowMessage(UINT message,
|
||||||
UINT message, WPARAM w_param, LPARAM l_param) {
|
WPARAM w_param,
|
||||||
|
LPARAM l_param) {
|
||||||
for (NativeWindowObserver& observer : observers_)
|
for (NativeWindowObserver& observer : observers_)
|
||||||
observer.OnWindowMessage(message, w_param, l_param);
|
observer.OnWindowMessage(message, w_param, l_param);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,12 +33,12 @@ class Point;
|
||||||
class Rect;
|
class Rect;
|
||||||
class RectF;
|
class RectF;
|
||||||
class Size;
|
class Size;
|
||||||
}
|
} // namespace gfx
|
||||||
|
|
||||||
namespace mate {
|
namespace mate {
|
||||||
class Dictionary;
|
class Dictionary;
|
||||||
class PersistentDictionary;
|
class PersistentDictionary;
|
||||||
}
|
} // namespace mate
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
|
@ -161,8 +161,7 @@ class NativeWindow : public base::SupportsUserData {
|
||||||
PROGRESS_NORMAL, // progress, not marked (green)
|
PROGRESS_NORMAL, // progress, not marked (green)
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void SetProgressBar(double progress,
|
virtual void SetProgressBar(double progress, const ProgressState state) = 0;
|
||||||
const ProgressState state) = 0;
|
|
||||||
virtual void SetOverlayIcon(const gfx::Image& overlay,
|
virtual void SetOverlayIcon(const gfx::Image& overlay,
|
||||||
const std::string& description) = 0;
|
const std::string& description) = 0;
|
||||||
|
|
||||||
|
@ -255,9 +254,7 @@ class NativeWindow : public base::SupportsUserData {
|
||||||
void NotifyWindowMessage(UINT message, WPARAM w_param, LPARAM l_param);
|
void NotifyWindowMessage(UINT message, WPARAM w_param, LPARAM l_param);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void AddObserver(NativeWindowObserver* obs) {
|
void AddObserver(NativeWindowObserver* obs) { observers_.AddObserver(obs); }
|
||||||
observers_.AddObserver(obs);
|
|
||||||
}
|
|
||||||
void RemoveObserver(NativeWindowObserver* obs) {
|
void RemoveObserver(NativeWindowObserver* obs) {
|
||||||
observers_.RemoveObserver(obs);
|
observers_.RemoveObserver(obs);
|
||||||
}
|
}
|
||||||
|
@ -273,8 +270,7 @@ class NativeWindow : public base::SupportsUserData {
|
||||||
bool is_modal() const { return is_modal_; }
|
bool is_modal() const { return is_modal_; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NativeWindow(const mate::Dictionary& options,
|
NativeWindow(const mate::Dictionary& options, NativeWindow* parent);
|
||||||
NativeWindow* parent);
|
|
||||||
|
|
||||||
void set_browser_view(NativeBrowserView* browser_view) {
|
void set_browser_view(NativeBrowserView* browser_view) {
|
||||||
browser_view_ = browser_view;
|
browser_view_ = browser_view;
|
||||||
|
@ -324,8 +320,8 @@ class NativeWindow : public base::SupportsUserData {
|
||||||
};
|
};
|
||||||
|
|
||||||
// This class provides a hook to get a NativeWindow from a WebContents.
|
// This class provides a hook to get a NativeWindow from a WebContents.
|
||||||
class NativeWindowRelay :
|
class NativeWindowRelay
|
||||||
public content::WebContentsUserData<NativeWindowRelay> {
|
: public content::WebContentsUserData<NativeWindowRelay> {
|
||||||
public:
|
public:
|
||||||
explicit NativeWindowRelay(base::WeakPtr<NativeWindow> window)
|
explicit NativeWindowRelay(base::WeakPtr<NativeWindow> window)
|
||||||
: key(UserDataKey()), window(window) {}
|
: key(UserDataKey()), window(window) {}
|
||||||
|
|
|
@ -21,8 +21,7 @@ namespace atom {
|
||||||
|
|
||||||
class NativeWindowMac : public NativeWindow {
|
class NativeWindowMac : public NativeWindow {
|
||||||
public:
|
public:
|
||||||
NativeWindowMac(const mate::Dictionary& options,
|
NativeWindowMac(const mate::Dictionary& options, NativeWindow* parent);
|
||||||
NativeWindow* parent);
|
|
||||||
~NativeWindowMac() override;
|
~NativeWindowMac() override;
|
||||||
|
|
||||||
// NativeWindow:
|
// NativeWindow:
|
||||||
|
@ -53,10 +52,10 @@ class NativeWindowMac : public NativeWindow {
|
||||||
void MoveTop() override;
|
void MoveTop() override;
|
||||||
bool IsResizable() override;
|
bool IsResizable() override;
|
||||||
void SetMovable(bool movable) override;
|
void SetMovable(bool movable) override;
|
||||||
void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size)
|
void SetAspectRatio(double aspect_ratio,
|
||||||
override;
|
const gfx::Size& extra_size) override;
|
||||||
void PreviewFile(const std::string& path, const std::string& display_name)
|
void PreviewFile(const std::string& path,
|
||||||
override;
|
const std::string& display_name) override;
|
||||||
void CloseFilePreview() override;
|
void CloseFilePreview() override;
|
||||||
bool IsMovable() override;
|
bool IsMovable() override;
|
||||||
void SetMinimizable(bool minimizable) override;
|
void SetMinimizable(bool minimizable) override;
|
||||||
|
@ -67,8 +66,10 @@ class NativeWindowMac : public NativeWindow {
|
||||||
bool IsFullScreenable() override;
|
bool IsFullScreenable() override;
|
||||||
void SetClosable(bool closable) override;
|
void SetClosable(bool closable) override;
|
||||||
bool IsClosable() override;
|
bool IsClosable() override;
|
||||||
void SetAlwaysOnTop(bool top, const std::string& level,
|
void SetAlwaysOnTop(bool top,
|
||||||
int relativeLevel, std::string* error) override;
|
const std::string& level,
|
||||||
|
int relativeLevel,
|
||||||
|
std::string* error) override;
|
||||||
bool IsAlwaysOnTop() override;
|
bool IsAlwaysOnTop() override;
|
||||||
void Center() override;
|
void Center() override;
|
||||||
void Invalidate() override;
|
void Invalidate() override;
|
||||||
|
|
|
@ -102,13 +102,12 @@ class NativeWindowClientView : public views::ClientView {
|
||||||
public:
|
public:
|
||||||
NativeWindowClientView(views::Widget* widget,
|
NativeWindowClientView(views::Widget* widget,
|
||||||
NativeWindowViews* contents_view)
|
NativeWindowViews* contents_view)
|
||||||
: views::ClientView(widget, contents_view) {
|
: views::ClientView(widget, contents_view) {}
|
||||||
}
|
|
||||||
virtual ~NativeWindowClientView() {}
|
virtual ~NativeWindowClientView() {}
|
||||||
|
|
||||||
bool CanClose() override {
|
bool CanClose() override {
|
||||||
static_cast<NativeWindowViews*>(contents_view())->
|
static_cast<NativeWindowViews*>(contents_view())
|
||||||
NotifyWindowCloseButtonClicked();
|
->NotifyWindowCloseButtonClicked();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,8 +195,7 @@ NativeWindowViews::NativeWindowViews(const mate::Dictionary& options,
|
||||||
|
|
||||||
params.native_widget = new AtomDesktopNativeWidgetAura(window_.get());
|
params.native_widget = new AtomDesktopNativeWidgetAura(window_.get());
|
||||||
atom_desktop_window_tree_host_win_ = new AtomDesktopWindowTreeHostWin(
|
atom_desktop_window_tree_host_win_ = new AtomDesktopWindowTreeHostWin(
|
||||||
this,
|
this, window_.get(),
|
||||||
window_.get(),
|
|
||||||
static_cast<views::DesktopNativeWidgetAura*>(params.native_widget));
|
static_cast<views::DesktopNativeWidgetAura*>(params.native_widget));
|
||||||
params.desktop_window_tree_host = atom_desktop_window_tree_host_win_;
|
params.desktop_window_tree_host = atom_desktop_window_tree_host_win_;
|
||||||
#elif defined(USE_X11)
|
#elif defined(USE_X11)
|
||||||
|
@ -227,10 +225,9 @@ NativeWindowViews::NativeWindowViews(const mate::Dictionary& options,
|
||||||
XDisplay* xdisplay = gfx::GetXDisplay();
|
XDisplay* xdisplay = gfx::GetXDisplay();
|
||||||
XChangeProperty(xdisplay, GetAcceleratedWidget(),
|
XChangeProperty(xdisplay, GetAcceleratedWidget(),
|
||||||
XInternAtom(xdisplay, "_GTK_THEME_VARIANT", False),
|
XInternAtom(xdisplay, "_GTK_THEME_VARIANT", False),
|
||||||
XInternAtom(xdisplay, "UTF8_STRING", False),
|
XInternAtom(xdisplay, "UTF8_STRING", False), 8,
|
||||||
8, PropModeReplace,
|
PropModeReplace,
|
||||||
reinterpret_cast<const unsigned char*>("dark"),
|
reinterpret_cast<const unsigned char*>("dark"), 4);
|
||||||
4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Before the window is mapped the SetWMSpecState can not work, so we have
|
// Before the window is mapped the SetWMSpecState can not work, so we have
|
||||||
|
@ -641,8 +638,8 @@ void NativeWindowViews::SetResizable(bool resizable) {
|
||||||
void NativeWindowViews::MoveTop() {
|
void NativeWindowViews::MoveTop() {
|
||||||
gfx::Point pos = GetPosition();
|
gfx::Point pos = GetPosition();
|
||||||
gfx::Size size = GetSize();
|
gfx::Size size = GetSize();
|
||||||
::SetWindowPos(GetAcceleratedWidget(), HWND_TOP,
|
::SetWindowPos(GetAcceleratedWidget(), HWND_TOP, pos.x(), pos.y(),
|
||||||
pos.x(), pos.y(), size.width(), size.height(),
|
size.width(), size.height(),
|
||||||
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
|
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -735,8 +732,10 @@ bool NativeWindowViews::IsClosable() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowViews::SetAlwaysOnTop(bool top, const std::string& level,
|
void NativeWindowViews::SetAlwaysOnTop(bool top,
|
||||||
int relativeLevel, std::string* error) {
|
const std::string& level,
|
||||||
|
int relativeLevel,
|
||||||
|
std::string* error) {
|
||||||
window_->SetAlwaysOnTop(top);
|
window_->SetAlwaysOnTop(top);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -820,9 +819,8 @@ void NativeWindowViews::SetBackgroundColor(SkColor background_color) {
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
// Set the background color of native window.
|
// Set the background color of native window.
|
||||||
HBRUSH brush = CreateSolidBrush(skia::SkColorToCOLORREF(background_color));
|
HBRUSH brush = CreateSolidBrush(skia::SkColorToCOLORREF(background_color));
|
||||||
ULONG_PTR previous_brush = SetClassLongPtr(
|
ULONG_PTR previous_brush =
|
||||||
GetAcceleratedWidget(),
|
SetClassLongPtr(GetAcceleratedWidget(), GCLP_HBRBACKGROUND,
|
||||||
GCLP_HBRBACKGROUND,
|
|
||||||
reinterpret_cast<LONG_PTR>(brush));
|
reinterpret_cast<LONG_PTR>(brush));
|
||||||
if (previous_brush)
|
if (previous_brush)
|
||||||
DeleteObject((HBRUSH)previous_brush);
|
DeleteObject((HBRUSH)previous_brush);
|
||||||
|
@ -830,14 +828,14 @@ void NativeWindowViews::SetBackgroundColor(SkColor background_color) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowViews::SetHasShadow(bool has_shadow) {
|
void NativeWindowViews::SetHasShadow(bool has_shadow) {
|
||||||
wm::SetShadowElevation(
|
wm::SetShadowElevation(GetNativeWindow(), has_shadow
|
||||||
GetNativeWindow(),
|
? wm::ShadowElevation::MEDIUM
|
||||||
has_shadow ? wm::ShadowElevation::MEDIUM : wm::ShadowElevation::NONE);
|
: wm::ShadowElevation::NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeWindowViews::HasShadow() {
|
bool NativeWindowViews::HasShadow() {
|
||||||
return GetNativeWindow()->GetProperty(wm::kShadowElevationKey)
|
return GetNativeWindow()->GetProperty(wm::kShadowElevationKey) !=
|
||||||
!= wm::ShadowElevation::NONE;
|
wm::ShadowElevation::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowViews::SetOpacity(const double opacity) {
|
void NativeWindowViews::SetOpacity(const double opacity) {
|
||||||
|
@ -881,8 +879,8 @@ void NativeWindowViews::SetIgnoreMouseEvents(bool ignore, bool forward) {
|
||||||
XShapeCombineRectangles(gfx::GetXDisplay(), GetAcceleratedWidget(),
|
XShapeCombineRectangles(gfx::GetXDisplay(), GetAcceleratedWidget(),
|
||||||
ShapeInput, 0, 0, &r, 1, ShapeSet, YXBanded);
|
ShapeInput, 0, 0, &r, 1, ShapeSet, YXBanded);
|
||||||
} else {
|
} else {
|
||||||
XShapeCombineMask(gfx::GetXDisplay(), GetAcceleratedWidget(),
|
XShapeCombineMask(gfx::GetXDisplay(), GetAcceleratedWidget(), ShapeInput, 0,
|
||||||
ShapeInput, 0, 0, None, ShapeSet);
|
0, None, ShapeSet);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1024,8 +1022,8 @@ gfx::NativeWindow NativeWindowViews::GetNativeWindow() const {
|
||||||
return window_->GetNativeWindow();
|
return window_->GetNativeWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowViews::SetProgressBar(
|
void NativeWindowViews::SetProgressBar(double progress,
|
||||||
double progress, NativeWindow::ProgressState state) {
|
NativeWindow::ProgressState state) {
|
||||||
#if defined(OS_WIN)
|
#if defined(OS_WIN)
|
||||||
taskbar_host_.SetProgressBar(GetAcceleratedWidget(), progress, state);
|
taskbar_host_.SetProgressBar(GetAcceleratedWidget(), progress, state);
|
||||||
#elif defined(USE_X11)
|
#elif defined(USE_X11)
|
||||||
|
@ -1085,8 +1083,8 @@ bool NativeWindowViews::IsVisibleOnAllWorkspaces() {
|
||||||
XAtom sticky_atom = GetAtom("_NET_WM_STATE_STICKY");
|
XAtom sticky_atom = GetAtom("_NET_WM_STATE_STICKY");
|
||||||
std::vector<XAtom> wm_states;
|
std::vector<XAtom> wm_states;
|
||||||
ui::GetAtomArrayProperty(GetAcceleratedWidget(), "_NET_WM_STATE", &wm_states);
|
ui::GetAtomArrayProperty(GetAcceleratedWidget(), "_NET_WM_STATE", &wm_states);
|
||||||
return std::find(wm_states.begin(),
|
return std::find(wm_states.begin(), wm_states.end(), sticky_atom) !=
|
||||||
wm_states.end(), sticky_atom) != wm_states.end();
|
wm_states.end();
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1165,21 +1163,21 @@ void NativeWindowViews::SetIcon(HICON window_icon, HICON app_icon) {
|
||||||
void NativeWindowViews::SetIcon(const gfx::ImageSkia& icon) {
|
void NativeWindowViews::SetIcon(const gfx::ImageSkia& icon) {
|
||||||
views::DesktopWindowTreeHostX11* tree_host =
|
views::DesktopWindowTreeHostX11* tree_host =
|
||||||
views::DesktopWindowTreeHostX11::GetHostForXID(GetAcceleratedWidget());
|
views::DesktopWindowTreeHostX11::GetHostForXID(GetAcceleratedWidget());
|
||||||
static_cast<views::DesktopWindowTreeHost*>(tree_host)->SetWindowIcons(
|
static_cast<views::DesktopWindowTreeHost*>(tree_host)->SetWindowIcons(icon,
|
||||||
icon, icon);
|
icon);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void NativeWindowViews::OnWidgetActivationChanged(
|
void NativeWindowViews::OnWidgetActivationChanged(views::Widget* widget,
|
||||||
views::Widget* widget, bool active) {
|
bool active) {
|
||||||
if (widget != window_.get())
|
if (widget != window_.get())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Post the notification to next tick.
|
// Post the notification to next tick.
|
||||||
content::BrowserThread::PostTask(
|
content::BrowserThread::PostTask(
|
||||||
content::BrowserThread::UI, FROM_HERE,
|
content::BrowserThread::UI, FROM_HERE,
|
||||||
base::Bind(active ? &NativeWindow::NotifyWindowFocus :
|
base::Bind(active ? &NativeWindow::NotifyWindowFocus
|
||||||
&NativeWindow::NotifyWindowBlur,
|
: &NativeWindow::NotifyWindowBlur,
|
||||||
GetWeakPtr()));
|
GetWeakPtr()));
|
||||||
|
|
||||||
// Hide menu bar when window is blured.
|
// Hide menu bar when window is blured.
|
||||||
|
@ -1189,8 +1187,8 @@ void NativeWindowViews::OnWidgetActivationChanged(
|
||||||
menu_bar_alt_pressed_ = false;
|
menu_bar_alt_pressed_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowViews::OnWidgetBoundsChanged(
|
void NativeWindowViews::OnWidgetBoundsChanged(views::Widget* widget,
|
||||||
views::Widget* widget, const gfx::Rect& bounds) {
|
const gfx::Rect& bounds) {
|
||||||
if (widget != window_.get())
|
if (widget != window_.get())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1199,8 +1197,8 @@ void NativeWindowViews::OnWidgetBoundsChanged(
|
||||||
const auto new_bounds = GetBounds();
|
const auto new_bounds = GetBounds();
|
||||||
if (widget_size_ != new_bounds.size()) {
|
if (widget_size_ != new_bounds.size()) {
|
||||||
if (browser_view()) {
|
if (browser_view()) {
|
||||||
const auto flags = static_cast<NativeBrowserViewViews*>(browser_view())->
|
const auto flags = static_cast<NativeBrowserViewViews*>(browser_view())
|
||||||
GetAutoResizeFlags();
|
->GetAutoResizeFlags();
|
||||||
int width_delta = 0;
|
int width_delta = 0;
|
||||||
int height_delta = 0;
|
int height_delta = 0;
|
||||||
if (flags & kAutoResizeWidth) {
|
if (flags & kAutoResizeWidth) {
|
||||||
|
@ -1285,8 +1283,8 @@ bool NativeWindowViews::ShouldDescendIntoChildForEventHandling(
|
||||||
|
|
||||||
// And the events on border for dragging resizable frameless window.
|
// And the events on border for dragging resizable frameless window.
|
||||||
if (!has_frame() && CanResize()) {
|
if (!has_frame() && CanResize()) {
|
||||||
FramelessView* frame = static_cast<FramelessView*>(
|
FramelessView* frame =
|
||||||
window_->non_client_view()->frame_view());
|
static_cast<FramelessView*>(window_->non_client_view()->frame_view());
|
||||||
return frame->ResizingBorderHitTest(location) == HTNOWHERE;
|
return frame->ResizingBorderHitTest(location) == HTNOWHERE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1328,8 +1326,8 @@ void NativeWindowViews::HandleKeyboardEvent(
|
||||||
|
|
||||||
// Show accelerator when "Alt" is pressed.
|
// Show accelerator when "Alt" is pressed.
|
||||||
if (menu_bar_visible_ && IsAltKey(event))
|
if (menu_bar_visible_ && IsAltKey(event))
|
||||||
menu_bar_->SetAcceleratorVisibility(
|
menu_bar_->SetAcceleratorVisibility(event.GetType() ==
|
||||||
event.GetType() == blink::WebInputEvent::kRawKeyDown);
|
blink::WebInputEvent::kRawKeyDown);
|
||||||
|
|
||||||
// Show the submenu when "Alt+Key" is pressed.
|
// Show the submenu when "Alt+Key" is pressed.
|
||||||
if (event.GetType() == blink::WebInputEvent::kRawKeyDown &&
|
if (event.GetType() == blink::WebInputEvent::kRawKeyDown &&
|
||||||
|
@ -1385,8 +1383,8 @@ gfx::Size NativeWindowViews::GetMaximumSize() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeWindowViews::AcceleratorPressed(const ui::Accelerator& accelerator) {
|
bool NativeWindowViews::AcceleratorPressed(const ui::Accelerator& accelerator) {
|
||||||
return accelerator_util::TriggerAcceleratorTableCommand(
|
return accelerator_util::TriggerAcceleratorTableCommand(&accelerator_table_,
|
||||||
&accelerator_table_, accelerator);
|
accelerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowViews::RegisterAccelerators(AtomMenuModel* menu_model) {
|
void NativeWindowViews::RegisterAccelerators(AtomMenuModel* menu_model) {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue