Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: extensions/browser/api/messaging/native_message_host.cc

Issue 591463003: Remote Assistance on Chrome OS Part III - NativeMessageHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@native_messaging
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 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 "extensions/browser/api/messaging/native_message_host.h"
6
7 #include "base/prefs/pref_service.h"
8 #include "base/values.h"
9 #include "extensions/browser/pref_names.h"
10
11 namespace extensions {
12
13 // static
14 NativeMessageHost::PolicyPermission
15 NativeMessageHost::IsHostAllowed(const PrefService* pref_service,
Sergey Ulanov 2014/09/22 23:42:59 I don't think this function belongs in this interf
kelvinp 2014/09/23 20:16:42 Done.
16 const std::string& native_host_name) {
17 NativeMessageHost::PolicyPermission allow_result = ALLOW_ALL;
18 if (pref_service->IsManagedPreference(
19 pref_names::kNativeMessagingUserLevelHosts)) {
20 if (!pref_service->GetBoolean(pref_names::kNativeMessagingUserLevelHosts))
21 allow_result = ALLOW_SYSTEM_ONLY;
22 }
23
24 // All native messaging hosts are allowed if there is no blacklist.
25 if (!pref_service->IsManagedPreference(pref_names::kNativeMessagingBlacklist))
26 return allow_result;
27 const base::ListValue* blacklist =
28 pref_service->GetList(pref_names::kNativeMessagingBlacklist);
29 if (!blacklist)
30 return allow_result;
31
32 // Check if the name or the wildcard is in the blacklist.
33 base::StringValue name_value(native_host_name);
34 base::StringValue wildcard_value("*");
35 if (blacklist->Find(name_value) == blacklist->end() &&
36 blacklist->Find(wildcard_value) == blacklist->end()) {
37 return allow_result;
38 }
39
40 // The native messaging host is blacklisted. Check the whitelist.
41 if (pref_service->IsManagedPreference(
42 pref_names::kNativeMessagingWhitelist)) {
43 const base::ListValue* whitelist =
44 pref_service->GetList(pref_names::kNativeMessagingWhitelist);
45 if (whitelist && whitelist->Find(name_value) != whitelist->end())
46 return allow_result;
47 }
48
49 return DISALLOW;
50 }
51
52 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698