Chromium Code Reviews| 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 "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
| 9 #include "chrome/common/extensions/extension_messages.h" | 9 #include "chrome/common/extensions/extension_messages.h" |
| 10 #include "chrome/renderer/extensions/chrome_v8_context.h" | 10 #include "chrome/renderer/extensions/chrome_v8_context.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 | 48 |
| 49 // chrome.webstore.install() calls generate an install ID so that the install's | 49 // chrome.webstore.install() calls generate an install ID so that the install's |
| 50 // callbacks may be fired when the browser notifies us of install completion | 50 // callbacks may be fired when the browser notifies us of install completion |
| 51 // (successful or not) via OnInlineWebstoreInstallResponse. | 51 // (successful or not) via OnInlineWebstoreInstallResponse. |
| 52 int g_next_install_id = 0; | 52 int g_next_install_id = 0; |
| 53 | 53 |
| 54 } // anonymous namespace | 54 } // anonymous namespace |
| 55 | 55 |
| 56 WebstoreBindings::WebstoreBindings(Dispatcher* dispatcher, | 56 WebstoreBindings::WebstoreBindings(Dispatcher* dispatcher, |
| 57 ChromeV8Context* context) | 57 ChromeV8Context* context) |
| 58 : ChromeV8Extension(dispatcher, context->v8_context()), | 58 : ChromeV8Extension(dispatcher, context), |
| 59 ChromeV8ExtensionHandler(context) { | 59 ChromeV8ExtensionHandler(context) { |
| 60 RouteFunction("Install", | 60 RouteFunction("Install", |
| 61 base::Bind(&WebstoreBindings::Install, base::Unretained(this))); | 61 base::Bind(&WebstoreBindings::Install, base::Unretained(this))); |
| 62 } | 62 } |
| 63 | 63 |
| 64 v8::Handle<v8::Value> WebstoreBindings::Install( | 64 v8::Handle<v8::Value> WebstoreBindings::Install( |
| 65 const v8::Arguments& args) { | 65 const v8::Arguments& args) { |
| 66 WebFrame* frame = WebFrame::frameForContext(v8_context()); | 66 WebFrame* frame = WebFrame::frameForContext(v8_context()); |
| 67 if (!frame || !frame->view()) | 67 if (!frame || !frame->view()) |
| 68 return v8::Undefined(); | 68 return v8::Undefined(); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 IPC_MESSAGE_UNHANDLED(CHECK(false) << "Unhandled IPC message") | 205 IPC_MESSAGE_UNHANDLED(CHECK(false) << "Unhandled IPC message") |
| 206 IPC_END_MESSAGE_MAP() | 206 IPC_END_MESSAGE_MAP() |
| 207 return true; | 207 return true; |
| 208 } | 208 } |
| 209 | 209 |
| 210 void WebstoreBindings::OnInlineWebstoreInstallResponse( | 210 void WebstoreBindings::OnInlineWebstoreInstallResponse( |
| 211 int install_id, | 211 int install_id, |
| 212 bool success, | 212 bool success, |
| 213 const std::string& error) { | 213 const std::string& error) { |
| 214 v8::HandleScope handle_scope; | 214 v8::HandleScope handle_scope; |
| 215 v8::Context::Scope context_scope(context_->v8_context()); | 215 v8::Context::Scope context_scope( |
| 216 ChromeV8ExtensionHandler::context_->v8_context()); | |
|
not at google - send to devlin
2013/05/29 15:55:13
likewise can this call context() instead of access
marja
2013/05/29 16:56:33
Done.
| |
| 216 v8::Handle<v8::Value> argv[3]; | 217 v8::Handle<v8::Value> argv[3]; |
| 217 argv[0] = v8::Integer::New(install_id); | 218 argv[0] = v8::Integer::New(install_id); |
| 218 argv[1] = v8::Boolean::New(success); | 219 argv[1] = v8::Boolean::New(success); |
| 219 argv[2] = v8::String::New(error.c_str()); | 220 argv[2] = v8::String::New(error.c_str()); |
| 220 context_->CallChromeHiddenMethod("webstore.onInstallResponse", | 221 ChromeV8ExtensionHandler::context_->CallChromeHiddenMethod( |
| 221 arraysize(argv), argv, NULL); | 222 "webstore.onInstallResponse", arraysize(argv), argv, NULL); |
| 222 } | 223 } |
| 223 | 224 |
| 224 } // namespace extensions | 225 } // namespace extensions |
| OLD | NEW |