Bug 1805294 [wpt PR 37463] - WebKit export of https://bugs.webkit.org/show_bug.cgi...
[gecko.git] / widget / nsColorPickerProxy.cpp
blob771b4e1ce55ff501ee2abd8c7abbc2d4c73f947e
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 const nsTArray<nsString>& aDefaultColors) {
19 BrowserChild* browserChild = BrowserChild::GetFrom(aParent);
20 if (!browserChild) {
21 return NS_ERROR_FAILURE;
24 browserChild->SendPColorPickerConstructor(this, aTitle, aInitialColor,
25 aDefaultColors);
26 NS_ADDREF_THIS();
27 return NS_OK;
30 NS_IMETHODIMP
31 nsColorPickerProxy::Open(
32 nsIColorPickerShownCallback* aColorPickerShownCallback) {
33 NS_ENSURE_STATE(!mCallback);
34 mCallback = aColorPickerShownCallback;
36 SendOpen();
37 return NS_OK;
40 mozilla::ipc::IPCResult nsColorPickerProxy::RecvUpdate(
41 const nsAString& aColor) {
42 if (mCallback) {
43 mCallback->Update(aColor);
45 return IPC_OK();
48 mozilla::ipc::IPCResult nsColorPickerProxy::Recv__delete__(
49 const nsAString& aColor) {
50 if (mCallback) {
51 mCallback->Done(aColor);
52 mCallback = nullptr;
54 return IPC_OK();