| 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), | 58 : ChromeV8Extension(dispatcher, context->v8_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::frameForCurrentContext(); | 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(); |
| 69 | 69 |
| 70 content::RenderView* render_view = | 70 content::RenderView* render_view = |
| 71 content::RenderView::FromWebView(frame->view()); | 71 content::RenderView::FromWebView(frame->view()); |
| 72 if (!render_view) | 72 if (!render_view) |
| 73 return v8::Undefined(); | 73 return v8::Undefined(); |
| 74 | 74 |
| 75 std::string preferred_store_link_url; | 75 std::string preferred_store_link_url; |
| 76 if (!args[0]->IsUndefined()) { | 76 if (!args[0]->IsUndefined()) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 v8::Context::Scope context_scope(context_->v8_context()); | 215 v8::Context::Scope context_scope(context_->v8_context()); |
| 216 v8::Handle<v8::Value> argv[3]; | 216 v8::Handle<v8::Value> argv[3]; |
| 217 argv[0] = v8::Integer::New(install_id); | 217 argv[0] = v8::Integer::New(install_id); |
| 218 argv[1] = v8::Boolean::New(success); | 218 argv[1] = v8::Boolean::New(success); |
| 219 argv[2] = v8::String::New(error.c_str()); | 219 argv[2] = v8::String::New(error.c_str()); |
| 220 context_->CallChromeHiddenMethod("webstore.onInstallResponse", | 220 context_->CallChromeHiddenMethod("webstore.onInstallResponse", |
| 221 arraysize(argv), argv, NULL); | 221 arraysize(argv), argv, NULL); |
| 222 } | 222 } |
| 223 | 223 |
| 224 } // namespace extensions | 224 } // namespace extensions |
| OLD | NEW |