| 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 #ifndef CHROME_BROWSER_MEDIA_EXTENSION_MEDIA_ACCESS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_EXTENSION_MEDIA_ACCESS_HANDLER_H_ |
| 6 #define CHROME_BROWSER_MEDIA_EXTENSION_MEDIA_ACCESS_HANDLER_H_ | 6 #define CHROME_BROWSER_MEDIA_EXTENSION_MEDIA_ACCESS_HANDLER_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 8 #include "chrome/browser/media/media_access_handler.h" | 9 #include "chrome/browser/media/media_access_handler.h" |
| 10 #include "extensions/common/extension_id.h" |
| 9 | 11 |
| 10 class MediaStreamCaptureIndicator; | 12 class MediaStreamCaptureIndicator; |
| 11 | 13 |
| 12 // MediaAccessHandler for extension capturing requests. | 14 // MediaAccessHandler for extension capturing requests. |
| 13 class ExtensionMediaAccessHandler : public MediaAccessHandler { | 15 class ExtensionMediaAccessHandler : public MediaAccessHandler { |
| 14 public: | 16 public: |
| 15 ExtensionMediaAccessHandler(); | 17 ExtensionMediaAccessHandler(); |
| 16 ~ExtensionMediaAccessHandler() override; | 18 ~ExtensionMediaAccessHandler() override; |
| 17 | 19 |
| 18 // MediaAccessHandler implementation. | 20 // MediaAccessHandler implementation. |
| 19 bool SupportsStreamType(const content::MediaStreamType type, | 21 bool SupportsStreamType(const content::MediaStreamType type, |
| 20 const extensions::Extension* extension) override; | 22 const extensions::Extension* extension) override; |
| 21 bool CheckMediaAccessPermission( | 23 bool CheckMediaAccessPermission( |
| 22 content::WebContents* web_contents, | 24 content::WebContents* web_contents, |
| 23 const GURL& security_origin, | 25 const GURL& security_origin, |
| 24 content::MediaStreamType type, | 26 content::MediaStreamType type, |
| 25 const extensions::Extension* extension) override; | 27 const extensions::Extension* extension) override; |
| 26 void HandleRequest(content::WebContents* web_contents, | 28 void HandleRequest(content::WebContents* web_contents, |
| 27 const content::MediaStreamRequest& request, | 29 const content::MediaStreamRequest& request, |
| 28 const content::MediaResponseCallback& callback, | 30 const content::MediaResponseCallback& callback, |
| 29 const extensions::Extension* extension) override; | 31 const extensions::Extension* extension) override; |
| 32 |
| 33 private: |
| 34 // Original HandleRequest function was split in two parts to allow prompting |
| 35 // the user for input, this is the second part. |
| 36 void HandleRequestContinuation(content::WebContents* web_contents, |
| 37 const content::MediaStreamRequest& request, |
| 38 const content::MediaResponseCallback& callback, |
| 39 const extensions::Extension* extension); |
| 40 |
| 41 // Function used to resolve user decision regarding allowing audio/video. |
| 42 void ResolvePermissionPrompt( |
| 43 content::WebContents* web_contents, |
| 44 const content::MediaStreamRequest& request, |
| 45 const content::MediaResponseCallback& callback, |
| 46 const extensions::Extension* extension, |
| 47 ExtensionInstallPrompt::Result prompt_result); |
| 48 |
| 49 std::unique_ptr<ExtensionInstallPrompt> prompt_; |
| 50 |
| 51 // Class used to cache user choice regarding allowing audio/video capture. |
| 52 class UserChoice { |
| 53 public: |
| 54 // Helper function for checking if audio/video is disallowed by user choice. |
| 55 bool Disallowed(content::MediaStreamType type) const; |
| 56 // Helper function which returns true if audio/video wasn't prompted yet. |
| 57 bool NeedsPrompting(content::MediaStreamType type) const; |
| 58 void Set(content::MediaStreamType type, bool allowed); |
| 59 |
| 60 private: |
| 61 bool audio_prompted_ = false; |
| 62 bool audio_allowed_ = false; |
| 63 bool video_prompted_ = false; |
| 64 bool video_allowed_ = false; |
| 65 }; |
| 66 |
| 67 std::map<extensions::ExtensionId, UserChoice> user_choice_cache_; |
| 30 }; | 68 }; |
| 31 | 69 |
| 32 #endif // CHROME_BROWSER_MEDIA_EXTENSION_MEDIA_ACCESS_HANDLER_H_ | 70 #endif // CHROME_BROWSER_MEDIA_EXTENSION_MEDIA_ACCESS_HANDLER_H_ |
| OLD | NEW |