Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2818)

Unified Diff: chrome/renderer/extensions/webstore_bindings_helper.cc

Issue 2791533002: Convert Web Store Inline Install IPCs to mojo (Closed)
Patch Set: WebContentsFrameBindingSet in TabHelper, weak binding in WebstoreBindings Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698