| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/shell/browser/shell_permission_manager.h" | 5 #include "content/shell/browser/shell_permission_manager.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "content/public/browser/permission_type.h" | 9 #include "content/public/browser/permission_type.h" |
| 10 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
| 11 #include "media/base/media_switches.h" | 11 #include "media/base/media_switches.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 ShellPermissionManager::ShellPermissionManager() | 15 ShellPermissionManager::ShellPermissionManager() |
| 16 : PermissionManager() { | 16 : PermissionManager() { |
| 17 } | 17 } |
| 18 | 18 |
| 19 ShellPermissionManager::~ShellPermissionManager() { | 19 ShellPermissionManager::~ShellPermissionManager() { |
| 20 } | 20 } |
| 21 | 21 |
| 22 int ShellPermissionManager::RequestPermission( | 22 int ShellPermissionManager::RequestPermission( |
| 23 PermissionType permission, | 23 PermissionType permission, |
| 24 RenderFrameHost* render_frame_host, | 24 RenderFrameHost* render_frame_host, |
| 25 const GURL& requesting_origin, | 25 const GURL& requesting_origin, |
| 26 const base::Callback<void(PermissionStatus)>& callback) { | 26 const base::Callback<void(mojom::PermissionStatus)>& callback) { |
| 27 callback.Run(permission == PermissionType::GEOLOCATION | 27 callback.Run(permission == PermissionType::GEOLOCATION |
| 28 ? PermissionStatus::GRANTED | 28 ? mojom::PermissionStatus::GRANTED |
| 29 : PermissionStatus::DENIED); | 29 : mojom::PermissionStatus::DENIED); |
| 30 return kNoPendingOperation; | 30 return kNoPendingOperation; |
| 31 } | 31 } |
| 32 | 32 |
| 33 int ShellPermissionManager::RequestPermissions( | 33 int ShellPermissionManager::RequestPermissions( |
| 34 const std::vector<PermissionType>& permissions, | 34 const std::vector<PermissionType>& permissions, |
| 35 content::RenderFrameHost* render_frame_host, | 35 content::RenderFrameHost* render_frame_host, |
| 36 const GURL& requesting_origin, | 36 const GURL& requesting_origin, |
| 37 const base::Callback<void( | 37 const base::Callback<void(const std::vector<mojom::PermissionStatus>&)>& |
| 38 const std::vector<PermissionStatus>&)>& callback) { | 38 callback) { |
| 39 std::vector<PermissionStatus> result(permissions.size()); | 39 std::vector<mojom::PermissionStatus> result(permissions.size()); |
| 40 for (const auto& permission : permissions) { | 40 for (const auto& permission : permissions) { |
| 41 result.push_back(permission == PermissionType::GEOLOCATION | 41 result.push_back(permission == PermissionType::GEOLOCATION |
| 42 ? PermissionStatus::GRANTED | 42 ? mojom::PermissionStatus::GRANTED |
| 43 : PermissionStatus::DENIED); | 43 : mojom::PermissionStatus::DENIED); |
| 44 } | 44 } |
| 45 callback.Run(result); | 45 callback.Run(result); |
| 46 return kNoPendingOperation; | 46 return kNoPendingOperation; |
| 47 } | 47 } |
| 48 | 48 |
| 49 void ShellPermissionManager::CancelPermissionRequest(int request_id) { | 49 void ShellPermissionManager::CancelPermissionRequest(int request_id) { |
| 50 } | 50 } |
| 51 | 51 |
| 52 void ShellPermissionManager::ResetPermission( | 52 void ShellPermissionManager::ResetPermission( |
| 53 PermissionType permission, | 53 PermissionType permission, |
| 54 const GURL& requesting_origin, | 54 const GURL& requesting_origin, |
| 55 const GURL& embedding_origin) { | 55 const GURL& embedding_origin) { |
| 56 } | 56 } |
| 57 | 57 |
| 58 PermissionStatus ShellPermissionManager::GetPermissionStatus( | 58 mojom::PermissionStatus ShellPermissionManager::GetPermissionStatus( |
| 59 PermissionType permission, | 59 PermissionType permission, |
| 60 const GURL& requesting_origin, | 60 const GURL& requesting_origin, |
| 61 const GURL& embedding_origin) { | 61 const GURL& embedding_origin) { |
| 62 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 62 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 63 if ((permission == PermissionType::AUDIO_CAPTURE || | 63 if ((permission == PermissionType::AUDIO_CAPTURE || |
| 64 permission == PermissionType::VIDEO_CAPTURE) && | 64 permission == PermissionType::VIDEO_CAPTURE) && |
| 65 command_line->HasSwitch(switches::kUseFakeDeviceForMediaStream) && | 65 command_line->HasSwitch(switches::kUseFakeDeviceForMediaStream) && |
| 66 command_line->HasSwitch(switches::kUseFakeUIForMediaStream)) { | 66 command_line->HasSwitch(switches::kUseFakeUIForMediaStream)) { |
| 67 return PermissionStatus::GRANTED; | 67 return mojom::PermissionStatus::GRANTED; |
| 68 } | 68 } |
| 69 return PermissionStatus::DENIED; | 69 return mojom::PermissionStatus::DENIED; |
| 70 } | 70 } |
| 71 | 71 |
| 72 void ShellPermissionManager::RegisterPermissionUsage( | 72 void ShellPermissionManager::RegisterPermissionUsage( |
| 73 PermissionType permission, | 73 PermissionType permission, |
| 74 const GURL& requesting_origin, | 74 const GURL& requesting_origin, |
| 75 const GURL& embedding_origin) { | 75 const GURL& embedding_origin) { |
| 76 } | 76 } |
| 77 | 77 |
| 78 int ShellPermissionManager::SubscribePermissionStatusChange( | 78 int ShellPermissionManager::SubscribePermissionStatusChange( |
| 79 PermissionType permission, | 79 PermissionType permission, |
| 80 const GURL& requesting_origin, | 80 const GURL& requesting_origin, |
| 81 const GURL& embedding_origin, | 81 const GURL& embedding_origin, |
| 82 const base::Callback<void(PermissionStatus)>& callback) { | 82 const base::Callback<void(mojom::PermissionStatus)>& callback) { |
| 83 return kNoPendingOperation; | 83 return kNoPendingOperation; |
| 84 } | 84 } |
| 85 | 85 |
| 86 void ShellPermissionManager::UnsubscribePermissionStatusChange( | 86 void ShellPermissionManager::UnsubscribePermissionStatusChange( |
| 87 int subscription_id) { | 87 int subscription_id) { |
| 88 } | 88 } |
| 89 | 89 |
| 90 } // namespace content | 90 } // namespace content |
| OLD | NEW |