Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=2 et sw=2 tw=80: */
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 "DeviceProviderHelpers.h"
8 :
9 : #include "nsCOMPtr.h"
10 : #include "nsIURI.h"
11 : #include "nsNetUtil.h"
12 :
13 : namespace mozilla {
14 : namespace dom {
15 : namespace presentation {
16 :
17 : static const char* const kFxTVPresentationAppUrls[] = {
18 : "app://fling-player.gaiamobile.org/index.html",
19 : "app://notification-receiver.gaiamobile.org/index.html",
20 : nullptr
21 : };
22 :
23 : /* static */ bool
24 0 : DeviceProviderHelpers::IsCommonlySupportedScheme(const nsAString& aUrl)
25 : {
26 0 : nsCOMPtr<nsIURI> uri;
27 0 : nsresult rv = NS_NewURI(getter_AddRefs(uri), aUrl);
28 0 : if (NS_FAILED(rv) || !uri) {
29 0 : return false;
30 : }
31 :
32 0 : nsAutoCString scheme;
33 0 : uri->GetScheme(scheme);
34 0 : if (scheme.LowerCaseEqualsLiteral("http") ||
35 0 : scheme.LowerCaseEqualsLiteral("https")) {
36 0 : return true;
37 : }
38 :
39 0 : return false;
40 : }
41 :
42 : /* static */ bool
43 0 : DeviceProviderHelpers::IsFxTVSupportedAppUrl(const nsAString& aUrl)
44 : {
45 : // Check if matched with any presentation Apps on TV.
46 0 : for (uint32_t i = 0; kFxTVPresentationAppUrls[i]; i++) {
47 0 : if (aUrl.EqualsASCII(kFxTVPresentationAppUrls[i])) {
48 0 : return true;
49 : }
50 : }
51 :
52 0 : return false;
53 : }
54 :
55 : } // namespace presentation
56 : } // namespace dom
57 : } // namespace mozilla
|