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( ...@@ -22,8 +22,9 @@ void pagePopupControllerAttributeGetter(
const v8::PropertyCallbackInfo<v8::Value>& info) { const v8::PropertyCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder(); v8::Local<v8::Object> holder = info.Holder();
DOMWindow* impl = V8Window::toImpl(holder); DOMWindow* impl = V8Window::toImpl(holder);
PagePopupController* cppValue = PagePopupSupplement::pagePopupController( PagePopupController* cppValue =
*toLocalDOMWindow(impl)->frame()); PagePopupSupplement::from(*toLocalDOMWindow(impl)->frame())
.pagePopupController();
v8SetReturnValue(info, ToV8(cppValue, holder, info.GetIsolate())); v8SetReturnValue(info, ToV8(cppValue, holder, info.GetIsolate()));
} }
......
...@@ -34,22 +34,31 @@ ...@@ -34,22 +34,31 @@
namespace blink { namespace blink {
PagePopupSupplement::PagePopupSupplement(PagePopup& popup, PagePopupSupplement::PagePopupSupplement(LocalFrame& frame,
PagePopup& popup,
PagePopupClient* popupClient) PagePopupClient* popupClient)
: m_controller(PagePopupController::create(popup, popupClient)) { : Supplement<LocalFrame>(frame),
ASSERT(popupClient); m_controller(PagePopupController::create(popup, popupClient)) {
DCHECK(popupClient);
} }
const char* PagePopupSupplement::supplementName() { const char* PagePopupSupplement::supplementName() {
return "PagePopupSupplement"; return "PagePopupSupplement";
} }
PagePopupController* PagePopupSupplement::pagePopupController( PagePopupSupplement& PagePopupSupplement::from(LocalFrame& frame) {
LocalFrame& frame) { PagePopupSupplement* supplement = static_cast<PagePopupSupplement*>(
PagePopupSupplement* supplement = Supplement<LocalFrame>::from(&frame, supplementName()));
static_cast<PagePopupSupplement*>(from(&frame, supplementName())); DCHECK(supplement);
ASSERT(supplement); return *supplement;
return supplement->m_controller.get(); }
PagePopupController* PagePopupSupplement::pagePopupController() const {
return m_controller;
}
void PagePopupSupplement::dispose() {
m_controller->clearPagePopupClient();
} }
void PagePopupSupplement::install(LocalFrame& frame, void PagePopupSupplement::install(LocalFrame& frame,
...@@ -57,11 +66,11 @@ void PagePopupSupplement::install(LocalFrame& frame, ...@@ -57,11 +66,11 @@ void PagePopupSupplement::install(LocalFrame& frame,
PagePopupClient* popupClient) { PagePopupClient* popupClient) {
ASSERT(popupClient); ASSERT(popupClient);
provideTo(frame, supplementName(), provideTo(frame, supplementName(),
new PagePopupSupplement(popup, popupClient)); new PagePopupSupplement(frame, popup, popupClient));
} }
void PagePopupSupplement::uninstall(LocalFrame& frame) { void PagePopupSupplement::uninstall(LocalFrame& frame) {
pagePopupController(frame)->clearPagePopupClient(); PagePopupSupplement::from(frame).dispose();
frame.removeSupplement(supplementName()); frame.removeSupplement(supplementName());
} }
......
...@@ -48,14 +48,17 @@ class CORE_EXPORT PagePopupSupplement final ...@@ -48,14 +48,17 @@ class CORE_EXPORT PagePopupSupplement final
USING_GARBAGE_COLLECTED_MIXIN(PagePopupSupplement); USING_GARBAGE_COLLECTED_MIXIN(PagePopupSupplement);
public: public:
static PagePopupController* pagePopupController(LocalFrame&); static PagePopupSupplement& from(LocalFrame&);
static void install(LocalFrame&, PagePopup&, PagePopupClient*); static void install(LocalFrame&, PagePopup&, PagePopupClient*);
static void uninstall(LocalFrame&); static void uninstall(LocalFrame&);
PagePopupController* pagePopupController() const;
DECLARE_TRACE(); DECLARE_TRACE();
private: private:
PagePopupSupplement(PagePopup&, PagePopupClient*); PagePopupSupplement(LocalFrame&, PagePopup&, PagePopupClient*);
static const char* supplementName(); static const char* supplementName();
void dispose();
Member<PagePopupController> m_controller; 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