Commit a7d69166 authored by haraken's avatar haraken Committed by Commit bot

Use a new Supplement construtor in PagePopupController

We're deprecating the default constructor of Supplement.

This CL also refactors PagePopupSupplement to make the implementation
closer to other supplement implementations.

BUG=610176

Review-Url: https://codereview.chromium.org/2617113003
Cr-Commit-Position: refs/heads/master@{#441949}
parent 67a34aac
......@@ -22,8 +22,9 @@ void pagePopupControllerAttributeGetter(
const v8::PropertyCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder();
DOMWindow* impl = V8Window::toImpl(holder);
PagePopupController* cppValue = PagePopupSupplement::pagePopupController(
*toLocalDOMWindow(impl)->frame());
PagePopupController* cppValue =
PagePopupSupplement::from(*toLocalDOMWindow(impl)->frame())
.pagePopupController();
v8SetReturnValue(info, ToV8(cppValue, holder, info.GetIsolate()));
}
......
......@@ -34,22 +34,31 @@
namespace blink {
PagePopupSupplement::PagePopupSupplement(PagePopup& popup,
PagePopupSupplement::PagePopupSupplement(LocalFrame& frame,
PagePopup& popup,
PagePopupClient* popupClient)
: m_controller(PagePopupController::create(popup, popupClient)) {
ASSERT(popupClient);
: Supplement<LocalFrame>(frame),
m_controller(PagePopupController::create(popup, popupClient)) {
DCHECK(popupClient);
}
const char* PagePopupSupplement::supplementName() {
return "PagePopupSupplement";
}
PagePopupController* PagePopupSupplement::pagePopupController(
LocalFrame& frame) {
PagePopupSupplement* supplement =
static_cast<PagePopupSupplement*>(from(&frame, supplementName()));
ASSERT(supplement);
return supplement->m_controller.get();
PagePopupSupplement& PagePopupSupplement::from(LocalFrame& frame) {
PagePopupSupplement* supplement = static_cast<PagePopupSupplement*>(
Supplement<LocalFrame>::from(&frame, supplementName()));
DCHECK(supplement);
return *supplement;
}
PagePopupController* PagePopupSupplement::pagePopupController() const {
return m_controller;
}
void PagePopupSupplement::dispose() {
m_controller->clearPagePopupClient();
}
void PagePopupSupplement::install(LocalFrame& frame,
......@@ -57,11 +66,11 @@ void PagePopupSupplement::install(LocalFrame& frame,
PagePopupClient* popupClient) {
ASSERT(popupClient);
provideTo(frame, supplementName(),
new PagePopupSupplement(popup, popupClient));
new PagePopupSupplement(frame, popup, popupClient));
}
void PagePopupSupplement::uninstall(LocalFrame& frame) {
pagePopupController(frame)->clearPagePopupClient();
PagePopupSupplement::from(frame).dispose();
frame.removeSupplement(supplementName());
}
......
......@@ -48,14 +48,17 @@ class CORE_EXPORT PagePopupSupplement final
USING_GARBAGE_COLLECTED_MIXIN(PagePopupSupplement);
public:
static PagePopupController* pagePopupController(LocalFrame&);
static PagePopupSupplement& from(LocalFrame&);
static void install(LocalFrame&, PagePopup&, PagePopupClient*);
static void uninstall(LocalFrame&);
PagePopupController* pagePopupController() const;
DECLARE_TRACE();
private:
PagePopupSupplement(PagePopup&, PagePopupClient*);
PagePopupSupplement(LocalFrame&, PagePopup&, PagePopupClient*);
static const char* supplementName();
void dispose();
Member<PagePopupController> m_controller;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment