LCOV - code coverage report
Current view: top level - dom/permission - PermissionUtils.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 13 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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 file,
       5             :  * You can obtain one at http://mozilla.org/MPL/2.0/. */
       6             : 
       7             : #include "PermissionUtils.h"
       8             : 
       9             : namespace mozilla {
      10             : namespace dom {
      11             : 
      12             : const char* kPermissionTypes[] = {
      13             :   "geo",
      14             :   "desktop-notification",
      15             :   // Alias `push` to `desktop-notification`.
      16             :   "desktop-notification",
      17             :   "persistent-storage"
      18             : };
      19             : 
      20             : // `-1` for the last null entry.
      21             : const size_t kPermissionNameCount =
      22             :   MOZ_ARRAY_LENGTH(PermissionNameValues::strings) - 1;
      23             : 
      24             : static_assert(MOZ_ARRAY_LENGTH(kPermissionTypes) == kPermissionNameCount,
      25             :               "kPermissionTypes and PermissionName count should match");
      26             : 
      27             : const char*
      28           0 : PermissionNameToType(PermissionName aName)
      29             : {
      30           0 :   MOZ_ASSERT((size_t)aName < ArrayLength(kPermissionTypes));
      31           0 :   return kPermissionTypes[static_cast<size_t>(aName)];
      32             : }
      33             : 
      34             : Maybe<PermissionName>
      35           0 : TypeToPermissionName(const char* aType)
      36             : {
      37           0 :   for (size_t i = 0; i < ArrayLength(kPermissionTypes); ++i) {
      38           0 :     if (!strcmp(aType, kPermissionTypes[i])) {
      39           0 :       return Some(static_cast<PermissionName>(i));
      40             :     }
      41             :   }
      42             : 
      43           0 :   return Nothing();
      44             : }
      45             : 
      46             : PermissionState
      47           0 : ActionToPermissionState(uint32_t aAction)
      48             : {
      49           0 :   switch (aAction) {
      50             :     case nsIPermissionManager::ALLOW_ACTION:
      51           0 :       return PermissionState::Granted;
      52             : 
      53             :     case nsIPermissionManager::DENY_ACTION:
      54           0 :       return PermissionState::Denied;
      55             : 
      56             :     default:
      57             :     case nsIPermissionManager::PROMPT_ACTION:
      58           0 :       return PermissionState::Prompt;
      59             :   }
      60             : }
      61             : 
      62             : } // namespace dom
      63             : } // namespace mozilla

Generated by: LCOV version 1.13