also format missing .cc files

This commit is contained in:
Shelley Vohr 2018-04-17 21:55:30 -04:00
parent 53bdf22c85
commit c6f4bbd143
No known key found for this signature in database
GPG key ID: F13993A75599653C
181 changed files with 4102 additions and 4254 deletions

View file

@ -61,17 +61,16 @@ content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path,
flash_version_numbers.push_back("999");
// E.g., "Shockwave Flash 10.2 r154":
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, ".");
content::WebPluginMimeType swf_mime_type(
content::kFlashPluginSwfMimeType,
content::kFlashPluginSwfExtension,
content::kFlashPluginSwfDescription);
content::WebPluginMimeType swf_mime_type(content::kFlashPluginSwfMimeType,
content::kFlashPluginSwfExtension,
content::kFlashPluginSwfDescription);
plugin.mime_types.push_back(swf_mime_type);
content::WebPluginMimeType spl_mime_type(
content::kFlashPluginSplMimeType,
content::kFlashPluginSplExtension,
content::kFlashPluginSplDescription);
content::WebPluginMimeType spl_mime_type(content::kFlashPluginSplMimeType,
content::kFlashPluginSplExtension,
content::kFlashPluginSplDescription);
plugin.mime_types.push_back(spl_mime_type);
return plugin;
@ -84,13 +83,11 @@ content::PepperPluginInfo CreateWidevineCdmInfo(const base::FilePath& path,
widevine_cdm.is_out_of_process = true;
widevine_cdm.path = path;
widevine_cdm.name = kWidevineCdmDisplayName;
widevine_cdm.description = kWidevineCdmDescription +
std::string(" (version: ") +
version + ")";
widevine_cdm.description =
kWidevineCdmDescription + std::string(" (version: ") + version + ")";
widevine_cdm.version = version;
content::WebPluginMimeType widevine_cdm_mime_type(
kWidevineCdmPluginMimeType,
kWidevineCdmPluginExtension,
kWidevineCdmPluginMimeType, kWidevineCdmPluginExtension,
kWidevineCdmPluginMimeTypeDescription);
// 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);
if (!string_with_separator.empty())
*vec = base::SplitString(string_with_separator, separator,
base::TRIM_WHITESPACE,
base::SPLIT_WANT_NONEMPTY);
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
}
} // namespace
@ -151,13 +147,13 @@ void ConvertStringWithSeparatorToVector(std::vector<std::string>* vec,
void AddPepperFlashFromCommandLine(
std::vector<content::PepperPluginInfo>* plugins) {
auto command_line = base::CommandLine::ForCurrentProcess();
base::FilePath flash_path = command_line->GetSwitchValuePath(
switches::kPpapiFlashPath);
base::FilePath flash_path =
command_line->GetSwitchValuePath(switches::kPpapiFlashPath);
if (flash_path.empty())
return;
auto flash_version = command_line->GetSwitchValueASCII(
switches::kPpapiFlashVersion);
auto flash_version =
command_line->GetSwitchValueASCII(switches::kPpapiFlashVersion);
plugins->push_back(CreatePepperFlashInfo(flash_path, flash_version));
}
@ -166,38 +162,36 @@ void AddPepperFlashFromCommandLine(
void AddWidevineCdmFromCommandLine(
std::vector<content::PepperPluginInfo>* plugins) {
auto command_line = base::CommandLine::ForCurrentProcess();
base::FilePath widevine_cdm_path = command_line->GetSwitchValuePath(
switches::kWidevineCdmPath);
base::FilePath widevine_cdm_path =
command_line->GetSwitchValuePath(switches::kWidevineCdmPath);
if (widevine_cdm_path.empty())
return;
if (!base::PathExists(widevine_cdm_path))
return;
auto widevine_cdm_version = command_line->GetSwitchValueASCII(
switches::kWidevineCdmVersion);
auto widevine_cdm_version =
command_line->GetSwitchValueASCII(switches::kWidevineCdmVersion);
if (widevine_cdm_version.empty())
return;
plugins->push_back(CreateWidevineCdmInfo(widevine_cdm_path,
widevine_cdm_version));
plugins->push_back(
CreateWidevineCdmInfo(widevine_cdm_path, widevine_cdm_version));
}
#endif // defined(WIDEVINE_CDM_AVAILABLE) && BUILDFLAG(ENABLE_LIBRARY_CDMS)
AtomContentClient::AtomContentClient() {
}
AtomContentClient::AtomContentClient() {}
AtomContentClient::~AtomContentClient() {
}
AtomContentClient::~AtomContentClient() {}
std::string AtomContentClient::GetProduct() const {
return "Chrome/" CHROME_VERSION_STRING;
}
std::string AtomContentClient::GetUserAgent() const {
return content::BuildUserAgentFromProduct(
"Chrome/" CHROME_VERSION_STRING " "
ATOM_PRODUCT_NAME "/" ATOM_VERSION_STRING);
return content::BuildUserAgentFromProduct("Chrome/" CHROME_VERSION_STRING
" " ATOM_PRODUCT_NAME
"/" ATOM_VERSION_STRING);
}
base::string16 AtomContentClient::GetLocalizedString(int message_id) const {

View file

@ -24,7 +24,7 @@
#include "base/win/windows_version.h"
#include "content/public/app/sandbox_helper_win.h"
#include "sandbox/win/src/sandbox_types.h"
#elif defined(OS_LINUX) // defined(OS_WIN)
#elif defined(OS_LINUX) // defined(OS_WIN)
#include "atom/app/atom_main_delegate.h" // NOLINT
#include "content/public/app/content_main.h"
#else // defined(OS_LINUX)
@ -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
// still active. The second invocation from the OS loader will be a no-op.
extern void NTAPI OnThreadExit(PVOID module, DWORD reason, PVOID reserved);
atexit([]() {
OnThreadExit(nullptr, DLL_THREAD_DETACH, nullptr);
});
atexit([]() { OnThreadExit(nullptr, DLL_THREAD_DETACH, nullptr); });
#endif
#ifdef ENABLE_RUN_AS_NODE

View file

@ -45,19 +45,20 @@ bool IsBrowserProcess(base::CommandLine* cmd) {
}
#if defined(OS_WIN)
void InvalidParameterHandler(const wchar_t*, const wchar_t*, const wchar_t*,
unsigned int, uintptr_t) {
void InvalidParameterHandler(const wchar_t*,
const wchar_t*,
const wchar_t*,
unsigned int,
uintptr_t) {
// noop.
}
#endif
} // namespace
AtomMainDelegate::AtomMainDelegate() {
}
AtomMainDelegate::AtomMainDelegate() {}
AtomMainDelegate::~AtomMainDelegate() {
}
AtomMainDelegate::~AtomMainDelegate() {}
bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
auto command_line = base::CommandLine::ForCurrentProcess();
@ -77,7 +78,7 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
#else
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
#endif // defined(DEBUG)
#else // defined(OS_WIN)
#else // defined(OS_WIN)
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
#endif // !defined(OS_WIN)
@ -129,8 +130,8 @@ void AtomMainDelegate::PreSandboxStartup() {
brightray::MainDelegate::PreSandboxStartup();
auto command_line = base::CommandLine::ForCurrentProcess();
std::string process_type = command_line->GetSwitchValueASCII(
::switches::kProcessType);
std::string process_type =
command_line->GetSwitchValueASCII(::switches::kProcessType);
// Only append arguments for browser process.
if (!IsBrowserProcess(command_line))
@ -162,11 +163,11 @@ content::ContentBrowserClient* AtomMainDelegate::CreateContentBrowserClient() {
}
content::ContentRendererClient*
AtomMainDelegate::CreateContentRendererClient() {
AtomMainDelegate::CreateContentRendererClient() {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableSandbox) ||
switches::kEnableSandbox) ||
!base::CommandLine::ForCurrentProcess()->HasSwitch(
::switches::kNoSandbox)) {
::switches::kNoSandbox)) {
renderer_client_.reset(new AtomSandboxedRendererClient);
} else {
renderer_client_.reset(new AtomRendererClient);

File diff suppressed because it is too large Load diff

View file

@ -26,7 +26,7 @@
namespace atom {
int NodeMain(int argc, char *argv[]) {
int NodeMain(int argc, char* argv[]) {
base::CommandLine::Init(argc, argv);
int exit_code = 1;

View file

@ -10,8 +10,7 @@
namespace atom {
UvTaskRunner::UvTaskRunner(uv_loop_t* loop) : loop_(loop) {
}
UvTaskRunner::UvTaskRunner(uv_loop_t* loop) : loop_(loop) {}
UvTaskRunner::~UvTaskRunner() {
for (auto& iter : tasks_) {
@ -35,10 +34,9 @@ bool UvTaskRunner::RunsTasksInCurrentSequence() const {
return true;
}
bool UvTaskRunner::PostNonNestableDelayedTask(
const base::Location& from_here,
base::OnceClosure task,
base::TimeDelta delay) {
bool UvTaskRunner::PostNonNestableDelayedTask(const base::Location& from_here,
base::OnceClosure task,
base::TimeDelta delay) {
return PostDelayedTask(from_here, std::move(task), delay);
}

View file

@ -64,9 +64,10 @@ using atom::Browser;
namespace mate {
#if defined(OS_WIN)
template<>
template <>
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) {
mate::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
@ -83,13 +84,14 @@ struct Converter<Browser::UserTask> {
}
};
using atom::JumpListItem;
using atom::JumpListCategory;
using atom::JumpListItem;
using atom::JumpListResult;
template<>
template <>
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) {
std::string item_type;
if (!ConvertFromV8(isolate, val, &item_type))
@ -127,9 +129,10 @@ struct Converter<JumpListItem::Type> {
}
};
template<>
template <>
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) {
mate::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
@ -189,9 +192,10 @@ struct Converter<JumpListItem> {
}
};
template<>
template <>
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) {
std::string category_type;
if (!ConvertFromV8(isolate, val, &category_type))
@ -235,9 +239,10 @@ struct Converter<JumpListCategory::Type> {
}
};
template<>
template <>
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) {
mate::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
@ -264,7 +269,7 @@ struct Converter<JumpListCategory> {
};
// static
template<>
template <>
struct Converter<JumpListResult> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, JumpListResult val) {
std::string result_code;
@ -298,9 +303,10 @@ struct Converter<JumpListResult> {
};
#endif
template<>
template <>
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) {
mate::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
@ -325,15 +331,16 @@ struct Converter<Browser::LoginItemSettings> {
}
};
template<>
template <>
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) {
bool b;
if (!ConvertFromV8(isolate, val, &b))
return false;
*out = b ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE :
content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL;
*out = b ? content::CERTIFICATE_REQUEST_RESULT_TYPE_CONTINUE
: content::CERTIFICATE_REQUEST_RESULT_TYPE_CANCEL;
return true;
}
};
@ -414,8 +421,8 @@ bool NotificationCallbackWrapper(
} else {
scoped_refptr<base::SingleThreadTaskRunner> task_runner(
base::ThreadTaskRunnerHandle::Get());
task_runner->PostTask(
FROM_HERE, base::Bind(base::IgnoreResult(callback), cmd, cwd));
task_runner->PostTask(FROM_HERE,
base::Bind(base::IgnoreResult(callback), cmd, cwd));
}
// ProcessSingleton needs to know whether current process is quiting.
return !Browser::Get()->is_shutting_down();
@ -479,9 +486,8 @@ void PassLoginInformation(scoped_refptr<LoginHandler> login_handler,
}
#if defined(USE_NSS_CERTS)
int ImportIntoCertStore(
CertificateManagerModel* model,
const base::DictionaryValue& options) {
int ImportIntoCertStore(CertificateManagerModel* model,
const base::DictionaryValue& options) {
std::string file_data, cert_path;
base::string16 password;
net::ScopedCERTCertificateList imported_certs;
@ -492,17 +498,13 @@ int ImportIntoCertStore(
if (!cert_path.empty()) {
if (base::ReadFileToString(base::FilePath(cert_path), &file_data)) {
auto module = model->cert_db()->GetPrivateSlot();
rv = model->ImportFromPKCS12(module.get(),
file_data,
password,
true,
rv = model->ImportFromPKCS12(module.get(), file_data, password, true,
&imported_certs);
if (imported_certs.size() > 1) {
auto it = imported_certs.begin();
++it; // skip first which would be the client certificate.
for (; it != imported_certs.end(); ++it)
rv &= model->SetCertTrust(it->get(),
net::CA_CERT,
rv &= model->SetCertTrust(it->get(), net::CA_CERT,
net::NSSCertDatabase::TRUSTED_SSL);
}
}
@ -521,7 +523,7 @@ void OnIconDataAvailable(v8::Isolate* isolate,
callback.Run(v8::Null(isolate), *icon);
} else {
v8::Local<v8::String> error_message =
v8::String::NewFromUtf8(isolate, "Failed to get file icon.");
v8::String::NewFromUtf8(isolate, "Failed to get file icon.");
callback.Run(v8::Exception::Error(error_message), gfx::Image());
}
}
@ -533,18 +535,16 @@ App::App(v8::Isolate* isolate) {
Browser::Get()->AddObserver(this);
content::GpuDataManager::GetInstance()->AddObserver(this);
base::ProcessId pid = base::GetCurrentProcId();
std::unique_ptr<atom::ProcessMetric> process_metric(
new atom::ProcessMetric(
content::PROCESS_TYPE_BROWSER,
pid,
base::ProcessMetrics::CreateCurrentProcessMetrics()));
std::unique_ptr<atom::ProcessMetric> process_metric(new atom::ProcessMetric(
content::PROCESS_TYPE_BROWSER, pid,
base::ProcessMetrics::CreateCurrentProcessMetrics()));
app_metrics_[pid] = std::move(process_metric);
Init(isolate);
}
App::~App() {
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())->set_delegate(
nullptr);
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())
->set_delegate(nullptr);
Browser::Get()->RemoveObserver(this);
content::GpuDataManager::GetInstance()->RemoveObserver(this);
content::BrowserChildProcessObserver::Remove(this);
@ -609,35 +609,30 @@ void App::OnAccessibilitySupportChanged() {
}
#if defined(OS_MACOSX)
void App::OnWillContinueUserActivity(
bool* prevent_default,
const std::string& type) {
void App::OnWillContinueUserActivity(bool* prevent_default,
const std::string& type) {
*prevent_default = Emit("will-continue-activity", type);
}
void App::OnDidFailToContinueUserActivity(
const std::string& type,
const std::string& error) {
void App::OnDidFailToContinueUserActivity(const std::string& type,
const std::string& error) {
Emit("continue-activity-error", type, error);
}
void App::OnContinueUserActivity(
bool* prevent_default,
const std::string& type,
const base::DictionaryValue& user_info) {
void App::OnContinueUserActivity(bool* prevent_default,
const std::string& type,
const base::DictionaryValue& user_info) {
*prevent_default = Emit("continue-activity", type, user_info);
}
void App::OnUserActivityWasContinued(
const std::string& type,
const base::DictionaryValue& user_info) {
void App::OnUserActivityWasContinued(const std::string& type,
const base::DictionaryValue& user_info) {
Emit("activity-was-continued", type, user_info);
}
void App::OnUpdateUserActivityState(
bool* prevent_default,
const std::string& type,
const base::DictionaryValue& user_info) {
void App::OnUpdateUserActivityState(bool* prevent_default,
const std::string& type,
const base::DictionaryValue& 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();
if (web_contents) {
prevent_default =
Emit("login",
WebContents::CreateFrom(isolate(), web_contents),
request_details,
login_handler->auth_info(),
base::Bind(&PassLoginInformation,
WrapRefCounted(login_handler)));
Emit("login", WebContents::CreateFrom(isolate(), web_contents),
request_details, login_handler->auth_info(),
base::Bind(&PassLoginInformation, WrapRefCounted(login_handler)));
}
// Default behavior is to always cancel the auth.
@ -708,12 +700,9 @@ void App::AllowCertificateError(
callback) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
bool prevent_default = Emit("certificate-error",
WebContents::CreateFrom(isolate(), web_contents),
request_url,
net::ErrorToString(cert_error),
ssl_info.cert,
callback);
bool prevent_default = Emit(
"certificate-error", WebContents::CreateFrom(isolate(), web_contents),
request_url, net::ErrorToString(cert_error), ssl_info.cert, callback);
// Deny the certificate by default.
if (!prevent_default)
@ -725,8 +714,8 @@ void App::SelectClientCertificate(
net::SSLCertRequestInfo* cert_request_info,
net::ClientCertIdentityList identities,
std::unique_ptr<content::ClientCertificateDelegate> delegate) {
std::shared_ptr<content::ClientCertificateDelegate>
shared_delegate(delegate.release());
std::shared_ptr<content::ClientCertificateDelegate> shared_delegate(
delegate.release());
// Convert the ClientCertIdentityList to a CertificateList
// to avoid changes in the API.
@ -756,7 +745,7 @@ void App::SelectClientCertificate(
void App::OnGpuProcessCrashed(base::TerminationStatus status) {
Emit("gpu-process-crashed",
status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED);
status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED);
}
void App::BrowserChildProcessLaunchedAndConnected(
@ -918,8 +907,9 @@ bool App::Relaunch(mate::Arguments* js_args) {
void App::DisableHardwareAcceleration(mate::Arguments* args) {
if (Browser::Get()->is_ready()) {
args->ThrowError("app.disableHardwareAcceleration() can only be called "
"before app is ready");
args->ThrowError(
"app.disableHardwareAcceleration() can only be called "
"before app is ready");
return;
}
content::GpuDataManager::GetInstance()->DisableHardwareAcceleration();
@ -958,18 +948,15 @@ Browser::LoginItemSettings App::GetLoginItemSettings(mate::Arguments* args) {
}
#if defined(USE_NSS_CERTS)
void App::ImportCertificate(
const base::DictionaryValue& options,
const net::CompletionCallback& callback) {
void App::ImportCertificate(const base::DictionaryValue& options,
const net::CompletionCallback& callback) {
auto browser_context = AtomBrowserContext::From("", false);
if (!certificate_manager_model_) {
std::unique_ptr<base::DictionaryValue> copy = options.CreateDeepCopy();
CertificateManagerModel::Create(
browser_context.get(),
base::Bind(&App::OnCertificateManagerModelCreated,
base::Unretained(this),
base::Passed(&copy),
callback));
base::Unretained(this), base::Passed(&copy), callback));
return;
}
@ -982,8 +969,8 @@ void App::OnCertificateManagerModelCreated(
const net::CompletionCallback& callback,
std::unique_ptr<CertificateManagerModel> model) {
certificate_manager_model_ = std::move(model);
int rv = ImportIntoCertStore(certificate_manager_model_.get(),
*(options.get()));
int rv =
ImportIntoCertStore(certificate_manager_model_.get(), *(options.get()));
callback.Run(rv);
}
#endif
@ -1012,7 +999,7 @@ JumpListResult App::SetJumpList(v8::Local<v8::Value> val,
std::vector<JumpListCategory> categories;
bool delete_jump_list = val->IsNull();
if (!delete_jump_list &&
!mate::ConvertFromV8(args->isolate(), val, &categories)) {
!mate::ConvertFromV8(args->isolate(), val, &categories)) {
args->ThrowError("Argument must be null or an array of categories");
return JumpListResult::ARGUMENT_ERROR;
}
@ -1020,9 +1007,8 @@ JumpListResult App::SetJumpList(v8::Local<v8::Value> val,
JumpList jump_list(Browser::Get()->GetAppUserModelID());
if (delete_jump_list) {
return jump_list.Delete()
? JumpListResult::SUCCESS
: JumpListResult::GENERIC_ERROR;
return jump_list.Delete() ? JumpListResult::SUCCESS
: JumpListResult::GENERIC_ERROR;
}
// Start a transaction that updates the JumpList of this application.
@ -1045,8 +1031,7 @@ JumpListResult App::SetJumpList(v8::Local<v8::Value> val,
}
#endif // defined(OS_WIN)
void App::GetFileIcon(const base::FilePath& path,
mate::Arguments* args) {
void App::GetFileIcon(const base::FilePath& path, mate::Arguments* args) {
mate::Dictionary options;
IconLoader::IconSize icon_size;
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 cpu_dict = mate::Dictionary::CreateEmpty(isolate);
memory_dict.Set("workingSetSize",
memory_dict.Set(
"workingSetSize",
static_cast<double>(
process_metric.second->metrics->GetWorkingSetSize() >> 10));
memory_dict.Set("peakWorkingSetSize",
memory_dict.Set(
"peakWorkingSetSize",
static_cast<double>(
process_metric.second->metrics->GetPeakWorkingSetSize() >> 10));
@ -1106,13 +1093,14 @@ std::vector<mate::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
}
pid_dict.Set("memory", memory_dict);
cpu_dict.Set("percentCPUUsage",
process_metric.second->metrics->GetPlatformIndependentCPUUsage()
/ processor_count);
cpu_dict.Set(
"percentCPUUsage",
process_metric.second->metrics->GetPlatformIndependentCPUUsage() /
processor_count);
#if !defined(OS_WIN)
cpu_dict.Set("idleWakeupsPerSecond",
process_metric.second->metrics->GetIdleWakeupsPerSecond());
process_metric.second->metrics->GetIdleWakeupsPerSecond());
#else
// Chrome's underlying process_metrics.cc will throw a non-fatal warning
// that this method isn't implemented on Windows, so set it to 0 instead
@ -1122,8 +1110,8 @@ std::vector<mate::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) {
pid_dict.Set("cpu", cpu_dict);
pid_dict.Set("pid", process_metric.second->pid);
pid_dict.Set("type",
content::GetProcessTypeNameInEnglish(process_metric.second->type));
pid_dict.Set("type", content::GetProcessTypeNameInEnglish(
process_metric.second->type));
result.push_back(pid_dict);
}
@ -1138,8 +1126,9 @@ v8::Local<v8::Value> App::GetGPUFeatureStatus(v8::Isolate* isolate) {
void App::EnableMixedSandbox(mate::Arguments* args) {
if (Browser::Get()->is_ready()) {
args->ThrowError("app.enableMixedSandbox() can only be called "
"before app is ready");
args->ThrowError(
"app.enableMixedSandbox() can only be called "
"before app is ready");
return;
}
@ -1179,8 +1168,8 @@ mate::Handle<App> App::Create(v8::Isolate* isolate) {
}
// static
void App::BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
void App::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "App"));
auto browser = base::Unretained(Browser::Get());
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
@ -1255,15 +1244,15 @@ void App::BuildPrototype(
.SetMethod("getFileIcon", &App::GetFileIcon)
.SetMethod("getAppMetrics", &App::GetAppMetrics)
.SetMethod("getGPUFeatureStatus", &App::GetGPUFeatureStatus)
// TODO(juturu): Remove in 2.0, deprecate before then with warnings
#if defined(OS_MACOSX)
// TODO(juturu): Remove in 2.0, deprecate before then with warnings
#if defined(OS_MACOSX)
.SetMethod("moveToApplicationsFolder", &App::MoveToApplicationsFolder)
.SetMethod("isInApplicationsFolder", &App::IsInApplicationsFolder)
#endif
#if defined(MAS_BUILD)
#endif
#if defined(MAS_BUILD)
.SetMethod("startAccessingSecurityScopedResource",
&App::StartAccessingSecurityScopedResource)
#endif
#endif
.SetMethod("enableMixedSandbox", &App::EnableMixedSandbox);
}
@ -1271,7 +1260,6 @@ void App::BuildPrototype(
} // namespace atom
namespace {
void AppendSwitch(const std::string& switch_string, mate::Arguments* args) {
@ -1308,8 +1296,10 @@ void DockSetMenu(atom::api::Menu* menu) {
}
#endif
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
auto command_line = base::CommandLine::ForCurrentProcess();
@ -1317,9 +1307,8 @@ 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::Create(isolate));
dict.SetMethod("appendSwitch", &AppendSwitch);
dict.SetMethod("appendArgument",
base::Bind(&base::CommandLine::AppendArg,
base::Unretained(command_line)));
dict.SetMethod("appendArgument", base::Bind(&base::CommandLine::AppendArg,
base::Unretained(command_line)));
#if defined(OS_MACOSX)
auto browser = base::Unretained(Browser::Get());
dict.SetMethod("dockBounce", &DockBounce);

View file

@ -16,12 +16,12 @@
namespace mate {
template<>
template <>
struct Converter<base::Time> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const base::Time& val) {
v8::MaybeLocal<v8::Value> date = v8::Date::New(
isolate->GetCurrentContext(), val.ToJsTime());
v8::MaybeLocal<v8::Value> date =
v8::Date::New(isolate->GetCurrentContext(), val.ToJsTime());
if (date.IsEmpty())
return v8::Null(isolate);
else
@ -49,21 +49,20 @@ void AutoUpdater::OnError(const std::string& message) {
v8::HandleScope handle_scope(isolate());
auto error = v8::Exception::Error(mate::StringToV8(isolate(), message));
mate::EmitEvent(
isolate(),
GetWrapper(),
"error",
isolate(), GetWrapper(), "error",
error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked(),
// Message is also emitted to keep compatibility with old code.
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::HandleScope handle_scope(isolate());
auto error = v8::Exception::Error(mate::StringToV8(isolate(), message));
auto errorObject = error->ToObject(
isolate()->GetCurrentContext()).ToLocalChecked();
auto errorObject =
error->ToObject(isolate()->GetCurrentContext()).ToLocalChecked();
// add two new params for better error handling
errorObject->Set(mate::StringToV8(isolate(), "code"),
@ -123,8 +122,8 @@ mate::Handle<AutoUpdater> AutoUpdater::Create(v8::Isolate* isolate) {
}
// static
void AutoUpdater::BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
void AutoUpdater::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "AutoUpdater"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.SetMethod("checkForUpdates", &auto_updater::AutoUpdater::CheckForUpdates)
@ -137,13 +136,14 @@ void AutoUpdater::BuildPrototype(
} // namespace atom
namespace {
using atom::api::AutoUpdater;
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("autoUpdater", AutoUpdater::Create(isolate));

View file

@ -153,9 +153,9 @@ void Initialize(v8::Local<v8::Object> exports,
mate::Dictionary browser_view(
isolate, BrowserView::GetConstructor(isolate)->GetFunction());
browser_view.SetMethod("fromId",
&mate::TrackableObject<BrowserView>::FromWeakMapID);
&mate::TrackableObject<BrowserView>::FromWeakMapID);
browser_view.SetMethod("getAllViews",
&mate::TrackableObject<BrowserView>::GetAll);
&mate::TrackableObject<BrowserView>::GetAll);
mate::Dictionary dict(isolate, exports);
dict.Set("BrowserView", browser_view);
}

View file

@ -29,8 +29,7 @@ namespace api {
BrowserWindow::BrowserWindow(v8::Isolate* isolate,
v8::Local<v8::Object> wrapper,
const mate::Dictionary& options)
: TopLevelWindow(isolate, wrapper, options),
weak_factory_(this) {
: TopLevelWindow(isolate, wrapper, options), weak_factory_(this) {
mate::Handle<class WebContents> web_contents;
// Use options.webPreferences in WebContents.
@ -69,8 +68,8 @@ BrowserWindow::BrowserWindow(v8::Isolate* isolate,
Observe(api_web_contents_->web_contents());
// Keep a copy of the options for later use.
mate::Dictionary(isolate, web_contents->GetWrapper()).Set(
"browserWindowOptions", options);
mate::Dictionary(isolate, web_contents->GetWrapper())
.Set("browserWindowOptions", options);
// Tell the content module to initialize renderer widget with transparent
// mode.
@ -142,11 +141,12 @@ void BrowserWindow::DidFirstVisuallyNonEmptyPaint() {
// Emit the ReadyToShow event in next tick in case of pending drawing work.
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind([](base::WeakPtr<BrowserWindow> self) {
if (self)
self->Emit("ready-to-show");
}, GetWeakPtr()));
FROM_HERE, base::Bind(
[](base::WeakPtr<BrowserWindow> self) {
if (self)
self->Emit("ready-to-show");
},
GetWeakPtr()));
}
void BrowserWindow::BeforeUnloadDialogCancelled() {
@ -339,9 +339,7 @@ std::unique_ptr<SkRegion> BrowserWindow::DraggableRegionsToSkRegion(
std::unique_ptr<SkRegion> sk_region(new SkRegion);
for (const DraggableRegion& region : regions) {
sk_region->op(
region.bounds.x(),
region.bounds.y(),
region.bounds.right(),
region.bounds.x(), region.bounds.y(), region.bounds.right(),
region.bounds.bottom(),
region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op);
}
@ -355,8 +353,7 @@ void BrowserWindow::ScheduleUnresponsiveEvent(int ms) {
window_unresponsive_closure_.Reset(
base::Bind(&BrowserWindow::NotifyWindowUnresponsive, GetWeakPtr()));
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
window_unresponsive_closure_.callback(),
FROM_HERE, window_unresponsive_closure_.callback(),
base::TimeDelta::FromMilliseconds(ms));
}
@ -397,7 +394,6 @@ mate::WrappableBase* BrowserWindow::New(mate::Arguments* args) {
return new BrowserWindow(args->isolate(), args->GetThis(), options);
}
// static
void BrowserWindow::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
@ -429,8 +425,10 @@ namespace {
using atom::api::BrowserWindow;
using atom::api::TopLevelWindow;
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
// Calling SetConstructor would only use TopLevelWindow's prototype.
v8::Local<v8::FunctionTemplate> templ = CreateFunctionTemplate(
@ -443,11 +441,9 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
mate::Dictionary browser_window(isolate, templ->GetFunction());
browser_window.SetMethod(
"fromId",
&mate::TrackableObject<TopLevelWindow>::FromWeakMapID);
browser_window.SetMethod(
"getAllWindows",
&mate::TrackableObject<TopLevelWindow>::GetAll);
"fromId", &mate::TrackableObject<TopLevelWindow>::FromWeakMapID);
browser_window.SetMethod("getAllWindows",
&mate::TrackableObject<TopLevelWindow>::GetAll);
mate::Dictionary dict(isolate, exports);
dict.Set("BrowserWindow", browser_window);

View file

@ -15,8 +15,8 @@ void BrowserWindow::UpdateDraggableRegions(
const std::vector<DraggableRegion>& regions) {
if (window_->has_frame())
return;
static_cast<NativeWindowViews*>(window_.get())->UpdateDraggableRegions(
DraggableRegionsToSkRegion(regions));
static_cast<NativeWindowViews*>(window_.get())
->UpdateDraggableRegions(DraggableRegionsToSkRegion(regions));
}
} // namespace api

View file

@ -18,7 +18,7 @@ using content::TracingController;
namespace mate {
template<>
template <>
struct Converter<base::trace_event::TraceConfig> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
@ -42,14 +42,14 @@ namespace {
using CompletionCallback = base::Callback<void(const base::FilePath&)>;
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;
if (result_file_path.empty() && !base::CreateTemporaryFile(&result_file_path))
LOG(ERROR) << "Creating temporary file failed";
return TracingController::CreateFileEndpoint(result_file_path,
base::Bind(callback,
result_file_path));
return TracingController::CreateFileEndpoint(
result_file_path, base::Bind(callback, result_file_path));
}
void StopRecording(const base::FilePath& path,
@ -58,17 +58,20 @@ void StopRecording(const base::FilePath& path,
GetTraceDataEndpoint(path, callback));
}
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
auto controller = base::Unretained(TracingController::GetInstance());
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("getCategories", base::Bind(
&TracingController::GetCategories, controller));
dict.SetMethod("startRecording", base::Bind(
&TracingController::StartTracing, controller));
dict.SetMethod("getCategories",
base::Bind(&TracingController::GetCategories, controller));
dict.SetMethod("startRecording",
base::Bind(&TracingController::StartTracing, controller));
dict.SetMethod("stopRecording", &StopRecording);
dict.SetMethod("getTraceBufferUsage", base::Bind(
&TracingController::GetTraceBufferUsage, controller));
dict.SetMethod(
"getTraceBufferUsage",
base::Bind(&TracingController::GetTraceBufferUsage, controller));
}
} // namespace

View file

@ -24,7 +24,7 @@ using content::BrowserThread;
namespace mate {
template<>
template <>
struct Converter<atom::api::Cookies::Error> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
atom::api::Cookies::Error val) {
@ -35,7 +35,7 @@ struct Converter<atom::api::Cookies::Error> {
}
};
template<>
template <>
struct Converter<net::CanonicalCookie> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const net::CanonicalCookie& val) {
@ -54,7 +54,7 @@ struct Converter<net::CanonicalCookie> {
}
};
template<>
template <>
struct Converter<net::CookieStore::ChangeCause> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const net::CookieStore::ChangeCause& val) {
@ -165,12 +165,13 @@ void GetCookiesOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
GetCookieStore(getter)->GetAllCookiesAsync(filtered_callback);
else
GetCookieStore(getter)->GetAllCookiesForURLAsync(GURL(url),
filtered_callback);
filtered_callback);
}
// Removes cookie with |url| and |name| in IO thread.
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) {
GetCookieStore(getter)->DeleteCookieAsync(
url, name, base::Bind(RunCallbackInUI, callback));
@ -209,30 +210,29 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
base::Time creation_time;
if (details->GetDouble("creationDate", &creation_date)) {
creation_time = (creation_date == 0) ?
base::Time::UnixEpoch() :
base::Time::FromDoubleT(creation_date);
creation_time = (creation_date == 0)
? base::Time::UnixEpoch()
: base::Time::FromDoubleT(creation_date);
}
base::Time expiration_time;
if (details->GetDouble("expirationDate", &expiration_date)) {
expiration_time = (expiration_date == 0) ?
base::Time::UnixEpoch() :
base::Time::FromDoubleT(expiration_date);
expiration_time = (expiration_date == 0)
? base::Time::UnixEpoch()
: base::Time::FromDoubleT(expiration_date);
}
base::Time last_access_time;
if (details->GetDouble("lastAccessDate", &last_access_date)) {
last_access_time = (last_access_date == 0) ?
base::Time::UnixEpoch() :
base::Time::FromDoubleT(last_access_date);
last_access_time = (last_access_date == 0)
? base::Time::UnixEpoch()
: base::Time::FromDoubleT(last_access_date);
}
GetCookieStore(getter)->SetCookieWithDetailsAsync(
GURL(url), name, value, domain, path, creation_time,
expiration_time, last_access_time, secure, http_only,
net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT,
base::Bind(OnSetCookie, callback));
GURL(url), name, value, domain, path, creation_time, expiration_time,
last_access_time, secure, http_only, net::CookieSameSite::DEFAULT_MODE,
net::COOKIE_PRIORITY_DEFAULT, base::Bind(OnSetCookie, callback));
}
} // namespace
@ -257,7 +257,8 @@ void Cookies::Get(const base::DictionaryValue& filter,
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) {
auto getter = browser_context_->GetRequestContext();
content::BrowserThread::PostTask(
@ -288,11 +289,9 @@ void Cookies::OnCookieChanged(const CookieDetails* details) {
Emit("changed", *(details->cookie), details->cause, details->removed);
}
// static
mate::Handle<Cookies> Cookies::Create(
v8::Isolate* isolate,
AtomBrowserContext* browser_context) {
mate::Handle<Cookies> Cookies::Create(v8::Isolate* isolate,
AtomBrowserContext* browser_context) {
return mate::CreateHandle(isolate, new Cookies(isolate, browser_context));
}

View file

@ -26,13 +26,11 @@ namespace atom {
namespace api {
Debugger::Debugger(v8::Isolate* isolate, content::WebContents* web_contents)
: web_contents_(web_contents),
previous_request_id_(0) {
: web_contents_(web_contents), previous_request_id_(0) {
Init(isolate);
}
Debugger::~Debugger() {
}
Debugger::~Debugger() {}
void Debugger::AgentHostClosed(DevToolsAgentHost* agent_host,
bool replaced_with_another_client) {
@ -144,9 +142,8 @@ void Debugger::SendCommand(mate::Arguments* args) {
}
// static
mate::Handle<Debugger> Debugger::Create(
v8::Isolate* isolate,
content::WebContents* web_contents) {
mate::Handle<Debugger> Debugger::Create(v8::Isolate* isolate,
content::WebContents* web_contents) {
return mate::CreateHandle(isolate, new Debugger(isolate, web_contents));
}
@ -169,8 +166,10 @@ namespace {
using atom::api::Debugger;
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary(isolate, exports)
.Set("Debugger", Debugger::GetConstructor(isolate)->GetFunction());

View file

@ -53,14 +53,13 @@ DesktopCapturer::DesktopCapturer(v8::Isolate* isolate) {
Init(isolate);
}
DesktopCapturer::~DesktopCapturer() {
}
DesktopCapturer::~DesktopCapturer() {}
void DesktopCapturer::StartHandling(bool capture_window,
bool capture_screen,
const gfx::Size& thumbnail_size) {
webrtc::DesktopCaptureOptions options =
content::CreateDesktopCaptureOptions();
content::CreateDesktopCaptureOptions();
#if defined(OS_WIN)
using_directx_capturer_ = options.allow_directx_capturer();
#endif // defined(OS_WIN)
@ -71,27 +70,22 @@ void DesktopCapturer::StartHandling(bool capture_window,
std::unique_ptr<webrtc::DesktopCapturer> window_capturer(
capture_window ? webrtc::DesktopCapturer::CreateWindowCapturer(options)
: nullptr);
media_list_.reset(new NativeDesktopMediaList(
std::move(screen_capturer), std::move(window_capturer)));
media_list_.reset(new NativeDesktopMediaList(std::move(screen_capturer),
std::move(window_capturer)));
media_list_->SetThumbnailSize(thumbnail_size);
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() {
const auto media_list_sources = media_list_->GetSources();
@ -131,14 +125,13 @@ bool DesktopCapturer::OnRefreshFinished() {
for (auto& source : sources) {
if (source.media_list_source.id.type ==
content::DesktopMediaID::TYPE_SCREEN) {
source.display_id =
base::Int64ToString(source.media_list_source.id.id);
source.display_id = base::Int64ToString(source.media_list_source.id.id);
}
}
#endif // defined(OS_WIN)
// TODO(ajmacd): Add Linux support. The IDs across APIs differ but Chrome only
// supports capturing the entire desktop on Linux. Revisit this if individual
// screen support is added.
// TODO(ajmacd): Add Linux support. The IDs across APIs differ but Chrome only
// supports capturing the entire desktop on Linux. Revisit this if individual
// screen support is added.
Emit("finished", sources);
return false;
@ -151,7 +144,8 @@ mate::Handle<DesktopCapturer> DesktopCapturer::Create(v8::Isolate* isolate) {
// static
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"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.SetMethod("startHandling", &DesktopCapturer::StartHandling);
@ -163,8 +157,10 @@ void DesktopCapturer::BuildPrototype(
namespace {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("desktopCapturer", atom::api::DesktopCapturer::Create(isolate));

View file

@ -21,7 +21,7 @@
namespace mate {
template<>
template <>
struct Converter<file_dialog::Filter> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
@ -37,7 +37,7 @@ struct Converter<file_dialog::Filter> {
}
};
template<>
template <>
struct Converter<file_dialog::DialogSettings> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
@ -54,9 +54,9 @@ struct Converter<file_dialog::DialogSettings> {
dict.Get("filters", &(out->filters));
dict.Get("properties", &(out->properties));
dict.Get("showsTagField", &(out->shows_tag_field));
#if defined(MAS_BUILD)
#if defined(MAS_BUILD)
dict.Get("securityScopedBookmarks", &(out->security_scoped_bookmarks));
#endif
#endif
return true;
}
};
@ -80,8 +80,7 @@ void ShowMessageBox(int type,
mate::Arguments* args) {
v8::Local<v8::Value> peek = args->PeekNext();
atom::MessageBoxCallback callback;
if (mate::Converter<atom::MessageBoxCallback>::FromV8(args->isolate(),
peek,
if (mate::Converter<atom::MessageBoxCallback>::FromV8(args->isolate(), peek,
&callback)) {
atom::ShowMessageBox(window, static_cast<atom::MessageBoxType>(type),
buttons, default_id, cancel_id, options, title,
@ -99,9 +98,8 @@ void ShowOpenDialog(const file_dialog::DialogSettings& settings,
mate::Arguments* args) {
v8::Local<v8::Value> peek = args->PeekNext();
file_dialog::OpenDialogCallback callback;
if (mate::Converter<file_dialog::OpenDialogCallback>::FromV8(args->isolate(),
peek,
&callback)) {
if (mate::Converter<file_dialog::OpenDialogCallback>::FromV8(
args->isolate(), peek, &callback)) {
file_dialog::ShowOpenDialog(settings, callback);
} else {
std::vector<base::FilePath> paths;
@ -114,9 +112,8 @@ void ShowSaveDialog(const file_dialog::DialogSettings& settings,
mate::Arguments* args) {
v8::Local<v8::Value> peek = args->PeekNext();
file_dialog::SaveDialogCallback callback;
if (mate::Converter<file_dialog::SaveDialogCallback>::FromV8(args->isolate(),
peek,
&callback)) {
if (mate::Converter<file_dialog::SaveDialogCallback>::FromV8(
args->isolate(), peek, &callback)) {
file_dialog::ShowSaveDialog(settings, callback);
} else {
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,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("showMessageBox", &ShowMessageBox);
dict.SetMethod("showErrorBox", &atom::ShowErrorBox);

View file

@ -19,7 +19,7 @@
namespace mate {
template<>
template <>
struct Converter<content::DownloadItem::DownloadState> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
content::DownloadItem::DownloadState state) {
@ -79,8 +79,8 @@ void DownloadItem::OnDownloadUpdated(content::DownloadItem* item) {
if (download_item_->IsDone()) {
Emit("done", item->GetState());
// Destroy the item once item is downloaded.
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, GetDestroyClosure());
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
GetDestroyClosure());
} else {
Emit("updated", item->GetState());
}
@ -129,12 +129,11 @@ bool DownloadItem::HasUserGesture() const {
}
std::string DownloadItem::GetFilename() const {
return base::UTF16ToUTF8(net::GenerateFileName(GetURL(),
GetContentDisposition(),
std::string(),
download_item_->GetSuggestedFilename(),
GetMimeType(),
"download").LossyDisplayName());
return base::UTF16ToUTF8(
net::GenerateFileName(GetURL(), GetContentDisposition(), std::string(),
download_item_->GetSuggestedFilename(),
GetMimeType(), "download")
.LossyDisplayName());
}
std::string DownloadItem::GetContentDisposition() const {
@ -206,8 +205,8 @@ void DownloadItem::BuildPrototype(v8::Isolate* isolate,
}
// static
mate::Handle<DownloadItem> DownloadItem::Create(
v8::Isolate* isolate, content::DownloadItem* item) {
mate::Handle<DownloadItem> DownloadItem::Create(v8::Isolate* isolate,
content::DownloadItem* item) {
auto existing = TrackableObject::FromWrappedClass(isolate, item);
if (existing)
return mate::CreateHandle(isolate, static_cast<DownloadItem*>(existing));
@ -226,8 +225,10 @@ mate::Handle<DownloadItem> DownloadItem::Create(
namespace {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary(isolate, exports)
.Set("DownloadItem",

View file

@ -40,8 +40,8 @@ void GlobalShortcut::OnKeyPressed(const ui::Accelerator& accelerator) {
bool GlobalShortcut::Register(const ui::Accelerator& accelerator,
const base::Closure& callback) {
if (!GlobalShortcutListener::GetInstance()->RegisterAccelerator(
accelerator, this)) {
if (!GlobalShortcutListener::GetInstance()->RegisterAccelerator(accelerator,
this)) {
return false;
}
@ -54,8 +54,8 @@ void GlobalShortcut::Unregister(const ui::Accelerator& accelerator) {
return;
accelerator_callback_map_.erase(accelerator);
GlobalShortcutListener::GetInstance()->UnregisterAccelerator(
accelerator, this);
GlobalShortcutListener::GetInstance()->UnregisterAccelerator(accelerator,
this);
}
bool GlobalShortcut::IsRegistered(const ui::Accelerator& accelerator) {
@ -73,8 +73,8 @@ mate::Handle<GlobalShortcut> GlobalShortcut::Create(v8::Isolate* isolate) {
}
// static
void GlobalShortcut::BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
void GlobalShortcut::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "GlobalShortcut"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.SetMethod("register", &GlobalShortcut::Register)
@ -89,8 +89,10 @@ void GlobalShortcut::BuildPrototype(
namespace {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("globalShortcut", atom::api::GlobalShortcut::Create(isolate));

View file

@ -99,8 +99,7 @@ InAppPurchase::InAppPurchase(v8::Isolate* isolate) {
Init(isolate);
}
InAppPurchase::~InAppPurchase() {
}
InAppPurchase::~InAppPurchase() {}
void InAppPurchase::PurchaseProduct(const std::string& product_id,
mate::Arguments* args) {

View file

@ -20,8 +20,7 @@ namespace atom {
namespace api {
Menu::Menu(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
: model_(new AtomMenuModel(this)),
parent_(nullptr) {
: model_(new AtomMenuModel(this)), parent_(nullptr) {
InitWith(isolate, wrapper);
model_->AddObserver(this);
}
@ -70,18 +69,17 @@ bool Menu::GetAcceleratorForCommandIdWithParams(
ui::Accelerator* accelerator) const {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
v8::Local<v8::Value> val = get_accelerator_.Run(
GetWrapper(), command_id, use_default_accelerator);
v8::Local<v8::Value> val =
get_accelerator_.Run(GetWrapper(), command_id, use_default_accelerator);
return mate::ConvertFromV8(isolate(), val, accelerator);
}
void Menu::ExecuteCommand(int command_id, int flags) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
execute_command_.Run(
GetWrapper(),
mate::internal::CreateEventFromFlags(isolate(), flags),
command_id);
execute_command_.Run(GetWrapper(),
mate::internal::CreateEventFromFlags(isolate(), flags),
command_id);
}
void Menu::MenuWillShow(ui::SimpleMenuModel* source) {
@ -90,8 +88,9 @@ void Menu::MenuWillShow(ui::SimpleMenuModel* source) {
menu_will_show_.Run(GetWrapper());
}
void Menu::InsertItemAt(
int index, int command_id, const base::string16& label) {
void Menu::InsertItemAt(int index,
int command_id,
const base::string16& label) {
model_->InsertItemAt(index, command_id, label);
}
@ -207,13 +206,14 @@ void Menu::BuildPrototype(v8::Isolate* isolate,
} // namespace atom
namespace {
using atom::api::Menu;
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
Menu::SetConstructor(isolate, base::Bind(&Menu::New));

View file

@ -17,12 +17,12 @@ namespace atom {
namespace api {
MenuViews::MenuViews(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
: Menu(isolate, wrapper),
weak_factory_(this) {
}
: Menu(isolate, wrapper), weak_factory_(this) {}
void MenuViews::PopupAt(BrowserWindow* window,
int x, int y, int positioning_item,
int x,
int y,
int positioning_item,
const base::Closure& callback) {
auto* native_window = static_cast<NativeWindowViews*>(window->window());
if (!native_window)
@ -46,14 +46,11 @@ void MenuViews::PopupAt(BrowserWindow* window,
int32_t window_id = window->weak_map_id();
auto close_callback = base::Bind(
&MenuViews::OnClosed, weak_factory_.GetWeakPtr(), window_id, callback);
menu_runners_[window_id] = std::unique_ptr<MenuRunner>(new MenuRunner(
model(), flags, close_callback));
menu_runners_[window_id] = std::unique_ptr<MenuRunner>(
new MenuRunner(model(), flags, close_callback));
menu_runners_[window_id]->RunMenuAt(
native_window->widget(),
NULL,
gfx::Rect(location, gfx::Size()),
views::MENU_ANCHOR_TOPLEFT,
ui::MENU_SOURCE_MOUSE);
native_window->widget(), NULL, gfx::Rect(location, gfx::Size()),
views::MENU_ANCHOR_TOPLEFT, ui::MENU_SOURCE_MOUSE);
}
void MenuViews::ClosePopupAt(int32_t window_id) {

View file

@ -20,10 +20,11 @@
#include "atom/common/node_includes.h"
namespace mate {
template<>
template <>
struct Converter<brightray::NotificationAction> {
static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val,
brightray::NotificationAction* out) {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
brightray::NotificationAction* out) {
mate::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
return false;
@ -36,7 +37,7 @@ struct Converter<brightray::NotificationAction> {
}
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
brightray::NotificationAction val) {
brightray::NotificationAction val) {
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
dict.Set("text", val.text);
dict.Set("type", val.type);
@ -155,7 +156,7 @@ void Notification::SetSound(const base::string16& new_sound) {
}
void Notification::SetActions(
const std::vector<brightray::NotificationAction>& actions) {
const std::vector<brightray::NotificationAction>& actions) {
actions_ = actions;
}
@ -179,8 +180,7 @@ void Notification::NotificationDisplayed() {
Emit("show");
}
void Notification::NotificationDestroyed() {
}
void Notification::NotificationDestroyed() {}
void Notification::NotificationClosed() {
Emit("close");
@ -232,14 +232,12 @@ void Notification::BuildPrototype(v8::Isolate* isolate,
.SetProperty("subtitle", &Notification::GetSubtitle,
&Notification::SetSubtitle)
.SetProperty("body", &Notification::GetBody, &Notification::SetBody)
.SetProperty("silent", &Notification::GetSilent,
&Notification::SetSilent)
.SetProperty("silent", &Notification::GetSilent, &Notification::SetSilent)
.SetProperty("hasReply", &Notification::GetHasReply,
&Notification::SetHasReply)
.SetProperty("replyPlaceholder", &Notification::GetReplyPlaceholder,
&Notification::SetReplyPlaceholder)
.SetProperty("sound", &Notification::GetSound,
&Notification::SetSound)
.SetProperty("sound", &Notification::GetSound, &Notification::SetSound)
.SetProperty("actions", &Notification::GetActions,
&Notification::SetActions)
.SetProperty("closeButtonText", &Notification::GetCloseButtonText,

View file

@ -13,7 +13,7 @@
#include "atom/common/node_includes.h"
namespace mate {
template<>
template <>
struct Converter<ui::IdleState> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const ui::IdleState& in) {
@ -38,11 +38,11 @@ namespace api {
PowerMonitor::PowerMonitor(v8::Isolate* isolate) {
#if defined(OS_LINUX)
SetShutdownHandler(base::Bind(&PowerMonitor::ShouldShutdown,
base::Unretained(this)));
SetShutdownHandler(
base::Bind(&PowerMonitor::ShouldShutdown, base::Unretained(this)));
#elif defined(OS_MACOSX)
Browser::Get()->SetShutdownHandler(base::Bind(&PowerMonitor::ShouldShutdown,
base::Unretained(this)));
Browser::Get()->SetShutdownHandler(
base::Bind(&PowerMonitor::ShouldShutdown, base::Unretained(this)));
#endif
base::PowerMonitor::Get()->AddObserver(this);
Init(isolate);
@ -87,9 +87,8 @@ void PowerMonitor::QuerySystemIdleState(v8::Isolate* isolate,
if (idle_threshold > 0) {
ui::CalculateIdleState(idle_threshold, callback);
} else {
isolate->ThrowException(v8::Exception::TypeError(
mate::StringToV8(isolate,
"Invalid idle threshold, must be greater than 0")));
isolate->ThrowException(v8::Exception::TypeError(mate::StringToV8(
isolate, "Invalid idle threshold, must be greater than 0")));
}
}
@ -110,31 +109,32 @@ v8::Local<v8::Value> PowerMonitor::Create(v8::Isolate* isolate) {
}
// static
void PowerMonitor::BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
void PowerMonitor::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "PowerMonitor"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.MakeDestroyable()
.MakeDestroyable()
#if defined(OS_LINUX)
.SetMethod("blockShutdown", &PowerMonitor::BlockShutdown)
.SetMethod("unblockShutdown", &PowerMonitor::UnblockShutdown)
.SetMethod("blockShutdown", &PowerMonitor::BlockShutdown)
.SetMethod("unblockShutdown", &PowerMonitor::UnblockShutdown)
#endif
.SetMethod("querySystemIdleState", &PowerMonitor::QuerySystemIdleState)
.SetMethod("querySystemIdleTime", &PowerMonitor::QuerySystemIdleTime);
.SetMethod("querySystemIdleState", &PowerMonitor::QuerySystemIdleState)
.SetMethod("querySystemIdleTime", &PowerMonitor::QuerySystemIdleTime);
}
} // namespace api
} // namespace atom
namespace {
using atom::api::PowerMonitor;
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("powerMonitor", PowerMonitor::Create(isolate));

View file

@ -15,7 +15,7 @@ using content::BrowserThread;
namespace mate {
template<>
template <>
struct Converter<device::PowerSaveBlocker::PowerSaveBlockerType> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
@ -46,8 +46,7 @@ PowerSaveBlocker::PowerSaveBlocker(v8::Isolate* isolate)
Init(isolate);
}
PowerSaveBlocker::~PowerSaveBlocker() {
}
PowerSaveBlocker::~PowerSaveBlocker() {}
void PowerSaveBlocker::UpdatePowerSaveBlocker() {
if (power_save_blocker_types_.empty()) {
@ -75,8 +74,7 @@ void PowerSaveBlocker::UpdatePowerSaveBlocker() {
if (!power_save_blocker_ || new_blocker_type != current_blocker_type_) {
std::unique_ptr<device::PowerSaveBlocker> new_blocker(
new device::PowerSaveBlocker(
new_blocker_type,
device::PowerSaveBlocker::kReasonOther,
new_blocker_type, device::PowerSaveBlocker::kReasonOther,
ATOM_PRODUCT_NAME,
BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)));
@ -110,7 +108,8 @@ mate::Handle<PowerSaveBlocker> PowerSaveBlocker::Create(v8::Isolate* isolate) {
// static
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"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.SetMethod("start", &PowerSaveBlocker::Start)
@ -124,8 +123,10 @@ void PowerSaveBlocker::BuildPrototype(
namespace {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("powerSaveBlocker", atom::api::PowerSaveBlocker::Create(isolate));

View file

@ -63,7 +63,7 @@ void RegisterStandardSchemes(const std::vector<std::string>& schemes,
atom::switches::kStandardSchemes, base::JoinString(schemes, ","));
if (secure) {
base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
atom::switches::kSecureSchemes, base::JoinString(schemes, ","));
atom::switches::kSecureSchemes, base::JoinString(schemes, ","));
}
}
@ -72,16 +72,15 @@ Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context)
Init(isolate);
}
Protocol::~Protocol() {
}
Protocol::~Protocol() {}
void Protocol::RegisterServiceWorkerSchemes(
const std::vector<std::string>& schemes) {
atom::AtomBrowserClient::SetCustomServiceWorkerSchemes(schemes);
}
void Protocol::UnregisterProtocol(
const std::string& scheme, mate::Arguments* args) {
void Protocol::UnregisterProtocol(const std::string& scheme,
mate::Arguments* args) {
CompletionCallback callback;
args->GetNext(&callback);
auto getter = browser_context_->GetRequestContext();
@ -121,8 +120,8 @@ bool Protocol::IsProtocolHandledInIO(
return request_context_getter->job_factory()->IsHandledProtocol(scheme);
}
void Protocol::UninterceptProtocol(
const std::string& scheme, mate::Arguments* args) {
void Protocol::UninterceptProtocol(const std::string& scheme,
mate::Arguments* args) {
CompletionCallback callback;
args->GetNext(&callback);
auto getter = browser_context_->GetRequestContext();
@ -138,12 +137,14 @@ Protocol::ProtocolError Protocol::UninterceptProtocolInIO(
scoped_refptr<brightray::URLRequestContextGetter> request_context_getter,
const std::string& scheme) {
return static_cast<AtomURLRequestJobFactory*>(
request_context_getter->job_factory())->UninterceptProtocol(scheme) ?
PROTOCOL_OK : PROTOCOL_NOT_INTERCEPTED;
request_context_getter->job_factory())
->UninterceptProtocol(scheme)
? PROTOCOL_OK
: PROTOCOL_NOT_INTERCEPTED;
}
void Protocol::OnIOCompleted(
const CompletionCallback& callback, ProtocolError error) {
void Protocol::OnIOCompleted(const CompletionCallback& callback,
ProtocolError error) {
// The completion callback is optional.
if (callback.is_null())
return;
@ -161,24 +162,30 @@ void Protocol::OnIOCompleted(
std::string Protocol::ErrorCodeToString(ProtocolError error) {
switch (error) {
case PROTOCOL_FAIL: return "Failed to manipulate protocol factory";
case PROTOCOL_REGISTERED: return "The scheme has been registered";
case PROTOCOL_NOT_REGISTERED: 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";
case PROTOCOL_FAIL:
return "Failed to manipulate protocol factory";
case PROTOCOL_REGISTERED:
return "The scheme has been registered";
case PROTOCOL_NOT_REGISTERED:
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
mate::Handle<Protocol> Protocol::Create(
v8::Isolate* isolate, AtomBrowserContext* browser_context) {
mate::Handle<Protocol> Protocol::Create(v8::Isolate* isolate,
AtomBrowserContext* browser_context) {
return mate::CreateHandle(isolate, new Protocol(isolate, browser_context));
}
// static
void Protocol::BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
void Protocol::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "Protocol"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.SetMethod("registerServiceWorkerSchemes",
@ -214,19 +221,22 @@ void Protocol::BuildPrototype(
namespace {
void RegisterStandardSchemes(
const std::vector<std::string>& schemes, mate::Arguments* args) {
void RegisterStandardSchemes(const std::vector<std::string>& schemes,
mate::Arguments* args) {
if (atom::Browser::Get()->is_ready()) {
args->ThrowError("protocol.registerStandardSchemes should be called before "
"app is ready");
args->ThrowError(
"protocol.registerStandardSchemes should be called before "
"app is ready");
return;
}
atom::api::RegisterStandardSchemes(schemes, args);
}
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.SetMethod("registerStandardSchemes", &RegisterStandardSchemes);

View file

@ -21,8 +21,8 @@ namespace {
bool IsWebContents(v8::Isolate* isolate, content::RenderProcessHost* process) {
content::WebContents* web_contents =
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())->
GetWebContentsFromProcessID(process->GetID());
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())
->GetWebContentsFromProcessID(process->GetID());
if (!web_contents)
return false;
@ -41,8 +41,7 @@ RenderProcessPreferences::RenderProcessPreferences(
Init(isolate);
}
RenderProcessPreferences::~RenderProcessPreferences() {
}
RenderProcessPreferences::~RenderProcessPreferences() {}
int RenderProcessPreferences::AddEntry(const base::DictionaryValue& entry) {
return preferences_.AddEntry(entry);
@ -54,7 +53,8 @@ void RenderProcessPreferences::RemoveEntry(int id) {
// static
void RenderProcessPreferences::BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(
mate::StringToV8(isolate, "RenderProcessPreferences"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
@ -65,10 +65,9 @@ void RenderProcessPreferences::BuildPrototype(
// static
mate::Handle<RenderProcessPreferences>
RenderProcessPreferences::ForAllWebContents(v8::Isolate* isolate) {
return mate::CreateHandle(
isolate,
new RenderProcessPreferences(isolate,
base::Bind(&IsWebContents, isolate)));
return mate::CreateHandle(isolate,
new RenderProcessPreferences(
isolate, base::Bind(&IsWebContents, isolate)));
}
} // namespace api
@ -77,8 +76,10 @@ RenderProcessPreferences::ForAllWebContents(v8::Isolate* isolate) {
namespace {
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("forAllWebContents",
&atom::api::RenderProcessPreferences::ForAllWebContents);

View file

@ -25,9 +25,9 @@ namespace api {
namespace {
// Find an item in container according to its ID.
template<class T>
template <class T>
typename T::iterator FindById(T* container, int id) {
auto predicate = [id] (const typename T::value_type& item) -> bool {
auto predicate = [id](const typename T::value_type& item) -> bool {
return item.id() == id;
};
return std::find_if(container->begin(), container->end(), predicate);
@ -96,15 +96,14 @@ void Screen::OnDisplayMetricsChanged(const display::Display& display,
v8::Local<v8::Value> Screen::Create(v8::Isolate* isolate) {
if (!Browser::Get()->is_ready()) {
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
isolate,
"Cannot require \"screen\" module before app is ready")));
isolate, "Cannot require \"screen\" module before app is ready")));
return v8::Null(isolate);
}
display::Screen* screen = display::Screen::GetScreen();
if (!screen) {
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
isolate, "Failed to get screen information")));
isolate->ThrowException(v8::Exception::Error(
mate::StringToV8(isolate, "Failed to get screen information")));
return v8::Null(isolate);
}
@ -112,8 +111,8 @@ v8::Local<v8::Value> Screen::Create(v8::Isolate* isolate) {
}
// static
void Screen::BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
void Screen::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "Screen"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.SetMethod("getCursorScreenPoint", &Screen::GetCursorScreenPoint)
@ -134,8 +133,10 @@ namespace {
using atom::api::Screen;
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("screen", Screen::Create(isolate));

View file

@ -139,7 +139,7 @@ void SetUserAgentInIO(scoped_refptr<net::URLRequestContextGetter> getter,
namespace mate {
template<>
template <>
struct Converter<ClearStorageDataOptions> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
@ -208,7 +208,7 @@ struct Converter<net::ProxyConfig> {
}
};
template<>
template <>
struct Converter<atom::VerifyRequestParams> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
atom::VerifyRequestParams val) {
@ -244,17 +244,15 @@ class ResolveProxyHelper {
scoped_refptr<net::URLRequestContextGetter> context_getter =
browser_context->url_request_context_getter();
context_getter->GetNetworkTaskRunner()->PostTask(
FROM_HERE,
base::Bind(&ResolveProxyHelper::ResolveProxy,
base::Unretained(this), context_getter, url));
FROM_HERE, base::Bind(&ResolveProxyHelper::ResolveProxy,
base::Unretained(this), context_getter, url));
}
void OnResolveProxyCompleted(int result) {
std::string proxy;
if (result == net::OK)
proxy = proxy_info_.ToPacString();
original_thread_->PostTask(FROM_HERE,
base::Bind(callback_, proxy));
original_thread_->PostTask(FROM_HERE, base::Bind(callback_, proxy));
delete this;
}
@ -265,14 +263,13 @@ class ResolveProxyHelper {
net::ProxyService* proxy_service =
context_getter->GetURLRequestContext()->proxy_service();
net::CompletionCallback completion_callback =
base::Bind(&ResolveProxyHelper::OnResolveProxyCompleted,
base::Unretained(this));
net::CompletionCallback completion_callback = base::Bind(
&ResolveProxyHelper::OnResolveProxyCompleted, base::Unretained(this));
// Start the request.
int result = proxy_service->ResolveProxy(
url, "GET", &proxy_info_, completion_callback, &pac_req_, nullptr,
net::NetLogWithSource());
int result = proxy_service->ResolveProxy(url, "GET", &proxy_info_,
completion_callback, &pac_req_,
nullptr, net::NetLogWithSource());
// Completed synchronously.
if (result != net::ERR_IO_PENDING)
@ -291,10 +288,10 @@ class ResolveProxyHelper {
void RunCallbackInUI(const base::Callback<void()>& callback) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback);
}
template<typename ...T>
template <typename... T>
void RunCallbackInUI(const base::Callback<void(T...)>& callback, T... result) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, base::Bind(callback, result...));
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(callback, result...));
}
// Callback of HttpCache::GetBackend.
@ -306,8 +303,8 @@ void OnGetBackend(disk_cache::Backend** backend_ptr,
RunCallbackInUI(callback, result);
} else if (backend_ptr && *backend_ptr) {
if (action == Session::CacheAction::CLEAR) {
(*backend_ptr)->DoomAllEntries(base::Bind(&RunCallbackInUI<int>,
callback));
(*backend_ptr)
->DoomAllEntries(base::Bind(&RunCallbackInUI<int>, callback));
} else if (action == Session::CacheAction::STATS) {
base::StringPairs stats;
(*backend_ptr)->GetStats(&stats);
@ -348,8 +345,8 @@ void SetProxyInIO(scoped_refptr<net::URLRequestContextGetter> getter,
const net::ProxyConfig& config,
const base::Closure& callback) {
auto proxy_service = getter->GetURLRequestContext()->proxy_service();
proxy_service->ResetConfigService(base::WrapUnique(
new net::ProxyConfigServiceFixed(config)));
proxy_service->ResetConfigService(
base::WrapUnique(new net::ProxyConfigServiceFixed(config)));
// Refetches and applies the new pac script if provided.
proxy_service->ForceReloadProxyConfig();
RunCallbackInUI(callback);
@ -359,8 +356,8 @@ void SetCertVerifyProcInIO(
const scoped_refptr<net::URLRequestContextGetter>& context_getter,
const AtomCertVerifier::VerifyProc& proc) {
auto request_context = context_getter->GetURLRequestContext();
static_cast<AtomCertVerifier*>(request_context->cert_verifier())->
SetVerifyProc(proc);
static_cast<AtomCertVerifier*>(request_context->cert_verifier())
->SetVerifyProc(proc);
}
void ClearHostResolverCacheInIO(
@ -437,9 +434,8 @@ void DownloadIdCallback(content::DownloadManager* download_manager,
last_modified, offset, length, std::string(),
content::DownloadItem::INTERRUPTED,
content::DownloadDangerType::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT, false,
base::Time(), false,
std::vector<content::DownloadItem::ReceivedSlice>());
content::DOWNLOAD_INTERRUPT_REASON_NETWORK_TIMEOUT, false, base::Time(),
false, std::vector<content::DownloadItem::ReceivedSlice>());
}
void SetDevToolsNetworkEmulationClientIdInIO(
@ -486,8 +482,8 @@ Session::Session(v8::Isolate* isolate, AtomBrowserContext* browser_context)
: devtools_network_emulation_client_id_(base::GenerateGUID()),
browser_context_(browser_context) {
// Observe DownloadManager to get download notifications.
content::BrowserContext::GetDownloadManager(browser_context)->
AddObserver(this);
content::BrowserContext::GetDownloadManager(browser_context)
->AddObserver(this);
new SessionPreferences(browser_context);
@ -500,8 +496,8 @@ Session::~Session() {
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::BindOnce(ClearJobFactoryInIO, base::RetainedRef(getter)));
content::BrowserContext::GetDownloadManager(browser_context())->
RemoveObserver(this);
content::BrowserContext::GetDownloadManager(browser_context())
->RemoveObserver(this);
DestroyGlobalHandle(isolate(), cookies_);
DestroyGlobalHandle(isolate(), web_request_);
DestroyGlobalHandle(isolate(), protocol_);
@ -529,12 +525,12 @@ void Session::ResolveProxy(const GURL& url, ResolveProxyCallback callback) {
new ResolveProxyHelper(browser_context(), url, callback);
}
template<Session::CacheAction action>
template <Session::CacheAction action>
void Session::DoCacheAction(const net::CompletionCallback& callback) {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&DoCacheActionInIO,
WrapRefCounted(browser_context_->GetRequestContext()),
action,
WrapRefCounted(browser_context_->GetRequestContext()), action,
callback));
}
@ -554,9 +550,8 @@ void Session::ClearStorageData(mate::Arguments* args) {
}
storage_partition->ClearData(
options.storage_types, options.quota_types, options.origin,
content::StoragePartition::OriginMatcherFunction(),
base::Time(), base::Time::Max(),
base::Bind(&OnClearStorageDataDone, callback));
content::StoragePartition::OriginMatcherFunction(), base::Time(),
base::Time::Max(), base::Bind(&OnClearStorageDataDone, callback));
}
void Session::FlushStorageData() {
@ -575,8 +570,8 @@ void Session::SetProxy(const net::ProxyConfig& config,
}
void Session::SetDownloadPath(const base::FilePath& path) {
browser_context_->prefs()->SetFilePath(
prefs::kDownloadDefaultDirectory, path);
browser_context_->prefs()->SetFilePath(prefs::kDownloadDefaultDirectory,
path);
}
void Session::EnableNetworkEmulation(const mate::Dictionary& options) {
@ -623,10 +618,10 @@ void Session::SetCertVerifyProc(v8::Local<v8::Value> val,
return;
}
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&SetCertVerifyProcInIO,
WrapRefCounted(browser_context_->GetRequestContext()),
proc));
WrapRefCounted(browser_context_->GetRequestContext()), proc));
}
void Session::SetPermissionRequestHandler(v8::Local<v8::Value> val,
@ -645,7 +640,8 @@ void Session::ClearHostResolverCache(mate::Arguments* args) {
base::Closure callback;
args->GetNext(&callback);
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&ClearHostResolverCacheInIO,
WrapRefCounted(browser_context_->GetRequestContext()),
callback));
@ -663,12 +659,13 @@ void Session::ClearAuthCache(mate::Arguments* args) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&ClearAuthCacheInIO,
WrapRefCounted(browser_context_->GetRequestContext()),
options, callback));
WrapRefCounted(browser_context_->GetRequestContext()), options,
callback));
}
void Session::AllowNTLMCredentialsForDomains(const std::string& domains) {
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&AllowNTLMCredentialsForDomainsInIO,
WrapRefCounted(browser_context_->GetRequestContext()),
domains));
@ -692,19 +689,16 @@ std::string Session::GetUserAgent() {
return browser_context_->GetUserAgent();
}
void Session::GetBlobData(
const std::string& uuid,
const AtomBlobReader::CompletionCallback& callback) {
void Session::GetBlobData(const std::string& uuid,
const AtomBlobReader::CompletionCallback& callback) {
if (callback.is_null())
return;
AtomBlobReader* blob_reader =
browser_context()->GetBlobReader();
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
base::Bind(&AtomBlobReader::StartReading,
base::Unretained(blob_reader),
uuid,
callback));
AtomBlobReader* blob_reader = browser_context()->GetBlobReader();
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&AtomBlobReader::StartReading, base::Unretained(blob_reader),
uuid, callback));
}
void Session::CreateInterruptedDownload(const mate::Dictionary& options) {
@ -776,14 +770,14 @@ v8::Local<v8::Value> Session::WebRequest(v8::Isolate* isolate) {
}
// static
mate::Handle<Session> Session::CreateFrom(
v8::Isolate* isolate, AtomBrowserContext* browser_context) {
mate::Handle<Session> Session::CreateFrom(v8::Isolate* isolate,
AtomBrowserContext* browser_context) {
auto existing = TrackableObject::FromWrappedClass(isolate, browser_context);
if (existing)
return mate::CreateHandle(isolate, static_cast<Session*>(existing));
auto handle = mate::CreateHandle(
isolate, new Session(isolate, browser_context));
auto handle =
mate::CreateHandle(isolate, new Session(isolate, browser_context));
// The Sessions should never be garbage collected, since the common pattern is
// to use partition strings, instead of using the Session object directly.
@ -795,7 +789,8 @@ mate::Handle<Session> Session::CreateFrom(
// static
mate::Handle<Session> Session::FromPartition(
v8::Isolate* isolate, const std::string& partition,
v8::Isolate* isolate,
const std::string& partition,
const base::DictionaryValue& options) {
scoped_refptr<AtomBrowserContext> browser_context;
if (partition.empty()) {
@ -852,8 +847,8 @@ namespace {
using atom::api::Session;
v8::Local<v8::Value> FromPartition(
const std::string& partition, mate::Arguments* args) {
v8::Local<v8::Value> FromPartition(const std::string& partition,
mate::Arguments* args) {
if (!atom::Browser::Get()->is_ready()) {
args->ThrowError("Session can only be received when app is ready");
return v8::Null(args->isolate());
@ -863,8 +858,10 @@ v8::Local<v8::Value> FromPartition(
return Session::FromPartition(args->isolate(), partition, options).ToV8();
}
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("Session", Session::GetConstructor(isolate)->GetFunction());

View file

@ -45,7 +45,8 @@ mate::Handle<SystemPreferences> SystemPreferences::Create(
// static
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"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
#if defined(OS_WIN)
@ -53,8 +54,7 @@ void SystemPreferences::BuildPrototype(
.SetMethod("isAeroGlassEnabled", &SystemPreferences::IsAeroGlassEnabled)
.SetMethod("getColor", &SystemPreferences::GetColor)
#elif defined(OS_MACOSX)
.SetMethod("postNotification",
&SystemPreferences::PostNotification)
.SetMethod("postNotification", &SystemPreferences::PostNotification)
.SetMethod("subscribeNotification",
&SystemPreferences::SubscribeNotification)
.SetMethod("unsubscribeNotification",
@ -91,8 +91,10 @@ namespace {
using atom::api::SystemPreferences;
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("systemPreferences", SystemPreferences::Create(isolate));

View file

@ -17,7 +17,7 @@ namespace atom {
namespace {
const wchar_t kSystemPreferencesWindowClass[] =
L"Electron_SystemPreferencesHostWindow";
L"Electron_SystemPreferencesHostWindow";
} // namespace
@ -130,9 +130,8 @@ void SystemPreferences::InitializeWindow() {
WNDCLASSEX window_class;
base::win::InitializeWindowClass(
kSystemPreferencesWindowClass,
&base::win::WrappedWindowProc<SystemPreferences::WndProcStatic>,
0, 0, 0, NULL, NULL, NULL, NULL, NULL,
&window_class);
&base::win::WrappedWindowProc<SystemPreferences::WndProcStatic>, 0, 0, 0,
NULL, NULL, NULL, NULL, NULL, &window_class);
instance_ = window_class.hInstance;
atom_ = RegisterClassEx(&window_class);
@ -140,16 +139,16 @@ void SystemPreferences::InitializeWindow() {
// colorization color. Create a hidden WS_POPUP window instead of an
// HWND_MESSAGE window, because only top-level windows such as popups can
// receive broadcast messages like "WM_DWMCOLORIZATIONCOLORCHANGED".
window_ = CreateWindow(MAKEINTATOM(atom_),
0, WS_POPUP, 0, 0, 0, 0, 0, 0, instance_, 0);
window_ = CreateWindow(MAKEINTATOM(atom_), 0, WS_POPUP, 0, 0, 0, 0, 0, 0,
instance_, 0);
gfx::CheckWindowCreated(window_);
gfx::SetWindowUserData(window_, this);
}
LRESULT CALLBACK SystemPreferences::WndProcStatic(HWND hwnd,
UINT message,
WPARAM wparam,
LPARAM lparam) {
UINT message,
WPARAM wparam,
LPARAM lparam) {
SystemPreferences* msg_wnd = reinterpret_cast<SystemPreferences*>(
GetWindowLongPtr(hwnd, GWLP_USERDATA));
if (msg_wnd)
@ -159,11 +158,11 @@ LRESULT CALLBACK SystemPreferences::WndProcStatic(HWND hwnd,
}
LRESULT CALLBACK SystemPreferences::WndProc(HWND hwnd,
UINT message,
WPARAM wparam,
LPARAM lparam) {
UINT message,
WPARAM wparam,
LPARAM lparam) {
if (message == WM_DWMCOLORIZATIONCOLORCHANGED) {
DWORD new_color = (DWORD) wparam;
DWORD new_color = (DWORD)wparam;
std::string new_color_string = hexColorDWORDToRGBA(new_color);
if (new_color_string != current_color_) {
Emit("accent-color-changed", hexColorDWORDToRGBA(new_color));

View file

@ -34,9 +34,10 @@
#if defined(OS_WIN)
namespace mate {
template<>
template <>
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) {
mate::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
@ -82,16 +83,14 @@ TopLevelWindow::TopLevelWindow(v8::Isolate* isolate,
mate::Dictionary web_preferences;
bool offscreen;
if (options.Get(options::kWebPreferences, &web_preferences) &&
web_preferences.Get("offscreen", &offscreen) &&
offscreen) {
web_preferences.Get("offscreen", &offscreen) && offscreen) {
const_cast<mate::Dictionary&>(options).Set(options::kFrame, false);
}
#endif
// Creates NativeWindow.
window_.reset(NativeWindow::Create(
options,
parent.IsEmpty() ? nullptr : parent->window_.get()));
options, parent.IsEmpty() ? nullptr : parent->window_.get()));
window_->AddObserver(this);
#if defined(TOOLKIT_VIEWS)
@ -227,8 +226,9 @@ void TopLevelWindow::OnExecuteWindowsCommand(const std::string& command_name) {
Emit("app-command", command_name);
}
void TopLevelWindow::OnTouchBarItemResult(const std::string& item_id,
const base::DictionaryValue& details) {
void TopLevelWindow::OnTouchBarItemResult(
const std::string& item_id,
const base::DictionaryValue& details) {
Emit("-touch-bar-interaction", item_id, details);
}
@ -238,8 +238,8 @@ void TopLevelWindow::OnNewWindowForTab() {
#if defined(OS_WIN)
void TopLevelWindow::OnWindowMessage(UINT message,
WPARAM w_param,
LPARAM l_param) {
WPARAM w_param,
LPARAM l_param) {
if (IsWindowMessageHooked(message)) {
messages_callback_map_[message].Run(
ToBuffer(isolate(), static_cast<void*>(&w_param), sizeof(WPARAM)),
@ -334,7 +334,7 @@ gfx::Rect TopLevelWindow::GetBounds() {
}
void TopLevelWindow::SetContentBounds(const gfx::Rect& bounds,
mate::Arguments* args) {
mate::Arguments* args) {
bool animate = false;
args->GetNext(&animate);
window_->SetContentBounds(bounds, animate);
@ -358,8 +358,9 @@ std::vector<int> TopLevelWindow::GetSize() {
return result;
}
void TopLevelWindow::SetContentSize(int width, int height,
mate::Arguments* args) {
void TopLevelWindow::SetContentSize(int width,
int height,
mate::Arguments* args) {
bool animate = false;
args->GetNext(&animate);
window_->SetContentSize(gfx::Size(width, height), animate);
@ -580,16 +581,15 @@ void TopLevelWindow::SetMenu(v8::Isolate* isolate, v8::Local<v8::Value> value) {
mate::Handle<Menu> menu;
if (value->IsObject() &&
mate::V8ToString(value->ToObject()->GetConstructorName()) == "Menu" &&
mate::ConvertFromV8(isolate, value, &menu) &&
!menu.IsEmpty()) {
mate::ConvertFromV8(isolate, value, &menu) && !menu.IsEmpty()) {
menu_.Reset(isolate, menu.ToV8());
window_->SetMenu(menu->model());
} else if (value->IsNull()) {
menu_.Reset();
window_->SetMenu(nullptr);
} else {
isolate->ThrowException(v8::Exception::TypeError(
mate::StringToV8(isolate, "Invalid Menu")));
isolate->ThrowException(
v8::Exception::TypeError(mate::StringToV8(isolate, "Invalid Menu")));
}
}
@ -789,19 +789,19 @@ bool TopLevelWindow::SetThumbarButtons(mate::Arguments* args) {
#if defined(TOOLKIT_VIEWS)
void TopLevelWindow::SetIcon(mate::Handle<NativeImage> icon) {
#if defined(OS_WIN)
static_cast<NativeWindowViews*>(window_.get())->SetIcon(
icon->GetHICON(GetSystemMetrics(SM_CXSMICON)),
icon->GetHICON(GetSystemMetrics(SM_CXICON)));
static_cast<NativeWindowViews*>(window_.get())
->SetIcon(icon->GetHICON(GetSystemMetrics(SM_CXSMICON)),
icon->GetHICON(GetSystemMetrics(SM_CXICON)));
#elif defined(USE_X11)
static_cast<NativeWindowViews*>(window_.get())->SetIcon(
icon->image().AsImageSkia());
static_cast<NativeWindowViews*>(window_.get())
->SetIcon(icon->image().AsImageSkia());
#endif
}
#endif
#if defined(OS_WIN)
bool TopLevelWindow::HookWindowMessage(UINT message,
const MessageCallback& callback) {
const MessageCallback& callback) {
messages_callback_map_[message] = callback;
return true;
}
@ -846,10 +846,9 @@ void TopLevelWindow::SetAppDetails(const mate::Dictionary& options) {
options.Get("relaunchCommand", &relaunch_command);
options.Get("relaunchDisplayName", &relaunch_display_name);
ui::win::SetAppDetailsForWindow(
app_id, app_icon_path, app_icon_index,
relaunch_command, relaunch_display_name,
window_->GetAcceleratedWidget());
ui::win::SetAppDetailsForWindow(app_id, app_icon_path, app_icon_index,
relaunch_command, relaunch_display_name,
window_->GetAcceleratedWidget());
}
#endif
@ -906,7 +905,7 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
.SetMethod("hide", &TopLevelWindow::Hide)
.SetMethod("isVisible", &TopLevelWindow::IsVisible)
.SetMethod("isEnabled", &TopLevelWindow::IsEnabled)
.SetMethod("setEnabled", & TopLevelWindow::SetEnabled)
.SetMethod("setEnabled", &TopLevelWindow::SetEnabled)
.SetMethod("maximize", &TopLevelWindow::Maximize)
.SetMethod("unmaximize", &TopLevelWindow::Unmaximize)
.SetMethod("isMaximized", &TopLevelWindow::IsMaximized)
@ -932,7 +931,7 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
.SetMethod("isResizable", &TopLevelWindow::IsResizable)
.SetMethod("setMovable", &TopLevelWindow::SetMovable)
#if defined(OS_WIN) || defined(OS_MACOSX)
.SetMethod("moveTop" , &TopLevelWindow::MoveTop)
.SetMethod("moveTop", &TopLevelWindow::MoveTop)
#endif
.SetMethod("isMovable", &TopLevelWindow::IsMovable)
.SetMethod("setMinimizable", &TopLevelWindow::SetMinimizable)
@ -1036,8 +1035,10 @@ namespace {
using atom::api::TopLevelWindow;
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
TopLevelWindow::SetConstructor(isolate, base::Bind(&TopLevelWindow::New));

View file

@ -20,9 +20,10 @@
namespace mate {
template<>
template <>
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) {
std::string mode;
if (ConvertFromV8(isolate, val, &mode)) {
@ -54,12 +55,12 @@ struct Converter<atom::TrayIcon::HighlightMode> {
};
} // namespace mate
namespace atom {
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)
: tray_icon_(TrayIcon::Create()) {
SetImage(isolate, image);
@ -70,8 +71,8 @@ Tray::Tray(v8::Isolate* isolate, v8::Local<v8::Object> wrapper,
Tray::~Tray() {
// Destroy the native tray in next tick.
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(
FROM_HERE, tray_icon_.release());
base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE,
tray_icon_.release());
}
// static
@ -180,8 +181,7 @@ void Tray::DisplayBalloon(mate::Arguments* args,
mate::Handle<NativeImage> icon;
options.Get("icon", &icon);
base::string16 title, content;
if (!options.Get("title", &title) ||
!options.Get("content", &content)) {
if (!options.Get("title", &title) || !options.Get("content", &content)) {
args->ThrowError("'title' and 'content' must be defined");
return;
}
@ -191,8 +191,8 @@ void Tray::DisplayBalloon(mate::Arguments* args,
icon.IsEmpty() ? NULL : icon->GetHICON(GetSystemMetrics(SM_CXSMICON)),
title, content);
#else
tray_icon_->DisplayBalloon(
icon.IsEmpty() ? gfx::Image() : icon->image(), title, content);
tray_icon_->DisplayBalloon(icon.IsEmpty() ? gfx::Image() : icon->image(),
title, content);
#endif
}
@ -234,13 +234,14 @@ void Tray::BuildPrototype(v8::Isolate* isolate,
} // namespace atom
namespace {
using atom::api::Tray;
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
Tray::SetConstructor(isolate, base::Bind(&Tray::New));

View file

@ -108,7 +108,7 @@ struct PrintSettings {
namespace mate {
template<>
template <>
struct Converter<atom::SetSizeParams> {
static bool FromV8(v8::Isolate* isolate,
v8::Local<v8::Value> val,
@ -130,9 +130,10 @@ struct Converter<atom::SetSizeParams> {
}
};
template<>
template <>
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) {
mate::Dictionary dict;
if (!ConvertFromV8(isolate, val, &dict))
@ -144,7 +145,7 @@ struct Converter<PrintSettings> {
}
};
template<>
template <>
struct Converter<printing::PrinterBasicInfo> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
const printing::PrinterBasicInfo& val) {
@ -158,7 +159,7 @@ struct Converter<printing::PrinterBasicInfo> {
}
};
template<>
template <>
struct Converter<WindowOpenDisposition> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
WindowOpenDisposition val) {
@ -187,9 +188,10 @@ struct Converter<WindowOpenDisposition> {
}
};
template<>
template <>
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) {
std::string save_type;
if (!ConvertFromV8(isolate, val, &save_type))
@ -208,25 +210,39 @@ struct Converter<content::SavePageType> {
}
};
template<>
template <>
struct Converter<atom::api::WebContents::Type> {
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
atom::api::WebContents::Type val) {
using Type = atom::api::WebContents::Type;
std::string type = "";
switch (val) {
case Type::BACKGROUND_PAGE: type = "backgroundPage"; break;
case Type::BROWSER_WINDOW: type = "window"; 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;
case Type::BACKGROUND_PAGE:
type = "backgroundPage";
break;
case Type::BROWSER_WINDOW:
type = "window";
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);
}
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) {
using Type = atom::api::WebContents::Type;
std::string type;
@ -251,7 +267,6 @@ struct Converter<atom::api::WebContents::Type> {
} // namespace mate
namespace atom {
namespace api {
@ -377,17 +392,17 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
content::WebContents* web_contents;
if (IsGuest()) {
scoped_refptr<content::SiteInstance> site_instance =
content::SiteInstance::CreateForURL(
session->browser_context(), GURL("chrome-guest://fake-host"));
content::WebContents::CreateParams params(
session->browser_context(), site_instance);
content::SiteInstance::CreateForURL(session->browser_context(),
GURL("chrome-guest://fake-host"));
content::WebContents::CreateParams params(session->browser_context(),
site_instance);
guest_delegate_.reset(new WebViewGuestDelegate);
params.guest_delegate = guest_delegate_.get();
#if defined(ENABLE_OSR)
if (embedder_ && embedder_->IsOffScreen()) {
auto* view = new OffScreenWebContentsView(false,
base::Bind(&WebContents::OnPaint, base::Unretained(this)));
auto* view = new OffScreenWebContentsView(
false, base::Bind(&WebContents::OnPaint, base::Unretained(this)));
params.view = view;
params.delegate_view = view;
@ -403,8 +418,8 @@ WebContents::WebContents(v8::Isolate* isolate, const mate::Dictionary& options)
options.Get("transparent", &transparent);
content::WebContents::CreateParams params(session->browser_context());
auto* view = new OffScreenWebContentsView(transparent,
base::Bind(&WebContents::OnPaint, base::Unretained(this)));
auto* view = new OffScreenWebContentsView(
transparent, base::Bind(&WebContents::OnPaint, base::Unretained(this)));
params.view = view;
params.delegate_view = view;
@ -429,7 +444,7 @@ void WebContents::InitZoomController(content::WebContents* web_contents,
}
void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
content::WebContents *web_contents,
content::WebContents* web_contents,
mate::Handle<api::Session> session,
const mate::Dictionary& options) {
Observe(web_contents);
@ -442,7 +457,8 @@ void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
#if defined(OS_LINUX) || defined(OS_WIN)
// Update font settings.
CR_DEFINE_STATIC_LOCAL(const gfx::FontRenderParams, params,
CR_DEFINE_STATIC_LOCAL(
const gfx::FontRenderParams, params,
(gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), nullptr)));
prefs->should_antialias_text = params.antialiasing;
prefs->use_subpixel_positioning = params.subpixel_positioning;
@ -541,13 +557,12 @@ void WebContents::OnCreateWindow(
Emit("new-window", target_url, frame_name, disposition, features);
}
void WebContents::WebContentsCreated(
content::WebContents* source_contents,
int opener_render_process_id,
int opener_render_frame_id,
const std::string& frame_name,
const GURL& target_url,
content::WebContents* new_contents) {
void WebContents::WebContentsCreated(content::WebContents* source_contents,
int opener_render_process_id,
int opener_render_frame_id,
const std::string& frame_name,
const GURL& target_url,
content::WebContents* new_contents) {
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
auto api_web_contents = CreateFrom(isolate(), new_contents, BROWSER_WINDOW);
@ -565,8 +580,8 @@ void WebContents::AddNewContents(content::WebContents* source,
v8::HandleScope handle_scope(isolate());
auto api_web_contents = CreateFrom(isolate(), new_contents);
if (Emit("-add-new-contents", api_web_contents, disposition, user_gesture,
initial_rect.x(), initial_rect.y(), initial_rect.width(),
initial_rect.height())) {
initial_rect.x(), initial_rect.y(), initial_rect.width(),
initial_rect.height())) {
api_web_contents->DestroyWebContents(true /* async */);
}
}
@ -660,8 +675,7 @@ content::KeyboardEventProcessingResult WebContents::PreHandleKeyboardEvent(
void WebContents::EnterFullscreenModeForTab(content::WebContents* source,
const GURL& origin) {
auto permission_helper =
WebContentsPermissionHelper::FromWebContents(source);
auto permission_helper = WebContentsPermissionHelper::FromWebContents(source);
auto callback = base::Bind(&WebContents::OnEnterFullscreenModeForTab,
base::Unretained(this), source, origin);
permission_helper->RequestFullscreenPermission(callback);
@ -695,8 +709,7 @@ void WebContents::RendererResponsive(content::WebContents* source) {
bool WebContents::HandleContextMenu(const content::ContextMenuParams& params) {
if (params.custom_context.is_pepper_menu) {
Emit("pepper-context-menu",
std::make_pair(params, web_contents()),
Emit("pepper-context-menu", std::make_pair(params, web_contents()),
base::Bind(&content::WebContents::NotifyContextMenuClosed,
base::Unretained(web_contents()), params.custom_context));
} else {
@ -731,10 +744,9 @@ void WebContents::FindReply(content::WebContents* web_contents,
Emit("found-in-page", result);
}
bool WebContents::CheckMediaAccessPermission(
content::WebContents* web_contents,
const GURL& security_origin,
content::MediaStreamType type) {
bool WebContents::CheckMediaAccessPermission(content::WebContents* web_contents,
const GURL& security_origin,
content::MediaStreamType type) {
return true;
}
@ -747,10 +759,9 @@ void WebContents::RequestMediaAccessPermission(
permission_helper->RequestMediaAccessPermission(request, callback);
}
void WebContents::RequestToLockMouse(
content::WebContents* web_contents,
bool user_gesture,
bool last_unlocked_by_target) {
void WebContents::RequestToLockMouse(content::WebContents* web_contents,
bool user_gesture,
bool last_unlocked_by_target) {
auto permission_helper =
WebContentsPermissionHelper::FromWebContents(web_contents);
permission_helper->RequestPointerLockPermission(user_gesture);
@ -764,8 +775,7 @@ std::unique_ptr<content::BluetoothChooser> WebContents::RunBluetoothChooser(
return std::move(bluetooth_chooser);
}
content::JavaScriptDialogManager*
WebContents::GetJavaScriptDialogManager(
content::JavaScriptDialogManager* WebContents::GetJavaScriptDialogManager(
content::WebContents* source) {
if (!dialog_manager_)
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_SUB_FRAME))
return;
Emit("did-get-response-details",
details.socket_address.IsEmpty(),
details.url,
details.original_url,
details.http_response_code,
details.method,
details.referrer,
details.headers.get(),
Emit("did-get-response-details", details.socket_address.IsEmpty(),
details.url, details.original_url, details.http_response_code,
details.method, details.referrer, details.headers.get(),
ResourceTypeToString(details.resource_type));
}
void WebContents::DidGetRedirectForResourceRequest(
const content::ResourceRedirectDetails& details) {
Emit("did-get-redirect-request",
details.url,
details.new_url,
Emit("did-get-redirect-request", details.url, details.new_url,
(details.resource_type == content::RESOURCE_TYPE_MAIN_FRAME),
details.http_response_code,
details.method,
details.referrer,
details.http_response_code, details.method, details.referrer,
details.headers.get());
}
@ -953,8 +954,8 @@ void WebContents::DevToolsOpened() {
// Set inspected tabID.
base::Value tab_id(ID());
managed_web_contents()->CallClientFunction(
"DevToolsAPI.setInspectedTabId", &tab_id, nullptr, nullptr);
managed_web_contents()->CallClientFunction("DevToolsAPI.setInspectedTabId",
&tab_id, nullptr, nullptr);
// Inherit owner window in devtools when it doesn't have one.
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>& labels) {
bool offscreen = IsOffScreen() || (embedder_ && embedder_->IsOffScreen());
CommonWebContentsDelegate::ShowAutofillPopup(
offscreen, frame_host, bounds, values, labels);
CommonWebContentsDelegate::ShowAutofillPopup(offscreen, frame_host, bounds,
values, labels);
}
#endif
@ -1041,8 +1042,7 @@ void WebContents::WebContentsDestroyed() {
Emit("destroyed");
// Destroy the native class in next tick.
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, GetDestroyClosure());
base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, GetDestroyClosure());
}
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) {
if (!url.is_valid() || url.spec().size() > url::kMaxURLChars) {
Emit("did-fail-load",
static_cast<int>(net::ERR_INVALID_URL),
Emit("did-fail-load", static_cast<int>(net::ERR_INVALID_URL),
net::ErrorToShortString(net::ERR_INVALID_URL),
url.possibly_invalid_spec(),
true);
url.possibly_invalid_spec(), true);
return;
}
@ -1147,7 +1145,7 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
void WebContents::DownloadURL(const GURL& url) {
auto browser_context = web_contents()->GetBrowserContext();
auto download_manager =
content::BrowserContext::GetDownloadManager(browser_context);
content::BrowserContext::GetDownloadManager(browser_context);
download_manager->DownloadUrl(
content::DownloadUrlParameters::CreateForWebContentsMainFrame(
@ -1194,8 +1192,7 @@ void WebContents::GoToOffset(int offset) {
}
const std::string WebContents::GetWebRTCIPHandlingPolicy() const {
return web_contents()->
GetMutableRendererPrefs()->webrtc_ip_handling_policy;
return web_contents()->GetMutableRendererPrefs()->webrtc_ip_handling_policy;
}
void WebContents::SetWebRTCIPHandlingPolicy(
@ -1203,7 +1200,7 @@ void WebContents::SetWebRTCIPHandlingPolicy(
if (GetWebRTCIPHandlingPolicy() == webrtc_ip_handling_policy)
return;
web_contents()->GetMutableRendererPrefs()->webrtc_ip_handling_policy =
webrtc_ip_handling_policy;
webrtc_ip_handling_policy;
content::RenderViewHost* host = web_contents()->GetRenderViewHost();
if (host)
@ -1345,8 +1342,7 @@ void WebContents::InspectServiceWorker() {
}
}
void WebContents::HasServiceWorker(
const base::Callback<void(bool)>& callback) {
void WebContents::HasServiceWorker(const base::Callback<void(bool)>& callback) {
auto context = GetServiceWorkerContext(web_contents());
if (!context)
return;
@ -1392,7 +1388,7 @@ bool WebContents::IsAudioMuted() {
}
void WebContents::Print(mate::Arguments* args) {
PrintSettings settings = { false, false, base::string16() };
PrintSettings settings = {false, false, base::string16()};
if (args->Length() >= 1 && !args->GetNext(&settings)) {
args->ThrowError();
return;
@ -1407,10 +1403,9 @@ void WebContents::Print(mate::Arguments* args) {
}
print_view_manager_basic_ptr->SetCallback(callback);
}
print_view_manager_basic_ptr->PrintNow(web_contents()->GetMainFrame(),
settings.silent,
settings.print_background,
settings.device_name);
print_view_manager_basic_ptr->PrintNow(
web_contents()->GetMainFrame(), settings.silent,
settings.print_background, settings.device_name);
}
std::vector<printing::PrinterBasicInfo> WebContents::GetPrinterList() {
@ -1423,8 +1418,8 @@ std::vector<printing::PrinterBasicInfo> WebContents::GetPrinterList() {
void WebContents::PrintToPDF(const base::DictionaryValue& setting,
const PrintToPDFCallback& callback) {
printing::PrintPreviewMessageHandler::FromWebContents(web_contents())->
PrintToPDF(setting, callback);
printing::PrintPreviewMessageHandler::FromWebContents(web_contents())
->PrintToPDF(setting, callback);
}
void WebContents::AddWorkSpace(mate::Arguments* args,
@ -1529,7 +1524,8 @@ void WebContents::Focus() {
#if !defined(OS_MACOSX)
bool WebContents::IsFocused() const {
auto view = web_contents()->GetRenderWidgetHostView();
if (!view) return false;
if (!view)
return false;
if (GetType() != BACKGROUND_PAGE) {
auto window = web_contents()->GetNativeView()->GetToplevelWindow();
@ -1559,12 +1555,12 @@ bool WebContents::SendIPCMessage(bool all_frames,
void WebContents::SendInputEvent(v8::Isolate* isolate,
v8::Local<v8::Value> input_event) {
const auto view = static_cast<content::RenderWidgetHostViewBase*>(
web_contents()->GetRenderWidgetHostView());
web_contents()->GetRenderWidgetHostView());
if (!view)
return;
blink::WebInputEvent::Type type = mate::GetWebInputEventType(isolate,
input_event);
blink::WebInputEvent::Type type =
mate::GetWebInputEventType(isolate, input_event);
if (blink::WebInputEvent::IsMouseEventType(type)) {
blink::WebMouseEvent 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)) {
content::NativeWebKeyboardEvent keyboard_event(
blink::WebKeyboardEvent::kRawKeyDown,
blink::WebInputEvent::kNoModifiers,
ui::EventTimeForNow());
blink::WebInputEvent::kNoModifiers, ui::EventTimeForNow());
if (mate::ConvertFromV8(isolate, input_event, &keyboard_event)) {
view->ProcessKeyboardEvent(keyboard_event, ui::LatencyInfo());
return;
@ -1588,8 +1583,8 @@ void WebContents::SendInputEvent(v8::Isolate* isolate,
}
}
isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
isolate, "Invalid event object")));
isolate->ThrowException(
v8::Exception::Error(mate::StringToV8(isolate, "Invalid event object")));
}
void WebContents::BeginFrameSubscription(mate::Arguments* args) {
@ -1604,8 +1599,8 @@ void WebContents::BeginFrameSubscription(mate::Arguments* args) {
const auto view = web_contents()->GetRenderWidgetHostView();
if (view) {
std::unique_ptr<FrameSubscriber> frame_subscriber(new FrameSubscriber(
isolate(), view, callback, only_dirty));
std::unique_ptr<FrameSubscriber> frame_subscriber(
new FrameSubscriber(isolate(), view, callback, only_dirty));
view->BeginFrameSubscription(std::move(frame_subscriber));
}
}
@ -1658,8 +1653,8 @@ void WebContents::CapturePage(mate::Arguments* args) {
base::Callback<void(const gfx::Image&)> callback;
if (!(args->Length() == 1 && args->GetNext(&callback)) &&
!(args->Length() == 2 && args->GetNext(&rect)
&& args->GetNext(&callback))) {
!(args->Length() == 2 && args->GetNext(&rect) &&
args->GetNext(&callback))) {
args->ThrowError();
return;
}
@ -1671,22 +1666,21 @@ void WebContents::CapturePage(mate::Arguments* args) {
}
// Capture full page if user doesn't specify a |rect|.
const gfx::Size view_size = rect.IsEmpty() ? view->GetViewBounds().size() :
rect.size();
const gfx::Size view_size =
rect.IsEmpty() ? view->GetViewBounds().size() : rect.size();
// By default, the requested bitmap size is the view size in screen
// coordinates. However, if there's more pixel detail available on the
// current system, increase the requested bitmap size to capture it all.
gfx::Size bitmap_size = view_size;
const gfx::NativeView native_view = view->GetNativeView();
const float scale =
display::Screen::GetScreen()->GetDisplayNearestView(native_view)
.device_scale_factor();
const float scale = display::Screen::GetScreen()
->GetDisplayNearestView(native_view)
.device_scale_factor();
if (scale > 1.0f)
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
view->CopyFromSurface(gfx::Rect(rect.origin(), view_size),
bitmap_size,
view->CopyFromSurface(gfx::Rect(rect.origin(), view_size), bitmap_size,
base::Bind(&OnCapturePageDone, callback),
kBGRA_8888_SkColorType);
}
@ -1697,10 +1691,10 @@ void WebContents::OnCursorChange(const content::WebCursor& cursor) {
if (cursor.IsCustom()) {
Emit("cursor-changed", CursorTypeToString(info),
gfx::Image::CreateFrom1xBitmap(info.custom_image),
info.image_scale_factor,
gfx::Size(info.custom_image.width(), info.custom_image.height()),
info.hotspot);
gfx::Image::CreateFrom1xBitmap(info.custom_image),
info.image_scale_factor,
gfx::Size(info.custom_image.width(), info.custom_image.height()),
info.hotspot);
} else {
Emit("cursor-changed", CursorTypeToString(info));
}
@ -1788,7 +1782,7 @@ void WebContents::Invalidate() {
if (IsOffScreen()) {
#if defined(ENABLE_OSR)
auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
web_contents()->GetRenderWidgetHostView());
web_contents()->GetRenderWidgetHostView());
if (osr_rwhv)
osr_rwhv->Invalidate();
#endif
@ -1799,8 +1793,7 @@ void WebContents::Invalidate() {
}
}
gfx::Size WebContents::GetSizeForNewRenderView(
content::WebContents* wc) const {
gfx::Size WebContents::GetSizeForNewRenderView(content::WebContents* wc) const {
if (IsOffScreen() && wc == web_contents()) {
auto relay = NativeWindowRelay::FromWebContents(web_contents());
if (relay) {
@ -1907,8 +1900,8 @@ void WebContents::SetDevToolsWebContents(const WebContents* devtools) {
v8::Local<v8::Value> WebContents::GetNativeView() const {
gfx::NativeView ptr = web_contents()->GetNativeView();
auto buffer = node::Buffer::Copy(
isolate(), reinterpret_cast<char*>(&ptr), sizeof(gfx::NativeView));
auto buffer = node::Buffer::Copy(isolate(), reinterpret_cast<char*>(&ptr),
sizeof(gfx::NativeView));
if (buffer.IsEmpty())
return v8::Null(isolate());
else
@ -1932,8 +1925,7 @@ v8::Local<v8::Value> WebContents::Debugger(v8::Isolate* isolate) {
void WebContents::GrantOriginAccess(const GURL& url) {
content::ChildProcessSecurityPolicy::GetInstance()->GrantOrigin(
web_contents()->GetMainFrame()->GetProcess()->GetID(),
url::Origin(url));
web_contents()->GetMainFrame()->GetProcess()->GetID(), url::Origin(url));
}
// static
@ -1969,8 +1961,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
.SetMethod("disableDeviceEmulation", &WebContents::DisableDeviceEmulation)
.SetMethod("toggleDevTools", &WebContents::ToggleDevTools)
.SetMethod("inspectElement", &WebContents::InspectElement)
.SetMethod("setIgnoreMenuShortcuts",
&WebContents::SetIgnoreMenuShortcuts)
.SetMethod("setIgnoreMenuShortcuts", &WebContents::SetIgnoreMenuShortcuts)
.SetMethod("setAudioMuted", &WebContents::SetAudioMuted)
.SetMethod("isAudioMuted", &WebContents::IsAudioMuted)
.SetMethod("undo", &WebContents::Undo)
@ -2060,27 +2051,30 @@ void WebContents::OnRendererMessageSync(content::RenderFrameHost* frame_host,
// static
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.
auto existing = TrackableObject::FromWrappedClass(isolate, web_contents);
if (existing)
return mate::CreateHandle(isolate, static_cast<WebContents*>(existing));
// Otherwise create a new WebContents wrapper object.
return mate::CreateHandle(isolate, new WebContents(isolate, web_contents,
REMOTE));
return mate::CreateHandle(isolate,
new WebContents(isolate, web_contents, REMOTE));
}
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.
return mate::CreateHandle(isolate, new WebContents(isolate, web_contents,
type));
return mate::CreateHandle(isolate,
new WebContents(isolate, web_contents, type));
}
// static
mate::Handle<WebContents> WebContents::Create(
v8::Isolate* isolate, const mate::Dictionary& options) {
mate::Handle<WebContents> WebContents::Create(v8::Isolate* isolate,
const mate::Dictionary& options) {
return mate::CreateHandle(isolate, new WebContents(isolate, options));
}
@ -2092,8 +2086,10 @@ namespace {
using atom::api::WebContents;
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.Set("WebContents", WebContents::GetConstructor(isolate)->GetFunction());

View file

@ -19,9 +19,10 @@ using content::BrowserThread;
namespace mate {
template<>
template <>
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) {
std::string pattern;
if (!ConvertFromV8(isolate, val, &pattern))
@ -39,7 +40,7 @@ namespace api {
namespace {
template<typename Method, typename Event, typename Listener>
template <typename Method, typename Event, typename Listener>
void CallNetworkDelegateMethod(
brightray::URLRequestContextGetter* url_request_context_getter,
Method method,
@ -63,22 +64,21 @@ WebRequest::WebRequest(v8::Isolate* isolate,
Init(isolate);
}
WebRequest::~WebRequest() {
}
WebRequest::~WebRequest() {}
template<AtomNetworkDelegate::SimpleEvent type>
template <AtomNetworkDelegate::SimpleEvent type>
void WebRequest::SetSimpleListener(mate::Arguments* args) {
SetListener<AtomNetworkDelegate::SimpleListener>(
&AtomNetworkDelegate::SetSimpleListenerInIO, type, args);
}
template<AtomNetworkDelegate::ResponseEvent type>
template <AtomNetworkDelegate::ResponseEvent type>
void WebRequest::SetResponseListener(mate::Arguments* args) {
SetListener<AtomNetworkDelegate::ResponseListener>(
&AtomNetworkDelegate::SetResponseListenerInIO, type, args);
}
template<typename Listener, typename Method, typename Event>
template <typename Listener, typename Method, typename Event>
void WebRequest::SetListener(Method method, Event type, mate::Arguments* args) {
// { urls }.
URLPatterns patterns;
@ -101,8 +101,8 @@ void WebRequest::SetListener(Method method, Event type, mate::Arguments* args) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&CallNetworkDelegateMethod<Method, Event, Listener>,
base::RetainedRef(url_request_context_getter),
method, type, std::move(patterns), std::move(listener)));
base::RetainedRef(url_request_context_getter), method, type,
std::move(patterns), std::move(listener)));
}
// static
@ -117,30 +117,28 @@ void WebRequest::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "WebRequest"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.SetMethod("onBeforeRequest",
&WebRequest::SetResponseListener<
AtomNetworkDelegate::kOnBeforeRequest>)
.SetMethod("onBeforeRequest", &WebRequest::SetResponseListener<
AtomNetworkDelegate::kOnBeforeRequest>)
.SetMethod("onBeforeSendHeaders",
&WebRequest::SetResponseListener<
AtomNetworkDelegate::kOnBeforeSendHeaders>)
AtomNetworkDelegate::kOnBeforeSendHeaders>)
.SetMethod("onHeadersReceived",
&WebRequest::SetResponseListener<
AtomNetworkDelegate::kOnHeadersReceived>)
.SetMethod("onSendHeaders",
&WebRequest::SetSimpleListener<
AtomNetworkDelegate::kOnSendHeaders>)
AtomNetworkDelegate::kOnHeadersReceived>)
.SetMethod(
"onSendHeaders",
&WebRequest::SetSimpleListener<AtomNetworkDelegate::kOnSendHeaders>)
.SetMethod("onBeforeRedirect",
&WebRequest::SetSimpleListener<
AtomNetworkDelegate::kOnBeforeRedirect>)
AtomNetworkDelegate::kOnBeforeRedirect>)
.SetMethod("onResponseStarted",
&WebRequest::SetSimpleListener<
AtomNetworkDelegate::kOnResponseStarted>)
.SetMethod("onCompleted",
&WebRequest::SetSimpleListener<
AtomNetworkDelegate::kOnCompleted>)
.SetMethod("onErrorOccurred",
&WebRequest::SetSimpleListener<
AtomNetworkDelegate::kOnErrorOccurred>);
AtomNetworkDelegate::kOnResponseStarted>)
.SetMethod(
"onCompleted",
&WebRequest::SetSimpleListener<AtomNetworkDelegate::kOnCompleted>)
.SetMethod("onErrorOccurred", &WebRequest::SetSimpleListener<
AtomNetworkDelegate::kOnErrorOccurred>);
}
} // namespace api

View file

@ -43,8 +43,10 @@ void RemoveGuest(content::WebContents* embedder, int guest_instance_id) {
manager->RemoveGuest(guest_instance_id);
}
void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
v8::Local<v8::Context> context, void* priv) {
void Initialize(v8::Local<v8::Object> exports,
v8::Local<v8::Value> unused,
v8::Local<v8::Context> context,
void* priv) {
mate::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("addGuest", &AddGuest);
dict.SetMethod("removeGuest", &RemoveGuest);

View file

@ -12,14 +12,11 @@
namespace mate {
Event::Event(v8::Isolate* isolate)
: sender_(nullptr),
message_(nullptr) {
Event::Event(v8::Isolate* isolate) : sender_(nullptr), message_(nullptr) {
Init(isolate);
}
Event::~Event() {
}
Event::~Event() {}
void Event::SetSenderAndMessage(content::RenderFrameHost* sender,
IPC::Message* message) {
@ -52,8 +49,7 @@ void Event::FrameDeleted(content::RenderFrameHost* rfh) {
}
void Event::PreventDefault(v8::Isolate* isolate) {
GetWrapper()->Set(StringToV8(isolate, "defaultPrevented"),
v8::True(isolate));
GetWrapper()->Set(StringToV8(isolate, "defaultPrevented"), v8::True(isolate));
}
bool Event::SendReply(const base::string16& json) {
@ -73,8 +69,8 @@ Handle<Event> Event::Create(v8::Isolate* isolate) {
}
// static
void Event::BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype) {
void Event::BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype) {
prototype->SetClassName(mate::StringToV8(isolate, "Event"));
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
.SetMethod("preventDefault", &Event::PreventDefault)

View file

@ -26,13 +26,14 @@ void PreventDefault(mate::Arguments* args) {
// Create a pure JavaScript Event object.
v8::Local<v8::Object> CreateEventObject(v8::Isolate* isolate) {
if (event_template.IsEmpty()) {
event_template.Reset(isolate, ObjectTemplateBuilder(isolate)
.SetMethod("preventDefault", &PreventDefault)
.Build());
event_template.Reset(isolate,
ObjectTemplateBuilder(isolate)
.SetMethod("preventDefault", &PreventDefault)
.Build());
}
return v8::Local<v8::ObjectTemplate>::New(
isolate, event_template)->NewInstance();
return v8::Local<v8::ObjectTemplate>::New(isolate, event_template)
->NewInstance();
}
} // namespace
@ -57,10 +58,9 @@ v8::Local<v8::Object> CreateJSEvent(v8::Isolate* isolate,
return event;
}
v8::Local<v8::Object> CreateCustomEvent(
v8::Isolate* isolate,
v8::Local<v8::Object> object,
v8::Local<v8::Object> custom_event) {
v8::Local<v8::Object> CreateCustomEvent(v8::Isolate* isolate,
v8::Local<v8::Object> object,
v8::Local<v8::Object> custom_event) {
v8::Local<v8::Object> event = CreateEventObject(isolate);
(void)event->SetPrototype(custom_event->CreationContext(), custom_event);
mate::Dictionary(isolate, event).Set("sender", object);

View file

@ -25,8 +25,7 @@ FrameSubscriber::FrameSubscriber(v8::Isolate* isolate,
callback_(callback),
only_dirty_(only_dirty),
source_id_for_copy_request_(base::UnguessableToken::Create()),
weak_factory_(this) {
}
weak_factory_(this) {}
bool FrameSubscriber::ShouldCaptureFrame(
const gfx::Rect& dirty_rect,
@ -46,19 +45,18 @@ bool FrameSubscriber::ShouldCaptureFrame(
gfx::Size view_size = rect.size();
gfx::Size bitmap_size = view_size;
gfx::NativeView native_view = view_->GetNativeView();
const float scale =
display::Screen::GetScreen()->GetDisplayNearestView(native_view)
.device_scale_factor();
const float scale = display::Screen::GetScreen()
->GetDisplayNearestView(native_view)
.device_scale_factor();
if (scale > 1.0f)
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
rect = gfx::Rect(rect.origin(), bitmap_size);
view_->CopyFromSurface(
rect,
rect.size(),
base::Bind(&FrameSubscriber::OnFrameDelivered,
weak_factory_.GetWeakPtr(), callback_, rect),
rect, rect.size(),
base::Bind(&FrameSubscriber::OnFrameDelivered, weak_factory_.GetWeakPtr(),
callback_, rect),
kBGRA_8888_SkColorType);
return false;

View file

@ -17,12 +17,9 @@ namespace api {
SavePageHandler::SavePageHandler(content::WebContents* web_contents,
const SavePageCallback& callback)
: web_contents_(web_contents),
callback_(callback) {
}
: web_contents_(web_contents), callback_(callback) {}
SavePageHandler::~SavePageHandler() {
}
SavePageHandler::~SavePageHandler() {}
void SavePageHandler::OnDownloadCreated(content::DownloadManager* manager,
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(
full_path.RemoveExtension().BaseName().value() +
FILE_PATH_LITERAL("_files"));
bool result = web_contents_->SavePage(full_path,
saved_main_directory_path,
save_type);
bool result =
web_contents_->SavePage(full_path, saved_main_directory_path, save_type);
download_manager->RemoveObserver(this);
// If initialization fails which means fail to create |DownloadItem|, we need
// 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) {
callback_.Run(v8::Null(isolate));
} else {
v8::Local<v8::String> error_message = v8::String::NewFromUtf8(
isolate, "Fail to save page");
v8::Local<v8::String> error_message =
v8::String::NewFromUtf8(isolate, "Fail to save page");
callback_.Run(v8::Exception::Error(error_message));
}
Destroy(item);

View file

@ -34,8 +34,7 @@ TrackableObjectBase::TrackableObjectBase()
GetDestroyClosure());
}
TrackableObjectBase::~TrackableObjectBase() {
}
TrackableObjectBase::~TrackableObjectBase() {}
base::OnceClosure TrackableObjectBase::GetDestroyClosure() {
return base::BindOnce(&TrackableObjectBase::Destroy,
@ -48,7 +47,7 @@ void TrackableObjectBase::Destroy() {
void TrackableObjectBase::AttachAsUserData(base::SupportsUserData* wrapped) {
wrapped->SetUserData(kTrackedObjectKey,
std::make_unique<IDUserData>(weak_map_id_));
std::make_unique<IDUserData>(weak_map_id_));
}
// static

View file

@ -25,19 +25,19 @@ void FreeNodeBufferData(char* data, void* hint) {
delete[] data;
}
void RunCallbackInUI(
const AtomBlobReader::CompletionCallback& callback,
char* blob_data,
int size) {
void RunCallbackInUI(const AtomBlobReader::CompletionCallback& callback,
char* blob_data,
int size) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
if (blob_data) {
v8::Local<v8::Value> buffer = node::Buffer::New(isolate,
blob_data, static_cast<size_t>(size), &FreeNodeBufferData, nullptr)
.ToLocalChecked();
v8::Local<v8::Value> buffer =
node::Buffer::New(isolate, blob_data, static_cast<size_t>(size),
&FreeNodeBufferData, nullptr)
.ToLocalChecked();
callback.Run(buffer);
} else {
callback.Run(v8::Null(isolate));
@ -46,33 +46,26 @@ void RunCallbackInUI(
} // namespace
AtomBlobReader::AtomBlobReader(
content::ChromeBlobStorageContext* blob_context,
storage::FileSystemContext* file_system_context)
: blob_context_(blob_context),
file_system_context_(file_system_context) {
}
AtomBlobReader::AtomBlobReader(content::ChromeBlobStorageContext* blob_context,
storage::FileSystemContext* file_system_context)
: blob_context_(blob_context), file_system_context_(file_system_context) {}
AtomBlobReader::~AtomBlobReader() {
}
AtomBlobReader::~AtomBlobReader() {}
void AtomBlobReader::StartReading(
const std::string& uuid,
const AtomBlobReader::CompletionCallback& completion_callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
auto blob_data_handle =
blob_context_->context()->GetBlobDataFromUUID(uuid);
auto callback = base::Bind(&RunCallbackInUI,
completion_callback);
auto blob_data_handle = blob_context_->context()->GetBlobDataFromUUID(uuid);
auto callback = base::Bind(&RunCallbackInUI, completion_callback);
if (!blob_data_handle) {
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(callback, nullptr, 0));
base::Bind(callback, nullptr, 0));
return;
}
auto blob_reader = blob_data_handle->CreateReader(
file_system_context_.get());
auto blob_reader = blob_data_handle->CreateReader(file_system_context_.get());
BlobReadHelper* blob_read_helper =
new BlobReadHelper(std::move(blob_reader), callback);
blob_read_helper->Read();
@ -81,12 +74,9 @@ void AtomBlobReader::StartReading(
AtomBlobReader::BlobReadHelper::BlobReadHelper(
std::unique_ptr<storage::BlobReader> blob_reader,
const BlobReadHelper::CompletionCallback& callback)
: blob_reader_(std::move(blob_reader)),
completion_callback_(callback) {
}
: blob_reader_(std::move(blob_reader)), completion_callback_(callback) {}
AtomBlobReader::BlobReadHelper::~BlobReadHelper() {
}
AtomBlobReader::BlobReadHelper::~BlobReadHelper() {}
void AtomBlobReader::BlobReadHelper::Read() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
@ -110,14 +100,11 @@ void AtomBlobReader::BlobReadHelper::DidCalculateSize(int result) {
int bytes_read = 0;
scoped_refptr<net::IOBuffer> blob_data =
new net::IOBuffer(static_cast<size_t>(total_size));
auto callback = base::Bind(&AtomBlobReader::BlobReadHelper::DidReadBlobData,
base::Unretained(this),
base::RetainedRef(blob_data));
storage::BlobReader::Status read_status = blob_reader_->Read(
blob_data.get(),
total_size,
&bytes_read,
callback);
auto callback =
base::Bind(&AtomBlobReader::BlobReadHelper::DidReadBlobData,
base::Unretained(this), base::RetainedRef(blob_data));
storage::BlobReader::Status read_status =
blob_reader_->Read(blob_data.get(), total_size, &bytes_read, callback);
if (read_status != storage::BlobReader::Status::IO_PENDING)
callback.Run(bytes_read);
}
@ -130,7 +117,7 @@ void AtomBlobReader::BlobReadHelper::DidReadBlobData(
char* data = new char[size];
memcpy(data, blob_data->data(), size);
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
base::Bind(completion_callback_, data, size));
base::Bind(completion_callback_, data, size));
delete this;
}

View file

@ -90,8 +90,7 @@ void AtomBrowserClient::SetCustomServiceWorkerSchemes(
AtomBrowserClient::AtomBrowserClient() : delegate_(nullptr) {}
AtomBrowserClient::~AtomBrowserClient() {
}
AtomBrowserClient::~AtomBrowserClient() {}
content::WebContents* AtomBrowserClient::GetWebContentsFromProcessID(
int process_id) {
@ -138,7 +137,8 @@ bool AtomBrowserClient::ShouldCreateNewSiteInstance(
}
void AtomBrowserClient::AddProcessPreferences(
int process_id, AtomBrowserClient::ProcessPreferences prefs) {
int process_id,
AtomBrowserClient::ProcessPreferences prefs) {
process_preferences_[process_id] = prefs;
}
@ -178,8 +178,8 @@ void AtomBrowserClient::RenderProcessWillLaunch(
new WidevineCdmMessageFilter(process_id, host->GetBrowserContext()));
ProcessPreferences prefs;
auto* web_preferences = WebContentsPreferences::From(
GetWebContentsFromProcessID(process_id));
auto* web_preferences =
WebContentsPreferences::From(GetWebContentsFromProcessID(process_id));
if (web_preferences) {
prefs.sandbox = web_preferences->IsEnabled("sandbox");
prefs.native_window_open = web_preferences->IsEnabled("nativeWindowOpen");
@ -191,12 +191,12 @@ void AtomBrowserClient::RenderProcessWillLaunch(
}
content::SpeechRecognitionManagerDelegate*
AtomBrowserClient::CreateSpeechRecognitionManagerDelegate() {
AtomBrowserClient::CreateSpeechRecognitionManagerDelegate() {
return new AtomSpeechRecognitionManagerDelegate;
}
void AtomBrowserClient::OverrideWebkitPrefs(
content::RenderViewHost* host, content::WebPreferences* prefs) {
void AtomBrowserClient::OverrideWebkitPrefs(content::RenderViewHost* host,
content::WebPreferences* prefs) {
prefs->javascript_enabled = true;
prefs->web_security_enabled = true;
prefs->plugins_enabled = true;
@ -295,14 +295,12 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
return;
// Copy following switches to child process.
static const char* const kCommonSwitchNames[] = {
switches::kStandardSchemes,
switches::kEnableSandbox,
switches::kSecureSchemes
};
command_line->CopySwitchesFrom(
*base::CommandLine::ForCurrentProcess(),
kCommonSwitchNames, arraysize(kCommonSwitchNames));
static const char* const kCommonSwitchNames[] = {switches::kStandardSchemes,
switches::kEnableSandbox,
switches::kSecureSchemes};
command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(),
kCommonSwitchNames,
arraysize(kCommonSwitchNames));
// The registered service worker schemes.
if (!g_custom_service_worker_schemes.empty())
@ -331,15 +329,13 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
SessionPreferences::AppendExtraCommandLineSwitches(
web_contents->GetBrowserContext(), command_line);
auto context_id = atom::api::WebContents::GetIDForContents(
web_contents);
auto context_id = atom::api::WebContents::GetIDForContents(web_contents);
command_line->AppendSwitchASCII(switches::kContextId,
base::IntToString(context_id));
base::IntToString(context_id));
}
}
void AtomBrowserClient::DidCreatePpapiPlugin(
content::BrowserPpapiHost* host) {
void AtomBrowserClient::DidCreatePpapiPlugin(content::BrowserPpapiHost* host) {
host->GetPpapiHost()->AddHostFactoryFilter(
base::WrapUnique(new chrome::ChromeBrowserPepperHostFactory(host)));
}
@ -363,7 +359,7 @@ std::string AtomBrowserClient::GetGeolocationApiKey() {
}
content::QuotaPermissionContext*
AtomBrowserClient::CreateQuotaPermissionContext() {
AtomBrowserClient::CreateQuotaPermissionContext() {
return new AtomQuotaPermissionContext;
}
@ -379,9 +375,8 @@ void AtomBrowserClient::AllowCertificateError(
callback) {
if (delegate_) {
delegate_->AllowCertificateError(
web_contents, cert_error, ssl_info, request_url,
resource_type, strict_enforcement,
expired_previous_decision, callback);
web_contents, cert_error, ssl_info, request_url, resource_type,
strict_enforcement, expired_previous_decision, callback);
}
}
@ -455,8 +450,7 @@ void AtomBrowserClient::GetAdditionalAllowedSchemesForFileSystem(
std::vector<std::string>* additional_schemes) {
auto schemes_list = api::GetStandardSchemes();
if (!schemes_list.empty())
additional_schemes->insert(additional_schemes->end(),
schemes_list.begin(),
additional_schemes->insert(additional_schemes->end(), schemes_list.begin(),
schemes_list.end());
additional_schemes->push_back(content::kChromeDevToolsScheme);
}
@ -466,7 +460,7 @@ void AtomBrowserClient::SiteInstanceDeleting(
// We are storing weak_ptr, is it fundamental to maintain the map up-to-date
// when an instance is destroyed.
for (auto iter = site_per_affinities.begin();
iter != site_per_affinities.end(); ++iter) {
iter != site_per_affinities.end(); ++iter) {
if (iter->second == site_instance) {
site_per_affinities.erase(iter);
break;

View file

@ -77,14 +77,12 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition,
std::string name = RemoveWhitespace(browser->GetName());
std::string user_agent;
if (name == ATOM_PRODUCT_NAME) {
user_agent = "Chrome/" CHROME_VERSION_STRING " "
ATOM_PRODUCT_NAME "/" ATOM_VERSION_STRING;
user_agent = "Chrome/" CHROME_VERSION_STRING " " ATOM_PRODUCT_NAME
"/" ATOM_VERSION_STRING;
} else {
user_agent = base::StringPrintf(
"%s/%s Chrome/%s " ATOM_PRODUCT_NAME "/" ATOM_VERSION_STRING,
name.c_str(),
browser->GetVersion().c_str(),
CHROME_VERSION_STRING);
name.c_str(), browser->GetVersion().c_str(), CHROME_VERSION_STRING);
}
user_agent_ = content::BuildUserAgentFromProduct(user_agent);
@ -96,8 +94,7 @@ AtomBrowserContext::AtomBrowserContext(const std::string& partition,
InitPrefs();
}
AtomBrowserContext::~AtomBrowserContext() {
}
AtomBrowserContext::~AtomBrowserContext() {}
void AtomBrowserContext::SetUserAgent(const std::string& user_agent) {
user_agent_ = user_agent;
@ -156,8 +153,7 @@ AtomBrowserContext::CreateURLRequestJobFactory(
auto host_resolver =
url_request_context_getter()->GetURLRequestContext()->host_resolver();
job_factory->SetProtocolHandler(
url::kFtpScheme,
net::FtpProtocolHandler::Create(host_resolver));
url::kFtpScheme, net::FtpProtocolHandler::Create(host_resolver));
return std::move(job_factory);
}
@ -202,8 +198,8 @@ std::unique_ptr<net::CertVerifier> AtomBrowserContext::CreateCertVerifier(
std::vector<std::string> AtomBrowserContext::GetCookieableSchemes() {
auto default_schemes = brightray::BrowserContext::GetCookieableSchemes();
const auto& standard_schemes = atom::api::GetStandardSchemes();
default_schemes.insert(default_schemes.end(),
standard_schemes.begin(), standard_schemes.end());
default_schemes.insert(default_schemes.end(), standard_schemes.begin(),
standard_schemes.end());
return default_schemes;
}
@ -230,17 +226,17 @@ AtomBlobReader* AtomBrowserContext::GetBlobReader() {
content::ChromeBlobStorageContext* blob_context =
content::ChromeBlobStorageContext::GetFor(this);
storage::FileSystemContext* file_system_context =
content::BrowserContext::GetStoragePartition(
this, nullptr)->GetFileSystemContext();
blob_reader_.reset(new AtomBlobReader(blob_context,
file_system_context));
content::BrowserContext::GetStoragePartition(this, nullptr)
->GetFileSystemContext();
blob_reader_.reset(new AtomBlobReader(blob_context, file_system_context));
}
return blob_reader_.get();
}
// static
scoped_refptr<AtomBrowserContext> AtomBrowserContext::From(
const std::string& partition, bool in_memory,
const std::string& partition,
bool in_memory,
const base::DictionaryValue& options) {
auto browser_context = brightray::BrowserContext::Get(partition, in_memory);
if (browser_context)

View file

@ -56,7 +56,7 @@ class AtomGeolocationDelegate : public device::GeolocationDelegate {
DISALLOW_COPY_AND_ASSIGN(AtomGeolocationDelegate);
};
template<typename T>
template <typename T>
void Erase(T* container, typename T::iterator iter) {
container->erase(iter);
}
@ -76,8 +76,8 @@ AtomBrowserMainParts::AtomBrowserMainParts()
DCHECK(!self_) << "Cannot have two AtomBrowserMainParts";
self_ = this;
// Register extension scheme as web safe scheme.
content::ChildProcessSecurityPolicy::GetInstance()->
RegisterWebSafeScheme("chrome-extension");
content::ChildProcessSecurityPolicy::GetInstance()->RegisterWebSafeScheme(
"chrome-extension");
}
AtomBrowserMainParts::~AtomBrowserMainParts() {
@ -85,10 +85,11 @@ AtomBrowserMainParts::~AtomBrowserMainParts() {
// Leak the JavascriptEnvironment on exit.
// 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
// about this can be found at https://github.com/electron/electron/issues/4767.
// On the other handle there is actually no need to gracefully shutdown V8
// on exit in the main process, we already ensured all necessary resources get
// cleaned up, and it would make quitting faster.
// about this can be found at
// https://github.com/electron/electron/issues/4767. On the other handle there
// is actually no need to gracefully shutdown V8 on exit in the main process,
// we already ensured all necessary resources get cleaned up, and it would
// make quitting faster.
ignore_result(js_env_.release());
}
@ -163,9 +164,9 @@ int AtomBrowserMainParts::PreCreateThreads() {
brightray::BrowserClient::Get()->GetApplicationLocale());
}
#if defined(OS_MACOSX)
ui::InitIdleMonitor();
#endif
#if defined(OS_MACOSX)
ui::InitIdleMonitor();
#endif
return result;
}
@ -183,10 +184,9 @@ void AtomBrowserMainParts::PreMainMessageLoopRun() {
#endif
// Start idle gc.
gc_timer_.Start(
FROM_HERE, base::TimeDelta::FromMinutes(1),
base::Bind(&v8::Isolate::LowMemoryNotification,
base::Unretained(js_env_->isolate())));
gc_timer_.Start(FROM_HERE, base::TimeDelta::FromMinutes(1),
base::Bind(&v8::Isolate::LowMemoryNotification,
base::Unretained(js_env_->isolate())));
#if defined(ENABLE_PDF_VIEWER)
content::WebUIControllerFactory::RegisterFactory(

View file

@ -24,8 +24,7 @@ namespace atom {
namespace {
// 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
// fork() returns. In that case, the shutdown pipe will still be
@ -121,8 +120,7 @@ void ShutdownDetector::ThreadMain() {
size_t bytes_read = 0;
do {
ssize_t ret = HANDLE_EINTR(
read(shutdown_fd_,
reinterpret_cast<char*>(&signal) + bytes_read,
read(shutdown_fd_, reinterpret_cast<char*>(&signal) + bytes_read,
sizeof(signal) - bytes_read));
if (ret < 0) {
NOTREACHED() << "Unexpected error: " << strerror(errno);

View file

@ -50,8 +50,7 @@ void CreateDownloadPath(
AtomDownloadManagerDelegate::AtomDownloadManagerDelegate(
content::DownloadManager* manager)
: download_manager_(manager),
weak_ptr_factory_(this) {}
: download_manager_(manager), weak_ptr_factory_(this) {}
AtomDownloadManagerDelegate::~AtomDownloadManagerDelegate() {
if (download_manager_) {
@ -67,8 +66,8 @@ void AtomDownloadManagerDelegate::GetItemSavePath(content::DownloadItem* item,
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
api::DownloadItem* download = api::DownloadItem::FromWrappedClass(isolate,
item);
api::DownloadItem* download =
api::DownloadItem::FromWrappedClass(isolate, item);
if (download)
*path = download->GetSavePath();
}
@ -85,8 +84,8 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
NativeWindow* window = nullptr;
content::WebContents* web_contents = item->GetWebContents();
auto relay = web_contents ? NativeWindowRelay::FromWebContents(web_contents)
: nullptr;
auto relay =
web_contents ? NativeWindowRelay::FromWebContents(web_contents) : nullptr;
if (relay)
window = relay->window.get();
@ -111,8 +110,8 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Locker locker(isolate);
v8::HandleScope handle_scope(isolate);
api::DownloadItem* download_item = api::DownloadItem::FromWrappedClass(
isolate, item);
api::DownloadItem* download_item =
api::DownloadItem::FromWrappedClass(isolate, item);
if (download_item)
download_item->SetSavePath(path);
}
@ -120,12 +119,10 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
// Running the DownloadTargetCallback with an empty FilePath signals that the
// download should be cancelled.
// If user cancels the file save dialog, run the callback with empty FilePath.
callback.Run(path,
content::DownloadItem::TARGET_DISPOSITION_PROMPT,
callback.Run(path, content::DownloadItem::TARGET_DISPOSITION_PROMPT,
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, path,
path.empty() ?
content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED :
content::DOWNLOAD_INTERRUPT_REASON_NONE);
path.empty() ? content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED
: content::DOWNLOAD_INTERRUPT_REASON_NONE);
}
void AtomDownloadManagerDelegate::Shutdown() {
@ -151,22 +148,20 @@ bool AtomDownloadManagerDelegate::DetermineDownloadTarget(
base::FilePath save_path;
GetItemSavePath(download, &save_path);
if (!save_path.empty()) {
callback.Run(save_path,
content::DownloadItem::TARGET_DISPOSITION_OVERWRITE,
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
save_path, content::DOWNLOAD_INTERRUPT_REASON_NONE);
callback.Run(save_path, content::DownloadItem::TARGET_DISPOSITION_OVERWRITE,
content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, save_path,
content::DOWNLOAD_INTERRUPT_REASON_NONE);
return true;
}
AtomBrowserContext* browser_context = static_cast<AtomBrowserContext*>(
download_manager_->GetBrowserContext());
base::FilePath default_download_path = browser_context->prefs()->GetFilePath(
prefs::kDownloadDefaultDirectory);
AtomBrowserContext* browser_context =
static_cast<AtomBrowserContext*>(download_manager_->GetBrowserContext());
base::FilePath default_download_path =
browser_context->prefs()->GetFilePath(prefs::kDownloadDefaultDirectory);
CreateDownloadPathCallback download_path_callback =
base::Bind(&AtomDownloadManagerDelegate::OnDownloadPathGenerated,
weak_ptr_factory_.GetWeakPtr(),
download->GetId(), callback);
weak_ptr_factory_.GetWeakPtr(), download->GetId(), callback);
content::BrowserThread::PostTask(
content::BrowserThread::FILE, FROM_HERE,

View file

@ -57,8 +57,7 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
auto* web_preferences = WebContentsPreferences::From(web_contents);
std::string checkbox;
if (origin_counts_[origin] > 1 &&
web_preferences &&
if (origin_counts_[origin] > 1 && web_preferences &&
web_preferences->IsEnabled("safeDialogs") &&
!web_preferences->dict()->GetString("safeDialogsMessage", &checkbox)) {
checkbox = "Prevent this app from creating additional dialogs";
@ -73,14 +72,11 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
}
atom::ShowMessageBox(
window,
atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, -1, 0,
window, atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, -1, 0,
atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
base::UTF16ToUTF8(message_text), "", checkbox,
false, gfx::ImageSkia(),
base::UTF16ToUTF8(message_text), "", checkbox, false, gfx::ImageSkia(),
base::Bind(&AtomJavaScriptDialogManager::OnMessageBoxCallback,
base::Unretained(this),
base::Passed(std::move(callback)),
base::Unretained(this), base::Passed(std::move(callback)),
origin));
}
@ -95,8 +91,7 @@ void AtomJavaScriptDialogManager::RunBeforeUnloadDialog(
void AtomJavaScriptDialogManager::CancelDialogs(
content::WebContents* web_contents,
bool reset_state) {
}
bool reset_state) {}
void AtomJavaScriptDialogManager::OnMessageBoxCallback(
DialogClosedCallback callback,

View file

@ -21,8 +21,8 @@ namespace {
bool WebContentsDestroyed(int process_id) {
content::WebContents* web_contents =
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())->
GetWebContentsFromProcessID(process_id);
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())
->GetWebContentsFromProcessID(process_id);
if (!web_contents)
return true;
return web_contents->IsBeingDestroyed();
@ -54,17 +54,11 @@ class AtomPermissionManager::PendingRequest {
--remaining_results_;
}
int render_process_id() const {
return render_process_id_;
}
int render_process_id() const { return render_process_id_; }
bool IsComplete() const {
return remaining_results_ == 0;
}
bool IsComplete() const { return remaining_results_ == 0; }
void RunCallback() const {
callback_.Run(results_);
}
void RunCallback() const { callback_.Run(results_); }
private:
int render_process_id_;
@ -73,11 +67,9 @@ class AtomPermissionManager::PendingRequest {
size_t remaining_results_;
};
AtomPermissionManager::AtomPermissionManager() {
}
AtomPermissionManager::AtomPermissionManager() {}
AtomPermissionManager::~AtomPermissionManager() {
}
AtomPermissionManager::~AtomPermissionManager() {}
void AtomPermissionManager::SetPermissionRequestHandler(
const RequestHandler& handler) {
@ -99,13 +91,9 @@ int AtomPermissionManager::RequestPermission(
const GURL& requesting_origin,
bool user_gesture,
const StatusCallback& response_callback) {
return RequestPermissionWithDetails(
permission,
render_frame_host,
requesting_origin,
user_gesture,
nullptr,
response_callback);
return RequestPermissionWithDetails(permission, render_frame_host,
requesting_origin, user_gesture, nullptr,
response_callback);
}
int AtomPermissionManager::RequestPermissionWithDetails(
@ -116,11 +104,8 @@ int AtomPermissionManager::RequestPermissionWithDetails(
const base::DictionaryValue* details,
const StatusCallback& response_callback) {
return RequestPermissionsWithDetails(
std::vector<content::PermissionType>(1, permission),
render_frame_host,
requesting_origin,
user_gesture,
details,
std::vector<content::PermissionType>(1, permission), render_frame_host,
requesting_origin, user_gesture, details,
base::Bind(&PermissionRequestResponseCallbackWrapper, response_callback));
}
@ -130,9 +115,9 @@ int AtomPermissionManager::RequestPermissions(
const GURL& requesting_origin,
bool user_gesture,
const StatusesCallback& response_callback) {
return RequestPermissionsWithDetails(
permissions, render_frame_host, requesting_origin,
user_gesture, nullptr, response_callback);
return RequestPermissionsWithDetails(permissions, render_frame_host,
requesting_origin, user_gesture, nullptr,
response_callback);
}
int AtomPermissionManager::RequestPermissionsWithDetails(
@ -151,8 +136,9 @@ int AtomPermissionManager::RequestPermissionsWithDetails(
std::vector<blink::mojom::PermissionStatus> statuses;
for (auto permission : permissions) {
if (permission == content::PermissionType::MIDI_SYSEX) {
content::ChildProcessSecurityPolicy::GetInstance()->
GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
content::ChildProcessSecurityPolicy::GetInstance()
->GrantSendMidiSysExMessage(
render_frame_host->GetProcess()->GetID());
}
statuses.push_back(blink::mojom::PermissionStatus::GRANTED);
}
@ -168,8 +154,8 @@ int AtomPermissionManager::RequestPermissionsWithDetails(
for (size_t i = 0; i < permissions.size(); ++i) {
auto permission = permissions[i];
if (permission == content::PermissionType::MIDI_SYSEX) {
content::ChildProcessSecurityPolicy::GetInstance()->
GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
content::ChildProcessSecurityPolicy::GetInstance()
->GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
}
const auto callback =
base::Bind(&AtomPermissionManager::OnPermissionResponse,
@ -210,11 +196,9 @@ void AtomPermissionManager::CancelPermissionRequest(int request_id) {
pending_requests_.Remove(request_id);
}
void AtomPermissionManager::ResetPermission(
content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) {
}
void AtomPermissionManager::ResetPermission(content::PermissionType permission,
const GURL& requesting_origin,
const GURL& embedding_origin) {}
blink::mojom::PermissionStatus AtomPermissionManager::GetPermissionStatus(
content::PermissionType permission,
@ -232,7 +216,6 @@ int AtomPermissionManager::SubscribePermissionStatusChange(
}
void AtomPermissionManager::UnsubscribePermissionStatusChange(
int subscription_id) {
}
int subscription_id) {}
} // namespace atom

View file

@ -8,11 +8,9 @@
namespace atom {
AtomQuotaPermissionContext::AtomQuotaPermissionContext() {
}
AtomQuotaPermissionContext::AtomQuotaPermissionContext() {}
AtomQuotaPermissionContext::~AtomQuotaPermissionContext() {
}
AtomQuotaPermissionContext::~AtomQuotaPermissionContext() {}
void AtomQuotaPermissionContext::RequestQuotaPermission(
const content::StorageQuotaParams& params,

View file

@ -32,7 +32,6 @@
#include "net/url_request/url_request.h"
#endif // defined(ENABLE_PDF_VIEWER)
using content::BrowserThread;
namespace atom {

View file

@ -10,45 +10,37 @@
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(
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(
int session_id, const content::SpeechRecognitionResults& result) {
}
int session_id,
const content::SpeechRecognitionResults& result) {}
void AtomSpeechRecognitionManagerDelegate::OnRecognitionError(
int session_id, const content::SpeechRecognitionError& error) {
}
int session_id,
const content::SpeechRecognitionError& error) {}
void AtomSpeechRecognitionManagerDelegate::OnAudioLevelsChange(
int session_id, float volume, float noise_volume) {
}
int session_id,
float volume,
float noise_volume) {}
void AtomSpeechRecognitionManagerDelegate::CheckRecognitionIsAllowed(
int session_id,

View file

@ -60,9 +60,9 @@ AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui,
std::string src;
const net::UnescapeRule::Type unescape_rules =
net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS |
net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS |
net::UnescapeRule::REPLACE_PLUS_WITH_SPACE;
net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS |
net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS |
net::UnescapeRule::REPLACE_PLUS_WITH_SPACE;
for (const auto& param : toplevel_params) {
if (param.first == kPdfPluginSrc) {

View file

@ -21,14 +21,11 @@ std::string AutoUpdater::GetFeedURL() {
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
} // namespace auto_updater

View file

@ -21,18 +21,17 @@ void BridgeTaskRunner::MessageLoopIsReady() {
}
}
bool BridgeTaskRunner::PostDelayedTask(
const base::Location& from_here,
base::OnceClosure task,
base::TimeDelta delay) {
bool BridgeTaskRunner::PostDelayedTask(const base::Location& from_here,
base::OnceClosure task,
base::TimeDelta delay) {
auto message_loop = base::MessageLoop::current();
if (!message_loop) {
tasks_.push_back(std::make_tuple(from_here, std::move(task), delay));
return true;
}
return message_loop->task_runner()->PostDelayedTask(
from_here, std::move(task), delay);
return message_loop->task_runner()->PostDelayedTask(from_here,
std::move(task), delay);
}
bool BridgeTaskRunner::RunsTasksInCurrentSequence() const {
@ -49,8 +48,8 @@ bool BridgeTaskRunner::PostNonNestableDelayedTask(
base::TimeDelta delay) {
auto message_loop = base::MessageLoop::current();
if (!message_loop) {
non_nestable_tasks_.push_back(std::make_tuple(
from_here, std::move(task), delay));
non_nestable_tasks_.push_back(
std::make_tuple(from_here, std::move(task), delay));
return true;
}

View file

@ -28,7 +28,8 @@ const char kXdgSettingsDefaultSchemeHandler[] = "default-url-scheme-handler";
bool LaunchXdgUtility(const std::vector<std::string>& argv, int* exit_code) {
*exit_code = EXIT_FAILURE;
int devnull = open("/dev/null", O_RDONLY);
if (devnull < 0) return false;
if (devnull < 0)
return false;
base::LaunchOptions options;
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);
close(devnull);
if (!process.IsValid()) return false;
if (!process.IsValid())
return false;
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,
mate::Arguments* args) {
@ -85,7 +84,8 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol,
mate::Arguments* args) {
std::unique_ptr<base::Environment> env(base::Environment::Create());
if (protocol.empty()) return false;
if (protocol.empty())
return false;
std::vector<std::string> argv;
argv.push_back(kXdgSettings);
@ -96,15 +96,15 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol,
std::string reply;
int success_code;
bool ran_ok = base::GetAppOutputWithExitCode(base::CommandLine(argv),
&reply, &success_code);
bool ran_ok = base::GetAppOutputWithExitCode(base::CommandLine(argv), &reply,
&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".
return base::StartsWith(reply, "yes", base::CompareCase::SENSITIVE)
? true
: false;
return base::StartsWith(reply, "yes", base::CompareCase::SENSITIVE) ? true
: false;
}
// Todo implement
@ -123,8 +123,7 @@ bool Browser::SetBadgeCount(int count) {
}
}
void Browser::SetLoginItemSettings(LoginItemSettings settings) {
}
void Browser::SetLoginItemSettings(LoginItemSettings settings) {}
Browser::LoginItemSettings Browser::GetLoginItemSettings(
const LoginItemSettings& options) {

View file

@ -61,8 +61,7 @@ bool GetProtocolLaunchPath(mate::Arguments* args, base::string16* exe) {
// Read in optional args arg
std::vector<base::string16> launch_args;
if (args->GetNext(&launch_args) && !launch_args.empty())
*exe = base::StringPrintf(L"\"%ls\" %ls \"%%1\"",
exe->c_str(),
*exe = base::StringPrintf(L"\"%ls\" %ls \"%%1\"", exe->c_str(),
base::JoinString(launch_args, L" ").c_str());
else
*exe = base::StringPrintf(L"\"%ls\" \"%%1\"", exe->c_str());
@ -76,8 +75,7 @@ bool FormatCommandLineString(base::string16* exe,
}
if (!launch_args.empty()) {
*exe = base::StringPrintf(L"%ls %ls",
exe->c_str(),
*exe = base::StringPrintf(L"%ls %ls", exe->c_str(),
base::JoinString(launch_args, L" ").c_str());
}
@ -97,8 +95,8 @@ void Browser::AddRecentDocument(const base::FilePath& path) {
return;
CComPtr<IShellItem> item;
HRESULT hr = SHCreateItemFromParsingName(
path.value().c_str(), NULL, IID_PPV_ARGS(&item));
HRESULT hr = SHCreateItemFromParsingName(path.value().c_str(), NULL,
IID_PPV_ARGS(&item));
if (SUCCEEDED(hr)) {
SHARDAPPIDINFO info;
info.psi = item;
@ -109,8 +107,8 @@ void Browser::AddRecentDocument(const base::FilePath& path) {
void Browser::ClearRecentDocuments() {
CComPtr<IApplicationDestinations> destinations;
if (FAILED(destinations.CoCreateInstance(CLSID_ApplicationDestinations,
NULL, CLSCTX_INPROC_SERVER)))
if (FAILED(destinations.CoCreateInstance(CLSID_ApplicationDestinations, NULL,
CLSCTX_INPROC_SERVER)))
return;
if (FAILED(destinations->SetAppID(GetAppUserModelID())))
return;
@ -189,8 +187,8 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
base::win::RegKey protocolKey;
base::string16 protocolPath = keyPath + wprotocol;
if (SUCCEEDED(protocolKey
.Open(root, protocolPath.c_str(), KEY_ALL_ACCESS))) {
if (SUCCEEDED(
protocolKey.Open(root, protocolPath.c_str(), KEY_ALL_ACCESS))) {
protocolKey.DeleteValue(L"URL Protocol");
// Overwrite the default value to be empty, we can't delete it right away
@ -208,7 +206,7 @@ bool Browser::RemoveAsDefaultProtocolClient(const std::string& protocol,
}
bool Browser::SetAsDefaultProtocolClient(const std::string& protocol,
mate::Arguments* args) {
mate::Arguments* args) {
// HKEY_CLASSES_ROOT
// $PROTOCOL
// (Default) = "URL:$NAME"

View file

@ -42,15 +42,13 @@ namespace {
const char kRootName[] = "<root>";
struct FileSystem {
FileSystem() {
}
FileSystem() {}
FileSystem(const std::string& file_system_name,
const std::string& root_url,
const std::string& file_system_path)
: file_system_name(file_system_name),
root_url(root_url),
file_system_path(file_system_path) {
}
: file_system_name(file_system_name),
root_url(root_url),
file_system_path(file_system_path) {}
std::string file_system_name;
std::string root_url;
@ -62,10 +60,7 @@ std::string RegisterFileSystem(content::WebContents* web_contents,
auto isolated_context = storage::IsolatedContext::GetInstance();
std::string root_name(kRootName);
std::string file_system_id = isolated_context->RegisterFileSystemForPath(
storage::kFileSystemTypeNativeLocal,
std::string(),
path,
&root_name);
storage::kFileSystemTypeNativeLocal, std::string(), path, &root_name);
content::ChildProcessSecurityPolicy* policy =
content::ChildProcessSecurityPolicy::GetInstance();
@ -82,10 +77,9 @@ std::string RegisterFileSystem(content::WebContents* web_contents,
return file_system_id;
}
FileSystem CreateFileSystemStruct(
content::WebContents* web_contents,
const std::string& file_system_id,
const std::string& file_system_path) {
FileSystem CreateFileSystemStruct(content::WebContents* web_contents,
const std::string& file_system_id,
const std::string& file_system_path) {
const GURL origin = web_contents->GetURL().GetOrigin();
std::string file_system_name =
storage::GetIsolatedFileSystemName(origin, file_system_id);
@ -104,16 +98,14 @@ std::unique_ptr<base::DictionaryValue> CreateFileSystemValue(
return file_system_value;
}
void WriteToFile(const base::FilePath& path,
const std::string& content) {
void WriteToFile(const base::FilePath& path, const std::string& content) {
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
DCHECK(!path.empty());
base::WriteFile(path, content.data(), content.size());
}
void AppendToFile(const base::FilePath& path,
const std::string& content) {
void AppendToFile(const base::FilePath& path, const std::string& content) {
DCHECK_CURRENTLY_ON(BrowserThread::FILE);
DCHECK(!path.empty());
@ -140,9 +132,8 @@ std::set<std::string> GetAddedFileSystemPaths(
return result;
}
bool IsDevToolsFileSystemAdded(
content::WebContents* web_contents,
const std::string& file_system_path) {
bool IsDevToolsFileSystemAdded(content::WebContents* web_contents,
const std::string& file_system_path) {
auto file_system_paths = GetAddedFileSystemPaths(web_contents);
return file_system_paths.find(file_system_path) != file_system_paths.end();
}
@ -154,11 +145,9 @@ CommonWebContentsDelegate::CommonWebContentsDelegate()
ignore_menu_shortcuts_(false),
html_fullscreen_(false),
native_fullscreen_(false),
devtools_file_system_indexer_(new DevToolsFileSystemIndexer) {
}
devtools_file_system_indexer_(new DevToolsFileSystemIndexer) {}
CommonWebContentsDelegate::~CommonWebContentsDelegate() {
}
CommonWebContentsDelegate::~CommonWebContentsDelegate() {}
void CommonWebContentsDelegate::InitWithWebContents(
content::WebContents* web_contents,
@ -183,7 +172,8 @@ void CommonWebContentsDelegate::SetOwnerWindow(NativeWindow* owner_window) {
}
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;
auto relay = std::make_unique<NativeWindowRelay>(owner_window_);
auto relay_key = relay->key;
@ -213,8 +203,8 @@ content::WebContents* CommonWebContentsDelegate::GetWebContents() const {
return web_contents_->GetWebContents();
}
content::WebContents*
CommonWebContentsDelegate::GetDevToolsWebContents() const {
content::WebContents* CommonWebContentsDelegate::GetDevToolsWebContents()
const {
if (!web_contents_)
return nullptr;
return web_contents_->GetDevToolsWebContents();
@ -264,7 +254,8 @@ void CommonWebContentsDelegate::EnumerateDirectory(content::WebContents* guest,
}
void CommonWebContentsDelegate::EnterFullscreenModeForTab(
content::WebContents* source, const GURL& origin) {
content::WebContents* source,
const GURL& origin) {
if (!owner_window_)
return;
SetHtmlApiFullscreen(true);
@ -298,8 +289,9 @@ blink::WebSecurityStyle CommonWebContentsDelegate::GetSecurityStyle(
security_style_explanations);
}
void CommonWebContentsDelegate::DevToolsSaveToFile(
const std::string& url, const std::string& content, bool save_as) {
void CommonWebContentsDelegate::DevToolsSaveToFile(const std::string& url,
const std::string& content,
bool save_as) {
base::FilePath path;
auto it = saved_files_.find(url);
if (it != saved_files_.end() && !save_as) {
@ -312,22 +304,22 @@ void CommonWebContentsDelegate::DevToolsSaveToFile(
settings.default_path = base::FilePath::FromUTF8Unsafe(url);
if (!file_dialog::ShowSaveDialog(settings, &path)) {
base::Value url_value(url);
web_contents_->CallClientFunction(
"DevToolsAPI.canceledSaveURL", &url_value, nullptr, nullptr);
web_contents_->CallClientFunction("DevToolsAPI.canceledSaveURL",
&url_value, nullptr, nullptr);
return;
}
}
saved_files_[url] = path;
BrowserThread::PostTaskAndReply(
BrowserThread::FILE, FROM_HERE,
base::Bind(&WriteToFile, path, content),
BrowserThread::FILE, FROM_HERE, base::Bind(&WriteToFile, path, content),
base::Bind(&CommonWebContentsDelegate::OnDevToolsSaveToFile,
base::Unretained(this), url));
}
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);
if (it == saved_files_.end())
return;
@ -344,19 +336,18 @@ void CommonWebContentsDelegate::DevToolsRequestFileSystems() {
if (file_system_paths.empty()) {
base::ListValue empty_file_system_value;
web_contents_->CallClientFunction("DevToolsAPI.fileSystemsLoaded",
&empty_file_system_value,
nullptr, nullptr);
&empty_file_system_value, nullptr,
nullptr);
return;
}
std::vector<FileSystem> file_systems;
for (const auto& file_system_path : file_system_paths) {
base::FilePath path = base::FilePath::FromUTF8Unsafe(file_system_path);
std::string file_system_id = RegisterFileSystem(GetDevToolsWebContents(),
path);
FileSystem file_system = CreateFileSystemStruct(GetDevToolsWebContents(),
file_system_id,
file_system_path);
std::string file_system_id =
RegisterFileSystem(GetDevToolsWebContents(), path);
FileSystem file_system = CreateFileSystemStruct(
GetDevToolsWebContents(), file_system_id, file_system_path);
file_systems.push_back(file_system);
}
@ -382,25 +373,23 @@ void CommonWebContentsDelegate::DevToolsAddFileSystem(
path = paths[0];
}
std::string file_system_id = RegisterFileSystem(GetDevToolsWebContents(),
path);
std::string file_system_id =
RegisterFileSystem(GetDevToolsWebContents(), path);
if (IsDevToolsFileSystemAdded(GetDevToolsWebContents(), path.AsUTF8Unsafe()))
return;
FileSystem file_system = CreateFileSystemStruct(GetDevToolsWebContents(),
file_system_id,
path.AsUTF8Unsafe());
FileSystem file_system = CreateFileSystemStruct(
GetDevToolsWebContents(), file_system_id, path.AsUTF8Unsafe());
std::unique_ptr<base::DictionaryValue> file_system_value(
CreateFileSystemValue(file_system));
auto pref_service = GetPrefService(GetDevToolsWebContents());
DictionaryPrefUpdate update(pref_service, prefs::kDevToolsFileSystemPaths);
update.Get()->SetWithoutPathExpansion(
path.AsUTF8Unsafe(), std::make_unique<base::Value>());
update.Get()->SetWithoutPathExpansion(path.AsUTF8Unsafe(),
std::make_unique<base::Value>());
web_contents_->CallClientFunction("DevToolsAPI.fileSystemAdded",
file_system_value.get(),
nullptr, nullptr);
file_system_value.get(), nullptr, nullptr);
}
void CommonWebContentsDelegate::DevToolsRemoveFileSystem(
@ -409,8 +398,8 @@ void CommonWebContentsDelegate::DevToolsRemoveFileSystem(
return;
std::string path = file_system_path.AsUTF8Unsafe();
storage::IsolatedContext::GetInstance()->
RevokeFileSystemByPath(file_system_path);
storage::IsolatedContext::GetInstance()->RevokeFileSystemByPath(
file_system_path);
auto pref_service = GetPrefService(GetDevToolsWebContents());
DictionaryPrefUpdate update(pref_service, prefs::kDevToolsFileSystemPaths);
@ -418,8 +407,7 @@ void CommonWebContentsDelegate::DevToolsRemoveFileSystem(
base::Value file_system_path_value(path);
web_contents_->CallClientFunction("DevToolsAPI.fileSystemRemoved",
&file_system_path_value,
nullptr, nullptr);
&file_system_path_value, nullptr, nullptr);
}
void CommonWebContentsDelegate::DevToolsIndexPath(
@ -437,16 +425,11 @@ void CommonWebContentsDelegate::DevToolsIndexPath(
file_system_path,
base::Bind(
&CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated,
base::Unretained(this),
request_id,
file_system_path),
base::Unretained(this), request_id, file_system_path),
base::Bind(&CommonWebContentsDelegate::OnDevToolsIndexingWorked,
base::Unretained(this),
request_id,
file_system_path),
base::Unretained(this), request_id, file_system_path),
base::Bind(&CommonWebContentsDelegate::OnDevToolsIndexingDone,
base::Unretained(this),
request_id,
base::Unretained(this), request_id,
file_system_path)));
}
@ -463,34 +446,28 @@ void CommonWebContentsDelegate::DevToolsSearchInPath(
const std::string& file_system_path,
const std::string& query) {
if (!IsDevToolsFileSystemAdded(GetDevToolsWebContents(), file_system_path)) {
OnDevToolsSearchCompleted(request_id,
file_system_path,
OnDevToolsSearchCompleted(request_id, file_system_path,
std::vector<std::string>());
return;
}
devtools_file_system_indexer_->SearchInPath(
file_system_path,
query,
file_system_path, query,
base::Bind(&CommonWebContentsDelegate::OnDevToolsSearchCompleted,
base::Unretained(this),
request_id,
file_system_path));
base::Unretained(this), request_id, file_system_path));
}
void CommonWebContentsDelegate::OnDevToolsSaveToFile(
const std::string& url) {
void CommonWebContentsDelegate::OnDevToolsSaveToFile(const std::string& url) {
// Notify DevTools.
base::Value url_value(url);
web_contents_->CallClientFunction(
"DevToolsAPI.savedURL", &url_value, nullptr, nullptr);
web_contents_->CallClientFunction("DevToolsAPI.savedURL", &url_value, nullptr,
nullptr);
}
void CommonWebContentsDelegate::OnDevToolsAppendToFile(
const std::string& url) {
void CommonWebContentsDelegate::OnDevToolsAppendToFile(const std::string& url) {
// Notify DevTools.
base::Value url_value(url);
web_contents_->CallClientFunction(
"DevToolsAPI.appendedToURL", &url_value, nullptr, nullptr);
web_contents_->CallClientFunction("DevToolsAPI.appendedToURL", &url_value,
nullptr, nullptr);
}
void CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated(
@ -501,8 +478,7 @@ void CommonWebContentsDelegate::OnDevToolsIndexingWorkCalculated(
base::Value file_system_path_value(file_system_path);
base::Value total_work_value(total_work);
web_contents_->CallClientFunction("DevToolsAPI.indexingTotalWorkCalculated",
&request_id_value,
&file_system_path_value,
&request_id_value, &file_system_path_value,
&total_work_value);
}
@ -514,8 +490,7 @@ void CommonWebContentsDelegate::OnDevToolsIndexingWorked(
base::Value file_system_path_value(file_system_path);
base::Value worked_value(worked);
web_contents_->CallClientFunction("DevToolsAPI.indexingWorked",
&request_id_value,
&file_system_path_value,
&request_id_value, &file_system_path_value,
&worked_value);
}
@ -526,8 +501,7 @@ void CommonWebContentsDelegate::OnDevToolsIndexingDone(
base::Value request_id_value(request_id);
base::Value file_system_path_value(file_system_path);
web_contents_->CallClientFunction("DevToolsAPI.indexingDone",
&request_id_value,
&file_system_path_value,
&request_id_value, &file_system_path_value,
nullptr);
}
@ -542,8 +516,7 @@ void CommonWebContentsDelegate::OnDevToolsSearchCompleted(
base::Value request_id_value(request_id);
base::Value file_system_path_value(file_system_path);
web_contents_->CallClientFunction("DevToolsAPI.searchCompleted",
&request_id_value,
&file_system_path_value,
&request_id_value, &file_system_path_value,
&file_paths_value);
}

View file

@ -37,8 +37,8 @@ void CommonWebContentsDelegate::ShowAutofillPopup(
return;
auto* window = static_cast<NativeWindowViews*>(owner_window());
autofill_popup_->CreateView(
frame_host, offscreen, window->content_view(), bounds);
autofill_popup_->CreateView(frame_host, offscreen, window->content_view(),
bounds);
autofill_popup_->SetItems(values, labels);
}
@ -50,13 +50,15 @@ void CommonWebContentsDelegate::HideAutofillPopup() {
gfx::ImageSkia CommonWebContentsDelegate::GetDevToolsWindowIcon() {
if (!owner_window())
return gfx::ImageSkia();
return static_cast<views::WidgetDelegate*>(static_cast<NativeWindowViews*>(
owner_window()))->GetWindowAppIcon();
return static_cast<views::WidgetDelegate*>(
static_cast<NativeWindowViews*>(owner_window()))
->GetWindowAppIcon();
}
#if defined(USE_X11)
void CommonWebContentsDelegate::GetDevToolsWindowWMClass(
std::string* name, std::string* class_name) {
std::string* name,
std::string* class_name) {
*class_name = Browser::Get()->GetName();
*name = base::ToLowerASCII(*class_name);
}

View file

@ -27,8 +27,7 @@ JavascriptEnvironment::JavascriptEnvironment()
locker_(isolate_),
handle_scope_(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() {
isolate_holder_.AddRunMicrotasksObserver();
@ -53,15 +52,13 @@ bool JavascriptEnvironment::Initialize() {
v8::V8::InitializePlatform(platform_);
node::tracing::TraceEventHelper::SetTracingController(
new v8::TracingController());
gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
gin::IsolateHolder::kStableV8Extras,
gin::ArrayBufferAllocator::SharedInstance(),
false);
gin::IsolateHolder::Initialize(
gin::IsolateHolder::kNonStrictMode, gin::IsolateHolder::kStableV8Extras,
gin::ArrayBufferAllocator::SharedInstance(), false);
return true;
}
NodeEnvironment::NodeEnvironment(node::Environment* env) : env_(env) {
}
NodeEnvironment::NodeEnvironment(node::Environment* env) : env_(env) {}
NodeEnvironment::~NodeEnvironment() {
node::FreeEnvironment(env_);

View file

@ -9,10 +9,11 @@
namespace mate {
template<>
template <>
struct Converter<atom::BluetoothChooser::DeviceInfo> {
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);
dict.Set("deviceName", val.device_name);
dict.Set("deviceId", val.device_id);
@ -28,9 +29,8 @@ namespace {
const int kMaxScanRetries = 5;
void OnDeviceChosen(
const content::BluetoothChooser::EventHandler& handler,
const std::string& device_id) {
void OnDeviceChosen(const content::BluetoothChooser::EventHandler& handler,
const std::string& device_id) {
if (device_id.empty()) {
handler.Run(content::BluetoothChooser::Event::CANCELLED, device_id);
} else {
@ -40,16 +40,13 @@ void OnDeviceChosen(
} // namespace
BluetoothChooser::BluetoothChooser(
api::WebContents* contents,
const EventHandler& event_handler)
BluetoothChooser::BluetoothChooser(api::WebContents* contents,
const EventHandler& event_handler)
: api_web_contents_(contents),
event_handler_(event_handler),
num_retries_(0) {
}
num_retries_(0) {}
BluetoothChooser::~BluetoothChooser() {
}
BluetoothChooser::~BluetoothChooser() {}
void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) {
switch (presence) {
@ -69,15 +66,13 @@ void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) {
break;
case DiscoveryState::IDLE:
if (device_list_.empty()) {
auto event = ++num_retries_ > kMaxScanRetries ? Event::CANCELLED
: Event::RESCAN;
auto event =
++num_retries_ > kMaxScanRetries ? Event::CANCELLED : Event::RESCAN;
event_handler_.Run(event, "");
} else {
bool prevent_default =
api_web_contents_->Emit("select-bluetooth-device",
device_list_,
base::Bind(&OnDeviceChosen,
event_handler_));
bool prevent_default = api_web_contents_->Emit(
"select-bluetooth-device", device_list_,
base::Bind(&OnDeviceChosen, event_handler_));
if (!prevent_default) {
auto device_id = device_list_[0].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
// bluetooth device found.
bool prevent_default = api_web_contents_->Emit("select-bluetooth-device",
device_list_, base::Bind(&OnDeviceChosen, event_handler_));
bool prevent_default =
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
// provided.

View file

@ -72,7 +72,7 @@ void PowerObserverLinux::OnLoginServiceAvailable(bool service_available) {
void PowerObserverLinux::BlockSleep() {
dbus::MethodCall sleep_inhibit_call(kLogindManagerInterface, "Inhibit");
dbus::MessageWriter inhibit_writer(&sleep_inhibit_call);
inhibit_writer.AppendString("sleep"); // what
inhibit_writer.AppendString("sleep"); // what
// Use the executable name as the lock owner, which will list rebrands of the
// electron executable as separate entities.
inhibit_writer.AppendString(lock_owner_name_); // who

View file

@ -38,7 +38,7 @@ LoginHandler::LoginHandler(net::AuthChallengeInfo* auth_info,
render_process_host_id_(0),
render_frame_id_(0) {
content::ResourceRequestInfo::ForRequest(request_)->GetAssociatedRenderFrame(
&render_process_host_id_, &render_frame_id_);
&render_process_host_id_, &render_frame_id_);
// Fill request details on IO thread.
std::unique_ptr<base::DictionaryValue> request_details(
@ -47,14 +47,12 @@ LoginHandler::LoginHandler(net::AuthChallengeInfo* auth_info,
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&Browser::RequestLogin,
base::Unretained(Browser::Get()),
base::Bind(&Browser::RequestLogin, base::Unretained(Browser::Get()),
base::RetainedRef(WrapRefCounted(this)),
base::Passed(&request_details)));
}
LoginHandler::~LoginHandler() {
}
LoginHandler::~LoginHandler() {}
content::WebContents* LoginHandler::GetWebContents() const {
DCHECK_CURRENTLY_ON(BrowserThread::UI);

View file

@ -113,9 +113,9 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
bool fullscreen = false;
if (options.Get(options::kFullscreen, &fullscreen) && !fullscreen) {
// Disable fullscreen button if 'fullscreen' is specified to false.
#if defined(OS_MACOSX)
#if defined(OS_MACOSX)
fullscreenable = false;
#endif
#endif
}
// Overriden by 'fullscreenable'.
options.Get(options::kFullScreenable, &fullscreenable);
@ -261,75 +261,59 @@ double NativeWindow::GetSheetOffsetY() {
return sheet_offset_y_;
}
void NativeWindow::SetRepresentedFilename(const std::string& filename) {
}
void NativeWindow::SetRepresentedFilename(const std::string& filename) {}
std::string NativeWindow::GetRepresentedFilename() {
return "";
}
void NativeWindow::SetDocumentEdited(bool edited) {
}
void NativeWindow::SetDocumentEdited(bool edited) {}
bool NativeWindow::IsDocumentEdited() {
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) {
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) {
return true; // for non-Mac platforms
}
void NativeWindow::SetVibrancy(const std::string& filename) {
}
void NativeWindow::SetVibrancy(const std::string& filename) {}
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(
const mate::PersistentDictionary& item) {
}
const mate::PersistentDictionary& item) {}
void NativeWindow::SetAutoHideMenuBar(bool auto_hide) {
}
void NativeWindow::SetAutoHideMenuBar(bool auto_hide) {}
bool NativeWindow::IsMenuBarAutoHide() {
return false;
}
void NativeWindow::SetMenuBarVisibility(bool visible) {
}
void NativeWindow::SetMenuBarVisibility(bool visible) {}
bool NativeWindow::IsMenuBarVisible() {
return true;
@ -350,11 +334,9 @@ void NativeWindow::SetAspectRatio(double aspect_ratio,
}
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) {
for (NativeWindowObserver& observer : observers_)
@ -510,13 +492,14 @@ void NativeWindow::NotifyTouchBarItemInteraction(
}
void NativeWindow::NotifyNewWindowForTab() {
for (NativeWindowObserver &observer : observers_)
for (NativeWindowObserver& observer : observers_)
observer.OnNewWindowForTab();
}
#if defined(OS_WIN)
void NativeWindow::NotifyWindowMessage(
UINT message, WPARAM w_param, LPARAM l_param) {
void NativeWindow::NotifyWindowMessage(UINT message,
WPARAM w_param,
LPARAM l_param) {
for (NativeWindowObserver& observer : observers_)
observer.OnWindowMessage(message, w_param, l_param);
}

View file

@ -102,13 +102,12 @@ class NativeWindowClientView : public views::ClientView {
public:
NativeWindowClientView(views::Widget* widget,
NativeWindowViews* contents_view)
: views::ClientView(widget, contents_view) {
}
: views::ClientView(widget, contents_view) {}
virtual ~NativeWindowClientView() {}
bool CanClose() override {
static_cast<NativeWindowViews*>(contents_view())->
NotifyWindowCloseButtonClicked();
static_cast<NativeWindowViews*>(contents_view())
->NotifyWindowCloseButtonClicked();
return false;
}
@ -196,8 +195,7 @@ NativeWindowViews::NativeWindowViews(const mate::Dictionary& options,
params.native_widget = new AtomDesktopNativeWidgetAura(window_.get());
atom_desktop_window_tree_host_win_ = new AtomDesktopWindowTreeHostWin(
this,
window_.get(),
this, window_.get(),
static_cast<views::DesktopNativeWidgetAura*>(params.native_widget));
params.desktop_window_tree_host = atom_desktop_window_tree_host_win_;
#elif defined(USE_X11)
@ -227,10 +225,9 @@ NativeWindowViews::NativeWindowViews(const mate::Dictionary& options,
XDisplay* xdisplay = gfx::GetXDisplay();
XChangeProperty(xdisplay, GetAcceleratedWidget(),
XInternAtom(xdisplay, "_GTK_THEME_VARIANT", False),
XInternAtom(xdisplay, "UTF8_STRING", False),
8, PropModeReplace,
reinterpret_cast<const unsigned char*>("dark"),
4);
XInternAtom(xdisplay, "UTF8_STRING", False), 8,
PropModeReplace,
reinterpret_cast<const unsigned char*>("dark"), 4);
}
// Before the window is mapped the SetWMSpecState can not work, so we have
@ -641,9 +638,9 @@ void NativeWindowViews::SetResizable(bool resizable) {
void NativeWindowViews::MoveTop() {
gfx::Point pos = GetPosition();
gfx::Size size = GetSize();
::SetWindowPos(GetAcceleratedWidget(), HWND_TOP,
pos.x(), pos.y(), size.width(), size.height(),
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
::SetWindowPos(GetAcceleratedWidget(), HWND_TOP, pos.x(), pos.y(),
size.width(), size.height(),
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
}
#endif
@ -735,8 +732,10 @@ bool NativeWindowViews::IsClosable() {
#endif
}
void NativeWindowViews::SetAlwaysOnTop(bool top, const std::string& level,
int relativeLevel, std::string* error) {
void NativeWindowViews::SetAlwaysOnTop(bool top,
const std::string& level,
int relativeLevel,
std::string* error) {
window_->SetAlwaysOnTop(top);
}
@ -820,24 +819,23 @@ void NativeWindowViews::SetBackgroundColor(SkColor background_color) {
#if defined(OS_WIN)
// Set the background color of native window.
HBRUSH brush = CreateSolidBrush(skia::SkColorToCOLORREF(background_color));
ULONG_PTR previous_brush = SetClassLongPtr(
GetAcceleratedWidget(),
GCLP_HBRBACKGROUND,
reinterpret_cast<LONG_PTR>(brush));
ULONG_PTR previous_brush =
SetClassLongPtr(GetAcceleratedWidget(), GCLP_HBRBACKGROUND,
reinterpret_cast<LONG_PTR>(brush));
if (previous_brush)
DeleteObject((HBRUSH)previous_brush);
#endif
}
void NativeWindowViews::SetHasShadow(bool has_shadow) {
wm::SetShadowElevation(
GetNativeWindow(),
has_shadow ? wm::ShadowElevation::MEDIUM : wm::ShadowElevation::NONE);
wm::SetShadowElevation(GetNativeWindow(), has_shadow
? wm::ShadowElevation::MEDIUM
: wm::ShadowElevation::NONE);
}
bool NativeWindowViews::HasShadow() {
return GetNativeWindow()->GetProperty(wm::kShadowElevationKey)
!= wm::ShadowElevation::NONE;
return GetNativeWindow()->GetProperty(wm::kShadowElevationKey) !=
wm::ShadowElevation::NONE;
}
void NativeWindowViews::SetOpacity(const double opacity) {
@ -881,8 +879,8 @@ void NativeWindowViews::SetIgnoreMouseEvents(bool ignore, bool forward) {
XShapeCombineRectangles(gfx::GetXDisplay(), GetAcceleratedWidget(),
ShapeInput, 0, 0, &r, 1, ShapeSet, YXBanded);
} else {
XShapeCombineMask(gfx::GetXDisplay(), GetAcceleratedWidget(),
ShapeInput, 0, 0, None, ShapeSet);
XShapeCombineMask(gfx::GetXDisplay(), GetAcceleratedWidget(), ShapeInput, 0,
0, None, ShapeSet);
}
#endif
}
@ -997,7 +995,7 @@ void NativeWindowViews::SetParentWindow(NativeWindow* parent) {
XDisplay* xdisplay = gfx::GetXDisplay();
XSetTransientForHint(
xdisplay, GetAcceleratedWidget(),
parent? parent->GetAcceleratedWidget() : DefaultRootWindow(xdisplay));
parent ? parent->GetAcceleratedWidget() : DefaultRootWindow(xdisplay));
#elif defined(OS_WIN) && defined(DEBUG)
// Should work, but does not, it seems that the views toolkit doesn't support
// reparenting on desktop.
@ -1024,8 +1022,8 @@ gfx::NativeWindow NativeWindowViews::GetNativeWindow() const {
return window_->GetNativeWindow();
}
void NativeWindowViews::SetProgressBar(
double progress, NativeWindow::ProgressState state) {
void NativeWindowViews::SetProgressBar(double progress,
NativeWindow::ProgressState state) {
#if defined(OS_WIN)
taskbar_host_.SetProgressBar(GetAcceleratedWidget(), progress, state);
#elif defined(USE_X11)
@ -1085,8 +1083,8 @@ bool NativeWindowViews::IsVisibleOnAllWorkspaces() {
XAtom sticky_atom = GetAtom("_NET_WM_STATE_STICKY");
std::vector<XAtom> wm_states;
ui::GetAtomArrayProperty(GetAcceleratedWidget(), "_NET_WM_STATE", &wm_states);
return std::find(wm_states.begin(),
wm_states.end(), sticky_atom) != wm_states.end();
return std::find(wm_states.begin(), wm_states.end(), sticky_atom) !=
wm_states.end();
#endif
return false;
}
@ -1165,21 +1163,21 @@ void NativeWindowViews::SetIcon(HICON window_icon, HICON app_icon) {
void NativeWindowViews::SetIcon(const gfx::ImageSkia& icon) {
views::DesktopWindowTreeHostX11* tree_host =
views::DesktopWindowTreeHostX11::GetHostForXID(GetAcceleratedWidget());
static_cast<views::DesktopWindowTreeHost*>(tree_host)->SetWindowIcons(
icon, icon);
static_cast<views::DesktopWindowTreeHost*>(tree_host)->SetWindowIcons(icon,
icon);
}
#endif
void NativeWindowViews::OnWidgetActivationChanged(
views::Widget* widget, bool active) {
void NativeWindowViews::OnWidgetActivationChanged(views::Widget* widget,
bool active) {
if (widget != window_.get())
return;
// Post the notification to next tick.
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(active ? &NativeWindow::NotifyWindowFocus :
&NativeWindow::NotifyWindowBlur,
base::Bind(active ? &NativeWindow::NotifyWindowFocus
: &NativeWindow::NotifyWindowBlur,
GetWeakPtr()));
// Hide menu bar when window is blured.
@ -1189,8 +1187,8 @@ void NativeWindowViews::OnWidgetActivationChanged(
menu_bar_alt_pressed_ = false;
}
void NativeWindowViews::OnWidgetBoundsChanged(
views::Widget* widget, const gfx::Rect& bounds) {
void NativeWindowViews::OnWidgetBoundsChanged(views::Widget* widget,
const gfx::Rect& bounds) {
if (widget != window_.get())
return;
@ -1199,8 +1197,8 @@ void NativeWindowViews::OnWidgetBoundsChanged(
const auto new_bounds = GetBounds();
if (widget_size_ != new_bounds.size()) {
if (browser_view()) {
const auto flags = static_cast<NativeBrowserViewViews*>(browser_view())->
GetAutoResizeFlags();
const auto flags = static_cast<NativeBrowserViewViews*>(browser_view())
->GetAutoResizeFlags();
int width_delta = 0;
int height_delta = 0;
if (flags & kAutoResizeWidth) {
@ -1285,8 +1283,8 @@ bool NativeWindowViews::ShouldDescendIntoChildForEventHandling(
// And the events on border for dragging resizable frameless window.
if (!has_frame() && CanResize()) {
FramelessView* frame = static_cast<FramelessView*>(
window_->non_client_view()->frame_view());
FramelessView* frame =
static_cast<FramelessView*>(window_->non_client_view()->frame_view());
return frame->ResizingBorderHitTest(location) == HTNOWHERE;
}
@ -1328,8 +1326,8 @@ void NativeWindowViews::HandleKeyboardEvent(
// Show accelerator when "Alt" is pressed.
if (menu_bar_visible_ && IsAltKey(event))
menu_bar_->SetAcceleratorVisibility(
event.GetType() == blink::WebInputEvent::kRawKeyDown);
menu_bar_->SetAcceleratorVisibility(event.GetType() ==
blink::WebInputEvent::kRawKeyDown);
// Show the submenu when "Alt+Key" is pressed.
if (event.GetType() == blink::WebInputEvent::kRawKeyDown &&
@ -1385,8 +1383,8 @@ gfx::Size NativeWindowViews::GetMaximumSize() const {
}
bool NativeWindowViews::AcceleratorPressed(const ui::Accelerator& accelerator) {
return accelerator_util::TriggerAcceleratorTableCommand(
&accelerator_table_, accelerator);
return accelerator_util::TriggerAcceleratorTableCommand(&accelerator_table_,
accelerator);
}
void NativeWindowViews::RegisterAccelerators(AtomMenuModel* menu_model) {

View file

@ -13,58 +13,110 @@ namespace {
// Convert Win32 WM_APPCOMMANDS to strings.
const char* AppCommandToString(int command_id) {
switch (command_id) {
case APPCOMMAND_BROWSER_BACKWARD : return "browser-backward";
case APPCOMMAND_BROWSER_FORWARD : return "browser-forward";
case APPCOMMAND_BROWSER_REFRESH : return "browser-refresh";
case APPCOMMAND_BROWSER_STOP : return "browser-stop";
case APPCOMMAND_BROWSER_SEARCH : return "browser-search";
case APPCOMMAND_BROWSER_FAVORITES : return "browser-favorites";
case APPCOMMAND_BROWSER_HOME : return "browser-home";
case APPCOMMAND_VOLUME_MUTE : return "volume-mute";
case APPCOMMAND_VOLUME_DOWN : return "volume-down";
case APPCOMMAND_VOLUME_UP : return "volume-up";
case APPCOMMAND_MEDIA_NEXTTRACK : return "media-nexttrack";
case APPCOMMAND_MEDIA_PREVIOUSTRACK : return "media-previoustrack";
case APPCOMMAND_MEDIA_STOP : return "media-stop";
case APPCOMMAND_MEDIA_PLAY_PAUSE : return "media-play_pause";
case APPCOMMAND_LAUNCH_MAIL : return "launch-mail";
case APPCOMMAND_LAUNCH_MEDIA_SELECT : return "launch-media-select";
case APPCOMMAND_LAUNCH_APP1 : return "launch-app1";
case APPCOMMAND_LAUNCH_APP2 : return "launch-app2";
case APPCOMMAND_BASS_DOWN : return "bass-down";
case APPCOMMAND_BASS_BOOST : return "bass-boost";
case APPCOMMAND_BASS_UP : return "bass-up";
case APPCOMMAND_TREBLE_DOWN : return "treble-down";
case APPCOMMAND_TREBLE_UP : return "treble-up";
case APPCOMMAND_MICROPHONE_VOLUME_MUTE : return "microphone-volume-mute";
case APPCOMMAND_MICROPHONE_VOLUME_DOWN : return "microphone-volume-down";
case APPCOMMAND_MICROPHONE_VOLUME_UP : return "microphone-volume-up";
case APPCOMMAND_HELP : return "help";
case APPCOMMAND_FIND : return "find";
case APPCOMMAND_NEW : return "new";
case APPCOMMAND_OPEN : return "open";
case APPCOMMAND_CLOSE : return "close";
case APPCOMMAND_SAVE : return "save";
case APPCOMMAND_PRINT : return "print";
case APPCOMMAND_UNDO : return "undo";
case APPCOMMAND_REDO : return "redo";
case APPCOMMAND_COPY : return "copy";
case APPCOMMAND_CUT : return "cut";
case APPCOMMAND_PASTE : return "paste";
case APPCOMMAND_REPLY_TO_MAIL : return "reply-to-mail";
case APPCOMMAND_FORWARD_MAIL : return "forward-mail";
case APPCOMMAND_SEND_MAIL : return "send-mail";
case APPCOMMAND_SPELL_CHECK : return "spell-check";
case APPCOMMAND_MIC_ON_OFF_TOGGLE : return "mic-on-off-toggle";
case APPCOMMAND_CORRECTION_LIST : return "correction-list";
case APPCOMMAND_MEDIA_PLAY : return "media-play";
case APPCOMMAND_MEDIA_PAUSE : return "media-pause";
case APPCOMMAND_MEDIA_RECORD : return "media-record";
case APPCOMMAND_MEDIA_FAST_FORWARD : return "media-fast-forward";
case APPCOMMAND_MEDIA_REWIND : return "media-rewind";
case APPCOMMAND_MEDIA_CHANNEL_UP : return "media-channel-up";
case APPCOMMAND_MEDIA_CHANNEL_DOWN : return "media-channel-down";
case APPCOMMAND_DELETE : return "delete";
case APPCOMMAND_BROWSER_BACKWARD:
return "browser-backward";
case APPCOMMAND_BROWSER_FORWARD:
return "browser-forward";
case APPCOMMAND_BROWSER_REFRESH:
return "browser-refresh";
case APPCOMMAND_BROWSER_STOP:
return "browser-stop";
case APPCOMMAND_BROWSER_SEARCH:
return "browser-search";
case APPCOMMAND_BROWSER_FAVORITES:
return "browser-favorites";
case APPCOMMAND_BROWSER_HOME:
return "browser-home";
case APPCOMMAND_VOLUME_MUTE:
return "volume-mute";
case APPCOMMAND_VOLUME_DOWN:
return "volume-down";
case APPCOMMAND_VOLUME_UP:
return "volume-up";
case APPCOMMAND_MEDIA_NEXTTRACK:
return "media-nexttrack";
case APPCOMMAND_MEDIA_PREVIOUSTRACK:
return "media-previoustrack";
case APPCOMMAND_MEDIA_STOP:
return "media-stop";
case APPCOMMAND_MEDIA_PLAY_PAUSE:
return "media-play_pause";
case APPCOMMAND_LAUNCH_MAIL:
return "launch-mail";
case APPCOMMAND_LAUNCH_MEDIA_SELECT:
return "launch-media-select";
case APPCOMMAND_LAUNCH_APP1:
return "launch-app1";
case APPCOMMAND_LAUNCH_APP2:
return "launch-app2";
case APPCOMMAND_BASS_DOWN:
return "bass-down";
case APPCOMMAND_BASS_BOOST:
return "bass-boost";
case APPCOMMAND_BASS_UP:
return "bass-up";
case APPCOMMAND_TREBLE_DOWN:
return "treble-down";
case APPCOMMAND_TREBLE_UP:
return "treble-up";
case APPCOMMAND_MICROPHONE_VOLUME_MUTE:
return "microphone-volume-mute";
case APPCOMMAND_MICROPHONE_VOLUME_DOWN:
return "microphone-volume-down";
case APPCOMMAND_MICROPHONE_VOLUME_UP:
return "microphone-volume-up";
case APPCOMMAND_HELP:
return "help";
case APPCOMMAND_FIND:
return "find";
case APPCOMMAND_NEW:
return "new";
case APPCOMMAND_OPEN:
return "open";
case APPCOMMAND_CLOSE:
return "close";
case APPCOMMAND_SAVE:
return "save";
case APPCOMMAND_PRINT:
return "print";
case APPCOMMAND_UNDO:
return "undo";
case APPCOMMAND_REDO:
return "redo";
case APPCOMMAND_COPY:
return "copy";
case APPCOMMAND_CUT:
return "cut";
case APPCOMMAND_PASTE:
return "paste";
case APPCOMMAND_REPLY_TO_MAIL:
return "reply-to-mail";
case APPCOMMAND_FORWARD_MAIL:
return "forward-mail";
case APPCOMMAND_SEND_MAIL:
return "send-mail";
case APPCOMMAND_SPELL_CHECK:
return "spell-check";
case APPCOMMAND_MIC_ON_OFF_TOGGLE:
return "mic-on-off-toggle";
case APPCOMMAND_CORRECTION_LIST:
return "correction-list";
case APPCOMMAND_MEDIA_PLAY:
return "media-play";
case APPCOMMAND_MEDIA_PAUSE:
return "media-pause";
case APPCOMMAND_MEDIA_RECORD:
return "media-record";
case APPCOMMAND_MEDIA_FAST_FORWARD:
return "media-fast-forward";
case APPCOMMAND_MEDIA_REWIND:
return "media-rewind";
case APPCOMMAND_MEDIA_CHANNEL_UP:
return "media-channel-up";
case APPCOMMAND_MEDIA_CHANNEL_DOWN:
return "media-channel-down";
case APPCOMMAND_DELETE:
return "delete";
case APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE:
return "dictate-or-command-control-toggle";
default:
@ -89,8 +141,10 @@ bool NativeWindowViews::ExecuteWindowsCommand(int command_id) {
return false;
}
bool NativeWindowViews::PreHandleMSG(
UINT message, WPARAM w_param, LPARAM l_param, LRESULT* result) {
bool NativeWindowViews::PreHandleMSG(UINT message,
WPARAM w_param,
LPARAM l_param,
LRESULT* result) {
NotifyWindowMessage(message, w_param, l_param);
switch (message) {
@ -100,7 +154,8 @@ bool NativeWindowViews::PreHandleMSG(
// because we still want Chromium to handle returning the actual
// accessibility object.
case WM_GETOBJECT: {
if (checked_for_a11y_support_) return false;
if (checked_for_a11y_support_)
return false;
const DWORD obj_id = static_cast<DWORD>(l_param);
@ -231,8 +286,8 @@ void NativeWindowViews::SetForwardMouseMessages(bool forward) {
// Subclassing is used to fix some issues when forwarding mouse messages;
// see comments in |SubclassProc|.
SetWindowSubclass(
legacy_window_, SubclassProc, 1, reinterpret_cast<DWORD_PTR>(this));
SetWindowSubclass(legacy_window_, SubclassProc, 1,
reinterpret_cast<DWORD_PTR>(this));
if (!mouse_hook_) {
mouse_hook_ = SetWindowsHookEx(WH_MOUSE_LL, MouseHookProc, NULL, 0);
@ -250,9 +305,12 @@ void NativeWindowViews::SetForwardMouseMessages(bool forward) {
}
}
LRESULT CALLBACK NativeWindowViews::SubclassProc(
HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param, UINT_PTR subclass_id,
DWORD_PTR ref_data) {
LRESULT CALLBACK NativeWindowViews::SubclassProc(HWND hwnd,
UINT msg,
WPARAM w_param,
LPARAM l_param,
UINT_PTR subclass_id,
DWORD_PTR ref_data) {
NativeWindowViews* window = reinterpret_cast<NativeWindowViews*>(ref_data);
switch (msg) {
case WM_MOUSELEAVE: {
@ -276,8 +334,9 @@ LRESULT CALLBACK NativeWindowViews::SubclassProc(
return DefSubclassProc(hwnd, msg, w_param, l_param);
}
LRESULT CALLBACK NativeWindowViews::MouseHookProc(
int n_code, WPARAM w_param, LPARAM l_param) {
LRESULT CALLBACK NativeWindowViews::MouseHookProc(int n_code,
WPARAM w_param,
LPARAM l_param) {
if (n_code < 0) {
return CallNextHookEx(NULL, n_code, w_param, l_param);
}

View file

@ -14,8 +14,7 @@ AsarProtocolHandler::AsarProtocolHandler(
const scoped_refptr<base::TaskRunner>& file_task_runner)
: file_task_runner_(file_task_runner) {}
AsarProtocolHandler::~AsarProtocolHandler() {
}
AsarProtocolHandler::~AsarProtocolHandler() {}
net::URLRequestJob* AsarProtocolHandler::MaybeCreateJob(
net::URLRequest* request,

View file

@ -36,12 +36,10 @@ URLRequestAsarJob::FileMetaInfo::FileMetaInfo()
: file_size(0),
mime_type_result(false),
file_exists(false),
is_directory(false) {
}
is_directory(false) {}
URLRequestAsarJob::URLRequestAsarJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate)
URLRequestAsarJob::URLRequestAsarJob(net::URLRequest* request,
net::NetworkDelegate* network_delegate)
: net::URLRequestJob(request, network_delegate),
type_(TYPE_ERROR),
remaining_bytes_(0),
@ -118,8 +116,7 @@ void URLRequestAsarJob::Start() {
} else {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
base::Bind(&URLRequestAsarJob::DidOpen,
weak_ptr_factory_.GetWeakPtr(),
base::Bind(&URLRequestAsarJob::DidOpen, weak_ptr_factory_.GetWeakPtr(),
net::ERR_FILE_NOT_FOUND));
}
}
@ -140,11 +137,10 @@ int URLRequestAsarJob::ReadRawData(net::IOBuffer* dest, int dest_size) {
if (!dest_size)
return 0;
int rv = stream_->Read(dest,
dest_size,
base::Bind(&URLRequestAsarJob::DidRead,
weak_ptr_factory_.GetWeakPtr(),
WrapRefCounted(dest)));
int rv = stream_->Read(
dest, dest_size,
base::Bind(&URLRequestAsarJob::DidRead, weak_ptr_factory_.GetWeakPtr(),
WrapRefCounted(dest)));
if (rv >= 0) {
remaining_bytes_ -= rv;
DCHECK_GE(remaining_bytes_, 0);
@ -184,9 +180,9 @@ std::unique_ptr<net::SourceStream> URLRequestAsarJob::SetUpSourceStream() {
net::URLRequestJob::SetUpSourceStream();
// Bug 9936 - .svgz files needs to be decompressed.
return base::LowerCaseEqualsASCII(file_path_.Extension(), ".svgz")
? net::GzipSourceStream::Create(std::move(source),
net::SourceStream::TYPE_GZIP)
: std::move(source);
? net::GzipSourceStream::Create(std::move(source),
net::SourceStream::TYPE_GZIP)
: std::move(source);
}
bool URLRequestAsarJob::GetMimeType(std::string* mime_type) const {
@ -265,9 +261,8 @@ void URLRequestAsarJob::DidFetchMetaInfo(const FileMetaInfo* meta_info) {
return;
}
int flags = base::File::FLAG_OPEN |
base::File::FLAG_READ |
base::File::FLAG_ASYNC;
int flags =
base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_ASYNC;
int rv = stream_->Open(
meta_info_.file_path, flags,
base::Bind(&URLRequestAsarJob::DidOpen, weak_ptr_factory_.GetWeakPtr()));
@ -277,8 +272,8 @@ void URLRequestAsarJob::DidFetchMetaInfo(const FileMetaInfo* meta_info) {
void URLRequestAsarJob::DidOpen(int result) {
if (result != net::OK) {
NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED,
result));
NotifyStartError(
net::URLRequestStatus(net::URLRequestStatus::FAILED, result));
return;
}
@ -298,20 +293,19 @@ void URLRequestAsarJob::DidOpen(int result) {
}
if (!byte_range_.ComputeBounds(file_size)) {
NotifyStartError(
net::URLRequestStatus(net::URLRequestStatus::FAILED,
net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
NotifyStartError(net::URLRequestStatus(
net::URLRequestStatus::FAILED, net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
return;
}
remaining_bytes_ = byte_range_.last_byte_position() -
byte_range_.first_byte_position() + 1;
remaining_bytes_ =
byte_range_.last_byte_position() - byte_range_.first_byte_position() + 1;
seek_offset_ = byte_range_.first_byte_position() + read_offset;
if (remaining_bytes_ > 0 && seek_offset_ != 0) {
int rv = stream_->Seek(seek_offset_,
base::Bind(&URLRequestAsarJob::DidSeek,
weak_ptr_factory_.GetWeakPtr()));
int rv =
stream_->Seek(seek_offset_, base::Bind(&URLRequestAsarJob::DidSeek,
weak_ptr_factory_.GetWeakPtr()));
if (rv != net::ERR_IO_PENDING) {
// stream_->Seek() failed, so pass an intentionally erroneous value
// into DidSeek().
@ -327,9 +321,8 @@ void URLRequestAsarJob::DidOpen(int result) {
void URLRequestAsarJob::DidSeek(int64_t result) {
if (result != seek_offset_) {
NotifyStartError(
net::URLRequestStatus(net::URLRequestStatus::FAILED,
net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
NotifyStartError(net::URLRequestStatus(
net::URLRequestStatus::FAILED, net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
return;
}
set_expected_content_size(remaining_bytes_);

View file

@ -75,8 +75,7 @@ class CertVerifierRequest : public AtomCertVerifier::Request {
delete response;
}
void Start(net::CRLSet* crl_set,
const net::NetLogWithSource& net_log) {
void Start(net::CRLSet* crl_set, const net::NetLogWithSource& net_log) {
int error = cert_verifier_->default_verifier()->Verify(
params_, crl_set, &result_,
base::Bind(&CertVerifierRequest::OnDefaultVerificationDone,
@ -158,13 +157,12 @@ void AtomCertVerifier::SetVerifyProc(const VerifyProc& proc) {
verify_proc_ = proc;
}
int AtomCertVerifier::Verify(
const RequestParams& params,
net::CRLSet* crl_set,
net::CertVerifyResult* verify_result,
const net::CompletionCallback& callback,
std::unique_ptr<Request>* out_req,
const net::NetLogWithSource& net_log) {
int AtomCertVerifier::Verify(const RequestParams& params,
net::CRLSet* crl_set,
net::CertVerifyResult* verify_result,
const net::CompletionCallback& callback,
std::unique_ptr<Request>* out_req,
const net::NetLogWithSource& net_log) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (verify_proc_.is_null()) {

View file

@ -15,8 +15,8 @@
#include "content/public/browser/render_frame_host.h"
#include "net/url_request/url_request.h"
using content::DevToolsNetworkTransaction;
using content::BrowserThread;
using content::DevToolsNetworkTransaction;
namespace atom {
@ -97,7 +97,7 @@ void ToDictionary(base::DictionaryValue* details, net::URLRequest* request) {
const auto* info = content::ResourceRequestInfo::ForRequest(request);
if (info) {
details->SetString("resourceType",
ResourceTypeToString(info->GetResourceType()));
ResourceTypeToString(info->GetResourceType()));
} else {
details->SetString("resourceType", "other");
}
@ -157,12 +157,12 @@ void ToDictionary(base::DictionaryValue* details,
}
// Helper function to fill |details| with arbitrary |args|.
template<typename Arg>
template <typename Arg>
void FillDetailsObject(base::DictionaryValue* details, Arg arg) {
ToDictionary(details, arg);
}
template<typename Arg, typename... Args>
template <typename Arg, typename... Args>
void FillDetailsObject(base::DictionaryValue* details, Arg arg, Args... args) {
ToDictionary(details, arg);
FillDetailsObject(details, args...);
@ -181,8 +181,7 @@ void ReadFromResponseObject(const base::DictionaryValue& response,
const base::DictionaryValue* dict;
if (response.GetDictionary("requestHeaders", &dict)) {
headers->Clear();
for (base::DictionaryValue::Iterator it(*dict);
!it.IsAtEnd();
for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd();
it.Advance()) {
std::string value;
if (it.value().GetAsString(&value))
@ -201,8 +200,7 @@ void ReadFromResponseObject(const base::DictionaryValue& response,
auto headers = container.first;
*headers = new net::HttpResponseHeaders("");
(*headers)->ReplaceStatusLine(status_line);
for (base::DictionaryValue::Iterator it(*dict);
!it.IsAtEnd();
for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd();
it.Advance()) {
const base::ListValue* list;
if (it.value().GetAsList(&list)) {
@ -219,30 +217,26 @@ void ReadFromResponseObject(const base::DictionaryValue& response,
} // namespace
AtomNetworkDelegate::AtomNetworkDelegate() {
}
AtomNetworkDelegate::AtomNetworkDelegate() {}
AtomNetworkDelegate::~AtomNetworkDelegate() {
}
AtomNetworkDelegate::~AtomNetworkDelegate() {}
void AtomNetworkDelegate::SetSimpleListenerInIO(
SimpleEvent type,
URLPatterns patterns,
SimpleListener callback) {
void AtomNetworkDelegate::SetSimpleListenerInIO(SimpleEvent type,
URLPatterns patterns,
SimpleListener callback) {
if (callback.is_null())
simple_listeners_.erase(type);
else
simple_listeners_[type] = { std::move(patterns), std::move(callback) };
simple_listeners_[type] = {std::move(patterns), std::move(callback)};
}
void AtomNetworkDelegate::SetResponseListenerInIO(
ResponseEvent type,
URLPatterns patterns,
ResponseListener callback) {
void AtomNetworkDelegate::SetResponseListenerInIO(ResponseEvent type,
URLPatterns patterns,
ResponseListener callback) {
if (callback.is_null())
response_listeners_.erase(type);
else
response_listeners_[type] = { std::move(patterns), std::move(callback) };
response_listeners_[type] = {std::move(patterns), std::move(callback)};
}
void AtomNetworkDelegate::SetDevToolsNetworkEmulationClientId(
@ -255,8 +249,8 @@ int AtomNetworkDelegate::OnBeforeURLRequest(
const net::CompletionCallback& callback,
GURL* new_url) {
if (!base::ContainsKey(response_listeners_, kOnBeforeRequest))
return brightray::NetworkDelegate::OnBeforeURLRequest(
request, callback, new_url);
return brightray::NetworkDelegate::OnBeforeURLRequest(request, callback,
new_url);
return HandleResponseEvent(kOnBeforeRequest, request, callback, new_url);
}
@ -273,8 +267,8 @@ int AtomNetworkDelegate::OnBeforeStartTransaction(
return brightray::NetworkDelegate::OnBeforeStartTransaction(
request, callback, headers);
return HandleResponseEvent(
kOnBeforeSendHeaders, request, callback, headers, *headers);
return HandleResponseEvent(kOnBeforeSendHeaders, request, callback, headers,
*headers);
}
void AtomNetworkDelegate::OnStartTransaction(
@ -358,8 +352,8 @@ void AtomNetworkDelegate::OnURLRequestDestroyed(net::URLRequest* request) {
callbacks_.erase(request->identifier());
}
void AtomNetworkDelegate::OnErrorOccurred(
net::URLRequest* request, bool started) {
void AtomNetworkDelegate::OnErrorOccurred(net::URLRequest* request,
bool started) {
if (!base::ContainsKey(simple_listeners_, kOnErrorOccurred)) {
brightray::NetworkDelegate::OnCompleted(request, started);
return;
@ -369,7 +363,7 @@ void AtomNetworkDelegate::OnErrorOccurred(
request->status());
}
template<typename Out, typename... Args>
template <typename Out, typename... Args>
int AtomNetworkDelegate::HandleResponseEvent(
ResponseEvent type,
net::URLRequest* request,
@ -400,9 +394,10 @@ int AtomNetworkDelegate::HandleResponseEvent(
return net::ERR_IO_PENDING;
}
template<typename...Args>
void AtomNetworkDelegate::HandleSimpleEvent(
SimpleEvent type, net::URLRequest* request, Args... args) {
template <typename... Args>
void AtomNetworkDelegate::HandleSimpleEvent(SimpleEvent type,
net::URLRequest* request,
Args... args) {
const auto& info = simple_listeners_[type];
if (!MatchesFilterCondition(request, info.url_patterns))
return;
@ -420,9 +415,11 @@ void AtomNetworkDelegate::HandleSimpleEvent(
render_process_id, render_frame_id));
}
template<typename T>
template <typename T>
void AtomNetworkDelegate::OnListenerResultInIO(
uint64_t id, T out, std::unique_ptr<base::DictionaryValue> response) {
uint64_t id,
T out,
std::unique_ptr<base::DictionaryValue> response) {
// The request has been destroyed.
if (!base::ContainsKey(callbacks_, id))
return;
@ -434,14 +431,16 @@ void AtomNetworkDelegate::OnListenerResultInIO(
callbacks_[id].Run(cancel ? net::ERR_BLOCKED_BY_CLIENT : net::OK);
}
template<typename T>
template <typename T>
void AtomNetworkDelegate::OnListenerResultInUI(
uint64_t id, T out, const base::DictionaryValue& response) {
uint64_t id,
T out,
const base::DictionaryValue& response) {
std::unique_ptr<base::DictionaryValue> copy = response.CreateDeepCopy();
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&AtomNetworkDelegate::OnListenerResultInIO<T>,
base::Unretained(this), id, out, base::Passed(&copy)));
base::Unretained(this), id, out, base::Passed(&copy)));
}
} // namespace atom

View file

@ -127,7 +127,7 @@ bool AtomURLRequestJobFactory::IsHandledProtocol(
DCHECK_CURRENTLY_ON(BrowserThread::IO);
return HasProtocolHandler(scheme) ||
net::URLRequest::IsHandledProtocol(scheme);
net::URLRequest::IsHandledProtocol(scheme);
}
bool AtomURLRequestJobFactory::IsSafeRedirectTarget(

View file

@ -9,18 +9,14 @@
namespace atom {
HttpProtocolHandler::HttpProtocolHandler(const std::string& scheme)
: scheme_(scheme) {
}
: scheme_(scheme) {}
HttpProtocolHandler::~HttpProtocolHandler() {
}
HttpProtocolHandler::~HttpProtocolHandler() {}
net::URLRequestJob* HttpProtocolHandler::MaybeCreateJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate) const {
return net::URLRequestHttpJob::Factory(request,
network_delegate,
scheme_);
return net::URLRequestHttpJob::Factory(request, network_delegate, scheme_);
}
} // namespace atom

View file

@ -22,9 +22,8 @@ void HandlerCallback(const BeforeStartCallback& before_start,
// If there is no argument passed then we failed.
v8::Local<v8::Value> value;
if (!args->GetNext(&value)) {
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::Bind(callback, false, nullptr));
content::BrowserThread::PostTask(content::BrowserThread::IO, FROM_HERE,
base::Bind(callback, false, nullptr));
return;
}
@ -52,10 +51,9 @@ void AskForOptions(v8::Isolate* isolate,
v8::HandleScope handle_scope(isolate);
v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Context::Scope context_scope(context);
handler.Run(
*(request_details.get()),
mate::ConvertToV8(isolate,
base::Bind(&HandlerCallback, before_start, callback)));
handler.Run(*(request_details.get()),
mate::ConvertToV8(isolate, base::Bind(&HandlerCallback,
before_start, callback)));
}
bool IsErrorOptions(base::Value* value, int* error) {

View file

@ -14,21 +14,20 @@ namespace atom {
URLRequestAsyncAsarJob::URLRequestAsyncAsarJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate)
: JsAsker<asar::URLRequestAsarJob>(request, network_delegate) {
}
: JsAsker<asar::URLRequestAsarJob>(request, network_delegate) {}
void URLRequestAsyncAsarJob::StartAsync(std::unique_ptr<base::Value> options) {
base::FilePath::StringType file_path;
if (options->IsType(base::Value::Type::DICTIONARY)) {
static_cast<base::DictionaryValue*>(options.get())->GetString(
"path", &file_path);
static_cast<base::DictionaryValue*>(options.get())
->GetString("path", &file_path);
} else if (options->IsType(base::Value::Type::STRING)) {
options->GetAsString(&file_path);
}
if (file_path.empty()) {
NotifyStartError(net::URLRequestStatus(
net::URLRequestStatus::FAILED, net::ERR_NOT_IMPLEMENTED));
NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED,
net::ERR_NOT_IMPLEMENTED));
} else {
asar::URLRequestAsarJob::Initialize(
base::CreateSequencedTaskRunnerWithTraits(

View file

@ -26,11 +26,10 @@ std::string GetExtFromURL(const GURL& url) {
} // namespace
URLRequestBufferJob::URLRequestBufferJob(
net::URLRequest* request, net::NetworkDelegate* network_delegate)
URLRequestBufferJob::URLRequestBufferJob(net::URLRequest* request,
net::NetworkDelegate* network_delegate)
: JsAsker<net::URLRequestSimpleJob>(request, network_delegate),
status_code_(net::HTTP_NOT_IMPLEMENTED) {
}
status_code_(net::HTTP_NOT_IMPLEMENTED) {}
void URLRequestBufferJob::StartAsync(std::unique_ptr<base::Value> options) {
const base::Value* binary = nullptr;
@ -54,8 +53,8 @@ void URLRequestBufferJob::StartAsync(std::unique_ptr<base::Value> options) {
}
if (!binary) {
NotifyStartError(net::URLRequestStatus(
net::URLRequestStatus::FAILED, net::ERR_NOT_IMPLEMENTED));
NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED,
net::ERR_NOT_IMPLEMENTED));
return;
}

View file

@ -77,15 +77,14 @@ class ResponsePiper : public net::URLFetcherResponseWriter {
} // namespace
URLRequestFetchJob::URLRequestFetchJob(
net::URLRequest* request, net::NetworkDelegate* network_delegate)
URLRequestFetchJob::URLRequestFetchJob(net::URLRequest* request,
net::NetworkDelegate* network_delegate)
: JsAsker<net::URLRequestJob>(request, network_delegate),
pending_buffer_size_(0),
write_num_bytes_(0) {
}
write_num_bytes_(0) {}
void URLRequestFetchJob::BeforeStartInUI(
v8::Isolate* isolate, v8::Local<v8::Value> value) {
void URLRequestFetchJob::BeforeStartInUI(v8::Isolate* isolate,
v8::Local<v8::Value> value) {
mate::Dictionary options;
if (!mate::ConvertFromV8(isolate, value, &options))
return;
@ -112,8 +111,8 @@ void URLRequestFetchJob::BeforeStartInUI(
void URLRequestFetchJob::StartAsync(std::unique_ptr<base::Value> options) {
if (!options->IsType(base::Value::Type::DICTIONARY)) {
NotifyStartError(net::URLRequestStatus(
net::URLRequestStatus::FAILED, net::ERR_NOT_IMPLEMENTED));
NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED,
net::ERR_NOT_IMPLEMENTED));
return;
}
@ -129,8 +128,8 @@ void URLRequestFetchJob::StartAsync(std::unique_ptr<base::Value> options) {
// Check if URL is valid.
GURL formated_url(url);
if (!formated_url.is_valid()) {
NotifyStartError(net::URLRequestStatus(
net::URLRequestStatus::FAILED, net::ERR_INVALID_URL));
NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED,
net::ERR_INVALID_URL));
return;
}
@ -191,8 +190,8 @@ int URLRequestFetchJob::DataAvailable(net::IOBuffer* buffer,
}
// Write data to the pending buffer and clear them after the writing.
int bytes_read = BufferCopy(buffer, num_bytes,
pending_buffer_.get(), pending_buffer_size_);
int bytes_read = BufferCopy(buffer, num_bytes, pending_buffer_.get(),
pending_buffer_size_);
ClearPendingBuffer();
ReadRawDataComplete(bytes_read);
return bytes_read;
@ -218,8 +217,8 @@ int URLRequestFetchJob::ReadRawData(net::IOBuffer* dest, int dest_size) {
}
// Read from the write buffer and clear them after reading.
int bytes_read = BufferCopy(write_buffer_.get(), write_num_bytes_,
dest, dest_size);
int bytes_read =
BufferCopy(write_buffer_.get(), write_num_bytes_, dest, dest_size);
net::CompletionCallback write_callback = write_callback_;
ClearWriteBuffer();
write_callback.Run(bytes_read);
@ -265,8 +264,10 @@ void URLRequestFetchJob::OnURLFetchComplete(const net::URLFetcher* source) {
}
}
int URLRequestFetchJob::BufferCopy(net::IOBuffer* source, int num_bytes,
net::IOBuffer* target, int target_size) {
int URLRequestFetchJob::BufferCopy(net::IOBuffer* source,
int num_bytes,
net::IOBuffer* target,
int target_size) {
int bytes_written = std::min(num_bytes, target_size);
memcpy(target->data(), source->data(), bytes_written);
return bytes_written;

View file

@ -11,10 +11,9 @@
namespace atom {
URLRequestStringJob::URLRequestStringJob(
net::URLRequest* request, net::NetworkDelegate* network_delegate)
: JsAsker<net::URLRequestSimpleJob>(request, network_delegate) {
}
URLRequestStringJob::URLRequestStringJob(net::URLRequest* request,
net::NetworkDelegate* network_delegate)
: JsAsker<net::URLRequestSimpleJob>(request, network_delegate) {}
void URLRequestStringJob::StartAsync(std::unique_ptr<base::Value> options) {
if (options->IsType(base::Value::Type::DICTIONARY)) {

View file

@ -13,12 +13,9 @@
namespace atom {
NodeDebugger::NodeDebugger(node::Environment* env)
: env_(env) {
}
NodeDebugger::NodeDebugger(node::Environment* env) : env_(env) {}
NodeDebugger::~NodeDebugger() {
}
NodeDebugger::~NodeDebugger() {}
void NodeDebugger::Start(node::MultiIsolatePlatform* platform) {
auto inspector = env_->inspector_agent();

View file

@ -13,25 +13,22 @@ namespace atom {
OffScreenOutputDevice::OffScreenOutputDevice(bool transparent,
const OnPaintCallback& callback)
: transparent_(transparent),
callback_(callback),
active_(false) {
: transparent_(transparent), callback_(callback), active_(false) {
DCHECK(!callback_.is_null());
}
OffScreenOutputDevice::~OffScreenOutputDevice() {
}
OffScreenOutputDevice::~OffScreenOutputDevice() {}
void OffScreenOutputDevice::Resize(
const gfx::Size& pixel_size, float scale_factor) {
if (viewport_pixel_size_ == pixel_size) return;
void OffScreenOutputDevice::Resize(const gfx::Size& pixel_size,
float scale_factor) {
if (viewport_pixel_size_ == pixel_size)
return;
viewport_pixel_size_ = pixel_size;
canvas_.reset();
bitmap_.reset(new SkBitmap);
bitmap_->allocN32Pixels(viewport_pixel_size_.width(),
viewport_pixel_size_.height(),
!transparent_);
viewport_pixel_size_.height(), !transparent_);
if (bitmap_->drawsNothing()) {
NOTREACHED();
bitmap_.reset();
@ -52,11 +49,9 @@ SkCanvas* OffScreenOutputDevice::BeginPaint(const gfx::Rect& damage_rect) {
DCHECK(bitmap_.get());
damage_rect_ = damage_rect;
SkIRect damage = SkIRect::MakeXYWH(
damage_rect_.x(),
damage_rect_.y(),
damage_rect_.width(),
damage_rect_.height());
SkIRect damage =
SkIRect::MakeXYWH(damage_rect_.x(), damage_rect_.y(),
damage_rect_.width(), damage_rect_.height());
if (transparent_) {
bitmap_->erase(SK_ColorTRANSPARENT, damage);
@ -71,7 +66,8 @@ void OffScreenOutputDevice::EndPaint() {
DCHECK(canvas_.get());
DCHECK(bitmap_.get());
if (!bitmap_.get()) return;
if (!bitmap_.get())
return;
viz::SoftwareOutputDevice::EndPaint();

View file

@ -106,7 +106,8 @@ ui::MouseEvent UiMouseEventFromWebMouseEvent(blink::WebMouseEvent event) {
ui::MouseWheelEvent UiMouseWheelEventFromWebMouseEvent(
blink::WebMouseWheelEvent event) {
return ui::MouseWheelEvent(UiMouseEventFromWebMouseEvent(event),
std::floor(event.delta_x), std::floor(event.delta_y));
std::floor(event.delta_x),
std::floor(event.delta_y));
}
} // namespace
@ -115,12 +116,12 @@ class AtomCopyFrameGenerator {
public:
AtomCopyFrameGenerator(OffScreenRenderWidgetHostView* view,
int frame_rate_threshold_us)
: view_(view),
frame_retry_count_(0),
next_frame_time_(base::TimeTicks::Now()),
frame_duration_(base::TimeDelta::FromMicroseconds(
frame_rate_threshold_us)),
weak_ptr_factory_(this) {
: view_(view),
frame_retry_count_(0),
next_frame_time_(base::TimeTicks::Now()),
frame_duration_(
base::TimeDelta::FromMicroseconds(frame_rate_threshold_us)),
weak_ptr_factory_(this) {
last_time_ = base::Time::Now();
}
@ -129,19 +130,18 @@ class AtomCopyFrameGenerator {
return;
auto request = std::make_unique<viz::CopyOutputRequest>(
viz::CopyOutputRequest::ResultFormat::RGBA_BITMAP,
base::BindOnce(
&AtomCopyFrameGenerator::CopyFromCompositingSurfaceHasResult,
weak_ptr_factory_.GetWeakPtr(),
damage_rect));
viz::CopyOutputRequest::ResultFormat::RGBA_BITMAP,
base::BindOnce(
&AtomCopyFrameGenerator::CopyFromCompositingSurfaceHasResult,
weak_ptr_factory_.GetWeakPtr(), damage_rect));
request->set_area(gfx::Rect(view_->GetPhysicalBackingSize()));
view_->GetRootLayer()->RequestCopyOfOutput(std::move(request));
}
void set_frame_rate_threshold_us(int frame_rate_threshold_us) {
frame_duration_ = base::TimeDelta::FromMicroseconds(
frame_rate_threshold_us);
frame_duration_ =
base::TimeDelta::FromMicroseconds(frame_rate_threshold_us);
}
private:
@ -165,13 +165,11 @@ class AtomCopyFrameGenerator {
base::TimeDelta next_frame_in = next_frame_time_ - now;
if (next_frame_in > frame_duration_ / 4) {
next_frame_time_ += frame_duration_;
content::BrowserThread::PostDelayedTask(content::BrowserThread::UI,
FROM_HERE,
base::Bind(&AtomCopyFrameGenerator::OnCopyFrameCaptureSuccess,
weak_ptr_factory_.GetWeakPtr(),
damage_rect,
bitmap),
next_frame_in);
content::BrowserThread::PostDelayedTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(&AtomCopyFrameGenerator::OnCopyFrameCaptureSuccess,
weak_ptr_factory_.GetWeakPtr(), damage_rect, bitmap),
next_frame_in);
} else {
next_frame_time_ = now + frame_duration_;
OnCopyFrameCaptureSuccess(damage_rect, bitmap);
@ -187,16 +185,15 @@ class AtomCopyFrameGenerator {
const bool force_frame = (++frame_retry_count_ <= kFrameRetryLimit);
if (force_frame) {
// Retry with the same |damage_rect|.
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
base::Bind(&AtomCopyFrameGenerator::GenerateCopyFrame,
weak_ptr_factory_.GetWeakPtr(),
damage_rect));
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(&AtomCopyFrameGenerator::GenerateCopyFrame,
weak_ptr_factory_.GetWeakPtr(), damage_rect));
}
}
void OnCopyFrameCaptureSuccess(
const gfx::Rect& damage_rect,
const std::shared_ptr<SkBitmap>& bitmap) {
void OnCopyFrameCaptureSuccess(const gfx::Rect& damage_rect,
const std::shared_ptr<SkBitmap>& bitmap) {
base::AutoLock lock(onPaintLock_);
view_->OnPaint(damage_rect, *bitmap);
}
@ -223,20 +220,17 @@ class AtomBeginFrameTimer : public viz::DelayBasedTimeSourceClient {
: callback_(callback) {
time_source_.reset(new viz::DelayBasedTimeSource(
content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::UI).get()));
content::BrowserThread::UI)
.get()));
time_source_->SetTimebaseAndInterval(
base::TimeTicks(),
base::TimeDelta::FromMicroseconds(frame_rate_threshold_us));
base::TimeTicks(),
base::TimeDelta::FromMicroseconds(frame_rate_threshold_us));
time_source_->SetClient(this);
}
void SetActive(bool active) {
time_source_->SetActive(active);
}
void SetActive(bool active) { time_source_->SetActive(active); }
bool IsActive() const {
return time_source_->Active();
}
bool IsActive() const { return time_source_->Active(); }
void SetFrameRateThresholdUs(int frame_rate_threshold_us) {
time_source_->SetTimebaseAndInterval(
@ -245,9 +239,7 @@ class AtomBeginFrameTimer : public viz::DelayBasedTimeSourceClient {
}
private:
void OnTimerTick() override {
callback_.Run();
}
void OnTimerTick() override { callback_.Run(); }
const base::Closure callback_;
std::unique_ptr<viz::DelayBasedTimeSource> time_source_;
@ -308,13 +300,11 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView(
ui::ContextFactoryPrivate* context_factory_private =
factory->GetContextFactoryPrivate();
compositor_.reset(
new ui::Compositor(
context_factory_private->AllocateFrameSinkId(),
content::GetContextFactory(),
context_factory_private,
base::ThreadTaskRunnerHandle::Get(),
false /* enable_surface_synchronization */,
false /* enable_pixel_canvas */));
new ui::Compositor(context_factory_private->AllocateFrameSinkId(),
content::GetContextFactory(), context_factory_private,
base::ThreadTaskRunnerHandle::Get(),
false /* enable_surface_synchronization */,
false /* enable_pixel_canvas */));
compositor_->SetAcceleratedWidget(gfx::kNullAcceleratedWidget);
compositor_->SetRootLayer(root_layer_.get());
#endif
@ -373,7 +363,8 @@ void OffScreenRenderWidgetHostView::OnBeginFrameTimerTick() {
}
void OffScreenRenderWidgetHostView::SendBeginFrame(
base::TimeTicks frame_time, base::TimeDelta vsync_period) {
base::TimeTicks frame_time,
base::TimeDelta vsync_period) {
base::TimeTicks display_time = frame_time + vsync_period;
base::TimeDelta estimated_browser_composite_time =
@ -382,11 +373,10 @@ void OffScreenRenderWidgetHostView::SendBeginFrame(
base::TimeTicks deadline = display_time - estimated_browser_composite_time;
const viz::BeginFrameArgs& begin_frame_args =
viz::BeginFrameArgs::Create(BEGINFRAME_FROM_HERE,
begin_frame_source_.source_id(),
begin_frame_number_, frame_time, deadline,
vsync_period, viz::BeginFrameArgs::NORMAL);
const viz::BeginFrameArgs& begin_frame_args = viz::BeginFrameArgs::Create(
BEGINFRAME_FROM_HERE, begin_frame_source_.source_id(),
begin_frame_number_, frame_time, deadline, vsync_period,
viz::BeginFrameArgs::NORMAL);
DCHECK(begin_frame_args.IsValid());
begin_frame_number_++;
@ -398,8 +388,7 @@ bool OffScreenRenderWidgetHostView::OnMessageReceived(
const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(OffScreenRenderWidgetHostView, message)
IPC_MESSAGE_HANDLER(ViewHostMsg_SetNeedsBeginFrames,
SetNeedsBeginFrames)
IPC_MESSAGE_HANDLER(ViewHostMsg_SetNeedsBeginFrames, SetNeedsBeginFrames)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@ -453,8 +442,7 @@ ui::TextInputClient* OffScreenRenderWidgetHostView::GetTextInputClient() {
return nullptr;
}
void OffScreenRenderWidgetHostView::Focus() {
}
void OffScreenRenderWidgetHostView::Focus() {}
bool OffScreenRenderWidgetHostView::HasFocus() const {
return false;
@ -528,15 +516,13 @@ gfx::Size OffScreenRenderWidgetHostView::GetVisibleViewportSize() const {
return size_;
}
void OffScreenRenderWidgetHostView::SetInsets(const gfx::Insets& insets) {
}
void OffScreenRenderWidgetHostView::SetInsets(const gfx::Insets& insets) {}
bool OffScreenRenderWidgetHostView::LockMouse() {
return false;
}
void OffScreenRenderWidgetHostView::UnlockMouse() {
}
void OffScreenRenderWidgetHostView::UnlockMouse() {}
void OffScreenRenderWidgetHostView::DidCreateNewRendererCompositorFrameSink(
viz::mojom::CompositorFrameSinkClient* renderer_compositor_frame_sink) {
@ -551,7 +537,7 @@ void OffScreenRenderWidgetHostView::SubmitCompositorFrame(
const viz::LocalSurfaceId& local_surface_id,
viz::CompositorFrame frame) {
TRACE_EVENT0("electron",
"OffScreenRenderWidgetHostView::SubmitCompositorFrame");
"OffScreenRenderWidgetHostView::SubmitCompositorFrame");
if (frame.metadata.root_scroll_offset != last_scroll_offset_) {
last_scroll_offset_ = frame.metadata.root_scroll_offset;
@ -602,7 +588,8 @@ void OffScreenRenderWidgetHostView::ClearCompositorFrame() {
}
void OffScreenRenderWidgetHostView::InitAsPopup(
content::RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) {
content::RenderWidgetHostView* parent_host_view,
const gfx::Rect& pos) {
DCHECK_EQ(parent_host_view_, parent_host_view);
if (parent_host_view_->popup_host_view_) {
@ -611,8 +598,9 @@ void OffScreenRenderWidgetHostView::InitAsPopup(
parent_host_view_->set_popup_host_view(this);
parent_host_view_->popup_bitmap_.reset(new SkBitmap);
parent_callback_ = base::Bind(&OffScreenRenderWidgetHostView::OnPopupPaint,
parent_host_view_->weak_ptr_factory_.GetWeakPtr());
parent_callback_ =
base::Bind(&OffScreenRenderWidgetHostView::OnPopupPaint,
parent_host_view_->weak_ptr_factory_.GetWeakPtr());
popup_position_ = pos;
@ -621,24 +609,19 @@ void OffScreenRenderWidgetHostView::InitAsPopup(
}
void OffScreenRenderWidgetHostView::InitAsFullscreen(
content::RenderWidgetHostView *) {
}
content::RenderWidgetHostView*) {}
void OffScreenRenderWidgetHostView::UpdateCursor(const content::WebCursor &) {
}
void OffScreenRenderWidgetHostView::UpdateCursor(const content::WebCursor&) {}
void OffScreenRenderWidgetHostView::SetIsLoading(bool loading) {
}
void OffScreenRenderWidgetHostView::SetIsLoading(bool loading) {}
void OffScreenRenderWidgetHostView::TextInputStateChanged(
const content::TextInputState& params) {
}
const content::TextInputState& params) {}
void OffScreenRenderWidgetHostView::ImeCancelComposition() {
}
void OffScreenRenderWidgetHostView::ImeCancelComposition() {}
void OffScreenRenderWidgetHostView::RenderProcessGone(base::TerminationStatus,
int) {
int) {
Destroy();
}
@ -671,12 +654,10 @@ void OffScreenRenderWidgetHostView::Destroy() {
delete this;
}
void OffScreenRenderWidgetHostView::SetTooltipText(const base::string16 &) {
}
void OffScreenRenderWidgetHostView::SetTooltipText(const base::string16&) {}
void OffScreenRenderWidgetHostView::SelectionBoundsChanged(
const ViewHostMsg_SelectionBounds_Params &) {
}
const ViewHostMsg_SelectionBounds_Params&) {}
void OffScreenRenderWidgetHostView::CopyFromSurface(
const gfx::Rect& src_subrect,
@ -684,7 +665,7 @@ void OffScreenRenderWidgetHostView::CopyFromSurface(
const content::ReadbackRequestCallback& callback,
const SkColorType preferred_color_type) {
GetDelegatedFrameHost()->CopyFromCompositingSurface(
src_subrect, dst_size, callback, preferred_color_type);
src_subrect, dst_size, callback, preferred_color_type);
}
void OffScreenRenderWidgetHostView::CopyFromSurfaceToVideoFrame(
@ -692,11 +673,11 @@ void OffScreenRenderWidgetHostView::CopyFromSurfaceToVideoFrame(
scoped_refptr<media::VideoFrame> target,
const base::Callback<void(const gfx::Rect&, bool)>& callback) {
GetDelegatedFrameHost()->CopyFromCompositingSurfaceToVideoFrame(
src_subrect, target, callback);
src_subrect, target, callback);
}
void OffScreenRenderWidgetHostView::BeginFrameSubscription(
std::unique_ptr<content::RenderWidgetHostViewFrameSubscriber> subscriber) {
std::unique_ptr<content::RenderWidgetHostViewFrameSubscriber> subscriber) {
GetDelegatedFrameHost()->BeginFrameSubscription(std::move(subscriber));
}
@ -711,7 +692,7 @@ void OffScreenRenderWidgetHostView::InitAsGuest(
parent_host_view_->RegisterGuestViewFrameSwappedCallback(guest_view);
}
bool OffScreenRenderWidgetHostView::HasAcceleratedSurface(const gfx::Size &) {
bool OffScreenRenderWidgetHostView::HasAcceleratedSurface(const gfx::Size&) {
return false;
}
@ -720,8 +701,8 @@ gfx::Rect OffScreenRenderWidgetHostView::GetBoundsInRootWindow() {
}
void OffScreenRenderWidgetHostView::ImeCompositionRangeChanged(
const gfx::Range &, const std::vector<gfx::Rect>&) {
}
const gfx::Range&,
const std::vector<gfx::Rect>&) {}
gfx::Size OffScreenRenderWidgetHostView::GetPhysicalBackingSize() const {
return gfx::ScaleToCeiledSize(GetRequestedRendererSize(), scale_factor_);
@ -732,7 +713,7 @@ gfx::Size OffScreenRenderWidgetHostView::GetRequestedRendererSize() const {
}
content::RenderWidgetHostViewBase*
OffScreenRenderWidgetHostView::CreateViewForWidget(
OffScreenRenderWidgetHostView::CreateViewForWidget(
content::RenderWidgetHost* render_widget_host,
content::RenderWidgetHost* embedder_render_widget_host,
content::WebContentsView* web_contents_view) {
@ -748,13 +729,8 @@ content::RenderWidgetHostViewBase*
}
return new OffScreenRenderWidgetHostView(
transparent_,
true,
embedder_host_view->GetFrameRate(),
callback_,
render_widget_host,
embedder_host_view,
native_window_);
transparent_, true, embedder_host_view->GetFrameRate(), callback_,
render_widget_host, embedder_host_view, native_window_);
}
#if !defined(OS_MACOSX)
@ -776,7 +752,7 @@ SkColor OffScreenRenderWidgetHostView::DelegatedFrameHostGetGutterColor(
}
gfx::Size OffScreenRenderWidgetHostView::DelegatedFrameHostDesiredSizeInDIP()
const {
const {
return GetRootLayer()->bounds().size();
}
@ -795,8 +771,7 @@ viz::LocalSurfaceId OffScreenRenderWidgetHostView::GetLocalSurfaceId() const {
return local_surface_id_;
}
void OffScreenRenderWidgetHostView::OnBeginFrame() {
}
void OffScreenRenderWidgetHostView::OnBeginFrame() {}
std::unique_ptr<ui::CompositorLock>
OffScreenRenderWidgetHostView::GetCompositorLock(
@ -816,8 +791,7 @@ bool OffScreenRenderWidgetHostView::TransformPointToLocalCoordSpace(
gfx::Point* transformed_point) {
// Transformations use physical pixels rather than DIP, so conversion
// is necessary.
gfx::Point point_in_pixels =
gfx::ConvertPointToPixel(scale_factor_, point);
gfx::Point point_in_pixels = gfx::ConvertPointToPixel(scale_factor_, point);
if (!GetDelegatedFrameHost()->TransformPointToLocalCoordSpace(
point_in_pixels, original_surface, transformed_point)) {
return false;
@ -897,22 +871,22 @@ void OffScreenRenderWidgetHostView::ProxyViewDestroyed(
void OffScreenRenderWidgetHostView::RegisterGuestViewFrameSwappedCallback(
content::RenderWidgetHostViewGuest* guest_host_view) {
guest_host_view->RegisterFrameSwappedCallback(std::make_unique<base::Closure>(
base::Bind(&OffScreenRenderWidgetHostView::OnGuestViewFrameSwapped,
weak_ptr_factory_.GetWeakPtr(),
base::Unretained(guest_host_view))));
guest_host_view->RegisterFrameSwappedCallback(
std::make_unique<base::Closure>(base::Bind(
&OffScreenRenderWidgetHostView::OnGuestViewFrameSwapped,
weak_ptr_factory_.GetWeakPtr(), base::Unretained(guest_host_view))));
}
void OffScreenRenderWidgetHostView::OnGuestViewFrameSwapped(
content::RenderWidgetHostViewGuest* guest_host_view) {
InvalidateBounds(
gfx::ConvertRectToPixel(scale_factor_, guest_host_view->GetViewBounds()));
gfx::ConvertRectToPixel(scale_factor_, guest_host_view->GetViewBounds()));
RegisterGuestViewFrameSwappedCallback(guest_host_view);
}
std::unique_ptr<viz::SoftwareOutputDevice>
OffScreenRenderWidgetHostView::CreateSoftwareOutputDevice(
OffScreenRenderWidgetHostView::CreateSoftwareOutputDevice(
ui::Compositor* compositor) {
DCHECK_EQ(GetCompositor(), compositor);
DCHECK(!copy_frame_generator_);
@ -921,9 +895,8 @@ std::unique_ptr<viz::SoftwareOutputDevice>
ResizeRootLayer();
software_output_device_ = new OffScreenOutputDevice(
transparent_,
base::Bind(&OffScreenRenderWidgetHostView::OnPaint,
weak_ptr_factory_.GetWeakPtr()));
transparent_, base::Bind(&OffScreenRenderWidgetHostView::OnPaint,
weak_ptr_factory_.GetWeakPtr()));
return base::WrapUnique(software_output_device_);
}
@ -955,32 +928,34 @@ void OffScreenRenderWidgetHostView::SetNeedsBeginFrames(
}
}
void CopyBitmapTo(
const SkBitmap& destination,
const SkBitmap& source,
const gfx::Rect& pos) {
void CopyBitmapTo(const SkBitmap& destination,
const SkBitmap& source,
const gfx::Rect& pos) {
char* src = static_cast<char*>(source.getPixels());
char* dest = static_cast<char*>(destination.getPixels());
int pixelsize = source.bytesPerPixel();
int width = pos.x() + pos.width() <= destination.width() ? pos.width()
: pos.width() - ((pos.x() + pos.width()) - destination.width());
int height = pos.y() + pos.height() <= destination.height() ? pos.height()
: pos.height() - ((pos.y() + pos.height()) - destination.height());
int width =
pos.x() + pos.width() <= destination.width()
? pos.width()
: pos.width() - ((pos.x() + pos.width()) - destination.width());
int height =
pos.y() + pos.height() <= destination.height()
? pos.height()
: pos.height() - ((pos.y() + pos.height()) - destination.height());
if (width > 0 && height > 0) {
for (int i = 0; i < height; i++) {
memcpy(dest + ((pos.y() + i) * destination.width() + pos.x()) * pixelsize,
src + (i * source.width()) * pixelsize,
width * pixelsize);
src + (i * source.width()) * pixelsize, width * pixelsize);
}
}
destination.notifyPixelsChanged();
}
void OffScreenRenderWidgetHostView::OnPaint(
const gfx::Rect& damage_rect, const SkBitmap& bitmap) {
void OffScreenRenderWidgetHostView::OnPaint(const gfx::Rect& damage_rect,
const SkBitmap& bitmap) {
TRACE_EVENT0("electron", "OffScreenRenderWidgetHostView::OnPaint");
HoldResize();
@ -999,8 +974,8 @@ void OffScreenRenderWidgetHostView::OnPaint(
damage.Union(pos);
damages.push_back(pos);
bitmaps.push_back(popup_bitmap_.get());
originals.push_back(SkBitmapOperations::CreateTiledBitmap(bitmap,
pos.x(), pos.y(), pos.width(), pos.height()));
originals.push_back(SkBitmapOperations::CreateTiledBitmap(
bitmap, pos.x(), pos.y(), pos.width(), pos.height()));
}
for (auto proxy_view : proxy_views_) {
@ -1008,8 +983,8 @@ void OffScreenRenderWidgetHostView::OnPaint(
damage.Union(pos);
damages.push_back(pos);
bitmaps.push_back(proxy_view->GetBitmap());
originals.push_back(SkBitmapOperations::CreateTiledBitmap(bitmap,
pos.x(), pos.y(), pos.width(), pos.height()));
originals.push_back(SkBitmapOperations::CreateTiledBitmap(
bitmap, pos.x(), pos.y(), pos.width(), pos.height()));
}
for (size_t i = 0; i < damages.size(); i++) {
@ -1029,8 +1004,8 @@ void OffScreenRenderWidgetHostView::OnPaint(
ReleaseResize();
}
void OffScreenRenderWidgetHostView::OnPopupPaint(
const gfx::Rect& damage_rect, const SkBitmap& bitmap) {
void OffScreenRenderWidgetHostView::OnPopupPaint(const gfx::Rect& damage_rect,
const SkBitmap& bitmap) {
if (popup_host_view_ && popup_bitmap_.get())
popup_bitmap_.reset(new SkBitmap(bitmap));
InvalidateBounds(popup_host_view_->popup_position_);
@ -1053,7 +1028,8 @@ void OffScreenRenderWidgetHostView::ReleaseResize() {
hold_resize_ = false;
if (pending_resize_) {
pending_resize_ = false;
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(&OffScreenRenderWidgetHostView::WasResized,
weak_ptr_factory_.GetWeakPtr()));
}
@ -1099,8 +1075,9 @@ void OffScreenRenderWidgetHostView::ProcessMouseEvent(
}
if (!IsPopupWidget()) {
if (popup_host_view_ && popup_host_view_->popup_position_.Contains(
event.PositionInWidget().x, event.PositionInWidget().y)) {
if (popup_host_view_ &&
popup_host_view_->popup_position_.Contains(
event.PositionInWidget().x, event.PositionInWidget().y)) {
blink::WebMouseEvent popup_event(event);
popup_event.SetPositionInWidget(
popup_event.PositionInWidget().x -
@ -1131,7 +1108,7 @@ void OffScreenRenderWidgetHostView::ProcessMouseWheelEvent(
proxy_event.PositionInWidget().y - bounds.y());
ui::MouseWheelEvent ui_event =
UiMouseWheelEventFromWebMouseEvent(proxy_event);
UiMouseWheelEventFromWebMouseEvent(proxy_event);
proxy_view->OnEvent(&ui_event);
return;
}
@ -1139,7 +1116,7 @@ void OffScreenRenderWidgetHostView::ProcessMouseWheelEvent(
if (!IsPopupWidget()) {
if (popup_host_view_) {
if (popup_host_view_->popup_position_.Contains(
event.PositionInWidget().x, event.PositionInWidget().y)) {
event.PositionInWidget().x, event.PositionInWidget().y)) {
blink::WebMouseWheelEvent popup_event(event);
popup_event.SetPositionInWidget(
popup_event.PositionInWidget().x -
@ -1152,7 +1129,8 @@ void OffScreenRenderWidgetHostView::ProcessMouseWheelEvent(
// Scrolling outside of the popup widget so destroy it.
// Execute asynchronously to avoid deleting the widget from inside some
// other callback.
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(&OffScreenRenderWidgetHostView::CancelWidget,
popup_host_view_->weak_ptr_factory_.GetWeakPtr()));
}
@ -1284,11 +1262,11 @@ viz::FrameSinkId OffScreenRenderWidgetHostView::AllocateFrameSinkId(
content::ImageTransportFactory* factory =
content::ImageTransportFactory::GetInstance();
return is_guest_view_hack
? factory->GetContextFactoryPrivate()->AllocateFrameSinkId()
: viz::FrameSinkId(base::checked_cast<uint32_t>(
render_widget_host_->GetProcess()->GetID()),
base::checked_cast<uint32_t>(
render_widget_host_->GetRoutingID()));
? factory->GetContextFactoryPrivate()->AllocateFrameSinkId()
: viz::FrameSinkId(base::checked_cast<uint32_t>(
render_widget_host_->GetProcess()->GetID()),
base::checked_cast<uint32_t>(
render_widget_host_->GetRoutingID()));
}
void OffScreenRenderWidgetHostView::UpdateBackgroundColorFromRenderer(

View file

@ -34,8 +34,7 @@ const SkBitmap* OffscreenViewProxy::GetBitmap() const {
void OffscreenViewProxy::SetBitmap(const SkBitmap& bitmap) {
if (view_bounds_.width() == bitmap.width() &&
view_bounds_.height() == bitmap.height() &&
observer_) {
view_bounds_.height() == bitmap.height() && observer_) {
view_bitmap_.reset(new SkBitmap(bitmap));
observer_->OnProxyViewPaint(view_bounds_);
}

View file

@ -13,7 +13,8 @@
namespace atom {
OffScreenWebContentsView::OffScreenWebContentsView(
bool transparent, const OnPaintCallback& callback)
bool transparent,
const OnPaintCallback& callback)
: transparent_(transparent),
painting_(true),
frame_rate_(60),
@ -39,26 +40,32 @@ void OffScreenWebContentsView::SetWebContents(
#if !defined(OS_MACOSX)
gfx::NativeView OffScreenWebContentsView::GetNativeView() const {
if (!web_contents_) return gfx::NativeView();
if (!web_contents_)
return gfx::NativeView();
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
if (!relay) return gfx::NativeView();
if (!relay)
return gfx::NativeView();
return relay->window->GetNativeView();
}
gfx::NativeView OffScreenWebContentsView::GetContentNativeView() const {
if (!web_contents_) return gfx::NativeView();
if (!web_contents_)
return gfx::NativeView();
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
if (!relay) return gfx::NativeView();
if (!relay)
return gfx::NativeView();
return relay->window->GetNativeView();
}
gfx::NativeWindow OffScreenWebContentsView::GetTopLevelNativeWindow() const {
if (!web_contents_) return gfx::NativeWindow();
if (!web_contents_)
return gfx::NativeWindow();
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
if (!relay) return gfx::NativeWindow();
if (!relay)
return gfx::NativeWindow();
return relay->window->GetNativeWindow();
}
#endif
@ -67,20 +74,15 @@ void OffScreenWebContentsView::GetContainerBounds(gfx::Rect* out) const {
*out = GetViewBounds();
}
void OffScreenWebContentsView::SizeContents(const gfx::Size& size) {
}
void OffScreenWebContentsView::SizeContents(const gfx::Size& size) {}
void OffScreenWebContentsView::Focus() {
}
void OffScreenWebContentsView::Focus() {}
void OffScreenWebContentsView::SetInitialFocus() {
}
void OffScreenWebContentsView::SetInitialFocus() {}
void OffScreenWebContentsView::StoreFocus() {
}
void OffScreenWebContentsView::StoreFocus() {}
void OffScreenWebContentsView::RestoreFocus() {
}
void OffScreenWebContentsView::RestoreFocus() {}
content::DropData* OffScreenWebContentsView::GetDropData() const {
return nullptr;
@ -91,12 +93,12 @@ gfx::Rect OffScreenWebContentsView::GetViewBounds() const {
}
void OffScreenWebContentsView::CreateView(const gfx::Size& initial_size,
gfx::NativeView context) {
}
gfx::NativeView context) {}
content::RenderWidgetHostViewBase*
OffScreenWebContentsView::CreateViewForWidget(
content::RenderWidgetHost* render_widget_host, bool is_guest_view_hack) {
OffScreenWebContentsView::CreateViewForWidget(
content::RenderWidgetHost* render_widget_host,
bool is_guest_view_hack) {
if (render_widget_host->GetView()) {
return static_cast<content::RenderWidgetHostViewBase*>(
render_widget_host->GetView());
@ -104,41 +106,31 @@ content::RenderWidgetHostViewBase*
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
return new OffScreenRenderWidgetHostView(
transparent_,
painting_,
GetFrameRate(),
callback_,
render_widget_host,
nullptr,
relay->window.get());
transparent_, painting_, GetFrameRate(), callback_, render_widget_host,
nullptr, relay->window.get());
}
content::RenderWidgetHostViewBase*
OffScreenWebContentsView::CreateViewForPopupWidget(
OffScreenWebContentsView::CreateViewForPopupWidget(
content::RenderWidgetHost* render_widget_host) {
auto relay = NativeWindowRelay::FromWebContents(web_contents_);
content::WebContentsImpl *web_contents_impl =
static_cast<content::WebContentsImpl*>(web_contents_);
content::WebContentsImpl* web_contents_impl =
static_cast<content::WebContentsImpl*>(web_contents_);
OffScreenRenderWidgetHostView *view =
static_cast<OffScreenRenderWidgetHostView*>(
web_contents_impl->GetOuterWebContents()
? web_contents_impl->GetOuterWebContents()->GetRenderWidgetHostView()
: web_contents_impl->GetRenderWidgetHostView());
OffScreenRenderWidgetHostView* view =
static_cast<OffScreenRenderWidgetHostView*>(
web_contents_impl->GetOuterWebContents()
? web_contents_impl->GetOuterWebContents()
->GetRenderWidgetHostView()
: web_contents_impl->GetRenderWidgetHostView());
return new OffScreenRenderWidgetHostView(
transparent_,
true,
view->GetFrameRate(),
callback_,
render_widget_host,
view,
relay->window.get());
transparent_, true, view->GetFrameRate(), callback_, render_widget_host,
view, relay->window.get());
}
void OffScreenWebContentsView::SetPageTitle(const base::string16& title) {
}
void OffScreenWebContentsView::SetPageTitle(const base::string16& title) {}
void OffScreenWebContentsView::RenderViewCreated(
content::RenderViewHost* host) {
@ -151,11 +143,9 @@ void OffScreenWebContentsView::RenderViewCreated(
}
void OffScreenWebContentsView::RenderViewSwappedIn(
content::RenderViewHost* host) {
}
content::RenderViewHost* host) {}
void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled) {
}
void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled) {}
void OffScreenWebContentsView::GetScreenInfo(
content::ScreenInfo* screen_info) const {
@ -171,15 +161,14 @@ void OffScreenWebContentsView::GetScreenInfo(
screen_info->available_rect = gfx::Rect(GetView()->size());
} else {
const display::Display display =
display::Screen::GetScreen()->GetPrimaryDisplay();
display::Screen::GetScreen()->GetPrimaryDisplay();
screen_info->rect = display.bounds();
screen_info->available_rect = display.work_area();
}
}
#if defined(OS_MACOSX)
void OffScreenWebContentsView::SetAllowOtherViews(bool allow) {
}
void OffScreenWebContentsView::SetAllowOtherViews(bool allow) {}
bool OffScreenWebContentsView::GetAllowOtherViews() const {
return false;
@ -189,8 +178,7 @@ bool OffScreenWebContentsView::IsEventTracking() const {
return false;
}
void OffScreenWebContentsView::CloseTabAfterEventTracking() {
}
void OffScreenWebContentsView::CloseTabAfterEventTracking() {}
#endif // defined(OS_MACOSX)
void OffScreenWebContentsView::StartDragging(
@ -205,8 +193,7 @@ void OffScreenWebContentsView::StartDragging(
}
void OffScreenWebContentsView::UpdateDragCursor(
blink::WebDragOperation operation) {
}
blink::WebDragOperation operation) {}
void OffScreenWebContentsView::SetPainting(bool painting) {
auto* view = GetView();

View file

@ -57,8 +57,8 @@ bool RelaunchAppWithHelper(const base::FilePath& helper,
relaunch_argv.push_back(helper.value());
relaunch_argv.push_back(internal::kRelauncherTypeArg);
relaunch_argv.insert(relaunch_argv.end(),
relauncher_args.begin(), relauncher_args.end());
relaunch_argv.insert(relaunch_argv.end(), relauncher_args.begin(),
relauncher_args.end());
relaunch_argv.push_back(internal::kRelauncherArgSeparator);
@ -84,8 +84,8 @@ bool RelaunchAppWithHelper(const base::FilePath& helper,
// preserve these three FDs in forked processes, so kRelauncherSyncFD should
// not conflict with them.
static_assert(internal::kRelauncherSyncFD != STDIN_FILENO &&
internal::kRelauncherSyncFD != STDOUT_FILENO &&
internal::kRelauncherSyncFD != STDERR_FILENO,
internal::kRelauncherSyncFD != STDOUT_FILENO &&
internal::kRelauncherSyncFD != STDERR_FILENO,
"kRelauncherSyncFD must not conflict with stdio fds");
#endif

View file

@ -41,7 +41,7 @@ void RelauncherSynchronizeWithParent() {
return;
}
struct kevent change = { 0 };
struct kevent change = {0};
EV_SET(&change, parent_pid, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, NULL);
if (kevent(kq.get(), &change, 1, nullptr, 0, nullptr) == -1) {
PLOG(ERROR) << "kevent (add)";
@ -68,8 +68,7 @@ void RelauncherSynchronizeWithParent() {
return;
}
if (event.filter != EVFILT_PROC ||
event.fflags != NOTE_EXIT ||
if (event.filter != EVFILT_PROC || event.fflags != NOTE_EXIT ||
event.ident != static_cast<uintptr_t>(parent_pid)) {
LOG(ERROR) << "kevent (monitor): unexpected event, filter " << event.filter
<< ", fflags " << event.fflags << ", ident " << event.ident;

View file

@ -30,9 +30,9 @@ HANDLE GetParentProcessHandle(base::ProcessHandle handle) {
}
PROCESS_BASIC_INFORMATION pbi;
LONG status = NtQueryInformationProcess(
handle, ProcessBasicInformation,
&pbi, sizeof(PROCESS_BASIC_INFORMATION), NULL);
LONG status =
NtQueryInformationProcess(handle, ProcessBasicInformation, &pbi,
sizeof(PROCESS_BASIC_INFORMATION), NULL);
if (!NT_SUCCESS(status)) {
LOG(ERROR) << "NtQueryInformationProcess failed";
return NULL;
@ -57,7 +57,8 @@ StringType AddQuoteForArg(const StringType& arg) {
if (arg[i] == '\\') {
// Find the extent of this run of backslashes.
size_t start = i, end = start + 1;
for (; end < arg.size() && arg[end] == '\\'; ++end) {}
for (; end < arg.size() && arg[end] == '\\'; ++end) {
}
size_t backslash_count = end - start;
// Backslashes are escapes only if the run is followed by a double quote.

View file

@ -12,16 +12,12 @@
namespace atom {
RenderProcessPreferences::RenderProcessPreferences(const Predicate& predicate)
: predicate_(predicate),
next_id_(0),
cache_needs_update_(true) {
registrar_.Add(this,
content::NOTIFICATION_RENDERER_PROCESS_CREATED,
: predicate_(predicate), next_id_(0), cache_needs_update_(true) {
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED,
content::NotificationService::AllBrowserContextsAndSources());
}
RenderProcessPreferences::~RenderProcessPreferences() {
}
RenderProcessPreferences::~RenderProcessPreferences() {}
int RenderProcessPreferences::AddEntry(const base::DictionaryValue& entry) {
int id = ++next_id_;

View file

@ -27,8 +27,7 @@ SessionPreferences::SessionPreferences(content::BrowserContext* context) {
context->SetUserData(&kLocatorKey, base::WrapUnique(this));
}
SessionPreferences::~SessionPreferences() {
}
SessionPreferences::~SessionPreferences() {}
// static
SessionPreferences* SessionPreferences::FromBrowserContext(
@ -38,7 +37,8 @@ SessionPreferences* SessionPreferences::FromBrowserContext(
// static
void SessionPreferences::AppendExtraCommandLineSwitches(
content::BrowserContext* context, base::CommandLine* command_line) {
content::BrowserContext* context,
base::CommandLine* command_line) {
SessionPreferences* self = FromBrowserContext(context);
if (!self)
return;

View file

@ -25,7 +25,7 @@ bool StringToAccelerator(const std::string& shortcut,
}
std::vector<std::string> tokens = base::SplitString(
shortcut, "+", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
shortcut, "+", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
// Now, parse it into an accelerator.
int modifiers = ui::EF_NONE;
@ -79,7 +79,7 @@ void GenerateAcceleratorTable(AcceleratorTable* table,
} else {
ui::Accelerator accelerator;
if (model->GetAcceleratorAtWithParams(i, true, &accelerator)) {
MenuItem item = { i, model };
MenuItem item = {i, model};
(*table)[accelerator] = item;
}
}

View file

@ -8,7 +8,6 @@
namespace accelerator_util {
void SetPlatformAccelerator(ui::Accelerator* accelerator) {
}
void SetPlatformAccelerator(ui::Accelerator* accelerator) {}
} // namespace accelerator_util

View file

@ -9,12 +9,9 @@
namespace atom {
AtomMenuModel::AtomMenuModel(Delegate* delegate)
: ui::SimpleMenuModel(delegate),
delegate_(delegate) {
}
: ui::SimpleMenuModel(delegate), delegate_(delegate) {}
AtomMenuModel::~AtomMenuModel() {
}
AtomMenuModel::~AtomMenuModel() {}
void AtomMenuModel::SetRole(int index, const base::string16& role) {
int command_id = GetCommandIdAt(index);

View file

@ -105,8 +105,7 @@ display::Display GetDisplayNearestPoint(const gfx::Point& point) {
} // namespace
AutofillPopup::AutofillPopup() {
bold_font_list_ =
gfx::FontList().DeriveWithWeight(gfx::Font::Weight::BOLD);
bold_font_list_ = gfx::FontList().DeriveWithWeight(gfx::Font::Weight::BOLD);
smaller_font_list_ =
gfx::FontList().DeriveWithSizeDelta(kSmallerFontSizeDelta);
}
@ -115,11 +114,10 @@ AutofillPopup::~AutofillPopup() {
Hide();
}
void AutofillPopup::CreateView(
content::RenderFrameHost* frame_host,
bool offscreen,
views::View* parent,
const gfx::RectF& r) {
void AutofillPopup::CreateView(content::RenderFrameHost* frame_host,
bool offscreen,
views::View* parent,
const gfx::RectF& r) {
Hide();
frame_host_ = frame_host;
@ -133,8 +131,8 @@ void AutofillPopup::CreateView(
#if defined(ENABLE_OSR)
if (offscreen) {
auto* osr_rwhv = static_cast<OffScreenRenderWidgetHostView*>(
frame_host_->GetView());
auto* osr_rwhv =
static_cast<OffScreenRenderWidgetHostView*>(frame_host_->GetView());
view_->view_proxy_.reset(new OffscreenViewProxy(view_));
osr_rwhv->AddViewProxy(view_->view_proxy_.get());
}
@ -192,19 +190,17 @@ void AutofillPopup::UpdatePopupBounds() {
display::Display bottom_right_display =
GetDisplayNearestPoint(bottom_right_corner_of_popup);
std::pair<int, int> popup_x_and_width =
CalculatePopupXAndWidth(top_left_display, bottom_right_display,
desired_width, bounds, is_rtl);
std::pair<int, int> popup_y_and_height =
CalculatePopupYAndHeight(top_left_display, bottom_right_display,
desired_height, bounds);
std::pair<int, int> popup_x_and_width = CalculatePopupXAndWidth(
top_left_display, bottom_right_display, desired_width, bounds, is_rtl);
std::pair<int, int> popup_y_and_height = CalculatePopupYAndHeight(
top_left_display, bottom_right_display, desired_height, bounds);
popup_bounds_ = gfx::Rect(
popup_x_and_width.first, popup_y_and_height.first,
popup_x_and_width.second, popup_y_and_height.second);
popup_bounds_in_view_ = gfx::Rect(
popup_bounds_in_view_.origin(),
gfx::Size(popup_x_and_width.second, popup_y_and_height.second));
popup_bounds_ =
gfx::Rect(popup_x_and_width.first, popup_y_and_height.first,
popup_x_and_width.second, popup_y_and_height.second);
popup_bounds_in_view_ =
gfx::Rect(popup_bounds_in_view_.origin(),
gfx::Size(popup_x_and_width.second, popup_y_and_height.second));
}
void AutofillPopup::OnViewBoundsChanged(views::View* view) {
@ -224,9 +220,10 @@ int AutofillPopup::GetDesiredPopupWidth() {
int popup_width = element_bounds_.width();
for (size_t i = 0; i < values_.size(); ++i) {
int row_size = kEndPadding + 2 * kPopupBorderThickness +
gfx::GetStringWidth(GetValueAt(i), GetValueFontListForRow(i)) +
gfx::GetStringWidth(GetLabelAt(i), GetLabelFontListForRow(i));
int row_size =
kEndPadding + 2 * kPopupBorderThickness +
gfx::GetStringWidth(GetValueAt(i), GetValueFontListForRow(i)) +
gfx::GetStringWidth(GetLabelAt(i), GetLabelFontListForRow(i));
if (GetLabelAt(i).length() > 0)
row_size += kNamePadding + kEndPadding;
@ -255,8 +252,8 @@ const gfx::FontList& AutofillPopup::GetLabelFontListForRow(int index) const {
ui::NativeTheme::ColorId AutofillPopup::GetBackgroundColorIDForRow(
int index) const {
return (view_ && index == view_->GetSelectedLine())
? ui::NativeTheme::kColorId_ResultsTableHoveredBackground
: ui::NativeTheme::kColorId_ResultsTableNormalBackground;
? ui::NativeTheme::kColorId_ResultsTableHoveredBackground
: ui::NativeTheme::kColorId_ResultsTableNormalBackground;
}
int AutofillPopup::GetLineCount() {

View file

@ -19,22 +19,15 @@ namespace certificate_trust {
// This requires prompting the user to confirm they trust the certificate.
BOOL AddToTrustedRootStore(const PCCERT_CONTEXT cert_context,
const scoped_refptr<net::X509Certificate>& cert) {
auto root_cert_store = CertOpenStore(
CERT_STORE_PROV_SYSTEM,
0,
NULL,
CERT_SYSTEM_STORE_CURRENT_USER,
L"Root");
auto root_cert_store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, NULL,
CERT_SYSTEM_STORE_CURRENT_USER, L"Root");
if (root_cert_store == NULL) {
return false;
}
auto result = CertAddCertificateContextToStore(
root_cert_store,
cert_context,
CERT_STORE_ADD_REPLACE_EXISTING,
NULL);
root_cert_store, cert_context, CERT_STORE_ADD_REPLACE_EXISTING, NULL);
if (result) {
// force Chromium to reload it's database for this certificate
@ -57,7 +50,7 @@ CERT_CHAIN_PARA GetCertificateChainParameters() {
cert_usage.dwType = USAGE_MATCH_TYPE_AND;
cert_usage.Usage = enhkey_usage;
CERT_CHAIN_PARA params = { sizeof(CERT_CHAIN_PARA) };
CERT_CHAIN_PARA params = {sizeof(CERT_CHAIN_PARA)};
params.RequestedUsage = cert_usage;
return params;
@ -73,14 +66,8 @@ void ShowCertificateTrust(atom::NativeWindow* parent_window,
auto params = GetCertificateChainParameters();
if (CertGetCertificateChain(NULL,
cert_context.get(),
NULL,
NULL,
&params,
NULL,
NULL,
&chain_context)) {
if (CertGetCertificateChain(NULL, cert_context.get(), NULL, NULL, &params,
NULL, NULL, &chain_context)) {
auto error_status = chain_context->TrustStatus.dwErrorStatus;
if (error_status == CERT_TRUST_IS_SELF_SIGNED ||
error_status == CERT_TRUST_IS_UNTRUSTED_ROOT) {

View file

@ -23,8 +23,8 @@ void DragFileItems(const std::vector<base::FilePath>& files,
// Set up our OLE machinery
ui::OSExchangeData data;
button_drag_utils::SetDragImage(GURL(), files[0].LossyDisplayName(),
icon.AsImageSkia(), nullptr,
button_drag_utils::SetDragImage(
GURL(), files[0].LossyDisplayName(), icon.AsImageSkia(), nullptr,
*views::Widget::GetTopLevelWidgetForNativeView(view), &data);
std::vector<ui::FileInfo> file_infos;
@ -39,13 +39,11 @@ void DragFileItems(const std::vector<base::FilePath>& files,
gfx::Point location = display::Screen::GetScreen()->GetCursorScreenPoint();
// TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below.
aura::client::GetDragDropClient(root_window)->StartDragAndDrop(
data,
root_window,
view,
location,
ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK,
ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE);
aura::client::GetDragDropClient(root_window)
->StartDragAndDrop(
data, root_window, view, location,
ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK,
ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE);
}
} // namespace atom

View file

@ -30,15 +30,15 @@ namespace {
// Distinguish directories from regular files.
bool IsDirectory(const base::FilePath& path) {
base::File::Info file_info;
return base::GetFileInfo(path, &file_info) ?
file_info.is_directory : path.EndsWithSeparator();
return base::GetFileInfo(path, &file_info) ? file_info.is_directory
: path.EndsWithSeparator();
}
void ConvertFilters(const Filters& filters,
std::vector<std::wstring>* buffer,
std::vector<COMDLG_FILTERSPEC>* filterspec) {
if (filters.empty()) {
COMDLG_FILTERSPEC spec = { L"All Files (*.*)", L"*.*" };
COMDLG_FILTERSPEC spec = {L"All Files (*.*)", L"*.*"};
filterspec->push_back(spec);
return;
}
@ -75,8 +75,8 @@ class FileDialog {
std::vector<COMDLG_FILTERSPEC> filterspec;
ConvertFilters(settings.filters, &buffer, &filterspec);
dialog_.reset(new T(file_part.c_str(), options, NULL,
filterspec.data(), filterspec.size()));
dialog_.reset(new T(file_part.c_str(), options, NULL, filterspec.data(),
filterspec.size()));
if (!settings.title.empty())
GetPtr()->SetTitle(base::UTF8ToUTF16(settings.title).c_str());
@ -99,7 +99,7 @@ class FileDialog {
for (size_t i = 0; i < filterspec.size(); ++i) {
if (std::wstring(filterspec[i].pszSpec) != L"*.*") {
// SetFileTypeIndex is regarded as one-based index.
GetPtr()->SetFileTypeIndex(i+1);
GetPtr()->SetFileTypeIndex(i + 1);
GetPtr()->SetDefaultExtension(filterspec[i].pszSpec);
break;
}
@ -112,9 +112,10 @@ class FileDialog {
bool Show(atom::NativeWindow* parent_window) {
atom::UnresponsiveSuppressor suppressor;
HWND window = parent_window ? static_cast<atom::NativeWindowViews*>(
parent_window)->GetAcceleratedWidget() :
NULL;
HWND window = parent_window
? static_cast<atom::NativeWindowViews*>(parent_window)
->GetAcceleratedWidget()
: NULL;
return dialog_->DoModal(window) == IDOK;
}
@ -125,13 +126,12 @@ class FileDialog {
private:
// Set up the initial directory for the dialog.
void SetDefaultFolder(const base::FilePath file_path) {
std::wstring directory = IsDirectory(file_path) ?
file_path.value() :
file_path.DirName().value();
std::wstring directory = IsDirectory(file_path)
? file_path.value()
: file_path.DirName().value();
ATL::CComPtr<IShellItem> folder_item;
HRESULT hr = SHCreateItemFromParsingName(directory.c_str(),
NULL,
HRESULT hr = SHCreateItemFromParsingName(directory.c_str(), NULL,
IID_PPV_ARGS(&folder_item));
if (SUCCEEDED(hr))
GetPtr()->SetFolder(folder_item);
@ -165,7 +165,7 @@ void RunOpenDialogInNewThread(const RunState& run_state,
std::vector<base::FilePath> paths;
bool result = ShowOpenDialog(settings, &paths);
run_state.ui_task_runner->PostTask(FROM_HERE,
base::Bind(callback, result, paths));
base::Bind(callback, result, paths));
run_state.ui_task_runner->DeleteSoon(FROM_HERE, run_state.dialog_thread);
}
@ -198,8 +198,8 @@ bool ShowOpenDialog(const DialogSettings& settings,
return false;
ATL::CComPtr<IShellItemArray> items;
HRESULT hr = static_cast<IFileOpenDialog*>(open_dialog.GetPtr())->GetResults(
&items);
HRESULT hr =
static_cast<IFileOpenDialog*>(open_dialog.GetPtr())->GetResults(&items);
if (FAILED(hr))
return false;
@ -216,8 +216,8 @@ bool ShowOpenDialog(const DialogSettings& settings,
return false;
wchar_t file_name[MAX_PATH];
hr = CShellFileOpenDialog::GetFileNameFromShellItem(
item, SIGDN_FILESYSPATH, file_name, MAX_PATH);
hr = CShellFileOpenDialog::GetFileNameFromShellItem(item, SIGDN_FILESYSPATH,
file_name, MAX_PATH);
if (FAILED(hr))
return false;
@ -240,8 +240,7 @@ void ShowOpenDialog(const DialogSettings& settings,
base::Bind(&RunOpenDialogInNewThread, run_state, settings, callback));
}
bool ShowSaveDialog(const DialogSettings& settings,
base::FilePath* path) {
bool ShowSaveDialog(const DialogSettings& settings, base::FilePath* path) {
FileDialog<CShellFileSaveDialog> save_dialog(
settings, FOS_FORCEFILESYSTEM | FOS_PATHMUSTEXIST | FOS_OVERWRITEPROMPT);
if (!save_dialog.Show(settings.parent_window))

View file

@ -227,7 +227,8 @@ void ShowErrorBox(const base::string16& title, const base::string16& content) {
base::UTF16ToUTF8(content).c_str(), "", false)
.RunSynchronous();
} else {
fprintf(stderr, ANSI_TEXT_BOLD ANSI_BACKGROUND_GRAY ANSI_FOREGROUND_RED
fprintf(stderr,
ANSI_TEXT_BOLD ANSI_BACKGROUND_GRAY ANSI_FOREGROUND_RED
"%s\n" ANSI_FOREGROUND_BLACK "%s" ANSI_RESET "\n",
base::UTF16ToUTF8(title).c_str(),
base::UTF16ToUTF8(content).c_str());

View file

@ -39,18 +39,18 @@ struct CommonButtonID {
CommonButtonID GetCommonID(const base::string16& button) {
base::string16 lower = base::ToLowerASCII(button);
if (lower == L"ok")
return { TDCBF_OK_BUTTON, IDOK };
return {TDCBF_OK_BUTTON, IDOK};
else if (lower == L"yes")
return { TDCBF_YES_BUTTON, IDYES };
return {TDCBF_YES_BUTTON, IDYES};
else if (lower == L"no")
return { TDCBF_NO_BUTTON, IDNO };
return {TDCBF_NO_BUTTON, IDNO};
else if (lower == L"cancel")
return { TDCBF_CANCEL_BUTTON, IDCANCEL };
return {TDCBF_CANCEL_BUTTON, IDCANCEL};
else if (lower == L"retry")
return { TDCBF_RETRY_BUTTON, IDRETRY };
return {TDCBF_RETRY_BUTTON, IDRETRY};
else if (lower == L"close")
return { TDCBF_CLOSE_BUTTON, IDCLOSE };
return { -1, -1 };
return {TDCBF_CLOSE_BUTTON, IDCLOSE};
return {-1, -1};
}
// Determine whether the buttons are common buttons, if so map common ID
@ -86,13 +86,13 @@ int ShowTaskDialogUTF16(NativeWindow* parent,
bool* checkbox_checked,
const gfx::ImageSkia& icon) {
TASKDIALOG_FLAGS flags =
TDF_SIZE_TO_CONTENT | // Show all content.
TDF_SIZE_TO_CONTENT | // Show all content.
TDF_ALLOW_DIALOG_CANCELLATION; // Allow canceling the dialog.
TASKDIALOGCONFIG config = { 0 };
config.cbSize = sizeof(config);
config.hInstance = GetModuleHandle(NULL);
config.dwFlags = flags;
TASKDIALOGCONFIG config = {0};
config.cbSize = sizeof(config);
config.hInstance = GetModuleHandle(NULL);
config.dwFlags = flags;
if (parent) {
config.hwndParent =
@ -223,8 +223,8 @@ void RunMessageBoxInNewThread(base::Thread* thread,
content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::Bind(callback, result, checkbox_checked));
content::BrowserThread::DeleteSoon(
content::BrowserThread::UI, FROM_HERE, thread);
content::BrowserThread::DeleteSoon(content::BrowserThread::UI, FROM_HERE,
thread);
}
} // namespace

View file

@ -6,29 +6,22 @@
namespace atom {
TrayIcon::TrayIcon() {
}
TrayIcon::TrayIcon() {}
TrayIcon::~TrayIcon() {
}
TrayIcon::~TrayIcon() {}
void TrayIcon::SetPressedImage(ImageType image) {
}
void TrayIcon::SetPressedImage(ImageType image) {}
void TrayIcon::SetTitle(const std::string& title) {
}
void TrayIcon::SetTitle(const std::string& title) {}
void TrayIcon::SetHighlightMode(TrayIcon::HighlightMode mode) {
}
void TrayIcon::SetHighlightMode(TrayIcon::HighlightMode mode) {}
void TrayIcon::DisplayBalloon(ImageType icon,
const base::string16& title,
const base::string16& contents) {
}
const base::string16& contents) {}
void TrayIcon::PopUpContextMenu(const gfx::Point& pos,
AtomMenuModel* menu_model) {
}
AtomMenuModel* menu_model) {}
gfx::Rect TrayIcon::GetBounds() {
return gfx::Rect();

View file

@ -21,11 +21,9 @@ int indicators_count;
} // namespace
TrayIconGtk::TrayIconGtk() {
}
TrayIconGtk::TrayIconGtk() {}
TrayIconGtk::~TrayIconGtk() {
}
TrayIconGtk::~TrayIconGtk() {}
void TrayIconGtk::SetImage(const gfx::Image& image) {
if (icon_) {
@ -38,10 +36,9 @@ void TrayIconGtk::SetImage(const gfx::Image& image) {
if (libgtkui::AppIndicatorIcon::CouldOpen()) {
++indicators_count;
icon_.reset(new libgtkui::AppIndicatorIcon(
base::StringPrintf(
"%s%d", Browser::Get()->GetName().c_str(), indicators_count),
image.AsImageSkia(),
toolTip));
base::StringPrintf("%s%d", Browser::Get()->GetName().c_str(),
indicators_count),
image.AsImageSkia(), toolTip));
} else {
icon_.reset(new libgtkui::Gtk2StatusIcon(image.AsImageSkia(), toolTip));
}

View file

@ -18,9 +18,8 @@
namespace atom {
AutofillPopupView::AutofillPopupView(
AutofillPopup* popup,
views::Widget* parent_widget)
AutofillPopupView::AutofillPopupView(AutofillPopup* popup,
views::Widget* parent_widget)
: popup_(popup),
parent_widget_(parent_widget),
#if defined(ENABLE_OSR)
@ -63,12 +62,10 @@ void AutofillPopupView::Show() {
views::FocusManager* focus_manager = parent_widget_->GetFocusManager();
focus_manager->RegisterAccelerator(
ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE),
ui::AcceleratorManager::kNormalPriority,
this);
ui::AcceleratorManager::kNormalPriority, this);
focus_manager->RegisterAccelerator(
ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE),
ui::AcceleratorManager::kNormalPriority,
this);
ui::AcceleratorManager::kNormalPriority, this);
// The widget is destroyed by the corresponding NativeWidget, so we use
// a weak pointer to hold the reference and don't have to worry about
@ -97,7 +94,7 @@ void AutofillPopupView::Show() {
views::WidgetFocusManager::GetInstance()->AddFocusChangeListener(this);
keypress_callback_ = base::Bind(&AutofillPopupView::HandleKeyPressEvent,
base::Unretained(this));
base::Unretained(this));
auto host = popup_->frame_host_->GetRenderViewHost()->GetWidget();
host->AddKeyPressEventCallback(keypress_callback_);
@ -150,30 +147,26 @@ void AutofillPopupView::DrawAutofillEntry(gfx::Canvas* canvas,
if (!popup_)
return;
canvas->FillRect(
entry_rect,
GetNativeTheme()->GetSystemColor(
popup_->GetBackgroundColorIDForRow(index)));
canvas->FillRect(entry_rect, GetNativeTheme()->GetSystemColor(
popup_->GetBackgroundColorIDForRow(index)));
const bool is_rtl = base::i18n::IsRTL();
const int text_align =
is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT;
is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT;
gfx::Rect value_rect = entry_rect;
value_rect.Inset(kEndPadding, 0);
int x_align_left = value_rect.x();
const int value_width = gfx::GetStringWidth(
popup_->GetValueAt(index),
popup_->GetValueFontListForRow(index));
popup_->GetValueAt(index), popup_->GetValueFontListForRow(index));
int value_x_align_left = x_align_left;
value_x_align_left =
is_rtl ? value_rect.right() - value_width : value_rect.x();
is_rtl ? value_rect.right() - value_width : value_rect.x();
canvas->DrawStringRectWithFlags(
popup_->GetValueAt(index),
popup_->GetValueFontListForRow(index),
popup_->GetValueAt(index), popup_->GetValueFontListForRow(index),
GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_ResultsTableNormalText),
ui::NativeTheme::kColorId_ResultsTableNormalText),
gfx::Rect(value_x_align_left, value_rect.y(), value_width,
value_rect.height()),
text_align);
@ -181,15 +174,13 @@ void AutofillPopupView::DrawAutofillEntry(gfx::Canvas* canvas,
// Draw the label text, if one exists.
if (!popup_->GetLabelAt(index).empty()) {
const int label_width = gfx::GetStringWidth(
popup_->GetLabelAt(index),
popup_->GetLabelFontListForRow(index));
popup_->GetLabelAt(index), popup_->GetLabelFontListForRow(index));
int label_x_align_left = x_align_left;
label_x_align_left =
is_rtl ? value_rect.x() : value_rect.right() - label_width;
is_rtl ? value_rect.x() : value_rect.right() - label_width;
canvas->DrawStringRectWithFlags(
popup_->GetLabelAt(index),
popup_->GetLabelFontListForRow(index),
popup_->GetLabelAt(index), popup_->GetLabelFontListForRow(index),
GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_ResultsTableNormalDimmedText),
gfx::Rect(label_x_align_left, entry_rect.y(), label_width,
@ -229,8 +220,7 @@ void AutofillPopupView::OnPaint(gfx::Canvas* canvas) {
std::unique_ptr<cc::SkiaPaintCanvas> paint_canvas;
if (view_proxy_.get()) {
bitmap.allocN32Pixels(popup_->popup_bounds_in_view_.width(),
popup_->popup_bounds_in_view_.height(),
true);
popup_->popup_bounds_in_view_.height(), true);
paint_canvas.reset(new cc::SkiaPaintCanvas(bitmap));
draw_canvas = new gfx::Canvas(paint_canvas.get(), 1.0);
}
@ -340,8 +330,7 @@ void AutofillPopupView::OnGestureEvent(ui::GestureEvent* event) {
event->SetHandled();
}
bool AutofillPopupView::AcceleratorPressed(
const ui::Accelerator& accelerator) {
bool AutofillPopupView::AcceleratorPressed(const ui::Accelerator& accelerator) {
if (accelerator.modifiers() != ui::EF_NONE)
return false;

View file

@ -21,11 +21,9 @@ const char kViewClassName[] = "FramelessView";
} // namespace
FramelessView::FramelessView() : window_(NULL), frame_(NULL) {
}
FramelessView::FramelessView() : window_(NULL), frame_(NULL) {}
FramelessView::~FramelessView() {
}
FramelessView::~FramelessView() {}
void FramelessView::Init(NativeWindowViews* window, views::Widget* frame) {
window_ = window;
@ -35,16 +33,17 @@ void FramelessView::Init(NativeWindowViews* window, views::Widget* frame) {
int FramelessView::ResizingBorderHitTest(const gfx::Point& point) {
// Check the frame first, as we allow a small area overlapping the contents
// to be used for resize handles.
bool can_ever_resize = frame_->widget_delegate() ?
frame_->widget_delegate()->CanResize() :
false;
bool can_ever_resize = frame_->widget_delegate()
? frame_->widget_delegate()->CanResize()
: false;
// Don't allow overlapping resize handles when the window is maximized or
// fullscreen, as it can't be resized in those states.
int resize_border =
frame_->IsMaximized() || frame_->IsFullscreen() ? 0 :
kResizeInsideBoundsSize;
int resize_border = frame_->IsMaximized() || frame_->IsFullscreen()
? 0
: kResizeInsideBoundsSize;
return GetHTComponentForFrame(point, resize_border, resize_border,
kResizeAreaCornerSize, kResizeAreaCornerSize, can_ever_resize);
kResizeAreaCornerSize, kResizeAreaCornerSize,
can_ever_resize);
}
gfx::Rect FramelessView::GetBoundsForClientView() const {
@ -83,24 +82,21 @@ int FramelessView::NonClientHitTest(const gfx::Point& cursor) {
}
void FramelessView::GetWindowMask(const gfx::Size& size,
gfx::Path* window_mask) {
}
gfx::Path* window_mask) {}
void FramelessView::ResetWindowControls() {
}
void FramelessView::ResetWindowControls() {}
void FramelessView::UpdateWindowIcon() {
}
void FramelessView::UpdateWindowIcon() {}
void FramelessView::UpdateWindowTitle() {
}
void FramelessView::UpdateWindowTitle() {}
void FramelessView::SizeConstraintsChanged() {
}
void FramelessView::SizeConstraintsChanged() {}
gfx::Size FramelessView::CalculatePreferredSize() const {
return frame_->non_client_view()->GetWindowBoundsForClientBounds(
gfx::Rect(frame_->client_view()->GetPreferredSize())).size();
return frame_->non_client_view()
->GetWindowBoundsForClientBounds(
gfx::Rect(frame_->client_view()->GetPreferredSize()))
.size();
}
gfx::Size FramelessView::GetMinimumSize() const {

View file

@ -55,7 +55,7 @@ typedef DbusmenuMenuitem* (*dbusmenu_menuitem_property_set_int_func)(
const char* property,
int value);
typedef struct _DbusmenuServer DbusmenuServer;
typedef struct _DbusmenuServer DbusmenuServer;
typedef DbusmenuServer* (*dbusmenu_server_new_func)(const char* object);
typedef void (*dbusmenu_server_set_root_func)(DbusmenuServer* self,
DbusmenuMenuitem* root);
@ -148,7 +148,7 @@ AtomMenuModel* ModelForMenuItem(DbusmenuMenuitem* item) {
g_object_get_data(G_OBJECT(item), "model"));
}
bool GetMenuItemID(DbusmenuMenuitem* item, int *id) {
bool GetMenuItemID(DbusmenuMenuitem* item, int* id) {
gpointer id_ptr = g_object_get_data(G_OBJECT(item), "menu-id");
if (id_ptr != NULL) {
*id = GPOINTER_TO_INT(id_ptr) - 1;
@ -168,9 +168,9 @@ void SetMenuItemID(DbusmenuMenuitem* item, int id) {
std::string GetMenuModelStatus(AtomMenuModel* model) {
std::string ret;
for (int i = 0; i < model->GetItemCount(); ++i) {
int status = model->GetTypeAt(i) | (model->IsVisibleAt(i) << 3)
| (model->IsEnabledAt(i) << 4)
| (model->IsItemCheckedAt(i) << 5);
int status = model->GetTypeAt(i) | (model->IsVisibleAt(i) << 3) |
(model->IsEnabledAt(i) << 4) |
(model->IsItemCheckedAt(i) << 5);
ret += base::StringPrintf(
"%s-%X\n", base::UTF16ToUTF8(model->GetLabelAt(i)).c_str(), status);
}
@ -252,8 +252,8 @@ void GlobalMenuBarX11::BuildMenuFromModel(AtomMenuModel* model,
if (type == AtomMenuModel::TYPE_SUBMENU) {
menuitem_property_set(item, kPropertyChildrenDisplay, kDisplaySubmenu);
g_signal_connect(item, "about-to-show",
G_CALLBACK(OnSubMenuShowThunk), this);
g_signal_connect(item, "about-to-show", G_CALLBACK(OnSubMenuShowThunk),
this);
} else {
ui::Accelerator accelerator;
if (model->GetAcceleratorAtWithParams(i, true, &accelerator))
@ -264,10 +264,11 @@ void GlobalMenuBarX11::BuildMenuFromModel(AtomMenuModel* model,
if (type == AtomMenuModel::TYPE_CHECK ||
type == AtomMenuModel::TYPE_RADIO) {
menuitem_property_set(item, kPropertyToggleType,
menuitem_property_set(
item, kPropertyToggleType,
type == AtomMenuModel::TYPE_CHECK ? kToggleCheck : kToggleRadio);
menuitem_property_set_int(item, kPropertyToggleState,
model->IsItemCheckedAt(i));
model->IsItemCheckedAt(i));
}
}
}
@ -291,8 +292,8 @@ void GlobalMenuBarX11::RegisterAccelerator(DbusmenuMenuitem* item,
if (accelerator.IsShiftDown())
g_variant_builder_add(&builder, "s", "Shift");
char* name = XKeysymToString(XKeysymForWindowsKeyCode(
accelerator.key_code(), false));
char* name =
XKeysymToString(XKeysymForWindowsKeyCode(accelerator.key_code(), false));
if (!name) {
NOTIMPLEMENTED();
return;
@ -332,7 +333,7 @@ void GlobalMenuBarX11::OnSubMenuShow(DbusmenuMenuitem* item) {
g_free);
// Clear children.
GList *children = menuitem_take_children(item);
GList* children = menuitem_take_children(item);
g_list_foreach(children, reinterpret_cast<GFunc>(g_object_unref), NULL);
g_list_free(children);

Some files were not shown because too many files have changed in this diff Show more