| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/extensions/webstore_bindings.h" | 5 #include "chrome/renderer/extensions/webstore_bindings.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 v8::Isolate* isolate = context()->isolate(); | 207 v8::Isolate* isolate = context()->isolate(); |
| 208 v8::HandleScope handle_scope(isolate); | 208 v8::HandleScope handle_scope(isolate); |
| 209 v8::Context::Scope context_scope(context()->v8_context()); | 209 v8::Context::Scope context_scope(context()->v8_context()); |
| 210 v8::Local<v8::Value> argv[] = { | 210 v8::Local<v8::Value> argv[] = { |
| 211 v8::Integer::New(isolate, install_id), | 211 v8::Integer::New(isolate, install_id), |
| 212 v8::Boolean::New(isolate, success), | 212 v8::Boolean::New(isolate, success), |
| 213 v8::String::NewFromUtf8(isolate, error.c_str()), | 213 v8::String::NewFromUtf8(isolate, error.c_str()), |
| 214 v8::String::NewFromUtf8( | 214 v8::String::NewFromUtf8( |
| 215 isolate, api::webstore::kInstallResultCodes[static_cast<int>(result)]) | 215 isolate, api::webstore::kInstallResultCodes[static_cast<int>(result)]) |
| 216 }; | 216 }; |
| 217 context()->module_system()->CallModuleMethod( | 217 context()->module_system()->CallModuleMethodSafe( |
| 218 "webstore", "onInstallResponse", arraysize(argv), argv); | 218 "webstore", "onInstallResponse", arraysize(argv), argv); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void WebstoreBindings::OnInlineInstallStageChanged(int stage) { | 221 void WebstoreBindings::OnInlineInstallStageChanged(int stage) { |
| 222 const char* stage_string = NULL; | 222 const char* stage_string = NULL; |
| 223 api::webstore::InstallStage install_stage = | 223 api::webstore::InstallStage install_stage = |
| 224 static_cast<api::webstore::InstallStage>(stage); | 224 static_cast<api::webstore::InstallStage>(stage); |
| 225 switch (install_stage) { | 225 switch (install_stage) { |
| 226 case api::webstore::INSTALL_STAGE_DOWNLOADING: | 226 case api::webstore::INSTALL_STAGE_DOWNLOADING: |
| 227 stage_string = api::webstore::kInstallStageDownloading; | 227 stage_string = api::webstore::kInstallStageDownloading; |
| 228 break; | 228 break; |
| 229 case api::webstore::INSTALL_STAGE_INSTALLING: | 229 case api::webstore::INSTALL_STAGE_INSTALLING: |
| 230 stage_string = api::webstore::kInstallStageInstalling; | 230 stage_string = api::webstore::kInstallStageInstalling; |
| 231 break; | 231 break; |
| 232 } | 232 } |
| 233 v8::Isolate* isolate = context()->isolate(); | 233 v8::Isolate* isolate = context()->isolate(); |
| 234 v8::HandleScope handle_scope(isolate); | 234 v8::HandleScope handle_scope(isolate); |
| 235 v8::Context::Scope context_scope(context()->v8_context()); | 235 v8::Context::Scope context_scope(context()->v8_context()); |
| 236 v8::Local<v8::Value> argv[] = { | 236 v8::Local<v8::Value> argv[] = { |
| 237 v8::String::NewFromUtf8(isolate, stage_string)}; | 237 v8::String::NewFromUtf8(isolate, stage_string)}; |
| 238 context()->module_system()->CallModuleMethod( | 238 context()->module_system()->CallModuleMethodSafe( |
| 239 "webstore", "onInstallStageChanged", arraysize(argv), argv); | 239 "webstore", "onInstallStageChanged", arraysize(argv), argv); |
| 240 } | 240 } |
| 241 | 241 |
| 242 void WebstoreBindings::OnInlineInstallDownloadProgress(int percent_downloaded) { | 242 void WebstoreBindings::OnInlineInstallDownloadProgress(int percent_downloaded) { |
| 243 v8::Isolate* isolate = context()->isolate(); | 243 v8::Isolate* isolate = context()->isolate(); |
| 244 v8::HandleScope handle_scope(isolate); | 244 v8::HandleScope handle_scope(isolate); |
| 245 v8::Context::Scope context_scope(context()->v8_context()); | 245 v8::Context::Scope context_scope(context()->v8_context()); |
| 246 v8::Local<v8::Value> argv[] = { | 246 v8::Local<v8::Value> argv[] = { |
| 247 v8::Number::New(isolate, percent_downloaded / 100.0)}; | 247 v8::Number::New(isolate, percent_downloaded / 100.0)}; |
| 248 context()->module_system()->CallModuleMethod( | 248 context()->module_system()->CallModuleMethodSafe( |
| 249 "webstore", "onDownloadProgress", arraysize(argv), argv); | 249 "webstore", "onDownloadProgress", arraysize(argv), argv); |
| 250 } | 250 } |
| 251 | 251 |
| 252 } // namespace extensions | 252 } // namespace extensions |
| OLD | NEW |