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

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: Rebase on top of other change Created 5 years, 4 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 PendingCallbackVector = ScopedVector<blink::WebPermissionCallback>; 89 using PendingCallbackVector = ScopedVector<blink::WebPermissionCallback>;
90 using PendingBatchCallbackVector =
91 ScopedVector<blink::WebPermissionsCallback>;
81 92
82 // Runs the given |callback| with |status| as a parameter. It has to be run 93 // Runs the given |callback| with |status| as a parameter. It has to be run
83 // on a worker thread. 94 // on a worker thread.
84 static void RunCallbackOnWorkerThread( 95 static void RunCallbackOnWorkerThread(
85 blink::WebPermissionCallback* callback, 96 blink::WebPermissionCallback* callback,
86 scoped_ptr<blink::WebPermissionStatus> status); 97 scoped_ptr<blink::WebPermissionStatus> status);
98 static void RunMultiCallbackOnWorkerThread(
99 blink::WebPermissionsCallback* callback,
100 scoped_ptr<blink::WebVector<blink::WebPermissionStatus>> statuses);
87 101
88 // Helper method that returns an initialized PermissionServicePtr. 102 // Helper method that returns an initialized PermissionServicePtr.
89 PermissionServicePtr& GetPermissionServicePtr(); 103 PermissionServicePtr& GetPermissionServicePtr();
90 104
91 void QueryPermissionInternal(blink::WebPermissionType type, 105 void QueryPermissionInternal(blink::WebPermissionType type,
92 const std::string& origin, 106 const std::string& origin,
93 blink::WebPermissionCallback* callback, 107 blink::WebPermissionCallback* callback,
94 int worker_thread_id); 108 int worker_thread_id);
95 void RequestPermissionInternal(blink::WebPermissionType type, 109 void RequestPermissionInternal(blink::WebPermissionType type,
96 const std::string& origin, 110 const std::string& origin,
97 blink::WebPermissionCallback* callback, 111 blink::WebPermissionCallback* callback,
98 int worker_thread_id); 112 int worker_thread_id);
113 void RequestPermissionsInternal(
114 const blink::WebVector<blink::WebPermissionType>& types,
115 const std::string& origin,
116 blink::WebPermissionsCallback* callback,
117 int worker_thread_id);
99 void RevokePermissionInternal(blink::WebPermissionType type, 118 void RevokePermissionInternal(blink::WebPermissionType type,
100 const std::string& origin, 119 const std::string& origin,
101 blink::WebPermissionCallback* callback, 120 blink::WebPermissionCallback* callback,
102 int worker_thread_id); 121 int worker_thread_id);
103 122
104 // This is the callback function used for query, request and revoke. 123 // This is the callback function used for query, request and revoke.
105 void OnPermissionResponse(int worker_thread_id, 124 void OnPermissionResponse(int worker_thread_id,
106 PendingCallbackVector::iterator callback_iterator, 125 PendingCallbackVector::iterator callback_iterator,
107 PermissionStatus status); 126 PermissionStatus status);
127 void OnPermissionsResponse(
128 int worker_thread_id,
129 PendingBatchCallbackVector::iterator callback_iterator,
130 const mojo::Array<PermissionStatus>& status);
108 void OnPermissionChanged(blink::WebPermissionType type, 131 void OnPermissionChanged(blink::WebPermissionType type,
109 const std::string& origin, 132 const std::string& origin,
110 blink::WebPermissionObserver* observer, 133 blink::WebPermissionObserver* observer,
111 PermissionStatus status); 134 PermissionStatus status);
112 void OnPermissionChangedForWorker( 135 void OnPermissionChangedForWorker(
113 int worker_thread_id, 136 int worker_thread_id,
114 const base::Callback<void(blink::WebPermissionStatus)>& callback, 137 const base::Callback<void(blink::WebPermissionStatus)>& callback,
115 PermissionStatus status); 138 PermissionStatus status);
116 139
117 void GetNextPermissionChange(blink::WebPermissionType type, 140 void GetNextPermissionChange(blink::WebPermissionType type,
118 const std::string& origin, 141 const std::string& origin,
119 blink::WebPermissionObserver* observer, 142 blink::WebPermissionObserver* observer,
120 PermissionStatus current_status); 143 PermissionStatus current_status);
121 144
122 PendingCallbackVector pending_callbacks_; 145 PendingCallbackVector pending_callbacks_;
146 PendingBatchCallbackVector batch_pending_callbacks_;
123 147
124 ServiceRegistry* service_registry_; 148 ServiceRegistry* service_registry_;
125 PermissionServicePtr permission_service_; 149 PermissionServicePtr permission_service_;
126 150
127 DISALLOW_COPY_AND_ASSIGN(PermissionDispatcher); 151 DISALLOW_COPY_AND_ASSIGN(PermissionDispatcher);
128 }; 152 };
129 153
130 } // namespace content 154 } // namespace content
131 155
132 #endif // CONTENT_CHILD_PERMISSIONS_PERMISSION_DISPATCHER_H_ 156 #endif // CONTENT_CHILD_PERMISSIONS_PERMISSION_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698