/src/mozilla-central/dom/presentation/provider/DeviceProviderHelpers.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=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 | | DeviceProviderHelpers::IsCommonlySupportedScheme(const nsAString& aUrl) |
25 | 0 | { |
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 | 0 | } |
31 | 0 | |
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 | 0 | } |
38 | 0 | |
39 | 0 | return false; |
40 | 0 | } |
41 | | |
42 | | /* static */ bool |
43 | | DeviceProviderHelpers::IsFxTVSupportedAppUrl(const nsAString& aUrl) |
44 | 0 | { |
45 | 0 | // 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 | 0 | } |
50 | 0 | } |
51 | 0 |
|
52 | 0 | return false; |
53 | 0 | } |
54 | | |
55 | | } // namespace presentation |
56 | | } // namespace dom |
57 | | } // namespace mozilla |