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

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

Issue 2571513003: InstalledAppController should use ContextLifecycleObserver instead of DOMWindowProperty (Closed)
Patch Set: temp Created 4 years 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/Source/modules/installedapp/InstalledAppController.h ('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/InstalledAppController.h" 5 #include "modules/installedapp/InstalledAppController.h"
6 6
7 #include "core/dom/Document.h"
7 #include "core/frame/LocalFrame.h" 8 #include "core/frame/LocalFrame.h"
8 #include "platform/RuntimeEnabledFeatures.h" 9 #include "platform/RuntimeEnabledFeatures.h"
9 #include "public/platform/WebSecurityOrigin.h" 10 #include "public/platform/WebSecurityOrigin.h"
10 11
11 #include <utility> 12 #include <utility>
12 13
13 namespace blink { 14 namespace blink {
14 15
15 InstalledAppController::~InstalledAppController() {} 16 InstalledAppController::~InstalledAppController() {}
16 17
17 void InstalledAppController::provideTo(LocalFrame& frame, 18 void InstalledAppController::provideTo(LocalFrame& frame,
18 WebInstalledAppClient* client) { 19 WebInstalledAppClient* client) {
19 ASSERT(RuntimeEnabledFeatures::installedAppEnabled()); 20 ASSERT(RuntimeEnabledFeatures::installedAppEnabled());
20 21
21 InstalledAppController* controller = 22 InstalledAppController* controller =
22 new InstalledAppController(frame, client); 23 new InstalledAppController(frame, client);
23 Supplement<LocalFrame>::provideTo(frame, supplementName(), controller); 24 Supplement<LocalFrame>::provideTo(frame, supplementName(), controller);
24 } 25 }
25 26
26 InstalledAppController* InstalledAppController::from(LocalFrame& frame) { 27 InstalledAppController* InstalledAppController::from(LocalFrame& frame) {
27 InstalledAppController* controller = static_cast<InstalledAppController*>( 28 InstalledAppController* controller = static_cast<InstalledAppController*>(
28 Supplement<LocalFrame>::from(frame, supplementName())); 29 Supplement<LocalFrame>::from(frame, supplementName()));
29 ASSERT(controller); 30 ASSERT(controller);
30 return controller; 31 return controller;
31 } 32 }
32 33
33 InstalledAppController::InstalledAppController(LocalFrame& frame, 34 InstalledAppController::InstalledAppController(LocalFrame& frame,
34 WebInstalledAppClient* client) 35 WebInstalledAppClient* client)
35 : DOMWindowProperty(&frame), m_client(client) {} 36 : ContextLifecycleObserver(frame.document()), m_client(client) {}
36 37
37 const char* InstalledAppController::supplementName() { 38 const char* InstalledAppController::supplementName() {
38 return "InstalledAppController"; 39 return "InstalledAppController";
39 } 40 }
40 41
41 void InstalledAppController::getInstalledApps( 42 void InstalledAppController::getInstalledApps(
42 const WebSecurityOrigin& url, 43 const WebSecurityOrigin& url,
43 std::unique_ptr<AppInstalledCallbacks> callback) { 44 std::unique_ptr<AppInstalledCallbacks> callback) {
44 // When detached, the client is no longer valid. 45 // When detached, the client is no longer valid.
45 if (!m_client) { 46 if (!m_client) {
46 callback.release()->onError(); 47 callback.release()->onError();
47 return; 48 return;
48 } 49 }
49 50
50 // Client is expected to take ownership of the callback 51 // Client is expected to take ownership of the callback
51 m_client->getInstalledRelatedApps(url, std::move(callback)); 52 m_client->getInstalledRelatedApps(url, std::move(callback));
52 } 53 }
53 54
54 void InstalledAppController::frameDestroyed() { 55 void InstalledAppController::contextDestroyed() {
55 m_client = nullptr; 56 m_client = nullptr;
56 DOMWindowProperty::frameDestroyed();
57 } 57 }
58 58
59 DEFINE_TRACE(InstalledAppController) { 59 DEFINE_TRACE(InstalledAppController) {
60 Supplement<LocalFrame>::trace(visitor); 60 Supplement<LocalFrame>::trace(visitor);
61 DOMWindowProperty::trace(visitor); 61 ContextLifecycleObserver::trace(visitor);
62 } 62 }
63 63
64 } // namespace blink 64 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/installedapp/InstalledAppController.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698