| Index: chrome/browser/permissions/permission_infobar_request.h
|
| diff --git a/chrome/browser/permissions/permission_infobar_request.h b/chrome/browser/permissions/permission_infobar_request.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..cd6dadd8a767167a2ebb09e76dd0348b0c9af3e1
|
| --- /dev/null
|
| +++ b/chrome/browser/permissions/permission_infobar_request.h
|
| @@ -0,0 +1,114 @@
|
| +// Copyright 2015 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_PERMISSIONS_PERMISSION_INFOBAR_REQUEST_H_
|
| +#define CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_REQUEST_H_
|
| +
|
| +#include "base/callback.h"
|
| +#include "base/macros.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "components/content_settings/core/common/content_settings.h"
|
| +#include "url/gurl.h"
|
| +
|
| +class InfoBarService;
|
| +class Profile;
|
| +
|
| +namespace content {
|
| +class WebContents;
|
| +} // namespace content
|
| +
|
| +namespace infobars {
|
| +class InfoBar;
|
| +} // namespace infobars
|
| +
|
| +// Represents a permission request which will be displayed using an InfoBar.
|
| +class PermissionInfoBarRequest {
|
| + public:
|
| + PermissionInfoBarRequest(
|
| + int request_id,
|
| + const GURL& requesting_origin,
|
| + const GURL& embedding_origin,
|
| + const base::Closure& callback);
|
| + ~PermissionInfoBarRequest();
|
| +
|
| + // Adds a permisison type which should be associated with this request.
|
| + /// This function can be called as many times as the caller wants until
|
| + // |ShowInfobar| is called. After this point this function should NOT be
|
| + // called.
|
| + void AddPermission(
|
| + const ContentSettingsType type,
|
| + const base::Callback<void(bool, ContentSetting)>& callback);
|
| +
|
| + // Shows the relavent infobar for this request in the specified web contents.
|
| + // Called after all permissions have been added to the request with
|
| + // |AddPermission|.
|
| + bool ShowInfobar(content::WebContents* web_contents);
|
| +
|
| + // Used to cancel the request without user action.
|
| + void Cancel();
|
| +
|
| + int request_id() const { return request_id_; }
|
| +
|
| + private:
|
| + friend class PermissionContextBaseTests;
|
| + using PermissionDecidedCallback = base::Callback<void(bool, ContentSetting)>;
|
| + class PermissionRequest {
|
| + public:
|
| + PermissionRequest(ContentSettingsType type,
|
| + const PermissionDecidedCallback& callback);
|
| + ~PermissionRequest();
|
| +
|
| + ContentSettingsType type() const { return type_; }
|
| + const PermissionDecidedCallback& callback() const {
|
| + return callback_;
|
| + }
|
| +
|
| + private:
|
| + ContentSettingsType type_;
|
| + PermissionDecidedCallback callback_;
|
| + };
|
| +
|
| + // Used to accept or dismiss the request in tests.
|
| + void AcceptForTests();
|
| + void ClosingForTests();
|
| +
|
| + // Called when this request is dismissed without user action.
|
| + void OnCancel();
|
| +
|
| + // Callback function which is called when the user responds to a single
|
| + // permission infobar.
|
| + void OnPermissionSet(bool update_content_setting,
|
| + bool allowed);
|
| +
|
| + // Callback function which is called when the user responds to a coalesced
|
| + // permission infobar.
|
| + void OnPermissionsSet(bool update_content_setting,
|
| + const std::vector<ContentSetting>& allowed);
|
| +
|
| + // Removes any permissions from this request for which there is no need to
|
| + // prompt the user.
|
| + void PruneAnsweredPermissions(Profile* profile);
|
| +
|
| + // Creates the single permission infobar for the PermissionRequest
|
| + // specified.
|
| + void CreateInfoBar(InfoBarService* infobar_service,
|
| + const PermissionRequest& request,
|
| + const std::string& display_languages,
|
| + const base::Callback<void(bool, bool)>& callback);
|
| +
|
| + // Owned by InfoBarService.
|
| + infobars::InfoBar* infobar_;
|
| +
|
| + int request_id_;
|
| + GURL requesting_origin_;
|
| + GURL embedding_origin_;
|
| + base::Closure callback_;
|
| + std::vector<PermissionRequest> requests_;
|
| +
|
| + base::WeakPtrFactory<PermissionInfoBarRequest> weak_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(PermissionInfoBarRequest);
|
| +};
|
| +
|
| +#endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_REQUEST_H_
|
|
|