Chromium Code Reviews| Index: chrome/renderer/extensions/webstore_bindings.cc |
| diff --git a/chrome/renderer/extensions/webstore_bindings.cc b/chrome/renderer/extensions/webstore_bindings.cc |
| index 5fd175a5f6ea863b9999df4e3d7dff8fb0cc4a40..c5842e3518b223dcdbacd2b050a42392f4bdb78d 100644 |
| --- a/chrome/renderer/extensions/webstore_bindings.cc |
| +++ b/chrome/renderer/extensions/webstore_bindings.cc |
| @@ -9,12 +9,14 @@ |
| #include "base/macros.h" |
| #include "base/strings/string_util.h" |
| #include "chrome/common/extensions/api/webstore/webstore_api_constants.h" |
| -#include "chrome/common/extensions/chrome_extension_messages.h" |
| #include "components/crx_file/id_util.h" |
| #include "content/public/renderer/render_frame.h" |
| #include "extensions/common/extension.h" |
| #include "extensions/common/extension_urls.h" |
| #include "extensions/renderer/script_context.h" |
| +#include "mojo/public/cpp/bindings/strong_binding.h" |
| +#include "services/service_manager/public/cpp/interface_provider.h" |
| +#include "services/service_manager/public/cpp/interface_registry.h" |
| #include "third_party/WebKit/public/web/WebDocument.h" |
| #include "third_party/WebKit/public/web/WebElement.h" |
| #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| @@ -45,7 +47,7 @@ const char kInvalidWebstoreItemUrlError[] = |
| // chrome.webstore.install() calls generate an install ID so that the install's |
| // callbacks may be fired when the browser notifies us of install completion |
| -// (successful or not) via OnInlineWebstoreInstallResponse. |
| +// (successful or not) via InlineWebstoreInstallResponse. |
| int g_next_install_id = 0; |
| } // anonymous namespace |
| @@ -54,6 +56,20 @@ WebstoreBindings::WebstoreBindings(ScriptContext* context) |
| : ObjectBackedNativeHandler(context) { |
| RouteFunction("Install", "webstore", |
| base::Bind(&WebstoreBindings::Install, base::Unretained(this))); |
| + context->GetRenderFrame()->GetRemoteInterfaces()->GetInterface( |
| + &inline_install_); |
| + context->GetRenderFrame()->GetInterfaceRegistry()->AddInterface( |
| + base::Bind(&WebstoreBindings::BindInlineInstallStatusRequest, context)); |
| +} |
| + |
| +WebstoreBindings::~WebstoreBindings() {} |
| + |
| +// static |
| +void WebstoreBindings::BindInlineInstallStatusRequest( |
| + ScriptContext* context, |
| + mojom::InlineInstallStatusRequest request) { |
| + mojo::MakeStrongBinding(base::MakeUnique<WebstoreBindings>(context), |
|
Devlin
2017/03/31 14:18:39
Here, too, this pattern will result in creating a
catmullings
2017/04/06 20:50:15
Done.
|
| + std::move(request)); |
| } |
| void WebstoreBindings::Install( |
| @@ -91,9 +107,8 @@ void WebstoreBindings::Install( |
| int install_id = g_next_install_id++; |
| - Send(new ExtensionHostMsg_InlineWebstoreInstall( |
| - render_frame->GetRoutingID(), install_id, GetRoutingID(), |
| - webstore_item_id, listener_mask)); |
| + inline_install_->InlineWebstoreInstall(install_id, GetRoutingID(), |
| + webstore_item_id, listener_mask); |
| args.GetReturnValue().Set(static_cast<int32_t>(install_id)); |
| } |
| @@ -187,19 +202,10 @@ bool WebstoreBindings::GetWebstoreItemIdFromFrame( |
| } |
| bool WebstoreBindings::OnMessageReceived(const IPC::Message& message) { |
| - IPC_BEGIN_MESSAGE_MAP(WebstoreBindings, message) |
| - IPC_MESSAGE_HANDLER(ExtensionMsg_InlineWebstoreInstallResponse, |
| - OnInlineWebstoreInstallResponse) |
| - IPC_MESSAGE_HANDLER(ExtensionMsg_InlineInstallStageChanged, |
| - OnInlineInstallStageChanged) |
| - IPC_MESSAGE_HANDLER(ExtensionMsg_InlineInstallDownloadProgress, |
| - OnInlineInstallDownloadProgress) |
| - IPC_MESSAGE_UNHANDLED(CHECK(false) << "Unhandled IPC message") |
| - IPC_END_MESSAGE_MAP() |
| return true; |
| } |
| -void WebstoreBindings::OnInlineWebstoreInstallResponse( |
| +void WebstoreBindings::InlineWebstoreInstallResponse( |
| int install_id, |
| bool success, |
| const std::string& error, |
| @@ -218,7 +224,8 @@ void WebstoreBindings::OnInlineWebstoreInstallResponse( |
| "webstore", "onInstallResponse", arraysize(argv), argv); |
| } |
| -void WebstoreBindings::OnInlineInstallStageChanged(int stage) { |
| +void WebstoreBindings::InlineInstallStageChanged( |
| + api::webstore::InstallStage stage) { |
| const char* stage_string = NULL; |
| api::webstore::InstallStage install_stage = |
| static_cast<api::webstore::InstallStage>(stage); |
| @@ -239,7 +246,7 @@ void WebstoreBindings::OnInlineInstallStageChanged(int stage) { |
| "webstore", "onInstallStageChanged", arraysize(argv), argv); |
| } |
| -void WebstoreBindings::OnInlineInstallDownloadProgress(int percent_downloaded) { |
| +void WebstoreBindings::InlineInstallDownloadProgress(int percent_downloaded) { |
| v8::Isolate* isolate = context()->isolate(); |
| v8::HandleScope handle_scope(isolate); |
| v8::Context::Scope context_scope(context()->v8_context()); |