michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsColorPickerProxy.h" michael@0: michael@0: #include "mozilla/dom/TabChild.h" michael@0: michael@0: using namespace mozilla::dom; michael@0: michael@0: NS_IMPL_ISUPPORTS(nsColorPickerProxy, nsIColorPicker) michael@0: michael@0: /* void init (in nsIDOMWindow parent, in AString title, in short mode); */ michael@0: NS_IMETHODIMP michael@0: nsColorPickerProxy::Init(nsIDOMWindow* aParent, const nsAString& aTitle, michael@0: const nsAString& aInitialColor) michael@0: { michael@0: TabChild* tabChild = TabChild::GetFrom(aParent); michael@0: if (!tabChild) { michael@0: return NS_ERROR_FAILURE; michael@0: } michael@0: michael@0: tabChild->SendPColorPickerConstructor(this, michael@0: nsString(aTitle), michael@0: nsString(aInitialColor)); michael@0: NS_ADDREF_THIS(); michael@0: return NS_OK; michael@0: } michael@0: michael@0: /* void open (in nsIColorPickerShownCallback aColorPickerShownCallback); */ michael@0: NS_IMETHODIMP michael@0: nsColorPickerProxy::Open(nsIColorPickerShownCallback* aColorPickerShownCallback) michael@0: { michael@0: NS_ENSURE_STATE(!mCallback); michael@0: mCallback = aColorPickerShownCallback; michael@0: michael@0: SendOpen(); michael@0: return NS_OK; michael@0: } michael@0: michael@0: bool michael@0: nsColorPickerProxy::RecvUpdate(const nsString& aColor) michael@0: { michael@0: if (mCallback) { michael@0: mCallback->Update(aColor); michael@0: } michael@0: return true; michael@0: } michael@0: michael@0: bool michael@0: nsColorPickerProxy::Recv__delete__(const nsString& aColor) michael@0: { michael@0: if (mCallback) { michael@0: mCallback->Done(aColor); michael@0: mCallback = nullptr; michael@0: } michael@0: return true; michael@0: }