Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
|
Devlin
2017/01/09 18:05:07
not 2016 anymore
Ivan Šandrk
2017/01/09 18:33:51
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PAGE_CAPTURE_PAGE_CAPTURE_PERMISSION_HELPE R_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_PAGE_CAPTURE_PAGE_CAPTURE_PERMISSION_HELPE R_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/callback_forward.h" | |
| 12 #include "chrome/browser/extensions/extension_install_prompt.h" | |
| 13 #include "components/prefs/pref_service.h" | |
| 14 #include "content/public/browser/web_contents.h" | |
| 15 | |
| 16 class PrefChangeRegistrar; | |
| 17 | |
| 18 namespace extensions { | |
| 19 class Extension; | |
| 20 | |
| 21 class PageCapturePermissionHelper { | |
| 22 public: | |
| 23 PageCapturePermissionHelper( | |
| 24 const Extension* extension, | |
| 25 PrefService* prefs, | |
| 26 const base::Closure& success_callback, | |
| 27 const base::Callback<void(const std::string&)>& failure_callback); | |
| 28 | |
| 29 ~PageCapturePermissionHelper(); | |
| 30 | |
| 31 // Handles permission checking inside of Public Sessions. | |
| 32 void HandlePermissionRequest(content::WebContents* web_contents); | |
| 33 | |
| 34 private: | |
| 35 enum PermissionState { | |
| 36 NOT_PROMPTED = 0, | |
| 37 SHOWN_PROMPT, | |
| 38 ALLOWED, | |
| 39 DENIED | |
| 40 }; | |
| 41 | |
| 42 // Sets up the dialog asking the user for permission. | |
| 43 void ShowPermissionPrompt(content::WebContents* web_contents); | |
| 44 | |
| 45 // Handles the user decision of whether to allow page capture. | |
| 46 void ResolvePermissionPrompt(ExtensionInstallPrompt::Result prompt_result); | |
| 47 | |
| 48 // Continues with the page capture (if user allowed it), or returns failure | |
| 49 // (user denied permission). | |
| 50 void ResolvePermissionRequest(); | |
| 51 | |
| 52 void SetUserChoice(PermissionState value); | |
| 53 PermissionState GetUserChoice(); | |
| 54 | |
| 55 std::unique_ptr<ExtensionInstallPrompt> prompt_; | |
| 56 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; | |
| 57 const Extension* extension_; | |
| 58 PrefService* prefs_; | |
| 59 base::Closure success_callback_; | |
| 60 base::Callback<void(const std::string&)> failure_callback_; | |
| 61 }; | |
| 62 | |
| 63 } // namespace extensions | |
| 64 | |
| 65 #endif // CHROME_BROWSER_EXTENSIONS_API_PAGE_CAPTURE_PAGE_CAPTURE_PERMISSION_HE LPER_H_ | |
| OLD | NEW |