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

Side by Side Diff: chrome/renderer/banners/app_banner_client.cc

Issue 2393513004: Convert app banners to use Mojo. (Closed)
Patch Set: Add TODO Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/renderer/banners/app_banner_client.h"
6
7 #include "chrome/common/render_messages.h"
8 #include "ipc/ipc_message.h"
9 #include "third_party/WebKit/public/platform/WebString.h"
10
11 using blink::WebString;
12
13 AppBannerClient::AppBannerClient(content::RenderFrame* render_frame)
14 : content::RenderFrameObserver(render_frame) {
15 }
16
17 AppBannerClient::~AppBannerClient() {
18 }
19
20 void AppBannerClient::OnDestruct() {}
21
22 bool AppBannerClient::OnMessageReceived(const IPC::Message& message) {
23 bool handled = true;
24 IPC_BEGIN_MESSAGE_MAP(AppBannerClient, message)
25 IPC_MESSAGE_HANDLER(ChromeViewMsg_AppBannerAccepted, OnBannerAccepted);
26 IPC_MESSAGE_HANDLER(ChromeViewMsg_AppBannerDismissed, OnBannerDismissed);
27 IPC_MESSAGE_UNHANDLED(handled = false)
28 IPC_END_MESSAGE_MAP()
29 return handled;
30 }
31
32 void AppBannerClient::registerBannerCallbacks(
33 int request_id,
34 blink::WebAppBannerCallbacks* callbacks) {
35 banner_callbacks_.AddWithID(callbacks, request_id);
36 }
37
38 void AppBannerClient::showAppBanner(int request_id) {
39 Send(new ChromeViewHostMsg_RequestShowAppBanner(routing_id(), request_id));
40 }
41
42 void AppBannerClient::ResolveEvent(
43 int request_id,
44 const std::string& platform,
45 const blink::WebAppBannerPromptResult::Outcome& outcome) {
46 blink::WebAppBannerCallbacks* callbacks =
47 banner_callbacks_.Lookup(request_id);
48 if (!callbacks)
49 return;
50
51 callbacks->onSuccess(blink::WebAppBannerPromptResult(
52 blink::WebString::fromUTF8(platform), outcome));
53 banner_callbacks_.Remove(request_id);
54 }
55
56 void AppBannerClient::OnBannerAccepted(int request_id,
57 const std::string& platform) {
58 ResolveEvent(request_id, platform,
59 blink::WebAppBannerPromptResult::Outcome::Accepted);
60 }
61
62 void AppBannerClient::OnBannerDismissed(int request_id) {
63 ResolveEvent(request_id, "",
64 blink::WebAppBannerPromptResult::Outcome::Dismissed);
65 }
OLDNEW
« no previous file with comments | « chrome/renderer/banners/app_banner_client.h ('k') | chrome/renderer/chrome_content_renderer_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698