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

Powered by Google App Engine
This is Rietveld 408576698