Chromium Code Reviews| Index: third_party/WebKit/Source/modules/installedapp/NavigatorInstalledApp.cpp |
| diff --git a/third_party/WebKit/Source/modules/installedapp/NavigatorInstalledApp.cpp b/third_party/WebKit/Source/modules/installedapp/NavigatorInstalledApp.cpp |
| index 78545b6bea4c6fcca8bbd8d1e13b43fa4e9782ca..3cd72a6bfa2f20dce045ebcb0c51a4ac301b82ec 100644 |
| --- a/third_party/WebKit/Source/modules/installedapp/NavigatorInstalledApp.cpp |
| +++ b/third_party/WebKit/Source/modules/installedapp/NavigatorInstalledApp.cpp |
| @@ -22,8 +22,8 @@ |
| namespace blink { |
| -NavigatorInstalledApp::NavigatorInstalledApp(LocalFrame* frame) |
| - : ContextClient(frame) {} |
| +NavigatorInstalledApp::NavigatorInstalledApp(Navigator& navigator) |
| + : Supplement<Navigator>(navigator) {} |
| NavigatorInstalledApp* NavigatorInstalledApp::from(Document& document) { |
| if (!document.frame() || !document.frame()->domWindow()) |
| @@ -36,7 +36,7 @@ NavigatorInstalledApp& NavigatorInstalledApp::from(Navigator& navigator) { |
| NavigatorInstalledApp* supplement = static_cast<NavigatorInstalledApp*>( |
| Supplement<Navigator>::from(navigator, supplementName())); |
| if (!supplement) { |
| - supplement = new NavigatorInstalledApp(navigator.frame()); |
| + supplement = new NavigatorInstalledApp(navigator); |
| provideTo(navigator, supplementName(), supplement); |
| } |
| return *supplement; |
| @@ -71,10 +71,7 @@ ScriptPromise NavigatorInstalledApp::getInstalledRelatedApps( |
| ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); |
| ScriptPromise promise = resolver->promise(); |
| - // Don't crash when called and unattached to document. |
| - Document* document = frame() ? frame()->document() : 0; |
| - |
| - if (!document || !controller()) { |
| + if (!controller()) { // If the associated frame is detached |
|
sof
2017/01/05 12:30:56
Bind it to a local so as to only call controller()
|
| DOMException* exception = DOMException::create( |
| InvalidStateError, "The object is no longer associated to a document."); |
| resolver->reject(exception); |
| @@ -90,10 +87,10 @@ ScriptPromise NavigatorInstalledApp::getInstalledRelatedApps( |
| } |
| InstalledAppController* NavigatorInstalledApp::controller() { |
| - if (!frame()) |
| + if (!host()->frame()) |
| return nullptr; |
| - return InstalledAppController::from(*frame()); |
| + return InstalledAppController::from(*host()->frame()); |
| } |
| const char* NavigatorInstalledApp::supplementName() { |
| @@ -102,7 +99,6 @@ const char* NavigatorInstalledApp::supplementName() { |
| DEFINE_TRACE(NavigatorInstalledApp) { |
| Supplement<Navigator>::trace(visitor); |
| - ContextClient::trace(visitor); |
| } |
| } // namespace blink |