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

View file

@ -117,9 +117,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) {
// from within the CRT's atexit facility, ensuring the heap functions are // from within the CRT's atexit facility, ensuring the heap functions are
// still active. The second invocation from the OS loader will be a no-op. // still active. The second invocation from the OS loader will be a no-op.
extern void NTAPI OnThreadExit(PVOID module, DWORD reason, PVOID reserved); extern void NTAPI OnThreadExit(PVOID module, DWORD reason, PVOID reserved);
atexit([]() { atexit([]() { OnThreadExit(nullptr, DLL_THREAD_DETACH, nullptr); });
OnThreadExit(nullptr, DLL_THREAD_DETACH, nullptr);
});
#endif #endif
#ifdef ENABLE_RUN_AS_NODE #ifdef ENABLE_RUN_AS_NODE

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -17,12 +17,9 @@ namespace api {
SavePageHandler::SavePageHandler(content::WebContents* web_contents, SavePageHandler::SavePageHandler(content::WebContents* web_contents,
const SavePageCallback& callback) const SavePageCallback& callback)
: web_contents_(web_contents), : web_contents_(web_contents), callback_(callback) {}
callback_(callback) {
}
SavePageHandler::~SavePageHandler() { SavePageHandler::~SavePageHandler() {}
}
void SavePageHandler::OnDownloadCreated(content::DownloadManager* manager, void SavePageHandler::OnDownloadCreated(content::DownloadManager* manager,
content::DownloadItem* item) { content::DownloadItem* item) {
@ -41,9 +38,8 @@ bool SavePageHandler::Handle(const base::FilePath& full_path,
base::FilePath saved_main_directory_path = full_path.DirName().Append( base::FilePath saved_main_directory_path = full_path.DirName().Append(
full_path.RemoveExtension().BaseName().value() + full_path.RemoveExtension().BaseName().value() +
FILE_PATH_LITERAL("_files")); FILE_PATH_LITERAL("_files"));
bool result = web_contents_->SavePage(full_path, bool result =
saved_main_directory_path, web_contents_->SavePage(full_path, saved_main_directory_path, save_type);
save_type);
download_manager->RemoveObserver(this); download_manager->RemoveObserver(this);
// If initialization fails which means fail to create |DownloadItem|, we need // If initialization fails which means fail to create |DownloadItem|, we need
// to delete the |SavePageHandler| instance to avoid memory-leak. // to delete the |SavePageHandler| instance to avoid memory-leak.
@ -60,8 +56,8 @@ void SavePageHandler::OnDownloadUpdated(content::DownloadItem* item) {
if (item->GetState() == content::DownloadItem::COMPLETE) { if (item->GetState() == content::DownloadItem::COMPLETE) {
callback_.Run(v8::Null(isolate)); callback_.Run(v8::Null(isolate));
} else { } else {
v8::Local<v8::String> error_message = v8::String::NewFromUtf8( v8::Local<v8::String> error_message =
isolate, "Fail to save page"); v8::String::NewFromUtf8(isolate, "Fail to save page");
callback_.Run(v8::Exception::Error(error_message)); callback_.Run(v8::Exception::Error(error_message));
} }
Destroy(item); Destroy(item);

View file

@ -34,8 +34,7 @@ TrackableObjectBase::TrackableObjectBase()
GetDestroyClosure()); GetDestroyClosure());
} }
TrackableObjectBase::~TrackableObjectBase() { TrackableObjectBase::~TrackableObjectBase() {}
}
base::OnceClosure TrackableObjectBase::GetDestroyClosure() { base::OnceClosure TrackableObjectBase::GetDestroyClosure() {
return base::BindOnce(&TrackableObjectBase::Destroy, return base::BindOnce(&TrackableObjectBase::Destroy,

View file

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

View file

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

View file

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

View file

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

View file

@ -24,8 +24,7 @@ namespace atom {
namespace { namespace {
// See comment in |PreEarlyInitialization()|, where sigaction is called. // See comment in |PreEarlyInitialization()|, where sigaction is called.
void SIGCHLDHandler(int signal) { void SIGCHLDHandler(int signal) {}
}
// The OSX fork() implementation can crash in the child process before // The OSX fork() implementation can crash in the child process before
// fork() returns. In that case, the shutdown pipe will still be // fork() returns. In that case, the shutdown pipe will still be
@ -121,8 +120,7 @@ void ShutdownDetector::ThreadMain() {
size_t bytes_read = 0; size_t bytes_read = 0;
do { do {
ssize_t ret = HANDLE_EINTR( ssize_t ret = HANDLE_EINTR(
read(shutdown_fd_, read(shutdown_fd_, reinterpret_cast<char*>(&signal) + bytes_read,
reinterpret_cast<char*>(&signal) + bytes_read,
sizeof(signal) - bytes_read)); sizeof(signal) - bytes_read));
if (ret < 0) { if (ret < 0) {
NOTREACHED() << "Unexpected error: " << strerror(errno); NOTREACHED() << "Unexpected error: " << strerror(errno);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -10,45 +10,37 @@
namespace atom { namespace atom {
AtomSpeechRecognitionManagerDelegate::AtomSpeechRecognitionManagerDelegate() { AtomSpeechRecognitionManagerDelegate::AtomSpeechRecognitionManagerDelegate() {}
}
AtomSpeechRecognitionManagerDelegate::~AtomSpeechRecognitionManagerDelegate() { AtomSpeechRecognitionManagerDelegate::~AtomSpeechRecognitionManagerDelegate() {}
}
void AtomSpeechRecognitionManagerDelegate::OnRecognitionStart(int session_id) { void AtomSpeechRecognitionManagerDelegate::OnRecognitionStart(int session_id) {}
}
void AtomSpeechRecognitionManagerDelegate::OnAudioStart(int session_id) { void AtomSpeechRecognitionManagerDelegate::OnAudioStart(int session_id) {}
}
void AtomSpeechRecognitionManagerDelegate::OnEnvironmentEstimationComplete( void AtomSpeechRecognitionManagerDelegate::OnEnvironmentEstimationComplete(
int session_id) { int session_id) {}
}
void AtomSpeechRecognitionManagerDelegate::OnSoundStart(int session_id) { void AtomSpeechRecognitionManagerDelegate::OnSoundStart(int session_id) {}
}
void AtomSpeechRecognitionManagerDelegate::OnSoundEnd(int session_id) { void AtomSpeechRecognitionManagerDelegate::OnSoundEnd(int session_id) {}
}
void AtomSpeechRecognitionManagerDelegate::OnAudioEnd(int session_id) { void AtomSpeechRecognitionManagerDelegate::OnAudioEnd(int session_id) {}
}
void AtomSpeechRecognitionManagerDelegate::OnRecognitionEnd(int session_id) { void AtomSpeechRecognitionManagerDelegate::OnRecognitionEnd(int session_id) {}
}
void AtomSpeechRecognitionManagerDelegate::OnRecognitionResults( void AtomSpeechRecognitionManagerDelegate::OnRecognitionResults(
int session_id, const content::SpeechRecognitionResults& result) { int session_id,
} const content::SpeechRecognitionResults& result) {}
void AtomSpeechRecognitionManagerDelegate::OnRecognitionError( void AtomSpeechRecognitionManagerDelegate::OnRecognitionError(
int session_id, const content::SpeechRecognitionError& error) { int session_id,
} const content::SpeechRecognitionError& error) {}
void AtomSpeechRecognitionManagerDelegate::OnAudioLevelsChange( void AtomSpeechRecognitionManagerDelegate::OnAudioLevelsChange(
int session_id, float volume, float noise_volume) { int session_id,
} float volume,
float noise_volume) {}
void AtomSpeechRecognitionManagerDelegate::CheckRecognitionIsAllowed( void AtomSpeechRecognitionManagerDelegate::CheckRecognitionIsAllowed(
int session_id, int session_id,

View file

@ -21,14 +21,11 @@ std::string AutoUpdater::GetFeedURL() {
return ""; return "";
} }
void AutoUpdater::SetFeedURL(mate::Arguments* args) { void AutoUpdater::SetFeedURL(mate::Arguments* args) {}
}
void AutoUpdater::CheckForUpdates() { void AutoUpdater::CheckForUpdates() {}
}
void AutoUpdater::QuitAndInstall() { void AutoUpdater::QuitAndInstall() {}
}
#endif #endif
} // namespace auto_updater } // namespace auto_updater

View file

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

View file

@ -28,7 +28,8 @@ const char kXdgSettingsDefaultSchemeHandler[] = "default-url-scheme-handler";
bool LaunchXdgUtility(const std::vector<std::string>& argv, int* exit_code) { bool LaunchXdgUtility(const std::vector<std::string>& argv, int* exit_code) {
*exit_code = EXIT_FAILURE; *exit_code = EXIT_FAILURE;
int devnull = open("/dev/null", O_RDONLY); int devnull = open("/dev/null", O_RDONLY);
if (devnull < 0) return false; if (devnull < 0)
return false;
base::LaunchOptions options; base::LaunchOptions options;
options.fds_to_remap.push_back(std::make_pair(devnull, STDIN_FILENO)); options.fds_to_remap.push_back(std::make_pair(devnull, STDIN_FILENO));
@ -36,7 +37,8 @@ bool LaunchXdgUtility(const std::vector<std::string>& argv, int* exit_code) {
base::Process process = base::LaunchProcess(argv, options); base::Process process = base::LaunchProcess(argv, options);
close(devnull); close(devnull);
if (!process.IsValid()) return false; if (!process.IsValid())
return false;
return process.WaitForExit(exit_code); return process.WaitForExit(exit_code);
} }
@ -67,14 +69,11 @@ void Browser::Focus() {
} }
} }
void Browser::AddRecentDocument(const base::FilePath& path) { void Browser::AddRecentDocument(const base::FilePath& path) {}
}
void Browser::ClearRecentDocuments() { void Browser::ClearRecentDocuments() {}
}
void Browser::SetAppUserModelID(const base::string16& name) { void Browser::SetAppUserModelID(const base::string16& name) {}
}
bool Browser::SetAsDefaultProtocolClient(const std::string& protocol, bool Browser::SetAsDefaultProtocolClient(const std::string& protocol,
mate::Arguments* args) { mate::Arguments* args) {
@ -85,7 +84,8 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol,
mate::Arguments* args) { mate::Arguments* args) {
std::unique_ptr<base::Environment> env(base::Environment::Create()); std::unique_ptr<base::Environment> env(base::Environment::Create());
if (protocol.empty()) return false; if (protocol.empty())
return false;
std::vector<std::string> argv; std::vector<std::string> argv;
argv.push_back(kXdgSettings); argv.push_back(kXdgSettings);
@ -96,14 +96,14 @@ bool Browser::IsDefaultProtocolClient(const std::string& protocol,
std::string reply; std::string reply;
int success_code; int success_code;
bool ran_ok = base::GetAppOutputWithExitCode(base::CommandLine(argv), bool ran_ok = base::GetAppOutputWithExitCode(base::CommandLine(argv), &reply,
&reply, &success_code); &success_code);
if (!ran_ok || success_code != EXIT_SUCCESS) return false; if (!ran_ok || success_code != EXIT_SUCCESS)
return false;
// Allow any reply that starts with "yes". // Allow any reply that starts with "yes".
return base::StartsWith(reply, "yes", base::CompareCase::SENSITIVE) return base::StartsWith(reply, "yes", base::CompareCase::SENSITIVE) ? true
? true
: false; : false;
} }
@ -123,8 +123,7 @@ bool Browser::SetBadgeCount(int count) {
} }
} }
void Browser::SetLoginItemSettings(LoginItemSettings settings) { void Browser::SetLoginItemSettings(LoginItemSettings settings) {}
}
Browser::LoginItemSettings Browser::GetLoginItemSettings( Browser::LoginItemSettings Browser::GetLoginItemSettings(
const LoginItemSettings& options) { const LoginItemSettings& options) {

View file

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

View file

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

View file

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

View file

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

View file

@ -9,10 +9,11 @@
namespace mate { namespace mate {
template<> template <>
struct Converter<atom::BluetoothChooser::DeviceInfo> { struct Converter<atom::BluetoothChooser::DeviceInfo> {
static v8::Local<v8::Value> ToV8( static v8::Local<v8::Value> ToV8(
v8::Isolate* isolate, const atom::BluetoothChooser::DeviceInfo& val) { v8::Isolate* isolate,
const atom::BluetoothChooser::DeviceInfo& val) {
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
dict.Set("deviceName", val.device_name); dict.Set("deviceName", val.device_name);
dict.Set("deviceId", val.device_id); dict.Set("deviceId", val.device_id);
@ -28,8 +29,7 @@ namespace {
const int kMaxScanRetries = 5; const int kMaxScanRetries = 5;
void OnDeviceChosen( void OnDeviceChosen(const content::BluetoothChooser::EventHandler& handler,
const content::BluetoothChooser::EventHandler& handler,
const std::string& device_id) { const std::string& device_id) {
if (device_id.empty()) { if (device_id.empty()) {
handler.Run(content::BluetoothChooser::Event::CANCELLED, device_id); handler.Run(content::BluetoothChooser::Event::CANCELLED, device_id);
@ -40,16 +40,13 @@ void OnDeviceChosen(
} // namespace } // namespace
BluetoothChooser::BluetoothChooser( BluetoothChooser::BluetoothChooser(api::WebContents* contents,
api::WebContents* contents,
const EventHandler& event_handler) const EventHandler& event_handler)
: api_web_contents_(contents), : api_web_contents_(contents),
event_handler_(event_handler), event_handler_(event_handler),
num_retries_(0) { num_retries_(0) {}
}
BluetoothChooser::~BluetoothChooser() { BluetoothChooser::~BluetoothChooser() {}
}
void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) { void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) {
switch (presence) { switch (presence) {
@ -69,15 +66,13 @@ void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) {
break; break;
case DiscoveryState::IDLE: case DiscoveryState::IDLE:
if (device_list_.empty()) { if (device_list_.empty()) {
auto event = ++num_retries_ > kMaxScanRetries ? Event::CANCELLED auto event =
: Event::RESCAN; ++num_retries_ > kMaxScanRetries ? Event::CANCELLED : Event::RESCAN;
event_handler_.Run(event, ""); event_handler_.Run(event, "");
} else { } else {
bool prevent_default = bool prevent_default = api_web_contents_->Emit(
api_web_contents_->Emit("select-bluetooth-device", "select-bluetooth-device", device_list_,
device_list_, base::Bind(&OnDeviceChosen, event_handler_));
base::Bind(&OnDeviceChosen,
event_handler_));
if (!prevent_default) { if (!prevent_default) {
auto device_id = device_list_[0].device_id; auto device_id = device_list_[0].device_id;
event_handler_.Run(Event::SELECTED, device_id); event_handler_.Run(Event::SELECTED, device_id);
@ -100,8 +95,9 @@ void BluetoothChooser::AddOrUpdateDevice(const std::string& device_id,
// Emit a select-bluetooth-device handler to allow for user to listen for // Emit a select-bluetooth-device handler to allow for user to listen for
// bluetooth device found. // bluetooth device found.
bool prevent_default = api_web_contents_->Emit("select-bluetooth-device", bool prevent_default =
device_list_, base::Bind(&OnDeviceChosen, event_handler_)); api_web_contents_->Emit("select-bluetooth-device", device_list_,
base::Bind(&OnDeviceChosen, event_handler_));
// If emit not implimented select first device that matches the filters // If emit not implimented select first device that matches the filters
// provided. // provided.

View file

@ -47,14 +47,12 @@ LoginHandler::LoginHandler(net::AuthChallengeInfo* auth_info,
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE, BrowserThread::UI, FROM_HERE,
base::Bind(&Browser::RequestLogin, base::Bind(&Browser::RequestLogin, base::Unretained(Browser::Get()),
base::Unretained(Browser::Get()),
base::RetainedRef(WrapRefCounted(this)), base::RetainedRef(WrapRefCounted(this)),
base::Passed(&request_details))); base::Passed(&request_details)));
} }
LoginHandler::~LoginHandler() { LoginHandler::~LoginHandler() {}
}
content::WebContents* LoginHandler::GetWebContents() const { content::WebContents* LoginHandler::GetWebContents() const {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);

View file

@ -113,9 +113,9 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
bool fullscreen = false; bool fullscreen = false;
if (options.Get(options::kFullscreen, &fullscreen) && !fullscreen) { if (options.Get(options::kFullscreen, &fullscreen) && !fullscreen) {
// Disable fullscreen button if 'fullscreen' is specified to false. // Disable fullscreen button if 'fullscreen' is specified to false.
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
fullscreenable = false; fullscreenable = false;
#endif #endif
} }
// Overriden by 'fullscreenable'. // Overriden by 'fullscreenable'.
options.Get(options::kFullScreenable, &fullscreenable); options.Get(options::kFullScreenable, &fullscreenable);
@ -261,75 +261,59 @@ double NativeWindow::GetSheetOffsetY() {
return sheet_offset_y_; return sheet_offset_y_;
} }
void NativeWindow::SetRepresentedFilename(const std::string& filename) { void NativeWindow::SetRepresentedFilename(const std::string& filename) {}
}
std::string NativeWindow::GetRepresentedFilename() { std::string NativeWindow::GetRepresentedFilename() {
return ""; return "";
} }
void NativeWindow::SetDocumentEdited(bool edited) { void NativeWindow::SetDocumentEdited(bool edited) {}
}
bool NativeWindow::IsDocumentEdited() { bool NativeWindow::IsDocumentEdited() {
return false; return false;
} }
void NativeWindow::SetFocusable(bool focusable) { void NativeWindow::SetFocusable(bool focusable) {}
}
void NativeWindow::SetMenu(AtomMenuModel* menu) { void NativeWindow::SetMenu(AtomMenuModel* menu) {}
}
void NativeWindow::SetParentWindow(NativeWindow* parent) { void NativeWindow::SetParentWindow(NativeWindow* parent) {
parent_ = parent; parent_ = parent;
} }
void NativeWindow::SetAutoHideCursor(bool auto_hide) { void NativeWindow::SetAutoHideCursor(bool auto_hide) {}
}
void NativeWindow::SelectPreviousTab() { void NativeWindow::SelectPreviousTab() {}
}
void NativeWindow::SelectNextTab() { void NativeWindow::SelectNextTab() {}
}
void NativeWindow::MergeAllWindows() { void NativeWindow::MergeAllWindows() {}
}
void NativeWindow::MoveTabToNewWindow() { void NativeWindow::MoveTabToNewWindow() {}
}
void NativeWindow::ToggleTabBar() { void NativeWindow::ToggleTabBar() {}
}
bool NativeWindow::AddTabbedWindow(NativeWindow* window) { bool NativeWindow::AddTabbedWindow(NativeWindow* window) {
return true; // for non-Mac platforms return true; // for non-Mac platforms
} }
void NativeWindow::SetVibrancy(const std::string& filename) { void NativeWindow::SetVibrancy(const std::string& filename) {}
}
void NativeWindow::SetTouchBar( void NativeWindow::SetTouchBar(
const std::vector<mate::PersistentDictionary>& items) { const std::vector<mate::PersistentDictionary>& items) {}
}
void NativeWindow::RefreshTouchBarItem(const std::string& item_id) { void NativeWindow::RefreshTouchBarItem(const std::string& item_id) {}
}
void NativeWindow::SetEscapeTouchBarItem( void NativeWindow::SetEscapeTouchBarItem(
const mate::PersistentDictionary& item) { const mate::PersistentDictionary& item) {}
}
void NativeWindow::SetAutoHideMenuBar(bool auto_hide) { void NativeWindow::SetAutoHideMenuBar(bool auto_hide) {}
}
bool NativeWindow::IsMenuBarAutoHide() { bool NativeWindow::IsMenuBarAutoHide() {
return false; return false;
} }
void NativeWindow::SetMenuBarVisibility(bool visible) { void NativeWindow::SetMenuBarVisibility(bool visible) {}
}
bool NativeWindow::IsMenuBarVisible() { bool NativeWindow::IsMenuBarVisible() {
return true; return true;
@ -350,11 +334,9 @@ void NativeWindow::SetAspectRatio(double aspect_ratio,
} }
void NativeWindow::PreviewFile(const std::string& path, void NativeWindow::PreviewFile(const std::string& path,
const std::string& display_name) { const std::string& display_name) {}
}
void NativeWindow::CloseFilePreview() { void NativeWindow::CloseFilePreview() {}
}
void NativeWindow::NotifyWindowRequestPreferredWith(int* width) { void NativeWindow::NotifyWindowRequestPreferredWith(int* width) {
for (NativeWindowObserver& observer : observers_) for (NativeWindowObserver& observer : observers_)
@ -510,13 +492,14 @@ void NativeWindow::NotifyTouchBarItemInteraction(
} }
void NativeWindow::NotifyNewWindowForTab() { void NativeWindow::NotifyNewWindowForTab() {
for (NativeWindowObserver &observer : observers_) for (NativeWindowObserver& observer : observers_)
observer.OnNewWindowForTab(); observer.OnNewWindowForTab();
} }
#if defined(OS_WIN) #if defined(OS_WIN)
void NativeWindow::NotifyWindowMessage( void NativeWindow::NotifyWindowMessage(UINT message,
UINT message, WPARAM w_param, LPARAM l_param) { WPARAM w_param,
LPARAM l_param) {
for (NativeWindowObserver& observer : observers_) for (NativeWindowObserver& observer : observers_)
observer.OnWindowMessage(message, w_param, l_param); observer.OnWindowMessage(message, w_param, l_param);
} }

View file

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

View file

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

View file

@ -36,11 +36,9 @@ URLRequestAsarJob::FileMetaInfo::FileMetaInfo()
: file_size(0), : file_size(0),
mime_type_result(false), mime_type_result(false),
file_exists(false), file_exists(false),
is_directory(false) { is_directory(false) {}
}
URLRequestAsarJob::URLRequestAsarJob( URLRequestAsarJob::URLRequestAsarJob(net::URLRequest* request,
net::URLRequest* request,
net::NetworkDelegate* network_delegate) net::NetworkDelegate* network_delegate)
: net::URLRequestJob(request, network_delegate), : net::URLRequestJob(request, network_delegate),
type_(TYPE_ERROR), type_(TYPE_ERROR),
@ -118,8 +116,7 @@ void URLRequestAsarJob::Start() {
} else { } else {
base::ThreadTaskRunnerHandle::Get()->PostTask( base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, FROM_HERE,
base::Bind(&URLRequestAsarJob::DidOpen, base::Bind(&URLRequestAsarJob::DidOpen, weak_ptr_factory_.GetWeakPtr(),
weak_ptr_factory_.GetWeakPtr(),
net::ERR_FILE_NOT_FOUND)); net::ERR_FILE_NOT_FOUND));
} }
} }
@ -140,10 +137,9 @@ int URLRequestAsarJob::ReadRawData(net::IOBuffer* dest, int dest_size) {
if (!dest_size) if (!dest_size)
return 0; return 0;
int rv = stream_->Read(dest, int rv = stream_->Read(
dest_size, dest, dest_size,
base::Bind(&URLRequestAsarJob::DidRead, base::Bind(&URLRequestAsarJob::DidRead, weak_ptr_factory_.GetWeakPtr(),
weak_ptr_factory_.GetWeakPtr(),
WrapRefCounted(dest))); WrapRefCounted(dest)));
if (rv >= 0) { if (rv >= 0) {
remaining_bytes_ -= rv; remaining_bytes_ -= rv;
@ -265,9 +261,8 @@ void URLRequestAsarJob::DidFetchMetaInfo(const FileMetaInfo* meta_info) {
return; return;
} }
int flags = base::File::FLAG_OPEN | int flags =
base::File::FLAG_READ | base::File::FLAG_OPEN | base::File::FLAG_READ | base::File::FLAG_ASYNC;
base::File::FLAG_ASYNC;
int rv = stream_->Open( int rv = stream_->Open(
meta_info_.file_path, flags, meta_info_.file_path, flags,
base::Bind(&URLRequestAsarJob::DidOpen, weak_ptr_factory_.GetWeakPtr())); base::Bind(&URLRequestAsarJob::DidOpen, weak_ptr_factory_.GetWeakPtr()));
@ -277,8 +272,8 @@ void URLRequestAsarJob::DidFetchMetaInfo(const FileMetaInfo* meta_info) {
void URLRequestAsarJob::DidOpen(int result) { void URLRequestAsarJob::DidOpen(int result) {
if (result != net::OK) { if (result != net::OK) {
NotifyStartError(net::URLRequestStatus(net::URLRequestStatus::FAILED, NotifyStartError(
result)); net::URLRequestStatus(net::URLRequestStatus::FAILED, result));
return; return;
} }
@ -298,19 +293,18 @@ void URLRequestAsarJob::DidOpen(int result) {
} }
if (!byte_range_.ComputeBounds(file_size)) { if (!byte_range_.ComputeBounds(file_size)) {
NotifyStartError( NotifyStartError(net::URLRequestStatus(
net::URLRequestStatus(net::URLRequestStatus::FAILED, net::URLRequestStatus::FAILED, net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
return; return;
} }
remaining_bytes_ = byte_range_.last_byte_position() - remaining_bytes_ =
byte_range_.first_byte_position() + 1; byte_range_.last_byte_position() - byte_range_.first_byte_position() + 1;
seek_offset_ = byte_range_.first_byte_position() + read_offset; seek_offset_ = byte_range_.first_byte_position() + read_offset;
if (remaining_bytes_ > 0 && seek_offset_ != 0) { if (remaining_bytes_ > 0 && seek_offset_ != 0) {
int rv = stream_->Seek(seek_offset_, int rv =
base::Bind(&URLRequestAsarJob::DidSeek, stream_->Seek(seek_offset_, base::Bind(&URLRequestAsarJob::DidSeek,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
if (rv != net::ERR_IO_PENDING) { if (rv != net::ERR_IO_PENDING) {
// stream_->Seek() failed, so pass an intentionally erroneous value // stream_->Seek() failed, so pass an intentionally erroneous value
@ -327,9 +321,8 @@ void URLRequestAsarJob::DidOpen(int result) {
void URLRequestAsarJob::DidSeek(int64_t result) { void URLRequestAsarJob::DidSeek(int64_t result) {
if (result != seek_offset_) { if (result != seek_offset_) {
NotifyStartError( NotifyStartError(net::URLRequestStatus(
net::URLRequestStatus(net::URLRequestStatus::FAILED, net::URLRequestStatus::FAILED, net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
net::ERR_REQUEST_RANGE_NOT_SATISFIABLE));
return; return;
} }
set_expected_content_size(remaining_bytes_); set_expected_content_size(remaining_bytes_);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -13,7 +13,8 @@
namespace atom { namespace atom {
OffScreenWebContentsView::OffScreenWebContentsView( OffScreenWebContentsView::OffScreenWebContentsView(
bool transparent, const OnPaintCallback& callback) bool transparent,
const OnPaintCallback& callback)
: transparent_(transparent), : transparent_(transparent),
painting_(true), painting_(true),
frame_rate_(60), frame_rate_(60),
@ -39,26 +40,32 @@ void OffScreenWebContentsView::SetWebContents(
#if !defined(OS_MACOSX) #if !defined(OS_MACOSX)
gfx::NativeView OffScreenWebContentsView::GetNativeView() const { gfx::NativeView OffScreenWebContentsView::GetNativeView() const {
if (!web_contents_) return gfx::NativeView(); if (!web_contents_)
return gfx::NativeView();
auto relay = NativeWindowRelay::FromWebContents(web_contents_); auto relay = NativeWindowRelay::FromWebContents(web_contents_);
if (!relay) return gfx::NativeView(); if (!relay)
return gfx::NativeView();
return relay->window->GetNativeView(); return relay->window->GetNativeView();
} }
gfx::NativeView OffScreenWebContentsView::GetContentNativeView() const { gfx::NativeView OffScreenWebContentsView::GetContentNativeView() const {
if (!web_contents_) return gfx::NativeView(); if (!web_contents_)
return gfx::NativeView();
auto relay = NativeWindowRelay::FromWebContents(web_contents_); auto relay = NativeWindowRelay::FromWebContents(web_contents_);
if (!relay) return gfx::NativeView(); if (!relay)
return gfx::NativeView();
return relay->window->GetNativeView(); return relay->window->GetNativeView();
} }
gfx::NativeWindow OffScreenWebContentsView::GetTopLevelNativeWindow() const { gfx::NativeWindow OffScreenWebContentsView::GetTopLevelNativeWindow() const {
if (!web_contents_) return gfx::NativeWindow(); if (!web_contents_)
return gfx::NativeWindow();
auto relay = NativeWindowRelay::FromWebContents(web_contents_); auto relay = NativeWindowRelay::FromWebContents(web_contents_);
if (!relay) return gfx::NativeWindow(); if (!relay)
return gfx::NativeWindow();
return relay->window->GetNativeWindow(); return relay->window->GetNativeWindow();
} }
#endif #endif
@ -67,20 +74,15 @@ void OffScreenWebContentsView::GetContainerBounds(gfx::Rect* out) const {
*out = GetViewBounds(); *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 { content::DropData* OffScreenWebContentsView::GetDropData() const {
return nullptr; return nullptr;
@ -91,12 +93,12 @@ gfx::Rect OffScreenWebContentsView::GetViewBounds() const {
} }
void OffScreenWebContentsView::CreateView(const gfx::Size& initial_size, void OffScreenWebContentsView::CreateView(const gfx::Size& initial_size,
gfx::NativeView context) { gfx::NativeView context) {}
}
content::RenderWidgetHostViewBase* content::RenderWidgetHostViewBase*
OffScreenWebContentsView::CreateViewForWidget( OffScreenWebContentsView::CreateViewForWidget(
content::RenderWidgetHost* render_widget_host, bool is_guest_view_hack) { content::RenderWidgetHost* render_widget_host,
bool is_guest_view_hack) {
if (render_widget_host->GetView()) { if (render_widget_host->GetView()) {
return static_cast<content::RenderWidgetHostViewBase*>( return static_cast<content::RenderWidgetHostViewBase*>(
render_widget_host->GetView()); render_widget_host->GetView());
@ -104,41 +106,31 @@ content::RenderWidgetHostViewBase*
auto relay = NativeWindowRelay::FromWebContents(web_contents_); auto relay = NativeWindowRelay::FromWebContents(web_contents_);
return new OffScreenRenderWidgetHostView( return new OffScreenRenderWidgetHostView(
transparent_, transparent_, painting_, GetFrameRate(), callback_, render_widget_host,
painting_, nullptr, relay->window.get());
GetFrameRate(),
callback_,
render_widget_host,
nullptr,
relay->window.get());
} }
content::RenderWidgetHostViewBase* content::RenderWidgetHostViewBase*
OffScreenWebContentsView::CreateViewForPopupWidget( OffScreenWebContentsView::CreateViewForPopupWidget(
content::RenderWidgetHost* render_widget_host) { content::RenderWidgetHost* render_widget_host) {
auto relay = NativeWindowRelay::FromWebContents(web_contents_); auto relay = NativeWindowRelay::FromWebContents(web_contents_);
content::WebContentsImpl *web_contents_impl = content::WebContentsImpl* web_contents_impl =
static_cast<content::WebContentsImpl*>(web_contents_); static_cast<content::WebContentsImpl*>(web_contents_);
OffScreenRenderWidgetHostView *view = OffScreenRenderWidgetHostView* view =
static_cast<OffScreenRenderWidgetHostView*>( static_cast<OffScreenRenderWidgetHostView*>(
web_contents_impl->GetOuterWebContents() web_contents_impl->GetOuterWebContents()
? web_contents_impl->GetOuterWebContents()->GetRenderWidgetHostView() ? web_contents_impl->GetOuterWebContents()
->GetRenderWidgetHostView()
: web_contents_impl->GetRenderWidgetHostView()); : web_contents_impl->GetRenderWidgetHostView());
return new OffScreenRenderWidgetHostView( return new OffScreenRenderWidgetHostView(
transparent_, transparent_, true, view->GetFrameRate(), callback_, render_widget_host,
true, view, relay->window.get());
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( void OffScreenWebContentsView::RenderViewCreated(
content::RenderViewHost* host) { content::RenderViewHost* host) {
@ -151,11 +143,9 @@ void OffScreenWebContentsView::RenderViewCreated(
} }
void OffScreenWebContentsView::RenderViewSwappedIn( void OffScreenWebContentsView::RenderViewSwappedIn(
content::RenderViewHost* host) { content::RenderViewHost* host) {}
}
void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled) { void OffScreenWebContentsView::SetOverscrollControllerEnabled(bool enabled) {}
}
void OffScreenWebContentsView::GetScreenInfo( void OffScreenWebContentsView::GetScreenInfo(
content::ScreenInfo* screen_info) const { content::ScreenInfo* screen_info) const {
@ -178,8 +168,7 @@ void OffScreenWebContentsView::GetScreenInfo(
} }
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
void OffScreenWebContentsView::SetAllowOtherViews(bool allow) { void OffScreenWebContentsView::SetAllowOtherViews(bool allow) {}
}
bool OffScreenWebContentsView::GetAllowOtherViews() const { bool OffScreenWebContentsView::GetAllowOtherViews() const {
return false; return false;
@ -189,8 +178,7 @@ bool OffScreenWebContentsView::IsEventTracking() const {
return false; return false;
} }
void OffScreenWebContentsView::CloseTabAfterEventTracking() { void OffScreenWebContentsView::CloseTabAfterEventTracking() {}
}
#endif // defined(OS_MACOSX) #endif // defined(OS_MACOSX)
void OffScreenWebContentsView::StartDragging( void OffScreenWebContentsView::StartDragging(
@ -205,8 +193,7 @@ void OffScreenWebContentsView::StartDragging(
} }
void OffScreenWebContentsView::UpdateDragCursor( void OffScreenWebContentsView::UpdateDragCursor(
blink::WebDragOperation operation) { blink::WebDragOperation operation) {}
}
void OffScreenWebContentsView::SetPainting(bool painting) { void OffScreenWebContentsView::SetPainting(bool painting) {
auto* view = GetView(); 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(helper.value());
relaunch_argv.push_back(internal::kRelauncherTypeArg); relaunch_argv.push_back(internal::kRelauncherTypeArg);
relaunch_argv.insert(relaunch_argv.end(), relaunch_argv.insert(relaunch_argv.end(), relauncher_args.begin(),
relauncher_args.begin(), relauncher_args.end()); relauncher_args.end());
relaunch_argv.push_back(internal::kRelauncherArgSeparator); relaunch_argv.push_back(internal::kRelauncherArgSeparator);

View file

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

View file

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

View file

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

View file

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

View file

@ -79,7 +79,7 @@ void GenerateAcceleratorTable(AcceleratorTable* table,
} else { } else {
ui::Accelerator accelerator; ui::Accelerator accelerator;
if (model->GetAcceleratorAtWithParams(i, true, &accelerator)) { if (model->GetAcceleratorAtWithParams(i, true, &accelerator)) {
MenuItem item = { i, model }; MenuItem item = {i, model};
(*table)[accelerator] = item; (*table)[accelerator] = item;
} }
} }

View file

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

View file

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

View file

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

View file

@ -19,22 +19,15 @@ namespace certificate_trust {
// This requires prompting the user to confirm they trust the certificate. // This requires prompting the user to confirm they trust the certificate.
BOOL AddToTrustedRootStore(const PCCERT_CONTEXT cert_context, BOOL AddToTrustedRootStore(const PCCERT_CONTEXT cert_context,
const scoped_refptr<net::X509Certificate>& cert) { const scoped_refptr<net::X509Certificate>& cert) {
auto root_cert_store = CertOpenStore( auto root_cert_store = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, NULL,
CERT_STORE_PROV_SYSTEM, CERT_SYSTEM_STORE_CURRENT_USER, L"Root");
0,
NULL,
CERT_SYSTEM_STORE_CURRENT_USER,
L"Root");
if (root_cert_store == NULL) { if (root_cert_store == NULL) {
return false; return false;
} }
auto result = CertAddCertificateContextToStore( auto result = CertAddCertificateContextToStore(
root_cert_store, root_cert_store, cert_context, CERT_STORE_ADD_REPLACE_EXISTING, NULL);
cert_context,
CERT_STORE_ADD_REPLACE_EXISTING,
NULL);
if (result) { if (result) {
// force Chromium to reload it's database for this certificate // 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.dwType = USAGE_MATCH_TYPE_AND;
cert_usage.Usage = enhkey_usage; 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; params.RequestedUsage = cert_usage;
return params; return params;
@ -73,14 +66,8 @@ void ShowCertificateTrust(atom::NativeWindow* parent_window,
auto params = GetCertificateChainParameters(); auto params = GetCertificateChainParameters();
if (CertGetCertificateChain(NULL, if (CertGetCertificateChain(NULL, cert_context.get(), NULL, NULL, &params,
cert_context.get(), NULL, NULL, &chain_context)) {
NULL,
NULL,
&params,
NULL,
NULL,
&chain_context)) {
auto error_status = chain_context->TrustStatus.dwErrorStatus; auto error_status = chain_context->TrustStatus.dwErrorStatus;
if (error_status == CERT_TRUST_IS_SELF_SIGNED || if (error_status == CERT_TRUST_IS_SELF_SIGNED ||
error_status == CERT_TRUST_IS_UNTRUSTED_ROOT) { 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 // Set up our OLE machinery
ui::OSExchangeData data; ui::OSExchangeData data;
button_drag_utils::SetDragImage(GURL(), files[0].LossyDisplayName(), button_drag_utils::SetDragImage(
icon.AsImageSkia(), nullptr, GURL(), files[0].LossyDisplayName(), icon.AsImageSkia(), nullptr,
*views::Widget::GetTopLevelWidgetForNativeView(view), &data); *views::Widget::GetTopLevelWidgetForNativeView(view), &data);
std::vector<ui::FileInfo> file_infos; std::vector<ui::FileInfo> file_infos;
@ -39,11 +39,9 @@ void DragFileItems(const std::vector<base::FilePath>& files,
gfx::Point location = display::Screen::GetScreen()->GetCursorScreenPoint(); gfx::Point location = display::Screen::GetScreen()->GetCursorScreenPoint();
// TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below. // TODO(varunjain): Properly determine and send DRAG_EVENT_SOURCE below.
aura::client::GetDragDropClient(root_window)->StartDragAndDrop( aura::client::GetDragDropClient(root_window)
data, ->StartDragAndDrop(
root_window, data, root_window, view, location,
view,
location,
ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK, ui::DragDropTypes::DRAG_COPY | ui::DragDropTypes::DRAG_LINK,
ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE);
} }

View file

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

View file

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

View file

@ -6,29 +6,22 @@
namespace atom { 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, void TrayIcon::DisplayBalloon(ImageType icon,
const base::string16& title, const base::string16& title,
const base::string16& contents) { const base::string16& contents) {}
}
void TrayIcon::PopUpContextMenu(const gfx::Point& pos, void TrayIcon::PopUpContextMenu(const gfx::Point& pos,
AtomMenuModel* menu_model) { AtomMenuModel* menu_model) {}
}
gfx::Rect TrayIcon::GetBounds() { gfx::Rect TrayIcon::GetBounds() {
return gfx::Rect(); return gfx::Rect();

View file

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

View file

@ -18,8 +18,7 @@
namespace atom { namespace atom {
AutofillPopupView::AutofillPopupView( AutofillPopupView::AutofillPopupView(AutofillPopup* popup,
AutofillPopup* popup,
views::Widget* parent_widget) views::Widget* parent_widget)
: popup_(popup), : popup_(popup),
parent_widget_(parent_widget), parent_widget_(parent_widget),
@ -63,12 +62,10 @@ void AutofillPopupView::Show() {
views::FocusManager* focus_manager = parent_widget_->GetFocusManager(); views::FocusManager* focus_manager = parent_widget_->GetFocusManager();
focus_manager->RegisterAccelerator( focus_manager->RegisterAccelerator(
ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE), ui::Accelerator(ui::VKEY_RETURN, ui::EF_NONE),
ui::AcceleratorManager::kNormalPriority, ui::AcceleratorManager::kNormalPriority, this);
this);
focus_manager->RegisterAccelerator( focus_manager->RegisterAccelerator(
ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE), ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE),
ui::AcceleratorManager::kNormalPriority, ui::AcceleratorManager::kNormalPriority, this);
this);
// The widget is destroyed by the corresponding NativeWidget, so we use // 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 // a weak pointer to hold the reference and don't have to worry about
@ -150,9 +147,7 @@ void AutofillPopupView::DrawAutofillEntry(gfx::Canvas* canvas,
if (!popup_) if (!popup_)
return; return;
canvas->FillRect( canvas->FillRect(entry_rect, GetNativeTheme()->GetSystemColor(
entry_rect,
GetNativeTheme()->GetSystemColor(
popup_->GetBackgroundColorIDForRow(index))); popup_->GetBackgroundColorIDForRow(index)));
const bool is_rtl = base::i18n::IsRTL(); const bool is_rtl = base::i18n::IsRTL();
@ -163,15 +158,13 @@ void AutofillPopupView::DrawAutofillEntry(gfx::Canvas* canvas,
int x_align_left = value_rect.x(); int x_align_left = value_rect.x();
const int value_width = gfx::GetStringWidth( const int value_width = gfx::GetStringWidth(
popup_->GetValueAt(index), popup_->GetValueAt(index), popup_->GetValueFontListForRow(index));
popup_->GetValueFontListForRow(index));
int value_x_align_left = x_align_left; int value_x_align_left = x_align_left;
value_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( canvas->DrawStringRectWithFlags(
popup_->GetValueAt(index), popup_->GetValueAt(index), popup_->GetValueFontListForRow(index),
popup_->GetValueFontListForRow(index),
GetNativeTheme()->GetSystemColor( GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_ResultsTableNormalText), ui::NativeTheme::kColorId_ResultsTableNormalText),
gfx::Rect(value_x_align_left, value_rect.y(), value_width, gfx::Rect(value_x_align_left, value_rect.y(), value_width,
@ -181,15 +174,13 @@ void AutofillPopupView::DrawAutofillEntry(gfx::Canvas* canvas,
// Draw the label text, if one exists. // Draw the label text, if one exists.
if (!popup_->GetLabelAt(index).empty()) { if (!popup_->GetLabelAt(index).empty()) {
const int label_width = gfx::GetStringWidth( const int label_width = gfx::GetStringWidth(
popup_->GetLabelAt(index), popup_->GetLabelAt(index), popup_->GetLabelFontListForRow(index));
popup_->GetLabelFontListForRow(index));
int label_x_align_left = x_align_left; int label_x_align_left = x_align_left;
label_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( canvas->DrawStringRectWithFlags(
popup_->GetLabelAt(index), popup_->GetLabelAt(index), popup_->GetLabelFontListForRow(index),
popup_->GetLabelFontListForRow(index),
GetNativeTheme()->GetSystemColor( GetNativeTheme()->GetSystemColor(
ui::NativeTheme::kColorId_ResultsTableNormalDimmedText), ui::NativeTheme::kColorId_ResultsTableNormalDimmedText),
gfx::Rect(label_x_align_left, entry_rect.y(), label_width, 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; std::unique_ptr<cc::SkiaPaintCanvas> paint_canvas;
if (view_proxy_.get()) { if (view_proxy_.get()) {
bitmap.allocN32Pixels(popup_->popup_bounds_in_view_.width(), bitmap.allocN32Pixels(popup_->popup_bounds_in_view_.width(),
popup_->popup_bounds_in_view_.height(), popup_->popup_bounds_in_view_.height(), true);
true);
paint_canvas.reset(new cc::SkiaPaintCanvas(bitmap)); paint_canvas.reset(new cc::SkiaPaintCanvas(bitmap));
draw_canvas = new gfx::Canvas(paint_canvas.get(), 1.0); draw_canvas = new gfx::Canvas(paint_canvas.get(), 1.0);
} }
@ -340,8 +330,7 @@ void AutofillPopupView::OnGestureEvent(ui::GestureEvent* event) {
event->SetHandled(); event->SetHandled();
} }
bool AutofillPopupView::AcceleratorPressed( bool AutofillPopupView::AcceleratorPressed(const ui::Accelerator& accelerator) {
const ui::Accelerator& accelerator) {
if (accelerator.modifiers() != ui::EF_NONE) if (accelerator.modifiers() != ui::EF_NONE)
return false; return false;

View file

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

View file

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

View file

@ -14,13 +14,9 @@
namespace atom { namespace atom {
MenuDelegate::MenuDelegate(MenuBar* menu_bar) MenuDelegate::MenuDelegate(MenuBar* menu_bar) : menu_bar_(menu_bar), id_(-1) {}
: menu_bar_(menu_bar),
id_(-1) {
}
MenuDelegate::~MenuDelegate() { MenuDelegate::~MenuDelegate() {}
}
void MenuDelegate::RunMenu(AtomMenuModel* model, views::MenuButton* button) { void MenuDelegate::RunMenu(AtomMenuModel* model, views::MenuButton* button) {
gfx::Point screen_loc; gfx::Point screen_loc;
@ -38,11 +34,8 @@ void MenuDelegate::RunMenu(AtomMenuModel* model, views::MenuButton* button) {
menu_runner_.reset(new views::MenuRunner( menu_runner_.reset(new views::MenuRunner(
item, item,
views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS)); views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS));
menu_runner_->RunMenuAt( menu_runner_->RunMenuAt(button->GetWidget()->GetTopLevelWidget(), button,
button->GetWidget()->GetTopLevelWidget(), bounds, views::MENU_ANCHOR_TOPRIGHT,
button,
bounds,
views::MENU_ANCHOR_TOPRIGHT,
ui::MENU_SOURCE_MOUSE); ui::MENU_SOURCE_MOUSE);
} }

View file

@ -7,20 +7,17 @@
namespace atom { namespace atom {
MenuModelAdapter::MenuModelAdapter(AtomMenuModel* menu_model) MenuModelAdapter::MenuModelAdapter(AtomMenuModel* menu_model)
: views::MenuModelAdapter(menu_model), : views::MenuModelAdapter(menu_model), menu_model_(menu_model) {}
menu_model_(menu_model) {
}
MenuModelAdapter::~MenuModelAdapter() { MenuModelAdapter::~MenuModelAdapter() {}
}
bool MenuModelAdapter::GetAccelerator(int id, bool MenuModelAdapter::GetAccelerator(int id,
ui::Accelerator* accelerator) const { ui::Accelerator* accelerator) const {
ui::MenuModel* model = menu_model_; ui::MenuModel* model = menu_model_;
int index = 0; int index = 0;
if (ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) { if (ui::MenuModel::GetModelAndIndexForCommandId(id, &model, &index)) {
return static_cast<AtomMenuModel*>(model)-> return static_cast<AtomMenuModel*>(model)->GetAcceleratorAtWithParams(
GetAcceleratorAtWithParams(index, true, accelerator); index, true, accelerator);
} }
return false; return false;
} }

View file

@ -15,9 +15,7 @@ const char kViewClassName[] = "AtomNativeFrameView";
} // namespace } // namespace
NativeFrameView::NativeFrameView(NativeWindow* window, views::Widget* widget) NativeFrameView::NativeFrameView(NativeWindow* window, views::Widget* widget)
: views::NativeFrameView(widget), : views::NativeFrameView(widget), window_(window) {}
window_(window) {
}
gfx::Size NativeFrameView::GetMinimumSize() const { gfx::Size NativeFrameView::GetMinimumSize() const {
return window_->GetMinimumSize(); return window_->GetMinimumSize();

View file

@ -20,7 +20,8 @@ SubmenuButton::SubmenuButton(const base::string16& title,
views::MenuButtonListener* menu_button_listener, views::MenuButtonListener* menu_button_listener,
const SkColor& background_color) const SkColor& background_color)
: views::MenuButton(gfx::RemoveAcceleratorChar(title, '&', NULL, NULL), : views::MenuButton(gfx::RemoveAcceleratorChar(title, '&', NULL, NULL),
menu_button_listener, false), menu_button_listener,
false),
accelerator_(0), accelerator_(0),
show_underline_(false), show_underline_(false),
underline_start_(0), underline_start_(0),
@ -44,16 +45,13 @@ SubmenuButton::SubmenuButton(const base::string16& title,
color_utils::BlendTowardOppositeLuma(background_color_, 0x61)); color_utils::BlendTowardOppositeLuma(background_color_, 0x61));
} }
SubmenuButton::~SubmenuButton() { SubmenuButton::~SubmenuButton() {}
}
std::unique_ptr<views::InkDropRipple> SubmenuButton::CreateInkDropRipple() std::unique_ptr<views::InkDropRipple> SubmenuButton::CreateInkDropRipple()
const { const {
std::unique_ptr<views::InkDropRipple> ripple( std::unique_ptr<views::InkDropRipple> ripple(
new views::FloodFillInkDropRipple( new views::FloodFillInkDropRipple(
size(), size(), GetInkDropCenterBasedOnLastEvent(), GetInkDropBaseColor(),
GetInkDropCenterBasedOnLastEvent(),
GetInkDropBaseColor(),
ink_drop_visible_opacity())); ink_drop_visible_opacity()));
return ripple; return ripple;
} }
@ -91,7 +89,8 @@ void SubmenuButton::PaintButtonContents(gfx::Canvas* canvas) {
bool SubmenuButton::GetUnderlinePosition(const base::string16& text, bool SubmenuButton::GetUnderlinePosition(const base::string16& text,
base::char16* accelerator, base::char16* accelerator,
int* start, int* end) const { int* start,
int* end) const {
int pos, span; int pos, span;
base::string16 trimmed = gfx::RemoveAcceleratorChar(text, '&', &pos, &span); base::string16 trimmed = gfx::RemoveAcceleratorChar(text, '&', &pos, &span);
if (pos > -1 && span != 0) { if (pos > -1 && span != 0) {
@ -104,8 +103,9 @@ bool SubmenuButton::GetUnderlinePosition(const base::string16& text,
return false; return false;
} }
void SubmenuButton::GetCharacterPosition( void SubmenuButton::GetCharacterPosition(const base::string16& text,
const base::string16& text, int index, int* pos) const { int index,
int* pos) const {
int height = 0; int height = 0;
gfx::Canvas::SizeStringInt(text.substr(0, index), gfx::FontList(), pos, gfx::Canvas::SizeStringInt(text.substr(0, index), gfx::FontList(), pos,
&height, 0, 0); &height, 0, 0);

View file

@ -16,12 +16,9 @@ const char kViewClassName[] = "WinFrameView";
} // namespace } // namespace
WinFrameView::WinFrameView() {}
WinFrameView::WinFrameView() { WinFrameView::~WinFrameView() {}
}
WinFrameView::~WinFrameView() {
}
gfx::Rect WinFrameView::GetWindowBoundsForClientBounds( gfx::Rect WinFrameView::GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const { const gfx::Rect& client_bounds) const {

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