Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
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/. */
6 :
7 : #include "nsColorPickerProxy.h"
8 :
9 : #include "mozilla/dom/TabChild.h"
10 :
11 : using namespace mozilla::dom;
12 :
13 0 : NS_IMPL_ISUPPORTS(nsColorPickerProxy, nsIColorPicker)
14 :
15 : NS_IMETHODIMP
16 0 : nsColorPickerProxy::Init(mozIDOMWindowProxy* aParent, const nsAString& aTitle,
17 : const nsAString& aInitialColor)
18 : {
19 0 : TabChild* tabChild = TabChild::GetFrom(aParent);
20 0 : if (!tabChild) {
21 0 : return NS_ERROR_FAILURE;
22 : }
23 :
24 0 : tabChild->SendPColorPickerConstructor(this,
25 0 : nsString(aTitle),
26 0 : nsString(aInitialColor));
27 0 : NS_ADDREF_THIS();
28 0 : return NS_OK;
29 : }
30 :
31 : NS_IMETHODIMP
32 0 : nsColorPickerProxy::Open(nsIColorPickerShownCallback* aColorPickerShownCallback)
33 : {
34 0 : NS_ENSURE_STATE(!mCallback);
35 0 : mCallback = aColorPickerShownCallback;
36 :
37 0 : SendOpen();
38 0 : return NS_OK;
39 : }
40 :
41 : mozilla::ipc::IPCResult
42 0 : nsColorPickerProxy::RecvUpdate(const nsString& aColor)
43 : {
44 0 : if (mCallback) {
45 0 : mCallback->Update(aColor);
46 : }
47 0 : return IPC_OK();
48 : }
49 :
50 : mozilla::ipc::IPCResult
51 0 : nsColorPickerProxy::Recv__delete__(const nsString& aColor)
52 : {
53 0 : if (mCallback) {
54 0 : mCallback->Done(aColor);
55 0 : mCallback = nullptr;
56 : }
57 0 : return IPC_OK();
58 : }
|