| 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/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "chrome/common/extensions/extension_constants.h" | 8 #include "chrome/common/extensions/extension_constants.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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 content::RenderView* render_view = | 71 content::RenderView* render_view = |
| 72 content::RenderView::FromWebView(frame->view()); | 72 content::RenderView::FromWebView(frame->view()); |
| 73 if (!render_view) | 73 if (!render_view) |
| 74 return; | 74 return; |
| 75 | 75 |
| 76 std::string preferred_store_link_url; | 76 std::string preferred_store_link_url; |
| 77 if (!args[0]->IsUndefined()) { | 77 if (!args[0]->IsUndefined()) { |
| 78 if (args[0]->IsString()) { | 78 if (args[0]->IsString()) { |
| 79 preferred_store_link_url = std::string(*v8::String::Utf8Value(args[0])); | 79 preferred_store_link_url = std::string(*v8::String::Utf8Value(args[0])); |
| 80 } else { | 80 } else { |
| 81 v8::ThrowException(v8::String::NewFromUtf8( | 81 args.GetIsolate()->ThrowException(v8::String::NewFromUtf8( |
| 82 args.GetIsolate(), kPreferredStoreLinkUrlNotAString)); | 82 args.GetIsolate(), kPreferredStoreLinkUrlNotAString)); |
| 83 return; | 83 return; |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 std::string webstore_item_id; | 87 std::string webstore_item_id; |
| 88 std::string error; | 88 std::string error; |
| 89 if (!GetWebstoreItemIdFromFrame( | 89 if (!GetWebstoreItemIdFromFrame( |
| 90 frame, preferred_store_link_url, &webstore_item_id, &error)) { | 90 frame, preferred_store_link_url, &webstore_item_id, &error)) { |
| 91 v8::ThrowException( | 91 args.GetIsolate()->ThrowException( |
| 92 v8::String::NewFromUtf8(args.GetIsolate(), error.c_str())); | 92 v8::String::NewFromUtf8(args.GetIsolate(), error.c_str())); |
| 93 return; | 93 return; |
| 94 } | 94 } |
| 95 | 95 |
| 96 int install_id = g_next_install_id++; | 96 int install_id = g_next_install_id++; |
| 97 if (!args[1]->IsUndefined() && !args[1]->IsFunction()) { | 97 if (!args[1]->IsUndefined() && !args[1]->IsFunction()) { |
| 98 v8::ThrowException(v8::String::NewFromUtf8( | 98 args.GetIsolate()->ThrowException(v8::String::NewFromUtf8( |
| 99 args.GetIsolate(), kSuccessCallbackNotAFunctionError)); | 99 args.GetIsolate(), kSuccessCallbackNotAFunctionError)); |
| 100 return; | 100 return; |
| 101 } | 101 } |
| 102 | 102 |
| 103 if (!args[2]->IsUndefined() && !args[2]->IsFunction()) { | 103 if (!args[2]->IsUndefined() && !args[2]->IsFunction()) { |
| 104 v8::ThrowException(v8::String::NewFromUtf8( | 104 args.GetIsolate()->ThrowException(v8::String::NewFromUtf8( |
| 105 args.GetIsolate(), kFailureCallbackNotAFunctionError)); | 105 args.GetIsolate(), kFailureCallbackNotAFunctionError)); |
| 106 return; | 106 return; |
| 107 } | 107 } |
| 108 | 108 |
| 109 Send(new ExtensionHostMsg_InlineWebstoreInstall( | 109 Send(new ExtensionHostMsg_InlineWebstoreInstall( |
| 110 render_view->GetRoutingID(), | 110 render_view->GetRoutingID(), |
| 111 install_id, | 111 install_id, |
| 112 GetRoutingID(), | 112 GetRoutingID(), |
| 113 webstore_item_id, | 113 webstore_item_id, |
| 114 frame->document().url())); | 114 frame->document().url())); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 v8::Handle<v8::Value> argv[] = { | 222 v8::Handle<v8::Value> argv[] = { |
| 223 v8::Integer::New(install_id), | 223 v8::Integer::New(install_id), |
| 224 v8::Boolean::New(isolate, success), | 224 v8::Boolean::New(isolate, success), |
| 225 v8::String::NewFromUtf8(isolate, error.c_str()) | 225 v8::String::NewFromUtf8(isolate, error.c_str()) |
| 226 }; | 226 }; |
| 227 context()->module_system()->CallModuleMethod( | 227 context()->module_system()->CallModuleMethod( |
| 228 "webstore", "onInstallResponse", arraysize(argv), argv); | 228 "webstore", "onInstallResponse", arraysize(argv), argv); |
| 229 } | 229 } |
| 230 | 230 |
| 231 } // namespace extensions | 231 } // namespace extensions |
| OLD | NEW |