OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/chromeos/extensions/active_tab_permission_granter_deleg ate_chromeos.h" | |
6 | |
7 #include <map> | |
8 | |
9 #include "base/lazy_instance.h" | |
10 #include "chrome/browser/chromeos/extensions/device_local_account_management_pol icy_provider.h" | |
11 #include "chrome/browser/chromeos/extensions/public_session_permission_helper.h" | |
12 #include "chrome/browser/profiles/profiles_state.h" | |
13 #include "extensions/common/extension.h" | |
14 #include "extensions/common/permissions/api_permission.h" | |
15 #include "extensions/common/permissions/api_permission_set.h" | |
16 | |
17 namespace extensions { | |
18 | |
19 namespace { | |
20 | |
21 base::LazyInstance<std::map<ExtensionId, bool>>::Leaky | |
22 g_active_tab_granted_map = LAZY_INSTANCE_INITIALIZER; | |
23 | |
24 void UpdateActiveTabGranted(const Extension* extension, | |
25 const PermissionIDSet& allowed_permissions) { | |
26 g_active_tab_granted_map.Get()[extension->id()] = | |
27 allowed_permissions.ContainsID(APIPermission::kActiveTab); | |
28 } | |
29 | |
30 } // namespace | |
31 | |
32 ActiveTabPermissionGranterDelegateChromeOS:: | |
33 ActiveTabPermissionGranterDelegateChromeOS() {} | |
34 | |
35 ActiveTabPermissionGranterDelegateChromeOS:: | |
36 ~ActiveTabPermissionGranterDelegateChromeOS() {} | |
37 | |
38 bool ActiveTabPermissionGranterDelegateChromeOS::ActiveTabPermissionGranted( | |
39 const Extension* extension, | |
40 content::WebContents* web_contents) { | |
41 bool active_tab_granted = g_active_tab_granted_map.Get()[extension->id()]; | |
42 | |
43 if (!profiles::IsPublicSession() || active_tab_granted || | |
44 chromeos::DeviceLocalAccountManagementPolicyProvider::IsWhitelisted( | |
45 extension->id())) { | |
46 return true; | |
47 } | |
48 | |
49 permission_helper::HandlePermissionRequest( | |
Ivan Šandrk
2017/05/05 16:24:26
Should I add a brief comment here explaining the m
| |
50 *extension, {APIPermission::kActiveTab}, web_contents, | |
51 base::Bind(&UpdateActiveTabGranted, extension), | |
52 permission_helper::PromptFactory()); | |
53 | |
54 return false; | |
55 } | |
56 | |
57 } // namespace extensions | |
OLD | NEW |