Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // 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.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/renderer/extensions/webstore_bindings_helper.h" | |
| 6 | |
| 7 #include "extensions/renderer/script_context.h" | |
| 8 | |
| 9 namespace extensions { | |
| 10 | |
| 11 // static | |
| 12 void WebstoreBindingsHelper::Create(ScriptContext* context, | |
| 13 mojom::InlineInstallStatusRequest request) { | |
| 14 new WebstoreBindingsHelper(context, std::move(request)); | |
| 15 } | |
| 16 | |
| 17 WebstoreBindingsHelper::WebstoreBindingsHelper( | |
| 18 ScriptContext* context, | |
| 19 mojom::InlineInstallStatusRequest request) | |
| 20 : ObjectBackedNativeHandler(context), binding_(this, std::move(request)) {} | |
| 21 | |
| 22 WebstoreBindingsHelper::~WebstoreBindingsHelper() = default; | |
| 23 | |
| 24 void WebstoreBindingsHelper::InlineInstallStageChanged( | |
| 25 api::webstore::InstallStage stage) { | |
| 26 const char* stage_string = NULL; | |
| 27 api::webstore::InstallStage install_stage = | |
| 28 static_cast<api::webstore::InstallStage>(stage); | |
| 29 switch (install_stage) { | |
| 30 case api::webstore::INSTALL_STAGE_DOWNLOADING: | |
| 31 stage_string = api::webstore::kInstallStageDownloading; | |
| 32 break; | |
| 33 case api::webstore::INSTALL_STAGE_INSTALLING: | |
| 34 stage_string = api::webstore::kInstallStageInstalling; | |
| 35 break; | |
| 36 } | |
| 37 v8::Isolate* isolate = context()->isolate(); | |
| 38 v8::HandleScope handle_scope(isolate); | |
| 39 v8::Context::Scope context_scope(context()->v8_context()); | |
| 40 v8::Local<v8::Value> argv[] = { | |
| 41 v8::String::NewFromUtf8(isolate, stage_string)}; | |
| 42 context()->module_system()->CallModuleMethodSafe( | |
| 43 "webstore", "onInstallStageChanged", arraysize(argv), argv); | |
| 44 } | |
| 45 | |
| 46 void WebstoreBindingsHelper::InlineInstallDownloadProgress( | |
| 47 int percent_downloaded) { | |
| 48 v8::Isolate* isolate = context()->isolate(); | |
| 49 v8::HandleScope handle_scope(isolate); | |
| 50 v8::Context::Scope context_scope(context()->v8_context()); | |
| 51 v8::Local<v8::Value> argv[] = { | |
| 52 v8::Number::New(isolate, percent_downloaded / 100.0)}; | |
| 53 context()->module_system()->CallModuleMethodSafe( | |
| 54 "webstore", "onDownloadProgress", arraysize(argv), argv); | |
| 55 } | |
| 56 | |
| 57 } // namespace extensions | |
| OLD | NEW |