1
// vim:expandtab:shiftwidth=2:tabstop=2:
2
// Copyright (C) 2015 Canonical Ltd.
4
// This library is free software; you can redistribute it and/or
5
// modify it under the terms of the GNU Lesser General Public
6
// License as published by the Free Software Foundation; either
7
// version 2.1 of the License, or (at your option) any later version.
9
// This library is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
// Lesser General Public License for more details.
14
// You should have received a copy of the GNU Lesser General Public
15
// License along with this library; if not, write to the Free Software
16
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
#include "oxide_temporary_saved_permission_context.h"
22
TemporarySavedPermissionContext::TemporarySavedPermissionContext() {}
24
TemporarySavedPermissionContext::~TemporarySavedPermissionContext() {}
26
TemporarySavedPermissionStatus
27
TemporarySavedPermissionContext::GetPermissionStatus(
28
TemporarySavedPermissionType type,
29
const GURL& primary_url,
30
const GURL& secondary_url) {
31
Key key = std::make_pair(primary_url, secondary_url);
33
base::AutoLock lock(lock_);
35
Map& map = maps_[type];
36
const auto& it = map.find(key);
37
if (it == map.end()) {
38
return TEMPORARY_SAVED_PERMISSION_STATUS_ASK;
44
void TemporarySavedPermissionContext::SetPermissionStatus(
45
TemporarySavedPermissionType type,
46
const GURL& primary_url,
47
const GURL& secondary_url,
48
TemporarySavedPermissionStatus status) {
49
Key key = std::make_pair(primary_url, secondary_url);
51
base::AutoLock lock(lock_);
53
Map& map = maps_[type];
54
if (status == TEMPORARY_SAVED_PERMISSION_STATUS_ASK) {
62
void TemporarySavedPermissionContext::Clear() {
63
base::AutoLock lock(lock_);
64
for (int i = PERMISSION_TYPES_START; i < NUM_PERMISSION_TYPES; ++i) {