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

Side by Side Diff: content/child/permissions/permission_dispatcher.h

Issue 1260193009: renderer: implement multiple permission requesting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@permissions-request-multiple
Patch Set: Fix review comments Created 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 CONTENT_CHILD_PERMISSIONS_PERMISSION_DISPATCHER_H_ 5 #ifndef CONTENT_CHILD_PERMISSIONS_PERMISSION_DISPATCHER_H_
6 #define CONTENT_CHILD_PERMISSIONS_PERMISSION_DISPATCHER_H_ 6 #define CONTENT_CHILD_PERMISSIONS_PERMISSION_DISPATCHER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
(...skipping 25 matching lines...) Expand all
36 explicit PermissionDispatcher(ServiceRegistry* service_registry); 36 explicit PermissionDispatcher(ServiceRegistry* service_registry);
37 virtual ~PermissionDispatcher(); 37 virtual ~PermissionDispatcher();
38 38
39 // blink::WebPermissionClient implementation. 39 // blink::WebPermissionClient implementation.
40 virtual void queryPermission(blink::WebPermissionType type, 40 virtual void queryPermission(blink::WebPermissionType type,
41 const blink::WebURL& origin, 41 const blink::WebURL& origin,
42 blink::WebPermissionCallback* callback); 42 blink::WebPermissionCallback* callback);
43 virtual void requestPermission(blink::WebPermissionType, 43 virtual void requestPermission(blink::WebPermissionType,
44 const blink::WebURL& origin, 44 const blink::WebURL& origin,
45 blink::WebPermissionCallback* callback); 45 blink::WebPermissionCallback* callback);
46 virtual void requestPermissions(
47 const blink::WebVector<blink::WebPermissionType>& types,
48 const blink::WebURL& origin,
49 blink::WebPermissionsCallback* callback);
46 virtual void revokePermission(blink::WebPermissionType, 50 virtual void revokePermission(blink::WebPermissionType,
47 const blink::WebURL& origin, 51 const blink::WebURL& origin,
48 blink::WebPermissionCallback* callback); 52 blink::WebPermissionCallback* callback);
49 virtual void startListening(blink::WebPermissionType type, 53 virtual void startListening(blink::WebPermissionType type,
50 const blink::WebURL& origin, 54 const blink::WebURL& origin,
51 blink::WebPermissionObserver* observer); 55 blink::WebPermissionObserver* observer);
52 virtual void stopListening(blink::WebPermissionObserver* observer); 56 virtual void stopListening(blink::WebPermissionObserver* observer);
53 57
54 // The following methods must be called by workers on the main thread. 58 // The following methods must be called by workers on the main thread.
55 void QueryPermissionForWorker(blink::WebPermissionType type, 59 void QueryPermissionForWorker(blink::WebPermissionType type,
56 const std::string& origin, 60 const std::string& origin,
57 blink::WebPermissionCallback* callback, 61 blink::WebPermissionCallback* callback,
58 int worker_thread_id); 62 int worker_thread_id);
59 void RequestPermissionForWorker(blink::WebPermissionType type, 63 void RequestPermissionForWorker(blink::WebPermissionType type,
60 const std::string& origin, 64 const std::string& origin,
61 blink::WebPermissionCallback* callback, 65 blink::WebPermissionCallback* callback,
62 int worker_thread_id); 66 int worker_thread_id);
67 void RequestPermissionsForWorker(
68 const blink::WebVector<blink::WebPermissionType>& types,
69 const std::string& origin,
70 blink::WebPermissionsCallback* callback,
71 int worker_thread_id);
63 void RevokePermissionForWorker(blink::WebPermissionType type, 72 void RevokePermissionForWorker(blink::WebPermissionType type,
64 const std::string& origin, 73 const std::string& origin,
65 blink::WebPermissionCallback* callback, 74 blink::WebPermissionCallback* callback,
66 int worker_thread_id); 75 int worker_thread_id);
67 void StartListeningForWorker( 76 void StartListeningForWorker(
68 blink::WebPermissionType type, 77 blink::WebPermissionType type,
69 const std::string& origin, 78 const std::string& origin,
70 int worker_thread_id, 79 int worker_thread_id,
71 const base::Callback<void(blink::WebPermissionStatus)>& callback); 80 const base::Callback<void(blink::WebPermissionStatus)>& callback);
72 void GetNextPermissionChangeForWorker( 81 void GetNextPermissionChangeForWorker(
73 blink::WebPermissionType type, 82 blink::WebPermissionType type,
74 const std::string& origin, 83 const std::string& origin,
75 blink::WebPermissionStatus status, 84 blink::WebPermissionStatus status,
76 int worker_thread_id, 85 int worker_thread_id,
77 const base::Callback<void(blink::WebPermissionStatus)>& callback); 86 const base::Callback<void(blink::WebPermissionStatus)>& callback);
78 87
79 private: 88 private:
80 using PendingCallbackMap = 89 using PendingCallbackMap =
81 base::ScopedPtrHashMap<uintptr_t, 90 base::ScopedPtrHashMap<uintptr_t,
82 scoped_ptr<blink::WebPermissionCallback>>; 91 scoped_ptr<blink::WebPermissionCallback>>;
92 using PendingBatchCallbackMap =
mlamouri (slow - plz ping) 2015/09/02 11:36:41 Name-wise, what about: PermissionCallbackMap and P
Lalit Maganti 2015/09/02 14:24:50 Done.
93 base::ScopedPtrHashMap<uintptr_t,
94 scoped_ptr<blink::WebPermissionsCallback>>;
83 95
84 // Runs the given |callback| with |status| as a parameter. It has to be run 96 // Runs the given |callback| with |status| as a parameter. It has to be run
85 // on a worker thread. 97 // on a worker thread.
86 static void RunCallbackOnWorkerThread( 98 static void RunCallbackOnWorkerThread(
mlamouri (slow - plz ping) 2015/09/02 11:36:41 Rename to RunPermissionCallbackOnWorkerThread?
Lalit Maganti 2015/09/02 14:24:50 Done.
87 blink::WebPermissionCallback* callback, 99 blink::WebPermissionCallback* callback,
88 scoped_ptr<blink::WebPermissionStatus> status); 100 scoped_ptr<blink::WebPermissionStatus> status);
101 static void RunMultiCallbackOnWorkerThread(
mlamouri (slow - plz ping) 2015/09/02 11:36:41 RunPermissionsCallbackOnWorkerThread?
Lalit Maganti 2015/09/02 14:24:50 Done.
102 blink::WebPermissionsCallback* callback,
103 scoped_ptr<blink::WebVector<blink::WebPermissionStatus>> statuses);
89 104
90 // Helper method that returns an initialized PermissionServicePtr. 105 // Helper method that returns an initialized PermissionServicePtr.
91 PermissionServicePtr& GetPermissionServicePtr(); 106 PermissionServicePtr& GetPermissionServicePtr();
92 107
93 void QueryPermissionInternal(blink::WebPermissionType type, 108 void QueryPermissionInternal(blink::WebPermissionType type,
94 const std::string& origin, 109 const std::string& origin,
95 blink::WebPermissionCallback* callback, 110 blink::WebPermissionCallback* callback,
96 int worker_thread_id); 111 int worker_thread_id);
97 void RequestPermissionInternal(blink::WebPermissionType type, 112 void RequestPermissionInternal(blink::WebPermissionType type,
98 const std::string& origin, 113 const std::string& origin,
99 blink::WebPermissionCallback* callback, 114 blink::WebPermissionCallback* callback,
100 int worker_thread_id); 115 int worker_thread_id);
116 void RequestPermissionsInternal(
117 const blink::WebVector<blink::WebPermissionType>& types,
118 const std::string& origin,
119 blink::WebPermissionsCallback* callback,
120 int worker_thread_id);
101 void RevokePermissionInternal(blink::WebPermissionType type, 121 void RevokePermissionInternal(blink::WebPermissionType type,
102 const std::string& origin, 122 const std::string& origin,
103 blink::WebPermissionCallback* callback, 123 blink::WebPermissionCallback* callback,
104 int worker_thread_id); 124 int worker_thread_id);
105 125
106 // This is the callback function used for query, request and revoke. 126 // This is the callback function used for query, request and revoke.
107 void OnPermissionResponse(int worker_thread_id, 127 void OnPermissionResponse(int worker_thread_id,
108 uintptr_t callback_key, 128 uintptr_t callback_key,
109 PermissionStatus status); 129 PermissionStatus status);
130 void OnPermissionsResponse(int worker_thread_id,
mlamouri (slow - plz ping) 2015/09/02 11:36:41 Rename OnRequestPermissionsResponse()
Lalit Maganti 2015/09/02 14:24:50 Done.
131 uintptr_t callback_key,
132 const mojo::Array<PermissionStatus>& status);
110 void OnPermissionChanged(blink::WebPermissionType type, 133 void OnPermissionChanged(blink::WebPermissionType type,
111 const std::string& origin, 134 const std::string& origin,
112 blink::WebPermissionObserver* observer, 135 blink::WebPermissionObserver* observer,
113 PermissionStatus status); 136 PermissionStatus status);
114 void OnPermissionChangedForWorker( 137 void OnPermissionChangedForWorker(
115 int worker_thread_id, 138 int worker_thread_id,
116 const base::Callback<void(blink::WebPermissionStatus)>& callback, 139 const base::Callback<void(blink::WebPermissionStatus)>& callback,
117 PermissionStatus status); 140 PermissionStatus status);
118 141
119 void GetNextPermissionChange(blink::WebPermissionType type, 142 void GetNextPermissionChange(blink::WebPermissionType type,
120 const std::string& origin, 143 const std::string& origin,
121 blink::WebPermissionObserver* observer, 144 blink::WebPermissionObserver* observer,
122 PermissionStatus current_status); 145 PermissionStatus current_status);
123 146
124 PendingCallbackMap pending_callbacks_; 147 PendingCallbackMap pending_callbacks_;
148 PendingBatchCallbackMap batch_pending_callbacks_;
mlamouri (slow - plz ping) 2015/09/02 11:36:41 // Pending callbacks for query(), revoke() and req
Lalit Maganti 2015/09/02 14:24:50 Done.
125 149
126 ServiceRegistry* service_registry_; 150 ServiceRegistry* service_registry_;
127 PermissionServicePtr permission_service_; 151 PermissionServicePtr permission_service_;
128 152
129 DISALLOW_COPY_AND_ASSIGN(PermissionDispatcher); 153 DISALLOW_COPY_AND_ASSIGN(PermissionDispatcher);
130 }; 154 };
131 155
132 } // namespace content 156 } // namespace content
133 157
134 #endif // CONTENT_CHILD_PERMISSIONS_PERMISSION_DISPATCHER_H_ 158 #endif // CONTENT_CHILD_PERMISSIONS_PERMISSION_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698