OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/pepper_flash_settings_manager.h" | 5 #include "chrome/browser/pepper_flash_settings_manager.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 : public IPC::Channel::Listener, | 33 : public IPC::Channel::Listener, |
34 public base::RefCountedThreadSafe<Core, BrowserThread::DeleteOnIOThread> { | 34 public base::RefCountedThreadSafe<Core, BrowserThread::DeleteOnIOThread> { |
35 public: | 35 public: |
36 Core(PepperFlashSettingsManager* manager, | 36 Core(PepperFlashSettingsManager* manager, |
37 content::BrowserContext* browser_context); | 37 content::BrowserContext* browser_context); |
38 | 38 |
39 // Stops sending notifications to |manager_| and sets it to NULL. | 39 // Stops sending notifications to |manager_| and sets it to NULL. |
40 void Detach(); | 40 void Detach(); |
41 | 41 |
42 void DeauthorizeContentLicenses(uint32 request_id); | 42 void DeauthorizeContentLicenses(uint32 request_id); |
| 43 void GetPermissionSettings( |
| 44 uint32 request_id, |
| 45 PP_Flash_BrowserOperations_SettingType setting_type); |
| 46 void SetDefaultPermission( |
| 47 uint32 request_id, |
| 48 PP_Flash_BrowserOperations_SettingType setting_type, |
| 49 PP_Flash_BrowserOperations_Permission permission, |
| 50 bool clear_site_specific); |
| 51 void SetSitePermission(uint32 request_id, |
| 52 PP_Flash_BrowserOperations_SettingType setting_type, |
| 53 const ppapi::FlashSiteSettings& sites); |
43 | 54 |
44 // IPC::Channel::Listener implementation. | 55 // IPC::Channel::Listener implementation. |
45 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 56 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
46 virtual void OnChannelError() OVERRIDE; | 57 virtual void OnChannelError() OVERRIDE; |
47 | 58 |
48 private: | 59 private: |
49 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; | 60 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; |
50 friend class base::DeleteHelper<Core>; | 61 friend class base::DeleteHelper<Core>; |
51 | 62 |
52 enum RequestType { | 63 enum RequestType { |
53 INVALID_REQUEST_TYPE = 0, | 64 INVALID_REQUEST_TYPE = 0, |
54 DEAUTHORIZE_CONTENT_LICENSES | 65 DEAUTHORIZE_CONTENT_LICENSES, |
| 66 GET_PERMISSION_SETTINGS, |
| 67 SET_DEFAULT_PERMISSION, |
| 68 SET_SITE_PERMISSION |
55 }; | 69 }; |
56 | 70 |
57 struct PendingRequest { | 71 struct PendingRequest { |
58 PendingRequest() : id(0), type(INVALID_REQUEST_TYPE) {} | 72 PendingRequest() |
| 73 : id(0), |
| 74 type(INVALID_REQUEST_TYPE), |
| 75 setting_type(PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC), |
| 76 permission(PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT), |
| 77 clear_site_specific(false) { |
| 78 } |
59 | 79 |
60 uint32 id; | 80 uint32 id; |
61 RequestType type; | 81 RequestType type; |
| 82 |
| 83 // Used by GET_PERMISSION_SETTINGS, SET_DEFAULT_PERMISSION and |
| 84 // SET_SITE_PERMISSION. |
| 85 PP_Flash_BrowserOperations_SettingType setting_type; |
| 86 |
| 87 // Used by SET_DEFAULT_PERMISSION. |
| 88 PP_Flash_BrowserOperations_Permission permission; |
| 89 bool clear_site_specific; |
| 90 |
| 91 // Used by SET_SITE_PERMISSION. |
| 92 ppapi::FlashSiteSettings sites; |
62 }; | 93 }; |
63 | 94 |
64 virtual ~Core(); | 95 virtual ~Core(); |
65 | 96 |
66 void Initialize(); | 97 void Initialize(); |
67 void ConnectToChannel(bool success, const IPC::ChannelHandle& handle); | 98 void ConnectToChannel(bool success, const IPC::ChannelHandle& handle); |
68 | 99 |
69 void DeauthorizeContentLicensesOnIOThread(uint32 request_id); | 100 void DeauthorizeContentLicensesOnIOThread(uint32 request_id); |
| 101 void GetPermissionSettingsOnIOThread( |
| 102 uint32 request_id, |
| 103 PP_Flash_BrowserOperations_SettingType setting_type); |
| 104 void SetDefaultPermissionOnIOThread( |
| 105 uint32 request_id, |
| 106 PP_Flash_BrowserOperations_SettingType setting_type, |
| 107 PP_Flash_BrowserOperations_Permission permission, |
| 108 bool clear_site_specific); |
| 109 void SetSitePermissionOnIOThread( |
| 110 uint32 request_id, |
| 111 PP_Flash_BrowserOperations_SettingType setting_type, |
| 112 const ppapi::FlashSiteSettings& sites); |
| 113 |
70 void NotifyErrorFromIOThread(); | 114 void NotifyErrorFromIOThread(); |
71 | 115 |
72 void NotifyDeauthorizeContentLicensesCompleted(uint32 request_id, | 116 void NotifyDeauthorizeContentLicensesCompleted(uint32 request_id, |
73 bool success); | 117 bool success); |
| 118 void NotifyGetPermissionSettingsCompleted( |
| 119 uint32 request_id, |
| 120 bool success, |
| 121 PP_Flash_BrowserOperations_Permission default_permission, |
| 122 const ppapi::FlashSiteSettings& sites); |
| 123 void NotifySetDefaultPermissionCompleted(uint32 request_id, bool success); |
| 124 void NotifySetSitePermissionCompleted(uint32 request_id, bool success); |
| 125 |
74 void NotifyError( | 126 void NotifyError( |
75 const std::vector<std::pair<uint32, RequestType> >& notifications); | 127 const std::vector<std::pair<uint32, RequestType> >& notifications); |
76 | 128 |
77 // Message handlers. | 129 // Message handlers. |
78 void OnDeauthorizeContentLicensesResult(uint32 request_id, bool success); | 130 void OnDeauthorizeContentLicensesResult(uint32 request_id, bool success); |
| 131 void OnGetPermissionSettingsResult( |
| 132 uint32 request_id, |
| 133 bool success, |
| 134 PP_Flash_BrowserOperations_Permission default_permission, |
| 135 const ppapi::FlashSiteSettings& sites); |
| 136 void OnSetDefaultPermissionResult(uint32 request_id, bool success); |
| 137 void OnSetSitePermissionResult(uint32 request_id, bool success); |
79 | 138 |
80 // Used only on the UI thread. | 139 // Used only on the UI thread. |
81 PepperFlashSettingsManager* manager_; | 140 PepperFlashSettingsManager* manager_; |
82 | 141 |
83 // Used only on the I/O thread. | 142 // Used only on the I/O thread. |
84 FilePath plugin_data_path_; | 143 FilePath plugin_data_path_; |
85 | 144 |
86 // The channel is NULL until we have opened a connection to the broker | 145 // The channel is NULL until we have opened a connection to the broker |
87 // process. Used only on the I/O thread. | 146 // process. Used only on the I/O thread. |
88 scoped_ptr<IPC::Channel> channel_; | 147 scoped_ptr<IPC::Channel> channel_; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 void PepperFlashSettingsManager::Core::DeauthorizeContentLicenses( | 192 void PepperFlashSettingsManager::Core::DeauthorizeContentLicenses( |
134 uint32 request_id) { | 193 uint32 request_id) { |
135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
136 | 195 |
137 BrowserThread::PostTask( | 196 BrowserThread::PostTask( |
138 BrowserThread::IO, FROM_HERE, | 197 BrowserThread::IO, FROM_HERE, |
139 base::Bind(&Core::DeauthorizeContentLicensesOnIOThread, this, | 198 base::Bind(&Core::DeauthorizeContentLicensesOnIOThread, this, |
140 request_id)); | 199 request_id)); |
141 } | 200 } |
142 | 201 |
| 202 void PepperFlashSettingsManager::Core::GetPermissionSettings( |
| 203 uint32 request_id, |
| 204 PP_Flash_BrowserOperations_SettingType setting_type) { |
| 205 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 206 |
| 207 BrowserThread::PostTask( |
| 208 BrowserThread::IO, FROM_HERE, |
| 209 base::Bind(&Core::GetPermissionSettingsOnIOThread, this, request_id, |
| 210 setting_type)); |
| 211 } |
| 212 |
| 213 void PepperFlashSettingsManager::Core::SetDefaultPermission( |
| 214 uint32 request_id, |
| 215 PP_Flash_BrowserOperations_SettingType setting_type, |
| 216 PP_Flash_BrowserOperations_Permission permission, |
| 217 bool clear_site_specific) { |
| 218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 219 |
| 220 BrowserThread::PostTask( |
| 221 BrowserThread::IO, FROM_HERE, |
| 222 base::Bind(&Core::SetDefaultPermissionOnIOThread, this, request_id, |
| 223 setting_type, permission, clear_site_specific)); |
| 224 } |
| 225 |
| 226 void PepperFlashSettingsManager::Core::SetSitePermission( |
| 227 uint32 request_id, |
| 228 PP_Flash_BrowserOperations_SettingType setting_type, |
| 229 const ppapi::FlashSiteSettings& sites) { |
| 230 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 231 |
| 232 BrowserThread::PostTask( |
| 233 BrowserThread::IO, FROM_HERE, |
| 234 base::Bind(&Core::SetSitePermissionOnIOThread, this, request_id, |
| 235 setting_type, sites)); |
| 236 } |
| 237 |
143 bool PepperFlashSettingsManager::Core::OnMessageReceived( | 238 bool PepperFlashSettingsManager::Core::OnMessageReceived( |
144 const IPC::Message& message) { | 239 const IPC::Message& message) { |
145 IPC_BEGIN_MESSAGE_MAP(Core, message) | 240 IPC_BEGIN_MESSAGE_MAP(Core, message) |
146 IPC_MESSAGE_HANDLER(PpapiHostMsg_DeauthorizeContentLicensesResult, | 241 IPC_MESSAGE_HANDLER(PpapiHostMsg_DeauthorizeContentLicensesResult, |
147 OnDeauthorizeContentLicensesResult) | 242 OnDeauthorizeContentLicensesResult) |
| 243 IPC_MESSAGE_HANDLER(PpapiHostMsg_GetPermissionSettingsResult, |
| 244 OnGetPermissionSettingsResult) |
| 245 IPC_MESSAGE_HANDLER(PpapiHostMsg_SetDefaultPermissionResult, |
| 246 OnSetDefaultPermissionResult) |
| 247 IPC_MESSAGE_HANDLER(PpapiHostMsg_SetSitePermissionResult, |
| 248 OnSetSitePermissionResult) |
148 IPC_MESSAGE_UNHANDLED_ERROR() | 249 IPC_MESSAGE_UNHANDLED_ERROR() |
149 IPC_END_MESSAGE_MAP() | 250 IPC_END_MESSAGE_MAP() |
150 | 251 |
151 return true; | 252 return true; |
152 } | 253 } |
153 | 254 |
154 void PepperFlashSettingsManager::Core::OnChannelError() { | 255 void PepperFlashSettingsManager::Core::OnChannelError() { |
155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 256 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
156 | 257 |
157 NotifyErrorFromIOThread(); | 258 NotifyErrorFromIOThread(); |
(...skipping 25 matching lines...) Expand all Loading... |
183 } | 284 } |
184 | 285 |
185 void PepperFlashSettingsManager::Core::ConnectToChannel( | 286 void PepperFlashSettingsManager::Core::ConnectToChannel( |
186 bool success, | 287 bool success, |
187 const IPC::ChannelHandle& handle) { | 288 const IPC::ChannelHandle& handle) { |
188 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 289 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
189 DCHECK(!initialized_); | 290 DCHECK(!initialized_); |
190 DCHECK(!channel_.get()); | 291 DCHECK(!channel_.get()); |
191 | 292 |
192 if (!success) { | 293 if (!success) { |
193 LOG(ERROR) << "Couldn't open plugin channel"; | 294 DLOG(ERROR) << "Couldn't open plugin channel"; |
194 NotifyErrorFromIOThread(); | 295 NotifyErrorFromIOThread(); |
195 return; | 296 return; |
196 } | 297 } |
197 | 298 |
198 channel_.reset(new IPC::Channel(handle, IPC::Channel::MODE_CLIENT, this)); | 299 channel_.reset(new IPC::Channel(handle, IPC::Channel::MODE_CLIENT, this)); |
199 if (!channel_->Connect()) { | 300 if (!channel_->Connect()) { |
200 LOG(ERROR) << "Couldn't connect to plugin"; | 301 DLOG(ERROR) << "Couldn't connect to plugin"; |
201 NotifyErrorFromIOThread(); | 302 NotifyErrorFromIOThread(); |
202 return; | 303 return; |
203 } | 304 } |
204 | 305 |
205 initialized_ = true; | 306 initialized_ = true; |
206 | 307 |
207 std::vector<PendingRequest> temp_pending_requests; | 308 std::vector<PendingRequest> temp_pending_requests; |
208 temp_pending_requests.swap(pending_requests_); | 309 temp_pending_requests.swap(pending_requests_); |
209 for (std::vector<PendingRequest>::iterator iter = | 310 for (std::vector<PendingRequest>::iterator iter = |
210 temp_pending_requests.begin(); | 311 temp_pending_requests.begin(); |
211 iter != temp_pending_requests.end(); ++iter) { | 312 iter != temp_pending_requests.end(); ++iter) { |
212 switch (iter->type) { | 313 switch (iter->type) { |
213 case DEAUTHORIZE_CONTENT_LICENSES: | 314 case DEAUTHORIZE_CONTENT_LICENSES: |
214 DeauthorizeContentLicensesOnIOThread(iter->id); | 315 DeauthorizeContentLicensesOnIOThread(iter->id); |
215 break; | 316 break; |
| 317 case GET_PERMISSION_SETTINGS: |
| 318 GetPermissionSettingsOnIOThread(iter->id, iter->setting_type); |
| 319 break; |
| 320 case SET_DEFAULT_PERMISSION: |
| 321 SetDefaultPermissionOnIOThread( |
| 322 iter->id, iter->setting_type, iter->permission, |
| 323 iter->clear_site_specific); |
| 324 break; |
| 325 case SET_SITE_PERMISSION: |
| 326 SetSitePermissionOnIOThread(iter->id, iter->setting_type, iter->sites); |
| 327 break; |
216 default: | 328 default: |
217 NOTREACHED(); | 329 NOTREACHED(); |
218 break; | 330 break; |
219 } | 331 } |
220 } | 332 } |
221 } | 333 } |
222 | 334 |
223 void PepperFlashSettingsManager::Core::DeauthorizeContentLicensesOnIOThread( | 335 void PepperFlashSettingsManager::Core::DeauthorizeContentLicensesOnIOThread( |
224 uint32 request_id) { | 336 uint32 request_id) { |
225 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 337 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
226 | 338 |
227 if (!initialized_) { | 339 if (!initialized_) { |
228 PendingRequest request; | 340 PendingRequest request; |
229 request.id = request_id; | 341 request.id = request_id; |
230 request.type = DEAUTHORIZE_CONTENT_LICENSES; | 342 request.type = DEAUTHORIZE_CONTENT_LICENSES; |
231 pending_requests_.push_back(request); | 343 pending_requests_.push_back(request); |
232 return; | 344 return; |
233 } | 345 } |
234 | 346 |
235 pending_responses_.insert( | 347 pending_responses_.insert( |
236 std::make_pair(request_id, DEAUTHORIZE_CONTENT_LICENSES)); | 348 std::make_pair(request_id, DEAUTHORIZE_CONTENT_LICENSES)); |
237 IPC::Message* msg = | 349 IPC::Message* msg = |
238 new PpapiMsg_DeauthorizeContentLicenses(request_id, plugin_data_path_); | 350 new PpapiMsg_DeauthorizeContentLicenses(request_id, plugin_data_path_); |
239 if (!channel_->Send(msg)) { | 351 if (!channel_->Send(msg)) { |
240 LOG(ERROR) << "Couldn't send DeauthorizeContentLicenses message"; | 352 DLOG(ERROR) << "Couldn't send DeauthorizeContentLicenses message"; |
241 // A failure notification for the current request will be sent since | 353 // A failure notification for the current request will be sent since |
242 // |pending_responses_| has been updated. | 354 // |pending_responses_| has been updated. |
243 NotifyErrorFromIOThread(); | 355 NotifyErrorFromIOThread(); |
| 356 } |
| 357 } |
| 358 |
| 359 void PepperFlashSettingsManager::Core::GetPermissionSettingsOnIOThread( |
| 360 uint32 request_id, |
| 361 PP_Flash_BrowserOperations_SettingType setting_type) { |
| 362 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 363 |
| 364 if (!initialized_) { |
| 365 PendingRequest request; |
| 366 request.id = request_id; |
| 367 request.type = GET_PERMISSION_SETTINGS; |
| 368 request.setting_type = setting_type; |
| 369 pending_requests_.push_back(request); |
| 370 return; |
| 371 } |
| 372 |
| 373 pending_responses_.insert( |
| 374 std::make_pair(request_id, GET_PERMISSION_SETTINGS)); |
| 375 IPC::Message* msg = new PpapiMsg_GetPermissionSettings( |
| 376 request_id, plugin_data_path_, setting_type); |
| 377 if (!channel_->Send(msg)) { |
| 378 DLOG(ERROR) << "Couldn't send GetPermissionSettings message"; |
| 379 // A failure notification for the current request will be sent since |
| 380 // |pending_responses_| has been updated. |
| 381 NotifyErrorFromIOThread(); |
| 382 } |
| 383 } |
| 384 |
| 385 void PepperFlashSettingsManager::Core::SetDefaultPermissionOnIOThread( |
| 386 uint32 request_id, |
| 387 PP_Flash_BrowserOperations_SettingType setting_type, |
| 388 PP_Flash_BrowserOperations_Permission permission, |
| 389 bool clear_site_specific) { |
| 390 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 391 |
| 392 if (!initialized_) { |
| 393 PendingRequest request; |
| 394 request.id = request_id; |
| 395 request.type = SET_DEFAULT_PERMISSION; |
| 396 request.setting_type = setting_type; |
| 397 request.permission = permission; |
| 398 request.clear_site_specific = clear_site_specific; |
| 399 pending_requests_.push_back(request); |
| 400 return; |
| 401 } |
| 402 |
| 403 pending_responses_.insert(std::make_pair(request_id, SET_DEFAULT_PERMISSION)); |
| 404 IPC::Message* msg = new PpapiMsg_SetDefaultPermission( |
| 405 request_id, plugin_data_path_, setting_type, permission, |
| 406 clear_site_specific); |
| 407 if (!channel_->Send(msg)) { |
| 408 DLOG(ERROR) << "Couldn't send SetDefaultPermission message"; |
| 409 // A failure notification for the current request will be sent since |
| 410 // |pending_responses_| has been updated. |
| 411 NotifyErrorFromIOThread(); |
| 412 } |
| 413 } |
| 414 |
| 415 void PepperFlashSettingsManager::Core::SetSitePermissionOnIOThread( |
| 416 uint32 request_id, |
| 417 PP_Flash_BrowserOperations_SettingType setting_type, |
| 418 const ppapi::FlashSiteSettings& sites) { |
| 419 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 420 |
| 421 if (!initialized_) { |
| 422 pending_requests_.push_back(PendingRequest()); |
| 423 PendingRequest& request = pending_requests_.back(); |
| 424 request.id = request_id; |
| 425 request.type = SET_SITE_PERMISSION; |
| 426 request.setting_type = setting_type; |
| 427 request.sites = sites; |
| 428 return; |
| 429 } |
| 430 |
| 431 pending_responses_.insert(std::make_pair(request_id, SET_SITE_PERMISSION)); |
| 432 IPC::Message* msg = new PpapiMsg_SetSitePermission( |
| 433 request_id, plugin_data_path_, setting_type, sites); |
| 434 if (!channel_->Send(msg)) { |
| 435 DLOG(ERROR) << "Couldn't send SetSitePermission message"; |
| 436 // A failure notification for the current request will be sent since |
| 437 // |pending_responses_| has been updated. |
| 438 NotifyErrorFromIOThread(); |
244 } | 439 } |
245 } | 440 } |
246 | 441 |
247 void PepperFlashSettingsManager::Core::NotifyErrorFromIOThread() { | 442 void PepperFlashSettingsManager::Core::NotifyErrorFromIOThread() { |
248 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 443 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
249 | 444 |
250 std::vector<std::pair<uint32, RequestType> > notifications; | 445 std::vector<std::pair<uint32, RequestType> > notifications; |
251 for (std::vector<PendingRequest>::iterator iter = pending_requests_.begin(); | 446 for (std::vector<PendingRequest>::iterator iter = pending_requests_.begin(); |
252 iter != pending_requests_.end(); ++iter) { | 447 iter != pending_requests_.end(); ++iter) { |
253 notifications.push_back(std::make_pair(iter->id, iter->type)); | 448 notifications.push_back(std::make_pair(iter->id, iter->type)); |
(...skipping 13 matching lines...) Expand all Loading... |
267 uint32 request_id, | 462 uint32 request_id, |
268 bool success) { | 463 bool success) { |
269 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 464 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
270 | 465 |
271 if (manager_) { | 466 if (manager_) { |
272 manager_->client_->OnDeauthorizeContentLicensesCompleted( | 467 manager_->client_->OnDeauthorizeContentLicensesCompleted( |
273 request_id, success); | 468 request_id, success); |
274 } | 469 } |
275 } | 470 } |
276 | 471 |
| 472 void PepperFlashSettingsManager::Core::NotifyGetPermissionSettingsCompleted( |
| 473 uint32 request_id, |
| 474 bool success, |
| 475 PP_Flash_BrowserOperations_Permission default_permission, |
| 476 const ppapi::FlashSiteSettings& sites) { |
| 477 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 478 |
| 479 if (manager_) { |
| 480 manager_->client_->OnGetPermissionSettingsCompleted( |
| 481 request_id, success, default_permission, sites); |
| 482 } |
| 483 } |
| 484 |
| 485 void PepperFlashSettingsManager::Core::NotifySetDefaultPermissionCompleted( |
| 486 uint32 request_id, |
| 487 bool success) { |
| 488 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 489 |
| 490 if (manager_) { |
| 491 manager_->client_->OnSetDefaultPermissionCompleted( |
| 492 request_id, success); |
| 493 } |
| 494 } |
| 495 |
| 496 void PepperFlashSettingsManager::Core::NotifySetSitePermissionCompleted( |
| 497 uint32 request_id, |
| 498 bool success) { |
| 499 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 500 |
| 501 if (manager_) { |
| 502 manager_->client_->OnSetSitePermissionCompleted( |
| 503 request_id, success); |
| 504 } |
| 505 } |
| 506 |
277 void PepperFlashSettingsManager::Core::NotifyError( | 507 void PepperFlashSettingsManager::Core::NotifyError( |
278 const std::vector<std::pair<uint32, RequestType> >& notifications) { | 508 const std::vector<std::pair<uint32, RequestType> >& notifications) { |
279 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 509 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
280 | 510 |
281 scoped_refptr<Core> protector(this); | 511 scoped_refptr<Core> protector(this); |
282 for (std::vector<std::pair<uint32, RequestType> >::const_iterator iter = | 512 for (std::vector<std::pair<uint32, RequestType> >::const_iterator iter = |
283 notifications.begin(); iter != notifications.end(); ++iter) { | 513 notifications.begin(); iter != notifications.end(); ++iter) { |
284 // Check |manager_| for each iteration in case Detach() happens in one of | 514 // Check |manager_| for each iteration in case Detach() happens in one of |
285 // the callbacks. | 515 // the callbacks. |
286 if (manager_) { | 516 if (manager_) { |
287 switch (iter->second) { | 517 switch (iter->second) { |
288 case DEAUTHORIZE_CONTENT_LICENSES: | 518 case DEAUTHORIZE_CONTENT_LICENSES: |
289 manager_->client_->OnDeauthorizeContentLicensesCompleted(iter->first, | 519 manager_->client_->OnDeauthorizeContentLicensesCompleted( |
290 false); | 520 iter->first, false); |
| 521 break; |
| 522 case GET_PERMISSION_SETTINGS: |
| 523 manager_->client_->OnGetPermissionSettingsCompleted( |
| 524 iter->first, false, PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT, |
| 525 ppapi::FlashSiteSettings()); |
| 526 break; |
| 527 case SET_DEFAULT_PERMISSION: |
| 528 manager_->client_->OnSetDefaultPermissionCompleted( |
| 529 iter->first, false); |
| 530 break; |
| 531 case SET_SITE_PERMISSION: |
| 532 manager_->client_->OnSetSitePermissionCompleted(iter->first, false); |
291 break; | 533 break; |
292 default: | 534 default: |
293 NOTREACHED(); | 535 NOTREACHED(); |
294 break; | 536 break; |
295 } | 537 } |
296 } | 538 } |
297 } | 539 } |
298 | 540 |
299 if (manager_) | 541 if (manager_) |
300 manager_->OnError(); | 542 manager_->OnError(); |
301 } | 543 } |
302 | 544 |
303 void PepperFlashSettingsManager::Core::OnDeauthorizeContentLicensesResult( | 545 void PepperFlashSettingsManager::Core::OnDeauthorizeContentLicensesResult( |
304 uint32 request_id, | 546 uint32 request_id, |
305 bool success) { | 547 bool success) { |
306 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 548 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
307 LOG_IF(ERROR, !success) << "DeauthorizeContentLicenses returned error"; | 549 DLOG_IF(ERROR, !success) << "DeauthorizeContentLicenses returned error"; |
308 | 550 |
309 std::map<uint32, RequestType>::iterator iter = | 551 std::map<uint32, RequestType>::iterator iter = |
310 pending_responses_.find(request_id); | 552 pending_responses_.find(request_id); |
311 if (iter != pending_responses_.end()) { | 553 if (iter != pending_responses_.end()) { |
312 DCHECK_EQ(iter->second, DEAUTHORIZE_CONTENT_LICENSES); | 554 DCHECK_EQ(iter->second, DEAUTHORIZE_CONTENT_LICENSES); |
313 | 555 |
314 pending_responses_.erase(iter); | 556 pending_responses_.erase(iter); |
315 BrowserThread::PostTask( | 557 BrowserThread::PostTask( |
316 BrowserThread::UI, FROM_HERE, | 558 BrowserThread::UI, FROM_HERE, |
317 base::Bind(&Core::NotifyDeauthorizeContentLicensesCompleted, this, | 559 base::Bind(&Core::NotifyDeauthorizeContentLicensesCompleted, this, |
318 request_id, success)); | 560 request_id, success)); |
319 } | 561 } |
320 } | 562 } |
321 | 563 |
| 564 void PepperFlashSettingsManager::Core::OnGetPermissionSettingsResult( |
| 565 uint32 request_id, |
| 566 bool success, |
| 567 PP_Flash_BrowserOperations_Permission default_permission, |
| 568 const ppapi::FlashSiteSettings& sites) { |
| 569 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 570 DLOG_IF(ERROR, !success) << "GetPermissionSettings returned error"; |
| 571 |
| 572 std::map<uint32, RequestType>::iterator iter = |
| 573 pending_responses_.find(request_id); |
| 574 if (iter != pending_responses_.end()) { |
| 575 DCHECK_EQ(iter->second, GET_PERMISSION_SETTINGS); |
| 576 |
| 577 pending_responses_.erase(iter); |
| 578 BrowserThread::PostTask( |
| 579 BrowserThread::UI, FROM_HERE, |
| 580 base::Bind(&Core::NotifyGetPermissionSettingsCompleted, this, |
| 581 request_id, success, default_permission, sites)); |
| 582 } |
| 583 } |
| 584 |
| 585 void PepperFlashSettingsManager::Core::OnSetDefaultPermissionResult( |
| 586 uint32 request_id, |
| 587 bool success) { |
| 588 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 589 DLOG_IF(ERROR, !success) << "SetDefaultPermission returned error"; |
| 590 |
| 591 std::map<uint32, RequestType>::iterator iter = |
| 592 pending_responses_.find(request_id); |
| 593 if (iter != pending_responses_.end()) { |
| 594 DCHECK_EQ(iter->second, SET_DEFAULT_PERMISSION); |
| 595 |
| 596 pending_responses_.erase(iter); |
| 597 BrowserThread::PostTask( |
| 598 BrowserThread::UI, FROM_HERE, |
| 599 base::Bind(&Core::NotifySetDefaultPermissionCompleted, this, |
| 600 request_id, success)); |
| 601 } |
| 602 } |
| 603 |
| 604 void PepperFlashSettingsManager::Core::OnSetSitePermissionResult( |
| 605 uint32 request_id, |
| 606 bool success) { |
| 607 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 608 DLOG_IF(ERROR, !success) << "SetSitePermission returned error"; |
| 609 |
| 610 std::map<uint32, RequestType>::iterator iter = |
| 611 pending_responses_.find(request_id); |
| 612 if (iter != pending_responses_.end()) { |
| 613 DCHECK_EQ(iter->second, SET_SITE_PERMISSION); |
| 614 |
| 615 pending_responses_.erase(iter); |
| 616 BrowserThread::PostTask( |
| 617 BrowserThread::UI, FROM_HERE, |
| 618 base::Bind(&Core::NotifySetSitePermissionCompleted, this, request_id, |
| 619 success)); |
| 620 } |
| 621 } |
| 622 |
322 PepperFlashSettingsManager::PepperFlashSettingsManager( | 623 PepperFlashSettingsManager::PepperFlashSettingsManager( |
323 Client* client, | 624 Client* client, |
324 content::BrowserContext* browser_context) | 625 content::BrowserContext* browser_context) |
325 : client_(client), | 626 : client_(client), |
326 browser_context_(browser_context), | 627 browser_context_(browser_context), |
327 next_request_id_(1) { | 628 next_request_id_(1) { |
328 DCHECK(client); | 629 DCHECK(client); |
329 DCHECK(browser_context); | 630 DCHECK(browser_context); |
330 } | 631 } |
331 | 632 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 | 674 |
374 uint32 PepperFlashSettingsManager::DeauthorizeContentLicenses() { | 675 uint32 PepperFlashSettingsManager::DeauthorizeContentLicenses() { |
375 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 676 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
376 | 677 |
377 EnsureCoreExists(); | 678 EnsureCoreExists(); |
378 uint32 id = GetNextRequestId(); | 679 uint32 id = GetNextRequestId(); |
379 core_->DeauthorizeContentLicenses(id); | 680 core_->DeauthorizeContentLicenses(id); |
380 return id; | 681 return id; |
381 } | 682 } |
382 | 683 |
| 684 uint32 PepperFlashSettingsManager::GetPermissionSettings( |
| 685 PP_Flash_BrowserOperations_SettingType setting_type) { |
| 686 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 687 |
| 688 EnsureCoreExists(); |
| 689 uint32 id = GetNextRequestId(); |
| 690 core_->GetPermissionSettings(id, setting_type); |
| 691 return id; |
| 692 } |
| 693 |
| 694 uint32 PepperFlashSettingsManager::SetDefaultPermission( |
| 695 PP_Flash_BrowserOperations_SettingType setting_type, |
| 696 PP_Flash_BrowserOperations_Permission permission, |
| 697 bool clear_site_specific) { |
| 698 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 699 |
| 700 EnsureCoreExists(); |
| 701 uint32 id = GetNextRequestId(); |
| 702 core_->SetDefaultPermission(id, setting_type, permission, |
| 703 clear_site_specific); |
| 704 return id; |
| 705 } |
| 706 |
| 707 uint32 PepperFlashSettingsManager::SetSitePermission( |
| 708 PP_Flash_BrowserOperations_SettingType setting_type, |
| 709 const ppapi::FlashSiteSettings& sites) { |
| 710 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 711 |
| 712 EnsureCoreExists(); |
| 713 uint32 id = GetNextRequestId(); |
| 714 core_->SetSitePermission(id, setting_type, sites); |
| 715 return id; |
| 716 } |
| 717 |
383 uint32 PepperFlashSettingsManager::GetNextRequestId() { | 718 uint32 PepperFlashSettingsManager::GetNextRequestId() { |
384 return next_request_id_++; | 719 return next_request_id_++; |
385 } | 720 } |
386 | 721 |
387 void PepperFlashSettingsManager::EnsureCoreExists() { | 722 void PepperFlashSettingsManager::EnsureCoreExists() { |
388 if (!core_.get()) | 723 if (!core_.get()) |
389 core_ = new Core(this, browser_context_); | 724 core_ = new Core(this, browser_context_); |
390 } | 725 } |
391 | 726 |
392 void PepperFlashSettingsManager::OnError() { | 727 void PepperFlashSettingsManager::OnError() { |
393 if (core_.get()) { | 728 if (core_.get()) { |
394 core_->Detach(); | 729 core_->Detach(); |
395 core_ = NULL; | 730 core_ = NULL; |
396 } else { | 731 } else { |
397 NOTREACHED(); | 732 NOTREACHED(); |
398 } | 733 } |
399 } | 734 } |
400 | 735 |
OLD | NEW |