Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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/. */
7 #include "nsColorPickerProxy.h"
9 #include "mozilla/dom/TabChild.h"
11 using namespace mozilla::dom;
13 NS_IMPL_ISUPPORTS(nsColorPickerProxy, nsIColorPicker)
15 /* void init (in nsIDOMWindow parent, in AString title, in short mode); */
16 NS_IMETHODIMP
17 nsColorPickerProxy::Init(nsIDOMWindow* aParent, const nsAString& aTitle,
18 const nsAString& aInitialColor)
19 {
20 TabChild* tabChild = TabChild::GetFrom(aParent);
21 if (!tabChild) {
22 return NS_ERROR_FAILURE;
23 }
25 tabChild->SendPColorPickerConstructor(this,
26 nsString(aTitle),
27 nsString(aInitialColor));
28 NS_ADDREF_THIS();
29 return NS_OK;
30 }
32 /* void open (in nsIColorPickerShownCallback aColorPickerShownCallback); */
33 NS_IMETHODIMP
34 nsColorPickerProxy::Open(nsIColorPickerShownCallback* aColorPickerShownCallback)
35 {
36 NS_ENSURE_STATE(!mCallback);
37 mCallback = aColorPickerShownCallback;
39 SendOpen();
40 return NS_OK;
41 }
43 bool
44 nsColorPickerProxy::RecvUpdate(const nsString& aColor)
45 {
46 if (mCallback) {
47 mCallback->Update(aColor);
48 }
49 return true;
50 }
52 bool
53 nsColorPickerProxy::Recv__delete__(const nsString& aColor)
54 {
55 if (mCallback) {
56 mCallback->Done(aColor);
57 mCallback = nullptr;
58 }
59 return true;
60 }