Add app.disableHardwareAcceleration() API

This commit is contained in:
Cheng Zhao 2016-06-06 20:19:55 +09:00
parent 3e809901e0
commit 02cfe30df9
3 changed files with 19 additions and 2 deletions

View file

@ -447,6 +447,15 @@ bool App::Relaunch(mate::Arguments* js_args) {
return relauncher::RelaunchApp(argv); return relauncher::RelaunchApp(argv);
} }
void App::DisableHardwareAcceleration(mate::Arguments* args) {
if (Browser::Get()->is_ready()) {
args->ThrowError("app.disableHardwareAcceleration() can only be called "
"before app is ready");
return;
}
content::GpuDataManager::GetInstance()->DisableHardwareAcceleration();
}
#if defined(USE_NSS_CERTS) #if defined(USE_NSS_CERTS)
void App::ImportCertificate( void App::ImportCertificate(
const base::DictionaryValue& options, const base::DictionaryValue& options,
@ -528,7 +537,9 @@ void App::BuildPrototype(
#endif #endif
.SetMethod("makeSingleInstance", &App::MakeSingleInstance) .SetMethod("makeSingleInstance", &App::MakeSingleInstance)
.SetMethod("releaseSingleInstance", &App::ReleaseSingleInstance) .SetMethod("releaseSingleInstance", &App::ReleaseSingleInstance)
.SetMethod("relaunch", &App::Relaunch); .SetMethod("relaunch", &App::Relaunch)
.SetMethod("disableHardwareAcceleration",
&App::DisableHardwareAcceleration);
} }
} // namespace api } // namespace api

View file

@ -111,7 +111,7 @@ class App : public AtomBrowserClient::Delegate,
const ProcessSingleton::NotificationCallback& callback); const ProcessSingleton::NotificationCallback& callback);
void ReleaseSingleInstance(); void ReleaseSingleInstance();
bool Relaunch(mate::Arguments* args); bool Relaunch(mate::Arguments* args);
void DisableHardwareAcceleration(mate::Arguments* args);
#if defined(USE_NSS_CERTS) #if defined(USE_NSS_CERTS)
void ImportCertificate(const base::DictionaryValue& options, void ImportCertificate(const base::DictionaryValue& options,
const net::CompletionCallback& callback); const net::CompletionCallback& callback);

View file

@ -561,6 +561,12 @@ Imports the certificate in pkcs12 format into the platform certificate store.
`callback` is called with the `result` of import operation, a value of `0` `callback` is called with the `result` of import operation, a value of `0`
indicates success while any other value indicates failure according to chromium [net_error_list](https://code.google.com/p/chromium/codesearch#chromium/src/net/base/net_error_list.h). indicates success while any other value indicates failure according to chromium [net_error_list](https://code.google.com/p/chromium/codesearch#chromium/src/net/base/net_error_list.h).
### `app.disableHardwareAcceleration()`
Disables hardware acceleration for current app.
This method can only be called before app is ready.
### `app.commandLine.appendSwitch(switch[, value])` ### `app.commandLine.appendSwitch(switch[, value])`
Append a switch (with optional `value`) to Chromium's command line. Append a switch (with optional `value`) to Chromium's command line.