Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1189)

Unified Diff: chrome/browser/permissions/permission_infobar_request.h

Issue 1337903002: permissions: remove PermissionQueueController and introduce PermissionInfoBarManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@callbacks-delegates
Patch Set: Fix compile failures Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..d0da118308bddbdd4a113ac168420ca4ac38019a
--- /dev/null
+++ b/chrome/browser/permissions/permission_infobar_request.h
@@ -0,0 +1,113 @@
+// 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/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_
« no previous file with comments | « chrome/browser/permissions/permission_infobar_manager.cc ('k') | chrome/browser/permissions/permission_infobar_request.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698