1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  *  Copyright © 2014 Igalia S.L.
4  *
5  *  This file is part of Epiphany.
6  *
7  *  Epiphany is free software: you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation, either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  Epiphany is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with Epiphany.  If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #include "config.h"
22 #include "ephy-security-levels.h"
23 
24 /**
25  * ephy_security_level_to_icon_name:
26  * @level: an #EphySecurityLevel
27  *
28  * Returns: the icon name corresponding to this security level,
29  *   or NULL if no icon should be shown.
30  */
31 const char *
ephy_security_level_to_icon_name(EphySecurityLevel level)32 ephy_security_level_to_icon_name (EphySecurityLevel level)
33 {
34   const char *result;
35 
36   switch (level) {
37     case EPHY_SECURITY_LEVEL_LOCAL_PAGE:
38     case EPHY_SECURITY_LEVEL_TO_BE_DETERMINED:
39       result = NULL;
40       break;
41     case EPHY_SECURITY_LEVEL_NO_SECURITY:
42     case EPHY_SECURITY_LEVEL_MIXED_CONTENT:
43     case EPHY_SECURITY_LEVEL_UNACCEPTABLE_CERTIFICATE:
44       result = "channel-insecure-symbolic";
45       break;
46     case EPHY_SECURITY_LEVEL_STRONG_SECURITY:
47       result = "channel-secure-symbolic";
48       break;
49     default:
50       g_assert_not_reached ();
51   }
52 
53   return result;
54 }
55 
56 gboolean
ephy_security_level_is_secure(EphySecurityLevel level)57 ephy_security_level_is_secure (EphySecurityLevel level)
58 {
59   return level >= EPHY_SECURITY_LEVEL_STRONG_SECURITY;
60 }
61