Bug 1073336 part 12 - Add AnimationPlayer::GetCollection(); r=dbaron
[gecko.git] / widget / nsColorPickerProxy.cpp
blob4409470a583ff416773a36619aef8b9219291cfb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
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)
20 TabChild* tabChild = TabChild::GetFrom(aParent);
21 if (!tabChild) {
22 return NS_ERROR_FAILURE;
25 tabChild->SendPColorPickerConstructor(this,
26 nsString(aTitle),
27 nsString(aInitialColor));
28 NS_ADDREF_THIS();
29 return NS_OK;
32 /* void open (in nsIColorPickerShownCallback aColorPickerShownCallback); */
33 NS_IMETHODIMP
34 nsColorPickerProxy::Open(nsIColorPickerShownCallback* aColorPickerShownCallback)
36 NS_ENSURE_STATE(!mCallback);
37 mCallback = aColorPickerShownCallback;
39 SendOpen();
40 return NS_OK;
43 bool
44 nsColorPickerProxy::RecvUpdate(const nsString& aColor)
46 if (mCallback) {
47 mCallback->Update(aColor);
49 return true;
52 bool
53 nsColorPickerProxy::Recv__delete__(const nsString& aColor)
55 if (mCallback) {
56 mCallback->Done(aColor);
57 mCallback = nullptr;
59 return true;