Chromium Code Reviews| Index: chrome/renderer/extensions/webstore_bindings_helper.cc |
| diff --git a/chrome/renderer/extensions/webstore_bindings_helper.cc b/chrome/renderer/extensions/webstore_bindings_helper.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..028227029a82864d8f12dadace8a585c60084d1e |
| --- /dev/null |
| +++ b/chrome/renderer/extensions/webstore_bindings_helper.cc |
| @@ -0,0 +1,57 @@ |
| +// Copyright (c) 2017 The Chromium Authors. All rights reserved. |
|
Devlin
2017/04/12 01:16:07
no (c) in new code
catmullings
2017/04/14 20:59:40
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/renderer/extensions/webstore_bindings_helper.h" |
| + |
| +#include "extensions/renderer/script_context.h" |
| + |
| +namespace extensions { |
| + |
| +// static |
| +void WebstoreBindingsHelper::Create(ScriptContext* context, |
| + mojom::InlineInstallStatusRequest request) { |
| + new WebstoreBindingsHelper(context, std::move(request)); |
| +} |
| + |
| +WebstoreBindingsHelper::WebstoreBindingsHelper( |
| + ScriptContext* context, |
| + mojom::InlineInstallStatusRequest request) |
| + : ObjectBackedNativeHandler(context), binding_(this, std::move(request)) {} |
| + |
| +WebstoreBindingsHelper::~WebstoreBindingsHelper() = default; |
| + |
| +void WebstoreBindingsHelper::InlineInstallStageChanged( |
| + api::webstore::InstallStage stage) { |
| + const char* stage_string = NULL; |
| + api::webstore::InstallStage install_stage = |
| + static_cast<api::webstore::InstallStage>(stage); |
| + switch (install_stage) { |
| + case api::webstore::INSTALL_STAGE_DOWNLOADING: |
| + stage_string = api::webstore::kInstallStageDownloading; |
| + break; |
| + case api::webstore::INSTALL_STAGE_INSTALLING: |
| + stage_string = api::webstore::kInstallStageInstalling; |
| + break; |
| + } |
| + v8::Isolate* isolate = context()->isolate(); |
| + v8::HandleScope handle_scope(isolate); |
| + v8::Context::Scope context_scope(context()->v8_context()); |
| + v8::Local<v8::Value> argv[] = { |
| + v8::String::NewFromUtf8(isolate, stage_string)}; |
| + context()->module_system()->CallModuleMethodSafe( |
| + "webstore", "onInstallStageChanged", arraysize(argv), argv); |
| +} |
| + |
| +void WebstoreBindingsHelper::InlineInstallDownloadProgress( |
| + int percent_downloaded) { |
| + v8::Isolate* isolate = context()->isolate(); |
| + v8::HandleScope handle_scope(isolate); |
| + v8::Context::Scope context_scope(context()->v8_context()); |
| + v8::Local<v8::Value> argv[] = { |
| + v8::Number::New(isolate, percent_downloaded / 100.0)}; |
| + context()->module_system()->CallModuleMethodSafe( |
| + "webstore", "onDownloadProgress", arraysize(argv), argv); |
| +} |
| + |
| +} // namespace extensions |