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..1ba851bda924a43bb5dbba1196f9e74d7bad3aff |
| --- /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. |
|
Devlin
2017/01/09 18:05:07
not 2016 anymore
Ivan Šandrk
2017/01/09 18:33:51
Done.
|
| +// 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 Extension* extension, |
| + PrefService* prefs, |
| + const base::Closure& success_callback, |
| + const 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 SetUserChoice(PermissionState value); |
| + PermissionState GetUserChoice(); |
| + |
| + std::unique_ptr<ExtensionInstallPrompt> prompt_; |
| + std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; |
| + const Extension* extension_; |
| + PrefService* prefs_; |
| + base::Closure success_callback_; |
| + base::Callback<void(const std::string&)> failure_callback_; |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_API_PAGE_CAPTURE_PAGE_CAPTURE_PERMISSION_HELPER_H_ |