Bug 1770047 [wpt PR 34117] - Update wpt metadata, a=testonly
[gecko.git] / widget / nsColorPickerProxy.cpp
blob5a9e5c13a4a8746e0c7188eefbd80aa6a024fdd6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsColorPickerProxy.h"
9 #include "mozilla/dom/BrowserChild.h"
11 using namespace mozilla::dom;
13 NS_IMPL_ISUPPORTS(nsColorPickerProxy, nsIColorPicker)
15 NS_IMETHODIMP
16 nsColorPickerProxy::Init(mozIDOMWindowProxy* aParent, const nsAString& aTitle,
17 const nsAString& aInitialColor) {
18 BrowserChild* browserChild = BrowserChild::GetFrom(aParent);
19 if (!browserChild) {
20 return NS_ERROR_FAILURE;
23 browserChild->SendPColorPickerConstructor(this, nsString(aTitle),
24 nsString(aInitialColor));
25 NS_ADDREF_THIS();
26 return NS_OK;
29 NS_IMETHODIMP
30 nsColorPickerProxy::Open(
31 nsIColorPickerShownCallback* aColorPickerShownCallback) {
32 NS_ENSURE_STATE(!mCallback);
33 mCallback = aColorPickerShownCallback;
35 SendOpen();
36 return NS_OK;
39 mozilla::ipc::IPCResult nsColorPickerProxy::RecvUpdate(const nsString& aColor) {
40 if (mCallback) {
41 mCallback->Update(aColor);
43 return IPC_OK();
46 mozilla::ipc::IPCResult nsColorPickerProxy::Recv__delete__(
47 const nsString& aColor) {
48 if (mCallback) {
49 mCallback->Done(aColor);
50 mCallback = nullptr;
52 return IPC_OK();