bug 818009 - canActivate: only click-to-play-type plugins are valid r=jaws
[gecko.git] / widget / cocoa / nsMacDockSupport.mm
blob4b23b9210b5a678afbdecf06ffa9d0f9d7b98adc
1 /* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #import <Cocoa/Cocoa.h>
8 #include "nsMacDockSupport.h"
9 #include "nsObjCExceptions.h"
11 NS_IMPL_ISUPPORTS1(nsMacDockSupport, nsIMacDockSupport)
13 NS_IMETHODIMP
14 nsMacDockSupport::GetDockMenu(nsIStandaloneNativeMenu ** aDockMenu)
16   *aDockMenu = nullptr;
18   if (mDockMenu)
19     return mDockMenu->QueryInterface(NS_GET_IID(nsIStandaloneNativeMenu),
20                                      reinterpret_cast<void **>(aDockMenu));
21   return NS_OK;
24 NS_IMETHODIMP
25 nsMacDockSupport::SetDockMenu(nsIStandaloneNativeMenu * aDockMenu)
27   nsresult rv;
28   mDockMenu = do_QueryInterface(aDockMenu, &rv);
29   return rv;
32 NS_IMETHODIMP
33 nsMacDockSupport::ActivateApplication(bool aIgnoreOtherApplications)
35   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
37   [[NSApplication sharedApplication] activateIgnoringOtherApps:aIgnoreOtherApplications];
38   return NS_OK;
40   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
43 NS_IMETHODIMP
44 nsMacDockSupport::SetBadgeText(const nsAString& aBadgeText)
46   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
48   NSDockTile *tile = [[NSApplication sharedApplication] dockTile];
49   mBadgeText = aBadgeText;
50   if (aBadgeText.IsEmpty())
51     [tile setBadgeLabel: nil];
52   else
53     [tile setBadgeLabel:[NSString stringWithCharacters:mBadgeText.get() length:mBadgeText.Length()]];
54   return NS_OK;
56   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
59 NS_IMETHODIMP
60 nsMacDockSupport::GetBadgeText(nsAString& aBadgeText)
62   aBadgeText = mBadgeText;
63   return NS_OK;