1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode:nil; c-basic-offset: 2 -*- */
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/. */
5
6 #include "nsParentalControlsService.h"
7 #include "nsString.h"
8 #include "nsIFile.h"
9
NS_IMPL_ISUPPORTS(nsParentalControlsService,nsIParentalControlsService)10 NS_IMPL_ISUPPORTS(nsParentalControlsService, nsIParentalControlsService)
11
12 nsParentalControlsService::nsParentalControlsService() : mEnabled(false) {}
13
~nsParentalControlsService()14 nsParentalControlsService::~nsParentalControlsService() {}
15
16 NS_IMETHODIMP
GetParentalControlsEnabled(bool * aResult)17 nsParentalControlsService::GetParentalControlsEnabled(bool* aResult) {
18 *aResult = mEnabled;
19 return NS_OK;
20 }
21
22 NS_IMETHODIMP
GetBlockFileDownloadsEnabled(bool * aResult)23 nsParentalControlsService::GetBlockFileDownloadsEnabled(bool* aResult) {
24 // NOTE: isAllowed returns the opposite intention, so we need to flip it
25 bool res;
26 IsAllowed(nsIParentalControlsService::DOWNLOAD, NULL, &res);
27 *aResult = !res;
28
29 return NS_OK;
30 }
31
32 NS_IMETHODIMP
GetLoggingEnabled(bool * aResult)33 nsParentalControlsService::GetLoggingEnabled(bool* aResult) {
34 // Android doesn't currently have any method of logging restricted actions.
35 *aResult = false;
36 return NS_OK;
37 }
38
39 NS_IMETHODIMP
Log(int16_t aEntryType,bool aBlocked,nsIURI * aSource,nsIFile * aTarget)40 nsParentalControlsService::Log(int16_t aEntryType, bool aBlocked,
41 nsIURI* aSource, nsIFile* aTarget) {
42 return NS_ERROR_NOT_AVAILABLE;
43 }
44
45 NS_IMETHODIMP
IsAllowed(int16_t aAction,nsIURI * aUri,bool * _retval)46 nsParentalControlsService::IsAllowed(int16_t aAction, nsIURI* aUri,
47 bool* _retval) {
48 nsresult rv = NS_OK;
49 *_retval = true;
50
51 if (!mEnabled) {
52 return rv;
53 }
54
55 return NS_ERROR_NOT_AVAILABLE;
56 }
57