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

Side by Side Diff: chrome/renderer/extensions/webstore_bindings.cc

Issue 384823002: Introduce a stable set of errors for inline install (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Replace printf with vlog(1) in unrelated code so it passes presubmit Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "chrome/common/extensions/api/webstore/webstore_api_constants.h" 8 #include "chrome/common/extensions/api/webstore/webstore_api_constants.h"
9 #include "chrome/common/extensions/chrome_extension_messages.h" 9 #include "chrome/common/extensions/chrome_extension_messages.h"
10 #include "chrome/common/extensions/extension_constants.h" 10 #include "chrome/common/extensions/extension_constants.h"
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 IPC_MESSAGE_HANDLER(ExtensionMsg_InlineInstallDownloadProgress, 195 IPC_MESSAGE_HANDLER(ExtensionMsg_InlineInstallDownloadProgress,
196 OnInlineInstallDownloadProgress) 196 OnInlineInstallDownloadProgress)
197 IPC_MESSAGE_UNHANDLED(CHECK(false) << "Unhandled IPC message") 197 IPC_MESSAGE_UNHANDLED(CHECK(false) << "Unhandled IPC message")
198 IPC_END_MESSAGE_MAP() 198 IPC_END_MESSAGE_MAP()
199 return true; 199 return true;
200 } 200 }
201 201
202 void WebstoreBindings::OnInlineWebstoreInstallResponse( 202 void WebstoreBindings::OnInlineWebstoreInstallResponse(
203 int install_id, 203 int install_id,
204 bool success, 204 bool success,
205 const std::string& error) { 205 const std::string& error,
206 webstore_install::Result result) {
206 v8::Isolate* isolate = context()->isolate(); 207 v8::Isolate* isolate = context()->isolate();
207 v8::HandleScope handle_scope(isolate); 208 v8::HandleScope handle_scope(isolate);
208 v8::Context::Scope context_scope(context()->v8_context()); 209 v8::Context::Scope context_scope(context()->v8_context());
209 v8::Handle<v8::Value> argv[] = { 210 v8::Handle<v8::Value> argv[] = {
210 v8::Integer::New(isolate, install_id), 211 v8::Integer::New(isolate, install_id),
211 v8::Boolean::New(isolate, success), 212 v8::Boolean::New(isolate, success),
212 v8::String::NewFromUtf8(isolate, error.c_str()) 213 v8::String::NewFromUtf8(isolate, error.c_str()),
214 v8::String::NewFromUtf8(
215 isolate, api::webstore::kInstallResultCodes[static_cast<int>(result)])
213 }; 216 };
214 context()->module_system()->CallModuleMethod( 217 context()->module_system()->CallModuleMethod(
215 "webstore", "onInstallResponse", arraysize(argv), argv); 218 "webstore", "onInstallResponse", arraysize(argv), argv);
216 } 219 }
217 220
218 void WebstoreBindings::OnInlineInstallStageChanged(int stage) { 221 void WebstoreBindings::OnInlineInstallStageChanged(int stage) {
219 const char* stage_string = NULL; 222 const char* stage_string = NULL;
220 api::webstore::InstallStage install_stage = 223 api::webstore::InstallStage install_stage =
221 static_cast<api::webstore::InstallStage>(stage); 224 static_cast<api::webstore::InstallStage>(stage);
222 switch (install_stage) { 225 switch (install_stage) {
(...skipping 17 matching lines...) Expand all
240 v8::Isolate* isolate = context()->isolate(); 243 v8::Isolate* isolate = context()->isolate();
241 v8::HandleScope handle_scope(isolate); 244 v8::HandleScope handle_scope(isolate);
242 v8::Context::Scope context_scope(context()->v8_context()); 245 v8::Context::Scope context_scope(context()->v8_context());
243 v8::Handle<v8::Value> argv[] = { 246 v8::Handle<v8::Value> argv[] = {
244 v8::Number::New(isolate, percent_downloaded / 100.0)}; 247 v8::Number::New(isolate, percent_downloaded / 100.0)};
245 context()->module_system()->CallModuleMethod( 248 context()->module_system()->CallModuleMethod(
246 "webstore", "onDownloadProgress", arraysize(argv), argv); 249 "webstore", "onDownloadProgress", arraysize(argv), argv);
247 } 250 }
248 251
249 } // namespace extensions 252 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698