Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / widget / nsColorPickerProxy.cpp
bloba6bb4b9f63779cc2d40fcb19ac39ff04f4e8f973
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(BrowsingContext* aBrowsingContext,
17 const nsAString& aTitle,
18 const nsAString& aInitialColor,
19 const nsTArray<nsString>& aDefaultColors) {
20 BrowserChild* browserChild =
21 BrowserChild::GetFrom(aBrowsingContext->GetDocShell());
22 if (!browserChild) {
23 return NS_ERROR_FAILURE;
26 browserChild->SendPColorPickerConstructor(this, aBrowsingContext, aTitle,
27 aInitialColor, aDefaultColors);
28 return NS_OK;
31 NS_IMETHODIMP
32 nsColorPickerProxy::Open(
33 nsIColorPickerShownCallback* aColorPickerShownCallback) {
34 NS_ENSURE_STATE(!mCallback);
35 mCallback = aColorPickerShownCallback;
37 SendOpen();
38 return NS_OK;
41 mozilla::ipc::IPCResult nsColorPickerProxy::RecvUpdate(
42 const nsAString& aColor) {
43 if (mCallback) {
44 mCallback->Update(aColor);
46 return IPC_OK();
49 mozilla::ipc::IPCResult nsColorPickerProxy::Recv__delete__(
50 const nsAString& aColor) {
51 if (mCallback) {
52 mCallback->Done(aColor);
53 mCallback = nullptr;
55 return IPC_OK();
58 void nsColorPickerProxy::ActorDestroy(ActorDestroyReason aWhy) {
59 if (mCallback) {
60 mCallback->Done(u""_ns);
61 mCallback = nullptr;