Chromium Code Reviews| Index: chrome/browser/extensions/api/page_capture/page_capture_permission_helper.h |
| diff --git a/chrome/browser/extensions/api/page_capture/page_capture_permission_helper.h b/chrome/browser/extensions/api/page_capture/page_capture_permission_helper.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1d299399f861eae2d673efe487fc4552e10d4a2a |
| --- /dev/null |
| +++ b/chrome/browser/extensions/api/page_capture/page_capture_permission_helper.h |
| @@ -0,0 +1,65 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_EXTENSIONS_API_PAGE_CAPTURE_PAGE_CAPTURE_PERMISSION_HELPER_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_API_PAGE_CAPTURE_PAGE_CAPTURE_PERMISSION_HELPER_H_ |
| + |
| +#include <memory> |
| +#include <string> |
| + |
| +#include "base/callback_forward.h" |
| +#include "chrome/browser/extensions/extension_install_prompt.h" |
| +#include "components/prefs/pref_service.h" |
| +#include "content/public/browser/web_contents.h" |
| + |
| +class PrefChangeRegistrar; |
| + |
| +namespace extensions { |
| +class Extension; |
| + |
| +class PageCapturePermissionHelper { |
| + public: |
| + PageCapturePermissionHelper( |
| + const extensions::Extension* extension, |
| + PrefService* prefs, |
| + 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.
|
| + base::Callback<void(const std::string&)> failure_callback); |
| + |
| + ~PageCapturePermissionHelper(); |
| + |
| + // Handles permission checking inside of Public Sessions. |
| + void HandlePermissionRequest(content::WebContents* web_contents); |
| + |
| + private: |
| + enum PermissionState { |
| + NOT_PROMPTED = 0, |
| + SHOWN_PROMPT, |
| + ALLOWED, |
| + DENIED |
| + }; |
| + |
| + // Sets up the dialog asking the user for permission. |
| + void ShowPermissionPrompt(content::WebContents* web_contents); |
| + |
| + // Handles the user decision of whether to allow page capture. |
| + void ResolvePermissionPrompt(ExtensionInstallPrompt::Result prompt_result); |
| + |
| + // Continues with the page capture (if user allowed it), or returns failure |
| + // (user denied permission). |
| + void ResolvePermissionRequest(); |
| + |
| + 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
|
| + PermissionState UserChoiceGet(); |
| + |
| + std::unique_ptr<ExtensionInstallPrompt> prompt_; |
| + std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; |
| + const extensions::Extension* extension_; |
|
Devlin
2017/01/06 20:45:49
nit: no extensions:: prefix
Ivan Šandrk
2017/01/09 13:14:56
Done.
|
| + PrefService* prefs_; |
| + base::Callback<void()> success_callback_; |
|
Devlin
2017/01/06 20:45:49
nit: base::Closure
Ivan Šandrk
2017/01/09 13:14:56
Done.
|
| + base::Callback<void(const std::string&)> failure_callback_; |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_API_PAGE_CAPTURE_PAGE_CAPTURE_PERMISSION_HELPER_H_ |