| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 // chrome.webstore.install() calls generate an install ID so that the install's | 47 // chrome.webstore.install() calls generate an install ID so that the install's |
| 48 // callbacks may be fired when the browser notifies us of install completion | 48 // callbacks may be fired when the browser notifies us of install completion |
| 49 // (successful or not) via OnInlineWebstoreInstallResponse. | 49 // (successful or not) via OnInlineWebstoreInstallResponse. |
| 50 int g_next_install_id = 0; | 50 int g_next_install_id = 0; |
| 51 | 51 |
| 52 } // anonymous namespace | 52 } // anonymous namespace |
| 53 | 53 |
| 54 WebstoreBindings::WebstoreBindings(Dispatcher* dispatcher, | 54 WebstoreBindings::WebstoreBindings(Dispatcher* dispatcher, |
| 55 ChromeV8Context* context) | 55 ChromeV8Context* context) |
| 56 : ChromeV8Extension(dispatcher, context->v8_context()), | 56 : ChromeV8Extension(dispatcher), |
| 57 ChromeV8ExtensionHandler(context) { | 57 ChromeV8ExtensionHandler(context) { |
| 58 RouteFunction("Install", | 58 RouteFunction("Install", |
| 59 base::Bind(&WebstoreBindings::Install, base::Unretained(this))); | 59 base::Bind(&WebstoreBindings::Install, base::Unretained(this))); |
| 60 } | 60 } |
| 61 | 61 |
| 62 v8::Handle<v8::Value> WebstoreBindings::Install( | 62 v8::Handle<v8::Value> WebstoreBindings::Install( |
| 63 const v8::Arguments& args) { | 63 const v8::Arguments& args) { |
| 64 WebFrame* frame = WebFrame::frameForContext(v8_context()); | 64 WebFrame* frame = WebFrame::frameForCurrentContext(); |
| 65 if (!frame || !frame->view()) | 65 if (!frame || !frame->view()) |
| 66 return v8::Undefined(); | 66 return v8::Undefined(); |
| 67 | 67 |
| 68 content::RenderView* render_view = | 68 content::RenderView* render_view = |
| 69 content::RenderView::FromWebView(frame->view()); | 69 content::RenderView::FromWebView(frame->view()); |
| 70 if (!render_view) | 70 if (!render_view) |
| 71 return v8::Undefined(); | 71 return v8::Undefined(); |
| 72 | 72 |
| 73 std::string preferred_store_link_url; | 73 std::string preferred_store_link_url; |
| 74 if (!args[0]->IsUndefined()) { | 74 if (!args[0]->IsUndefined()) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 v8::Context::Scope context_scope(context_->v8_context()); | 213 v8::Context::Scope context_scope(context_->v8_context()); |
| 214 v8::Handle<v8::Value> argv[3]; | 214 v8::Handle<v8::Value> argv[3]; |
| 215 argv[0] = v8::Integer::New(install_id); | 215 argv[0] = v8::Integer::New(install_id); |
| 216 argv[1] = v8::Boolean::New(success); | 216 argv[1] = v8::Boolean::New(success); |
| 217 argv[2] = v8::String::New(error.c_str()); | 217 argv[2] = v8::String::New(error.c_str()); |
| 218 context_->CallChromeHiddenMethod("webstore.onInstallResponse", | 218 context_->CallChromeHiddenMethod("webstore.onInstallResponse", |
| 219 arraysize(argv), argv, NULL); | 219 arraysize(argv), argv, NULL); |
| 220 } | 220 } |
| 221 | 221 |
| 222 } // namespace extensions | 222 } // namespace extensions |
| OLD | NEW |