Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 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 extensions::Extension* extension, | |
| 25 PrefService* prefs, | |
| 26 base::Callback<void()> success_callback, | |
|
Devlin
2017/01/06 20:45:49
nit: base::Closure
Devlin
2017/01/06 20:45:49
nit: these can be const &
Ivan Šandrk
2017/01/09 13:14:56
Done.
Ivan Šandrk
2017/01/09 13:14:56
Done.
| |
| 27 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 UserChoiceSet(PermissionState value); | |
|
Devlin
2017/01/06 20:45:49
nit: prefer SetUserChoice and GetUserChoice
Ivan Šandrk
2017/01/09 13:14:56
Done. They do sound better, was thinking of this
| |
| 53 PermissionState UserChoiceGet(); | |
| 54 | |
| 55 std::unique_ptr<ExtensionInstallPrompt> prompt_; | |
| 56 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; | |
| 57 const extensions::Extension* extension_; | |
|
Devlin
2017/01/06 20:45:49
nit: no extensions:: prefix
Ivan Šandrk
2017/01/09 13:14:56
Done.
| |
| 58 PrefService* prefs_; | |
| 59 base::Callback<void()> success_callback_; | |
|
Devlin
2017/01/06 20:45:49
nit: base::Closure
Ivan Šandrk
2017/01/09 13:14:56
Done.
| |
| 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 |