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 bool user_gesture, | 26 bool user_gesture, |
27 const base::Callback<void(PermissionStatus)>& callback) { | 27 const base::Callback<void(PermissionStatus)>& callback) { |
28 callback.Run(permission == PermissionType::GEOLOCATION | 28 callback.Run(permission == PermissionType::GEOLOCATION |
29 ? PERMISSION_STATUS_GRANTED : PERMISSION_STATUS_DENIED); | 29 ? PermissionStatus::GRANTED |
| 30 : PermissionStatus::DENIED); |
30 return kNoPendingOperation; | 31 return kNoPendingOperation; |
31 } | 32 } |
32 | 33 |
33 int ShellPermissionManager::RequestPermissions( | 34 int ShellPermissionManager::RequestPermissions( |
34 const std::vector<PermissionType>& permissions, | 35 const std::vector<PermissionType>& permissions, |
35 content::RenderFrameHost* render_frame_host, | 36 content::RenderFrameHost* render_frame_host, |
36 const GURL& requesting_origin, | 37 const GURL& requesting_origin, |
37 bool user_gesture, | 38 bool user_gesture, |
38 const base::Callback<void( | 39 const base::Callback<void( |
39 const std::vector<PermissionStatus>&)>& callback) { | 40 const std::vector<PermissionStatus>&)>& callback) { |
40 std::vector<PermissionStatus> result(permissions.size()); | 41 std::vector<PermissionStatus> result(permissions.size()); |
41 for (const auto& permission : permissions) { | 42 for (const auto& permission : permissions) { |
42 result.push_back(permission == PermissionType::GEOLOCATION | 43 result.push_back(permission == PermissionType::GEOLOCATION |
43 ? PERMISSION_STATUS_GRANTED : PERMISSION_STATUS_DENIED); | 44 ? PermissionStatus::GRANTED |
| 45 : PermissionStatus::DENIED); |
44 } | 46 } |
45 callback.Run(result); | 47 callback.Run(result); |
46 return kNoPendingOperation; | 48 return kNoPendingOperation; |
47 } | 49 } |
48 | 50 |
49 void ShellPermissionManager::CancelPermissionRequest(int request_id) { | 51 void ShellPermissionManager::CancelPermissionRequest(int request_id) { |
50 } | 52 } |
51 | 53 |
52 void ShellPermissionManager::ResetPermission( | 54 void ShellPermissionManager::ResetPermission( |
53 PermissionType permission, | 55 PermissionType permission, |
54 const GURL& requesting_origin, | 56 const GURL& requesting_origin, |
55 const GURL& embedding_origin) { | 57 const GURL& embedding_origin) { |
56 } | 58 } |
57 | 59 |
58 PermissionStatus ShellPermissionManager::GetPermissionStatus( | 60 PermissionStatus ShellPermissionManager::GetPermissionStatus( |
59 PermissionType permission, | 61 PermissionType permission, |
60 const GURL& requesting_origin, | 62 const GURL& requesting_origin, |
61 const GURL& embedding_origin) { | 63 const GURL& embedding_origin) { |
62 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 64 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
63 if ((permission == PermissionType::AUDIO_CAPTURE || | 65 if ((permission == PermissionType::AUDIO_CAPTURE || |
64 permission == PermissionType::VIDEO_CAPTURE) && | 66 permission == PermissionType::VIDEO_CAPTURE) && |
65 command_line->HasSwitch(switches::kUseFakeDeviceForMediaStream) && | 67 command_line->HasSwitch(switches::kUseFakeDeviceForMediaStream) && |
66 command_line->HasSwitch(switches::kUseFakeUIForMediaStream)) { | 68 command_line->HasSwitch(switches::kUseFakeUIForMediaStream)) { |
67 return PERMISSION_STATUS_GRANTED; | 69 return PermissionStatus::GRANTED; |
68 } | 70 } |
69 return PERMISSION_STATUS_DENIED; | 71 return PermissionStatus::DENIED; |
70 } | 72 } |
71 | 73 |
72 void ShellPermissionManager::RegisterPermissionUsage( | 74 void ShellPermissionManager::RegisterPermissionUsage( |
73 PermissionType permission, | 75 PermissionType permission, |
74 const GURL& requesting_origin, | 76 const GURL& requesting_origin, |
75 const GURL& embedding_origin) { | 77 const GURL& embedding_origin) { |
76 } | 78 } |
77 | 79 |
78 int ShellPermissionManager::SubscribePermissionStatusChange( | 80 int ShellPermissionManager::SubscribePermissionStatusChange( |
79 PermissionType permission, | 81 PermissionType permission, |
80 const GURL& requesting_origin, | 82 const GURL& requesting_origin, |
81 const GURL& embedding_origin, | 83 const GURL& embedding_origin, |
82 const base::Callback<void(PermissionStatus)>& callback) { | 84 const base::Callback<void(PermissionStatus)>& callback) { |
83 return kNoPendingOperation; | 85 return kNoPendingOperation; |
84 } | 86 } |
85 | 87 |
86 void ShellPermissionManager::UnsubscribePermissionStatusChange( | 88 void ShellPermissionManager::UnsubscribePermissionStatusChange( |
87 int subscription_id) { | 89 int subscription_id) { |
88 } | 90 } |
89 | 91 |
90 } // namespace content | 92 } // namespace content |
OLD | NEW |