Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8527)

Unified Diff: chrome/renderer/chrome_render_frame_observer.cc

Issue 2393513004: Convert app banners to use Mojo. (Closed)
Patch Set: Rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/renderer/chrome_render_frame_observer.cc
diff --git a/chrome/renderer/chrome_render_frame_observer.cc b/chrome/renderer/chrome_render_frame_observer.cc
index 977faf83e927caa2d683a55984e439d3115329fa..6ae8c9e8b020ccbddd4524469bb74a2de517905a 100644
--- a/chrome/renderer/chrome_render_frame_observer.cc
+++ b/chrome/renderer/chrome_render_frame_observer.cc
@@ -9,6 +9,7 @@
#include <limits>
#include <string>
+#include <utility>
#include <vector>
#include "base/command_line.h"
@@ -30,7 +31,6 @@
#include "skia/ext/image_operations.h"
#include "third_party/WebKit/public/platform/WebImage.h"
#include "third_party/WebKit/public/platform/WebURLRequest.h"
-#include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerPromptReply.h"
#include "third_party/WebKit/public/web/WebDataSource.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebElement.h"
@@ -107,6 +107,15 @@ SkBitmap Downscale(const blink::WebImage& image,
} // namespace
+// static
+void ChromeRenderFrameObserver::BindBannerClient(
+ ChromeRenderFrameObserver* observer,
+ mojo::InterfaceRequest<blink::mojom::AppBannerClient> request) {
+ observer->banner_binding_.reset(
dcheng 2016/10/07 07:03:16 Nit: I think this can be replaced with Binding::Cl
dominickn 2016/10/13 00:18:15 Done.
+ new mojo::Binding<blink::mojom::AppBannerClient>(observer,
+ std::move(request)));
+}
+
ChromeRenderFrameObserver::ChromeRenderFrameObserver(
content::RenderFrame* render_frame)
: content::RenderFrameObserver(render_frame),
@@ -149,8 +158,6 @@ bool ChromeRenderFrameObserver::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(PrintMsg_PrintNodeUnderContextMenu,
OnPrintNodeUnderContextMenu)
#endif
- IPC_MESSAGE_HANDLER(ChromeViewMsg_AppBannerPromptRequest,
- OnAppBannerPromptRequest)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -240,18 +247,27 @@ void ChromeRenderFrameObserver::OnSetClientSidePhishingDetection(
#endif
}
-void ChromeRenderFrameObserver::OnAppBannerPromptRequest(
- int request_id,
- const std::string& platform) {
- // App banner prompt requests are handled in the general chrome render frame
- // observer, not the AppBannerClient, as the AppBannerClient is created lazily
- // by blink and may not exist when the request is sent.
- blink::WebAppBannerPromptReply reply = blink::WebAppBannerPromptReply::None;
+void ChromeRenderFrameObserver::BannerPromptRequest(
+ blink::mojom::AppBannerServicePtr banner_service,
+ blink::mojom::AppBannerEventRequest event_request,
+ const std::string& platform,
+ const BannerPromptRequestCallback& callback) {
+ // Break up the InterfacePtr and InterfaceRequest so they can be passed
+ // through to Blink as ScopedMessagePipeHandle. They will be reconstituted on
+ // the other side.
dcheng 2016/10/07 07:03:16 Maybe put a TODO here that we should be able to ge
+ mojo::ScopedMessagePipeHandle service_handle =
+ banner_service.PassInterface().PassHandle();
+ mojo::ScopedMessagePipeHandle event_handle = event_request.PassMessagePipe();
+
+ blink::mojom::AppBannerPromptReply reply =
+ blink::mojom::AppBannerPromptReply::NONE;
blink::WebString web_platform(base::UTF8ToUTF16(platform));
blink::WebVector<blink::WebString> web_platforms(&web_platform, 1);
blink::WebLocalFrame* frame = render_frame()->GetWebFrame();
- frame->willShowInstallBannerPrompt(request_id, web_platforms, &reply);
+ frame->willShowInstallBannerPrompt(std::move(service_handle),
+ std::move(event_handle), web_platforms,
+ &reply);
// Extract the referrer header for this site according to its referrer policy.
// Pass in an empty URL as the destination so that it is always treated
@@ -260,8 +276,7 @@ void ChromeRenderFrameObserver::OnAppBannerPromptRequest(
frame->document().referrerPolicy(), GURL(),
frame->document().outgoingReferrer()).utf8();
- Send(new ChromeViewHostMsg_AppBannerPromptReply(
- routing_id(), request_id, reply, referrer));
+ callback.Run(reply, referrer);
}
void ChromeRenderFrameObserver::DidFinishLoad() {

Powered by Google App Engine
This is Rietveld 408576698