| 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(mojom::PermissionStatus)>& callback) { | 26 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) { |
| 27 callback.Run(permission == PermissionType::GEOLOCATION | 27 callback.Run(permission == PermissionType::GEOLOCATION |
| 28 ? mojom::PermissionStatus::GRANTED | 28 ? blink::mojom::PermissionStatus::GRANTED |
| 29 : mojom::PermissionStatus::DENIED); | 29 : blink::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(const std::vector<mojom::PermissionStatus>&)>& | 37 const base::Callback< |
| 38 callback) { | 38 void(const std::vector<blink::mojom::PermissionStatus>&)>& callback) { |
| 39 std::vector<mojom::PermissionStatus> result(permissions.size()); | 39 std::vector<blink::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 ? mojom::PermissionStatus::GRANTED | 42 ? blink::mojom::PermissionStatus::GRANTED |
| 43 : mojom::PermissionStatus::DENIED); | 43 : blink::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 mojom::PermissionStatus ShellPermissionManager::GetPermissionStatus( | 58 blink::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 // Background sync browser tests require permission to be granted by default. | 62 // Background sync browser tests require permission to be granted by default. |
| 63 // TODO(nsatragno): add a command line flag so that it's only granted for | 63 // TODO(nsatragno): add a command line flag so that it's only granted for |
| 64 // tests. | 64 // tests. |
| 65 if (permission == PermissionType::BACKGROUND_SYNC) | 65 if (permission == PermissionType::BACKGROUND_SYNC) |
| 66 return mojom::PermissionStatus::GRANTED; | 66 return blink::mojom::PermissionStatus::GRANTED; |
| 67 | 67 |
| 68 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 68 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 69 if ((permission == PermissionType::AUDIO_CAPTURE || | 69 if ((permission == PermissionType::AUDIO_CAPTURE || |
| 70 permission == PermissionType::VIDEO_CAPTURE) && | 70 permission == PermissionType::VIDEO_CAPTURE) && |
| 71 command_line->HasSwitch(switches::kUseFakeDeviceForMediaStream) && | 71 command_line->HasSwitch(switches::kUseFakeDeviceForMediaStream) && |
| 72 command_line->HasSwitch(switches::kUseFakeUIForMediaStream)) { | 72 command_line->HasSwitch(switches::kUseFakeUIForMediaStream)) { |
| 73 return mojom::PermissionStatus::GRANTED; | 73 return blink::mojom::PermissionStatus::GRANTED; |
| 74 } | 74 } |
| 75 return mojom::PermissionStatus::DENIED; | 75 return blink::mojom::PermissionStatus::DENIED; |
| 76 } | 76 } |
| 77 | 77 |
| 78 void ShellPermissionManager::RegisterPermissionUsage( | 78 void ShellPermissionManager::RegisterPermissionUsage( |
| 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 } | 82 } |
| 83 | 83 |
| 84 int ShellPermissionManager::SubscribePermissionStatusChange( | 84 int ShellPermissionManager::SubscribePermissionStatusChange( |
| 85 PermissionType permission, | 85 PermissionType permission, |
| 86 const GURL& requesting_origin, | 86 const GURL& requesting_origin, |
| 87 const GURL& embedding_origin, | 87 const GURL& embedding_origin, |
| 88 const base::Callback<void(mojom::PermissionStatus)>& callback) { | 88 const base::Callback<void(blink::mojom::PermissionStatus)>& callback) { |
| 89 return kNoPendingOperation; | 89 return kNoPendingOperation; |
| 90 } | 90 } |
| 91 | 91 |
| 92 void ShellPermissionManager::UnsubscribePermissionStatusChange( | 92 void ShellPermissionManager::UnsubscribePermissionStatusChange( |
| 93 int subscription_id) { | 93 int subscription_id) { |
| 94 } | 94 } |
| 95 | 95 |
| 96 } // namespace content | 96 } // namespace content |
| OLD | NEW |