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..c149ca471ae90b24b3cdd7c5d611ad881b0c5b88 |
--- /dev/null |
+++ b/chrome/browser/permissions/permission_infobar_request.h |
@@ -0,0 +1,107 @@ |
+// 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. |
+ void AddPermission( |
+ const ContentSettingsType type, |
+ const base::Callback<void(bool, ContentSetting)>& response_callback); |
+ |
+ // Shows the relavent infobar for this request in the specified web contents. |
mlamouri (slow - plz ping)
2015/10/02 11:49:39
I think you should add comments regarding the rela
Lalit Maganti
2015/10/02 13:37:45
Done.
|
+ bool ShowInfobar(content::WebContents* web_contents); |
+ |
+ // Used to manually accept the request. |
mlamouri (slow - plz ping)
2015/10/02 11:49:40
Here and below. What do you mean by "manually"?
Lalit Maganti
2015/10/02 13:37:45
Done.
|
+ void Accept(); |
+ |
+ // Used to manually dismiss the request. |
+ void Closing(); |
+ |
+ // Used to manually cancel the request. |
+ void Cancel(); |
+ |
+ int request_id() const { return request_id_; } |
+ |
+ private: |
+ using PermissionDecidedCallback = base::Callback<void(bool, ContentSetting)>; |
+ class PermissionRequest { |
+ public: |
+ PermissionRequest(ContentSettingsType type, |
+ const PermissionDecidedCallback& response_callback); |
+ ~PermissionRequest(); |
+ |
+ ContentSettingsType type() const { return type_; } |
+ const PermissionDecidedCallback& response_callback() const { |
+ return response_callback_; |
+ } |
+ |
+ private: |
+ ContentSettingsType type_; |
+ PermissionDecidedCallback response_callback_; |
mlamouri (slow - plz ping)
2015/10/02 11:49:39
nit: rename |callback_|.
Lalit Maganti
2015/10/02 13:37:45
Done.
|
+ }; |
+ |
+ // Called when this request is dismissed manually. |
+ void OnManualClose(); |
+ |
+ // Callback function used when single permission infobar is shown. |
mlamouri (slow - plz ping)
2015/10/02 11:49:39
"Shown" for "OnPermissionSet"?
Lalit Maganti
2015/10/02 13:37:45
Done.
|
+ void OnPermissionSet(bool update_content_setting, |
+ bool allowed); |
+ |
+ // Callback function used when a coalesced infobar is shown. |
mlamouri (slow - plz ping)
2015/10/02 11:49:39
ditto
Lalit Maganti
2015/10/02 13:37:45
Done.
|
+ void OnPermissionsSet(bool update_content_setting, |
+ const std::vector<ContentSetting>& allowed); |
+ |
+ // Removes any permissions from this request for which there is already |
+ // a user specified ContentSetting. |
mlamouri (slow - plz ping)
2015/10/02 11:49:39
nit: do not mention ContentSetting. Maybe:
"""
Rem
Lalit Maganti
2015/10/02 13:37:45
Done.
|
+ void PruneAnsweredPermissions(Profile* profile); |
+ |
+ // Creates the single permission infobar for the PermissionRequest| |
mlamouri (slow - plz ping)
2015/10/02 11:49:40
nit: remove "|"
Lalit Maganti
2015/10/02 13:37:45
Done.
|
+ // 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_ |