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

Unified Diff: Source/modules/app_banner/AppBannerController.cpp

Issue 1247283004: Refactor BeforeInstallPromptEvent to use ScriptPromiseProperty (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Restoring missing semicolon in test Created 5 years, 5 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: Source/modules/app_banner/AppBannerController.cpp
diff --git a/Source/modules/app_banner/AppBannerController.cpp b/Source/modules/app_banner/AppBannerController.cpp
index af8b67f11f5c43cf8ccff7711fa76374464bbd6b..971afc72baa8be1762a76986472b4c0024a52853 100644
--- a/Source/modules/app_banner/AppBannerController.cpp
+++ b/Source/modules/app_banner/AppBannerController.cpp
@@ -5,12 +5,16 @@
#include "config.h"
#include "modules/app_banner/AppBannerController.h"
+#include "bindings/core/v8/ScriptController.h"
+#include "bindings/core/v8/ScriptState.h"
#include "core/EventTypeNames.h"
#include "core/frame/DOMWindow.h"
#include "core/frame/LocalFrame.h"
+#include "modules/app_banner/AppBannerCallbacks.h"
#include "modules/app_banner/BeforeInstallPromptEvent.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "public/platform/WebVector.h"
+#include "public/platform/modules/app_banner/WebAppBannerClient.h"
#include "public/platform/modules/app_banner/WebAppBannerPromptReply.h"
namespace blink {
@@ -24,9 +28,15 @@ void AppBannerController::willShowInstallBannerPrompt(int requestId, WebAppBanne
for (const WebString& platform : platforms)
wtfPlatforms.append(platform);
+ ScriptState* scriptState = ScriptState::forMainWorld(frame);
+ ScriptState::Scope scope(scriptState);
+ RefPtrWillBeRawPtr<BeforeInstallPromptEvent> event = BeforeInstallPromptEvent::create(EventTypeNames::beforeinstallprompt, scriptState, wtfPlatforms, requestId, client);
yhirano 2015/07/23 12:25:02 IIUC You don't need ScriptState. You only need Exe
dominickn 2015/07/23 13:13:48 Done.
yhirano 2015/07/24 03:41:16 You can use frame->document() if it is the right E
dominickn 2015/07/24 05:02:09 Done.
+ WebAppBannerCallbacks* callbacks = new AppBannerCallbacks(event.get());
+ client->registerBannerCallbacks(requestId, callbacks);
+
// dispatchEvent() returns whether the default behavior can happen. In other
// words, it returns false if preventDefault() was called.
- *reply = frame->domWindow()->dispatchEvent(BeforeInstallPromptEvent::create(EventTypeNames::beforeinstallprompt, wtfPlatforms, requestId, client))
+ *reply = frame->domWindow()->dispatchEvent(event)
? WebAppBannerPromptReply::None : WebAppBannerPromptReply::Cancel;
}

Powered by Google App Engine
This is Rietveld 408576698