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

Side by Side Diff: chrome/browser/content_settings/permission_context_base.h

Issue 371933002: Add UMA for the new generic permisison class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_
6 #define CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ 6 #define CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/containers/scoped_ptr_hash_map.h" 9 #include "base/containers/scoped_ptr_hash_map.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/ui/website_settings/permission_bubble_request.h" 12 #include "chrome/browser/ui/website_settings/permission_bubble_request.h"
13 #include "chrome/common/content_settings_types.h" 13 #include "chrome/common/content_settings_types.h"
14 #include "components/keyed_service/core/keyed_service.h" 14 #include "components/keyed_service/core/keyed_service.h"
15 #include "url/gurl.h" 15 #include "url/gurl.h"
16 16
17 class PermissionQueueController; 17 class PermissionQueueController;
18 class PermissionRequestID; 18 class PermissionRequestID;
19 class Profile; 19 class Profile;
20 20
21 namespace content { 21 namespace content {
22 class WebContents; 22 class WebContents;
23 } 23 }
24 24
25 // Enum for UMA purposes, make sure you update histograms.xml if you
26 // add new pemissions.
27 enum PermissionType {
28 PERMISSION_UNKNOWN,
29 PERMISSION_MIDI_SYSEX,
30 PERMISSION_PUSH_MESSAGING,
31
32 // Always keep this at the end.
33 PERMISSION_NUM,
34 };
35
25 typedef base::Callback<void(bool)> BrowserPermissionCallback; 36 typedef base::Callback<void(bool)> BrowserPermissionCallback;
26 37
27 // This base class contains common operations for granting permissions. 38 // This base class contains common operations for granting permissions.
28 // It offers the following functionality: 39 // It offers the following functionality:
29 // - Creates a bubble or infobar when a permission is needed 40 // - Creates a bubble or infobar when a permission is needed
30 // - If accepted/denied the permission is saved in content settings for 41 // - If accepted/denied the permission is saved in content settings for
31 // future uses (for the domain that requested it). 42 // future uses (for the domain that requested it).
32 // - If dismissed the permission is not saved but it's considered denied for 43 // - If dismissed the permission is not saved but it's considered denied for
33 // this one request 44 // this one request
34 // - In any case the BrowserPermissionCallback is executed once a decision 45 // - In any case the BrowserPermissionCallback is executed once a decision
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 const GURL& requesting_origin, 83 const GURL& requesting_origin,
73 const GURL& embedder_origin, 84 const GURL& embedder_origin,
74 bool user_gesture, 85 bool user_gesture,
75 const BrowserPermissionCallback& callback); 86 const BrowserPermissionCallback& callback);
76 87
77 // Called when permission is granted without interactively asking the user. 88 // Called when permission is granted without interactively asking the user.
78 void PermissionDecided(const PermissionRequestID& id, 89 void PermissionDecided(const PermissionRequestID& id,
79 const GURL& requesting_origin, 90 const GURL& requesting_origin,
80 const GURL& embedder_origin, 91 const GURL& embedder_origin,
81 const BrowserPermissionCallback& callback, 92 const BrowserPermissionCallback& callback,
93 bool persist,
82 bool allowed); 94 bool allowed);
83 95
84 void NotifyPermissionSet(const PermissionRequestID& id, 96 void NotifyPermissionSet(const PermissionRequestID& id,
85 const GURL& requesting_origin, 97 const GURL& requesting_origin,
86 const GURL& embedder_origin, 98 const GURL& embedder_origin,
87 const BrowserPermissionCallback& callback, 99 const BrowserPermissionCallback& callback,
88 bool persist, 100 bool persist,
89 bool allowed); 101 bool allowed);
90 102
91 // Implementors can override this method to update the icons on the 103 // Implementors can override this method to update the icons on the
92 // url bar with the result of the new permission. 104 // url bar with the result of the new permission.
93 virtual void UpdateTabContext(const PermissionRequestID& id, 105 virtual void UpdateTabContext(const PermissionRequestID& id,
94 const GURL& requesting_origin, 106 const GURL& requesting_origin,
95 bool allowed) {} 107 bool allowed) {}
96 108
97 // Return an instance of the infobar queue controller, creating it if needed. 109 // Return an instance of the infobar queue controller, creating it if needed.
98 PermissionQueueController* GetQueueController(); 110 PermissionQueueController* GetQueueController();
99 111
100 private: 112 private:
113 static PermissionType SettingToPermission(ContentSettingsType permission);
Bernhard Bauer 2014/07/08 12:54:52 If this method is static and private, do you need
Miguel Garcia 2014/07/08 14:14:20 Sure, it does not need to be a method, it cans jus
101 void UpdateContentSetting( 114 void UpdateContentSetting(
102 const GURL& requesting_origin, 115 const GURL& requesting_origin,
103 const GURL& embedder_origin, 116 const GURL& embedder_origin,
104 bool allowed); 117 bool allowed);
105 118
106 // Called when a bubble is no longer used so it can be cleaned up. 119 // Called when a bubble is no longer used so it can be cleaned up.
107 void CleanUpBubble(const PermissionRequestID& id); 120 void CleanUpBubble(const PermissionRequestID& id);
108 121
109 Profile* profile_; 122 Profile* profile_;
110 const ContentSettingsType permission_type_; 123 const ContentSettingsType permission_type_;
111 base::WeakPtrFactory<PermissionContextBase> weak_factory_; 124 base::WeakPtrFactory<PermissionContextBase> weak_factory_;
112 scoped_ptr<PermissionQueueController> permission_queue_controller_; 125 scoped_ptr<PermissionQueueController> permission_queue_controller_;
113 base::ScopedPtrHashMap<std::string, PermissionBubbleRequest> 126 base::ScopedPtrHashMap<std::string, PermissionBubbleRequest>
114 pending_bubbles_; 127 pending_bubbles_;
115 }; 128 };
116 129
117 #endif // CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_ 130 #endif // CHROME_BROWSER_CONTENT_SETTINGS_PERMISSION_CONTEXT_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698