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

Side by Side Diff: third_party/WebKit/Source/modules/app_banner/AppBannerController.cpp

Issue 2393513004: Convert app banners to use Mojo. (Closed)
Patch Set: Fix Win clang compile 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "modules/app_banner/AppBannerController.h" 5 #include "modules/app_banner/AppBannerController.h"
6 6
7 #include "core/EventTypeNames.h" 7 #include "core/EventTypeNames.h"
8 #include "core/dom/Document.h"
9 #include "core/frame/DOMWindow.h" 8 #include "core/frame/DOMWindow.h"
10 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
11 #include "modules/app_banner/BeforeInstallPromptEvent.h" 10 #include "modules/app_banner/BeforeInstallPromptEvent.h"
12 #include "public/platform/WebVector.h" 11 #include "public/platform/WebVector.h"
13 #include "public/platform/modules/app_banner/WebAppBannerClient.h" 12 #include "third_party/WebKit/public/platform/modules/app_banner/app_banner.mojom -blink.h"
14 #include "public/platform/modules/app_banner/WebAppBannerPromptReply.h"
15 13
16 namespace blink { 14 namespace blink {
17 15
18 // static 16 // static
19 void AppBannerController::willShowInstallBannerPrompt( 17 void AppBannerController::willShowInstallBannerPrompt(
18 LocalFrame* frame,
20 int requestId, 19 int requestId,
21 WebAppBannerClient* client,
22 LocalFrame* frame,
23 const WebVector<WebString>& platforms, 20 const WebVector<WebString>& platforms,
24 WebAppBannerPromptReply* reply) { 21 mojom::AppBannerPromptReply* reply) {
Sam McNally 2016/10/06 07:17:43 Could the reply be a return value instead?
dominickn 2016/10/06 22:58:12 I'd rather leave it so that it's consistently an o
25 Vector<String> wtfPlatforms; 22 Vector<String> wtfPlatforms;
26 for (const WebString& platform : platforms) 23 for (const WebString& platform : platforms)
27 wtfPlatforms.append(platform); 24 wtfPlatforms.append(platform);
28 25
29 // dispatchEvent() returns whether the default behavior can happen. In other 26 // dispatchEvent() returns whether the default behavior can happen. In other
30 // words, it returns false if preventDefault() was called. 27 // words, it returns false if preventDefault() was called.
31 *reply = 28 *reply = frame->domWindow()->dispatchEvent(BeforeInstallPromptEvent::create(
32 frame->domWindow()->dispatchEvent(BeforeInstallPromptEvent::create( 29 EventTypeNames::beforeinstallprompt, frame, requestId,
33 EventTypeNames::beforeinstallprompt, frame->document(), wtfPlatforms, 30 wtfPlatforms)) == DispatchEventResult::NotCanceled
34 requestId, client)) == DispatchEventResult::NotCanceled 31 ? mojom::AppBannerPromptReply::NONE
35 ? WebAppBannerPromptReply::None 32 : mojom::AppBannerPromptReply::CANCEL;
36 : WebAppBannerPromptReply::Cancel;
37 } 33 }
38 34
39 } // namespace blink 35 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698