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

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

Issue 2910363002: Propagate a user gesture bit for beforeinstallprompt.prompt() (Closed)
Patch Set: Created 3 years, 6 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/BeforeInstallPromptEvent.h" 5 #include "modules/app_banner/BeforeInstallPromptEvent.h"
6 6
7 #include "core/dom/DOMException.h" 7 #include "core/dom/DOMException.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/dom/ExceptionCode.h" 9 #include "core/dom/ExceptionCode.h"
10 #include "core/dom/ExecutionContext.h" 10 #include "core/dom/ExecutionContext.h"
11 #include "core/dom/UserGestureIndicator.h"
11 #include "core/frame/UseCounter.h" 12 #include "core/frame/UseCounter.h"
12 #include "modules/app_banner/BeforeInstallPromptEventInit.h" 13 #include "modules/app_banner/BeforeInstallPromptEventInit.h"
13 14
14 namespace blink { 15 namespace blink {
15 16
16 BeforeInstallPromptEvent::BeforeInstallPromptEvent( 17 BeforeInstallPromptEvent::BeforeInstallPromptEvent(
17 const AtomicString& name, 18 const AtomicString& name,
18 LocalFrame& frame, 19 LocalFrame& frame,
19 mojom::blink::AppBannerServicePtr service_ptr, 20 mojom::blink::AppBannerServicePtr service_ptr,
20 mojom::blink::AppBannerEventRequest event_request, 21 mojom::blink::AppBannerEventRequest event_request,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 script_state, 73 script_state,
73 DOMException::Create(kInvalidStateError, 74 DOMException::Create(kInvalidStateError,
74 "The prompt() method may only be called once, " 75 "The prompt() method may only be called once, "
75 "following preventDefault().")); 76 "following preventDefault()."));
76 } 77 }
77 78
78 UseCounter::Count(ExecutionContext::From(script_state), 79 UseCounter::Count(ExecutionContext::From(script_state),
79 UseCounter::kBeforeInstallPromptEventPrompt); 80 UseCounter::kBeforeInstallPromptEventPrompt);
80 81
81 prompt_called_ = true; 82 prompt_called_ = true;
82 banner_service_->DisplayAppBanner(); 83 banner_service_->DisplayAppBanner(
84 UserGestureIndicator::ProcessingUserGesture());
83 return ScriptPromise::CastUndefined(script_state); 85 return ScriptPromise::CastUndefined(script_state);
84 } 86 }
85 87
86 const AtomicString& BeforeInstallPromptEvent::InterfaceName() const { 88 const AtomicString& BeforeInstallPromptEvent::InterfaceName() const {
87 return EventNames::BeforeInstallPromptEvent; 89 return EventNames::BeforeInstallPromptEvent;
88 } 90 }
89 91
90 void BeforeInstallPromptEvent::preventDefault() { 92 void BeforeInstallPromptEvent::preventDefault() {
91 Event::preventDefault(); 93 Event::preventDefault();
92 if (target()) { 94 if (target()) {
(...skipping 11 matching lines...) Expand all
104 user_choice_->Resolve(AppBannerPromptResult::Create( 106 user_choice_->Resolve(AppBannerPromptResult::Create(
105 g_empty_atom, AppBannerPromptResult::Outcome::kDismissed)); 107 g_empty_atom, AppBannerPromptResult::Outcome::kDismissed));
106 } 108 }
107 109
108 DEFINE_TRACE(BeforeInstallPromptEvent) { 110 DEFINE_TRACE(BeforeInstallPromptEvent) {
109 visitor->Trace(user_choice_); 111 visitor->Trace(user_choice_);
110 Event::Trace(visitor); 112 Event::Trace(visitor);
111 } 113 }
112 114
113 } // namespace blink 115 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698