permission_manager.cc 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Copyright (c) 2015 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-CHROMIUM file.
  4. #include "brightray/browser/permission_manager.h"
  5. #include "base/callback.h"
  6. #include "content/public/browser/child_process_security_policy.h"
  7. #include "content/public/browser/permission_type.h"
  8. #include "content/public/browser/render_frame_host.h"
  9. #include "content/public/browser/render_process_host.h"
  10. namespace brightray {
  11. PermissionManager::PermissionManager() {}
  12. PermissionManager::~PermissionManager() {}
  13. int PermissionManager::RequestPermission(
  14. content::PermissionType permission,
  15. content::RenderFrameHost* render_frame_host,
  16. const GURL& requesting_origin,
  17. bool user_gesture,
  18. const base::Callback<void(blink::mojom::PermissionStatus)>& callback) {
  19. if (permission == content::PermissionType::MIDI_SYSEX) {
  20. content::ChildProcessSecurityPolicy::GetInstance()
  21. ->GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
  22. }
  23. callback.Run(blink::mojom::PermissionStatus::GRANTED);
  24. return kNoPendingOperation;
  25. }
  26. int PermissionManager::RequestPermissions(
  27. const std::vector<content::PermissionType>& permissions,
  28. content::RenderFrameHost* render_frame_host,
  29. const GURL& requesting_origin,
  30. bool user_gesture,
  31. const base::Callback<
  32. void(const std::vector<blink::mojom::PermissionStatus>&)>& callback) {
  33. std::vector<blink::mojom::PermissionStatus> permissionStatuses;
  34. for (auto permission : permissions) {
  35. if (permission == content::PermissionType::MIDI_SYSEX) {
  36. content::ChildProcessSecurityPolicy::GetInstance()
  37. ->GrantSendMidiSysExMessage(render_frame_host->GetProcess()->GetID());
  38. }
  39. permissionStatuses.push_back(blink::mojom::PermissionStatus::GRANTED);
  40. }
  41. callback.Run(permissionStatuses);
  42. return kNoPendingOperation;
  43. }
  44. void PermissionManager::CancelPermissionRequest(int request_id) {}
  45. void PermissionManager::ResetPermission(content::PermissionType permission,
  46. const GURL& requesting_origin,
  47. const GURL& embedding_origin) {}
  48. blink::mojom::PermissionStatus PermissionManager::GetPermissionStatus(
  49. content::PermissionType permission,
  50. const GURL& requesting_origin,
  51. const GURL& embedding_origin) {
  52. return blink::mojom::PermissionStatus::GRANTED;
  53. }
  54. int PermissionManager::SubscribePermissionStatusChange(
  55. content::PermissionType permission,
  56. const GURL& requesting_origin,
  57. const GURL& embedding_origin,
  58. const base::Callback<void(blink::mojom::PermissionStatus)>& callback) {
  59. return -1;
  60. }
  61. void PermissionManager::UnsubscribePermissionStatusChange(int subscription_id) {
  62. }
  63. } // namespace brightray