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

Unified Diff: chrome/browser/bluetooth/bluetooth_permission_context.cc

Issue 1560263002: Store Bluetooth permissions in website settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added code to check session->chooser_permission_manager Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/bluetooth/bluetooth_permission_context.cc
diff --git a/chrome/browser/bluetooth/bluetooth_permission_context.cc b/chrome/browser/bluetooth/bluetooth_permission_context.cc
new file mode 100644
index 0000000000000000000000000000000000000000..003fbad2675dabbe5bd5ebe48fc858ca76db13f9
--- /dev/null
+++ b/chrome/browser/bluetooth/bluetooth_permission_context.cc
@@ -0,0 +1,34 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/bluetooth/bluetooth_permission_context.h"
+
+#include "base/values.h"
+
+namespace {
+
+const char kDeviceAddressKey[] = "device-address";
+const char kDeviceNameKey[] = "device-name";
+const char kDeviceUUIDsKey[] = "device-uuids";
+
+} // namespace
+
+BluetoothPermissionContext::BluetoothPermissionContext(Profile* profile)
+ : ChooserContextBase(profile,
+ CONTENT_SETTINGS_TYPE_BLUETOOTH_CHOOSER_DATA) {}
+
+BluetoothPermissionContext::~BluetoothPermissionContext() {}
+
+bool BluetoothPermissionContext::IsValidObject(
+ const base::DictionaryValue& object) {
+ std::string* null_string_ptr = nullptr;
+ // To be backward-compatible with preferences written by previous versions of
+ // Chrome.
+ return object.size() == 3 && object.HasKey(kDeviceAddressKey) &&
+ object.GetString(kDeviceAddressKey, null_string_ptr) &&
+ object.HasKey(kDeviceNameKey) &&
+ object.GetString(kDeviceNameKey, null_string_ptr) &&
+ object.HasKey(kDeviceUUIDsKey) &&
+ object.GetList(kDeviceUUIDsKey, nullptr);
+}

Powered by Google App Engine
This is Rietveld 408576698