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

Side by Side Diff: chrome/browser/permissions/grouped_permission_infobar_delegate_android.h

Issue 2319443002: Add InfoBarIdentifier to GroupedPermissionInfoBarDelegate (Closed)
Patch Set: address review comments Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_PERMISSIONS_GROUPED_PERMISSION_INFOBAR_DELEGATE_H_ 5 #ifndef CHROME_BROWSER_PERMISSIONS_GROUPED_PERMISSION_INFOBAR_DELEGATE_ANDROID_H _
6 #define CHROME_BROWSER_PERMISSIONS_GROUPED_PERMISSION_INFOBAR_DELEGATE_H_ 6 #define CHROME_BROWSER_PERMISSIONS_GROUPED_PERMISSION_INFOBAR_DELEGATE_ANDROID_H _
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "components/content_settings/core/common/content_settings_types.h" 11 #include "components/content_settings/core/common/content_settings_types.h"
12 #include "components/infobars/core/confirm_infobar_delegate.h" 12 #include "components/infobars/core/confirm_infobar_delegate.h"
13 13
14 class GURL; 14 class GURL;
15 class InfoBarService; 15 class InfoBarService;
16 16
17 namespace infobars { 17 namespace infobars {
18 class InfoBarManager; 18 class InfoBarManager;
19 } 19 }
20 20
21 // Configures an InfoBar to display a group of permission requests, each of 21 // Configures an InfoBar to display a group of permission requests, each of
Peter Kasting 2016/09/21 18:44:39 Nit: Configures an InfoBar to display -> An infoba
lshang 2016/09/22 02:11:31 Done.
22 // which can be allowed or blocked independently. 22 // which can be allowed or blocked independently.
23 // TODO(tsergeant): Expand this class so it can be used without subclassing. 23 // TODO(tsergeant): Expand this class so it can be used without subclassing.
24 class GroupedPermissionInfoBarDelegate : public ConfirmInfoBarDelegate { 24 class GroupedPermissionInfoBarDelegate : public ConfirmInfoBarDelegate {
25 public: 25 public:
26 ~GroupedPermissionInfoBarDelegate() override;
Peter Kasting 2016/09/21 18:44:39 Nit: May be able to make private as well, dependin
lshang 2016/09/22 02:11:31 This can't be private, since we have grouped permi
Peter Kasting 2016/09/23 00:42:05 I don't really understand that reply. Normally th
lshang 2016/09/27 01:50:42 Yeah, the compiler seems complaining about one lin
Peter Kasting 2016/09/27 02:05:42 I think the problem is that GroupedPermissionInfoB
lshang 2016/09/28 00:55:05 Done.
27
26 // Implementation is in platform-specific infobar file. 28 // Implementation is in platform-specific infobar file.
Peter Kasting 2016/09/21 18:44:39 Nit: This comment should disappear.
lshang 2016/09/22 02:11:31 Done.
27 static std::unique_ptr<infobars::InfoBar> CreateInfoBar( 29 static infobars::InfoBar* Create(
28 infobars::InfoBarManager* infobar_manager, 30 InfoBarService* infobar_service,
29 std::unique_ptr<GroupedPermissionInfoBarDelegate> delegate);
30
31 GroupedPermissionInfoBarDelegate(
32 const GURL& requesting_origin, 31 const GURL& requesting_origin,
33 const std::vector<ContentSettingsType>& types); 32 const std::vector<ContentSettingsType>& types);
34 ~GroupedPermissionInfoBarDelegate() override;
35 33
36 bool ShouldShowPersistenceToggle() const; 34 bool ShouldShowPersistenceToggle() const;
Peter Kasting 2016/09/21 18:44:39 Nit: This deserves a comment, I think.
lshang 2016/09/22 02:11:31 Done.
37 bool persist() const { return persist_; } 35 bool persist() const { return persist_; }
Peter Kasting 2016/09/21 18:44:39 Nit: I suggest grouping all cheap inlined accessor
lshang 2016/09/22 02:11:30 Done.
38 void set_persist(bool persist) { persist_ = persist; } 36 void set_persist(bool persist) { persist_ = persist; }
39 37
38 size_t GetPermissionCount() const { return types_.size(); }
Peter Kasting 2016/09/21 18:44:40 Nit: Inlined accessors should be named unix_hacker
lshang 2016/09/22 02:11:31 Done.
39 ContentSettingsType GetContentSettingType(size_t index) const;
40 int GetIconIdForPermission(size_t index) const;
41
42 // ConfirmInfoBarDelegate:
40 base::string16 GetMessageText() const override; 43 base::string16 GetMessageText() const override;
Peter Kasting 2016/09/21 18:44:39 Nit: Place overrides either above or below non-ove
lshang 2016/09/22 02:11:31 Done.
41 44
42 int GetPermissionCount() const;
43 ContentSettingsType GetContentSettingType(int index) const;
44 int GetIconIdForPermission(int index) const;
45 // Message text to display for an individual permission at |index|. 45 // Message text to display for an individual permission at |index|.
46 base::string16 GetMessageTextFragment(int index) const; 46 base::string16 GetMessageTextFragment(size_t index) const;
47 47
48 void ToggleAccept(int position, bool new_value); 48 // Toggle Allow/Block for each permission type.
49 void ToggleAccept(size_t position, bool new_value);
Peter Kasting 2016/09/21 18:44:39 Nit: Why |index| on most APIs, but |position| on t
lshang 2016/09/22 02:11:31 Done. Changed them all to |position|.
49 50
50 protected: 51 protected:
51 bool GetAcceptState(int position); 52 bool GetAcceptState(size_t position);
52 53
53 private: 54 private:
55 GroupedPermissionInfoBarDelegate(
56 const GURL& requesting_origin,
57 const std::vector<ContentSettingsType>& types);
58
54 // ConfirmInfoBarDelegate: 59 // ConfirmInfoBarDelegate:
60 InfoBarIdentifier GetIdentifier() const override;
61 Type GetInfoBarType() const override;
62 int GetButtons() const override;
55 base::string16 GetButtonLabel(InfoBarButton button) const override; 63 base::string16 GetButtonLabel(InfoBarButton button) const override;
56 int GetButtons() const override;
57
58 // InfoBarDelegate:
59 Type GetInfoBarType() const override;
60 64
61 const GURL requesting_origin_; 65 const GURL requesting_origin_;
62 const std::vector<ContentSettingsType> types_; 66 const std::vector<ContentSettingsType> types_;
63 std::vector<bool> accept_states_; 67 std::vector<bool> accept_states_;
64 bool persist_; 68 bool persist_;
65 69
66 DISALLOW_COPY_AND_ASSIGN(GroupedPermissionInfoBarDelegate); 70 DISALLOW_COPY_AND_ASSIGN(GroupedPermissionInfoBarDelegate);
67 }; 71 };
68 72
69 #endif // CHROME_BROWSER_PERMISSIONS_GROUPED_PERMISSION_INFOBAR_DELEGATE_H_ 73 // Implementation is in platform-specific infobar file.
Peter Kasting 2016/09/21 18:44:39 Seems like you have an Android-specific infobar an
lshang 2016/09/22 02:11:30 Done. Also referred to other infobars, Removed thi
74 std::unique_ptr<infobars::InfoBar> CreateGroupedPermissionInfoBar(
75 std::unique_ptr<GroupedPermissionInfoBarDelegate> delegate);
76
77 #endif // CHROME_BROWSER_PERMISSIONS_GROUPED_PERMISSION_INFOBAR_DELEGATE_ANDROI D_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698