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

Side by Side Diff: third_party/WebKit/Source/modules/installedapp/NavigatorInstalledApp.cpp

Issue 2800523004: Restrict navigator.getInstalledRelatedApps() to top-level frames (Closed)
Patch Set: update error (top-level frames -> top-level browing contexts) Created 3 years, 8 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
« no previous file with comments | « third_party/WebKit/LayoutTests/installedapp/getinstalledrelatedapps-iframe.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/installedapp/NavigatorInstalledApp.h" 5 #include "modules/installedapp/NavigatorInstalledApp.h"
6 6
7 #include "bindings/core/v8/CallbackPromiseAdapter.h" 7 #include "bindings/core/v8/CallbackPromiseAdapter.h"
8 #include "bindings/core/v8/ScriptPromise.h" 8 #include "bindings/core/v8/ScriptPromise.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 ScriptPromise promise = resolver->promise(); 73 ScriptPromise promise = resolver->promise();
74 74
75 InstalledAppController* appController = controller(); 75 InstalledAppController* appController = controller();
76 if (!appController) { // If the associated frame is detached 76 if (!appController) { // If the associated frame is detached
77 DOMException* exception = DOMException::create( 77 DOMException* exception = DOMException::create(
78 InvalidStateError, "The object is no longer associated to a document."); 78 InvalidStateError, "The object is no longer associated to a document.");
79 resolver->reject(exception); 79 resolver->reject(exception);
80 return promise; 80 return promise;
81 } 81 }
82 82
83 if (!appController->supplementable()->isMainFrame()) {
84 DOMException* exception =
85 DOMException::create(InvalidStateError,
86 "getInstalledRelatedApps() is only supported in "
87 "top-level browsing contexts.");
88 resolver->reject(exception);
89 return promise;
90 }
91
83 appController->getInstalledRelatedApps( 92 appController->getInstalledRelatedApps(
84 WTF::wrapUnique( 93 WTF::wrapUnique(
85 new CallbackPromiseAdapter<RelatedAppArray, void>(resolver))); 94 new CallbackPromiseAdapter<RelatedAppArray, void>(resolver)));
86 return promise; 95 return promise;
87 } 96 }
88 97
89 InstalledAppController* NavigatorInstalledApp::controller() { 98 InstalledAppController* NavigatorInstalledApp::controller() {
90 if (!supplementable()->frame()) 99 if (!supplementable()->frame())
91 return nullptr; 100 return nullptr;
92 101
93 return InstalledAppController::from(*supplementable()->frame()); 102 return InstalledAppController::from(*supplementable()->frame());
94 } 103 }
95 104
96 const char* NavigatorInstalledApp::supplementName() { 105 const char* NavigatorInstalledApp::supplementName() {
97 return "NavigatorInstalledApp"; 106 return "NavigatorInstalledApp";
98 } 107 }
99 108
100 DEFINE_TRACE(NavigatorInstalledApp) { 109 DEFINE_TRACE(NavigatorInstalledApp) {
101 Supplement<Navigator>::trace(visitor); 110 Supplement<Navigator>::trace(visitor);
102 } 111 }
103 112
104 } // namespace blink 113 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/installedapp/getinstalledrelatedapps-iframe.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698