| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "android_webview/browser/aw_permission_manager.h" | 5 #include "android_webview/browser/aw_permission_manager.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "android_webview/browser/aw_browser_permission_request_delegate.h" | 10 #include "android_webview/browser/aw_browser_permission_request_delegate.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 void RequestMIDISysexPermission( | 70 void RequestMIDISysexPermission( |
| 71 const GURL& origin, | 71 const GURL& origin, |
| 72 const base::Callback<void(bool)>& callback) override { | 72 const base::Callback<void(bool)>& callback) override { |
| 73 RequestPermission(origin, PermissionType::MIDI_SYSEX, callback); | 73 RequestPermission(origin, PermissionType::MIDI_SYSEX, callback); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void CancelMIDISysexPermissionRequests(const GURL& origin) override { | 76 void CancelMIDISysexPermissionRequests(const GURL& origin) override { |
| 77 CancelPermission(origin, PermissionType::MIDI_SYSEX); | 77 CancelPermission(origin, PermissionType::MIDI_SYSEX); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void RequestSensorPermission( |
| 81 const GURL& origin, |
| 82 const base::Callback<void(bool)>& callback) override { |
| 83 RequestPermission(origin, PermissionType::SENSORS, callback); |
| 84 } |
| 85 |
| 86 void CancelSensorPermissionRequests(const GURL& origin) override { |
| 87 CancelPermission(origin, PermissionType::SENSORS); |
| 88 } |
| 89 |
| 80 private: | 90 private: |
| 81 void RequestPermission(const GURL& origin, | 91 void RequestPermission(const GURL& origin, |
| 82 PermissionType type, | 92 PermissionType type, |
| 83 const base::Callback<void(bool)>& callback) { | 93 const base::Callback<void(bool)>& callback) { |
| 84 for (auto it = response_.begin(); it != response_.end(); ++it) { | 94 for (auto it = response_.begin(); it != response_.end(); ++it) { |
| 85 if ((*it)->type != type || (*it)->origin != origin) | 95 if ((*it)->type != type || (*it)->origin != origin) |
| 86 continue; | 96 continue; |
| 87 bool grant = (*it)->grant; | 97 bool grant = (*it)->grant; |
| 88 response_.erase(it); | 98 response_.erase(it); |
| 89 callback.Run(grant); | 99 callback.Run(grant); |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 EXPECT_EQ(2u, resolved_permission_status.size()); | 899 EXPECT_EQ(2u, resolved_permission_status.size()); |
| 890 EXPECT_EQ(PermissionStatus::GRANTED, resolved_permission_status[0]); | 900 EXPECT_EQ(PermissionStatus::GRANTED, resolved_permission_status[0]); |
| 891 EXPECT_EQ(2, resolved_permission_request_id[0]); | 901 EXPECT_EQ(2, resolved_permission_request_id[0]); |
| 892 EXPECT_EQ(PermissionStatus::GRANTED, resolved_permission_status[1]); | 902 EXPECT_EQ(PermissionStatus::GRANTED, resolved_permission_status[1]); |
| 893 EXPECT_EQ(2, resolved_permission_request_id[1]); | 903 EXPECT_EQ(2, resolved_permission_request_id[1]); |
| 894 } | 904 } |
| 895 | 905 |
| 896 } // namespace | 906 } // namespace |
| 897 | 907 |
| 898 } // namespace android_webview | 908 } // namespace android_webview |
| OLD | NEW |