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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 uint32 request_id, | 45 uint32 request_id, |
46 PP_Flash_BrowserOperations_SettingType setting_type); | 46 PP_Flash_BrowserOperations_SettingType setting_type); |
47 void SetDefaultPermission( | 47 void SetDefaultPermission( |
48 uint32 request_id, | 48 uint32 request_id, |
49 PP_Flash_BrowserOperations_SettingType setting_type, | 49 PP_Flash_BrowserOperations_SettingType setting_type, |
50 PP_Flash_BrowserOperations_Permission permission, | 50 PP_Flash_BrowserOperations_Permission permission, |
51 bool clear_site_specific); | 51 bool clear_site_specific); |
52 void SetSitePermission(uint32 request_id, | 52 void SetSitePermission(uint32 request_id, |
53 PP_Flash_BrowserOperations_SettingType setting_type, | 53 PP_Flash_BrowserOperations_SettingType setting_type, |
54 const ppapi::FlashSiteSettings& sites); | 54 const ppapi::FlashSiteSettings& sites); |
| 55 void GetSitesWithData(uint32 request_id); |
| 56 void ClearSiteData(uint32 request_id, |
| 57 const std::string& site, |
| 58 uint64 flags, |
| 59 uint64 max_age); |
55 | 60 |
56 // IPC::Listener implementation. | 61 // IPC::Listener implementation. |
57 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 62 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
58 virtual void OnChannelError() OVERRIDE; | 63 virtual void OnChannelError() OVERRIDE; |
59 | 64 |
60 private: | 65 private: |
61 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; | 66 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; |
62 friend class base::DeleteHelper<Core>; | 67 friend class base::DeleteHelper<Core>; |
63 | 68 |
64 enum RequestType { | 69 enum RequestType { |
65 INVALID_REQUEST_TYPE = 0, | 70 INVALID_REQUEST_TYPE = 0, |
66 DEAUTHORIZE_CONTENT_LICENSES, | 71 DEAUTHORIZE_CONTENT_LICENSES, |
67 GET_PERMISSION_SETTINGS, | 72 GET_PERMISSION_SETTINGS, |
68 SET_DEFAULT_PERMISSION, | 73 SET_DEFAULT_PERMISSION, |
69 SET_SITE_PERMISSION | 74 SET_SITE_PERMISSION, |
| 75 GET_SITES_WITH_DATA, |
| 76 CLEAR_SITE_DATA, |
70 }; | 77 }; |
71 | 78 |
72 struct PendingRequest { | 79 struct PendingRequest { |
73 PendingRequest() | 80 PendingRequest() |
74 : id(0), | 81 : id(0), |
75 type(INVALID_REQUEST_TYPE), | 82 type(INVALID_REQUEST_TYPE), |
76 setting_type(PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC), | 83 setting_type(PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC), |
77 permission(PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT), | 84 permission(PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT), |
78 clear_site_specific(false) { | 85 clear_site_specific(false) { |
79 } | 86 } |
80 | 87 |
81 uint32 id; | 88 uint32 id; |
82 RequestType type; | 89 RequestType type; |
83 | 90 |
84 // Used by GET_PERMISSION_SETTINGS, SET_DEFAULT_PERMISSION and | 91 // Used by GET_PERMISSION_SETTINGS, SET_DEFAULT_PERMISSION and |
85 // SET_SITE_PERMISSION. | 92 // SET_SITE_PERMISSION. |
86 PP_Flash_BrowserOperations_SettingType setting_type; | 93 PP_Flash_BrowserOperations_SettingType setting_type; |
87 | 94 |
88 // Used by SET_DEFAULT_PERMISSION. | 95 // Used by SET_DEFAULT_PERMISSION. |
89 PP_Flash_BrowserOperations_Permission permission; | 96 PP_Flash_BrowserOperations_Permission permission; |
90 bool clear_site_specific; | 97 bool clear_site_specific; |
91 | 98 |
92 // Used by SET_SITE_PERMISSION. | 99 // Used by SET_SITE_PERMISSION. |
93 ppapi::FlashSiteSettings sites; | 100 ppapi::FlashSiteSettings sites; |
| 101 |
| 102 // Used by CLEAR_SITE_DATA |
| 103 std::string site; |
| 104 uint64 flags; |
| 105 uint64 max_age; |
94 }; | 106 }; |
95 | 107 |
96 virtual ~Core(); | 108 virtual ~Core(); |
97 | 109 |
98 void ConnectToChannel(bool success, const IPC::ChannelHandle& handle); | 110 void ConnectToChannel(bool success, const IPC::ChannelHandle& handle); |
99 | 111 |
100 void InitializeOnIOThread(); | 112 void InitializeOnIOThread(); |
101 void DeauthorizeContentLicensesOnIOThread(uint32 request_id); | 113 void DeauthorizeContentLicensesOnIOThread(uint32 request_id); |
102 void GetPermissionSettingsOnIOThread( | 114 void GetPermissionSettingsOnIOThread( |
103 uint32 request_id, | 115 uint32 request_id, |
104 PP_Flash_BrowserOperations_SettingType setting_type); | 116 PP_Flash_BrowserOperations_SettingType setting_type); |
105 void SetDefaultPermissionOnIOThread( | 117 void SetDefaultPermissionOnIOThread( |
106 uint32 request_id, | 118 uint32 request_id, |
107 PP_Flash_BrowserOperations_SettingType setting_type, | 119 PP_Flash_BrowserOperations_SettingType setting_type, |
108 PP_Flash_BrowserOperations_Permission permission, | 120 PP_Flash_BrowserOperations_Permission permission, |
109 bool clear_site_specific); | 121 bool clear_site_specific); |
110 void SetSitePermissionOnIOThread( | 122 void SetSitePermissionOnIOThread( |
111 uint32 request_id, | 123 uint32 request_id, |
112 PP_Flash_BrowserOperations_SettingType setting_type, | 124 PP_Flash_BrowserOperations_SettingType setting_type, |
113 const ppapi::FlashSiteSettings& sites); | 125 const ppapi::FlashSiteSettings& sites); |
| 126 void GetSitesWithDataOnIOThread(uint32 request_id); |
| 127 void ClearSiteDataOnIOThread(uint32 request_id, |
| 128 const std::string& site, |
| 129 uint64 flags, |
| 130 uint64 max_age); |
114 void DetachOnIOThread(); | 131 void DetachOnIOThread(); |
115 | 132 |
116 void NotifyErrorFromIOThread(); | 133 void NotifyErrorFromIOThread(); |
117 | 134 |
118 void NotifyDeauthorizeContentLicensesCompleted(uint32 request_id, | 135 void NotifyDeauthorizeContentLicensesCompleted(uint32 request_id, |
119 bool success); | 136 bool success); |
120 void NotifyGetPermissionSettingsCompleted( | 137 void NotifyGetPermissionSettingsCompleted( |
121 uint32 request_id, | 138 uint32 request_id, |
122 bool success, | 139 bool success, |
123 PP_Flash_BrowserOperations_Permission default_permission, | 140 PP_Flash_BrowserOperations_Permission default_permission, |
124 const ppapi::FlashSiteSettings& sites); | 141 const ppapi::FlashSiteSettings& sites); |
125 void NotifySetDefaultPermissionCompleted(uint32 request_id, bool success); | 142 void NotifySetDefaultPermissionCompleted(uint32 request_id, bool success); |
126 void NotifySetSitePermissionCompleted(uint32 request_id, bool success); | 143 void NotifySetSitePermissionCompleted(uint32 request_id, bool success); |
| 144 void NotifyGetSitesWithDataCompleted(uint32 request_id, |
| 145 const std::vector<std::string>& sites); |
| 146 void NotifyClearSiteDataCompleted(uint32 request_id, bool success); |
127 | 147 |
128 void NotifyError( | 148 void NotifyError( |
129 const std::vector<std::pair<uint32, RequestType> >& notifications); | 149 const std::vector<std::pair<uint32, RequestType> >& notifications); |
130 | 150 |
131 // Message handlers. | 151 // Message handlers. |
132 void OnDeauthorizeContentLicensesResult(uint32 request_id, bool success); | 152 void OnDeauthorizeContentLicensesResult(uint32 request_id, bool success); |
133 void OnGetPermissionSettingsResult( | 153 void OnGetPermissionSettingsResult( |
134 uint32 request_id, | 154 uint32 request_id, |
135 bool success, | 155 bool success, |
136 PP_Flash_BrowserOperations_Permission default_permission, | 156 PP_Flash_BrowserOperations_Permission default_permission, |
137 const ppapi::FlashSiteSettings& sites); | 157 const ppapi::FlashSiteSettings& sites); |
138 void OnSetDefaultPermissionResult(uint32 request_id, bool success); | 158 void OnSetDefaultPermissionResult(uint32 request_id, bool success); |
139 void OnSetSitePermissionResult(uint32 request_id, bool success); | 159 void OnSetSitePermissionResult(uint32 request_id, bool success); |
| 160 void OnGetSitesWithDataResult(uint32 request_id, |
| 161 const std::vector<std::string>& sites); |
| 162 void OnClearSiteDataResult(uint32 request_id, bool success); |
140 | 163 |
141 // Used only on the UI thread. | 164 // Used only on the UI thread. |
142 PepperFlashSettingsManager* manager_; | 165 PepperFlashSettingsManager* manager_; |
143 | 166 |
144 // Used only on the I/O thread. | 167 // Used only on the I/O thread. |
145 FilePath plugin_data_path_; | 168 FilePath plugin_data_path_; |
146 | 169 |
147 // The channel is NULL until we have opened a connection to the broker | 170 // The channel is NULL until we have opened a connection to the broker |
148 // process. Used only on the I/O thread. | 171 // process. Used only on the I/O thread. |
149 scoped_ptr<IPC::Channel> channel_; | 172 scoped_ptr<IPC::Channel> channel_; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 PP_Flash_BrowserOperations_SettingType setting_type, | 267 PP_Flash_BrowserOperations_SettingType setting_type, |
245 const ppapi::FlashSiteSettings& sites) { | 268 const ppapi::FlashSiteSettings& sites) { |
246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 269 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
247 | 270 |
248 BrowserThread::PostTask( | 271 BrowserThread::PostTask( |
249 BrowserThread::IO, FROM_HERE, | 272 BrowserThread::IO, FROM_HERE, |
250 base::Bind(&Core::SetSitePermissionOnIOThread, this, request_id, | 273 base::Bind(&Core::SetSitePermissionOnIOThread, this, request_id, |
251 setting_type, sites)); | 274 setting_type, sites)); |
252 } | 275 } |
253 | 276 |
| 277 void PepperFlashSettingsManager::Core::GetSitesWithData(uint32 request_id) { |
| 278 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 279 |
| 280 BrowserThread::PostTask( |
| 281 BrowserThread::IO, FROM_HERE, |
| 282 base::Bind(&Core::GetSitesWithDataOnIOThread, this, request_id)); |
| 283 } |
| 284 |
| 285 void PepperFlashSettingsManager::Core::ClearSiteData(uint32 request_id, |
| 286 const std::string& site, |
| 287 uint64 flags, |
| 288 uint64 max_age) { |
| 289 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 290 |
| 291 BrowserThread::PostTask( |
| 292 BrowserThread::IO, FROM_HERE, |
| 293 base::Bind(&Core::ClearSiteDataOnIOThread, this, request_id, |
| 294 site, flags, max_age)); |
| 295 } |
| 296 |
254 bool PepperFlashSettingsManager::Core::OnMessageReceived( | 297 bool PepperFlashSettingsManager::Core::OnMessageReceived( |
255 const IPC::Message& message) { | 298 const IPC::Message& message) { |
256 IPC_BEGIN_MESSAGE_MAP(Core, message) | 299 IPC_BEGIN_MESSAGE_MAP(Core, message) |
257 IPC_MESSAGE_HANDLER(PpapiHostMsg_DeauthorizeContentLicensesResult, | 300 IPC_MESSAGE_HANDLER(PpapiHostMsg_DeauthorizeContentLicensesResult, |
258 OnDeauthorizeContentLicensesResult) | 301 OnDeauthorizeContentLicensesResult) |
259 IPC_MESSAGE_HANDLER(PpapiHostMsg_GetPermissionSettingsResult, | 302 IPC_MESSAGE_HANDLER(PpapiHostMsg_GetPermissionSettingsResult, |
260 OnGetPermissionSettingsResult) | 303 OnGetPermissionSettingsResult) |
261 IPC_MESSAGE_HANDLER(PpapiHostMsg_SetDefaultPermissionResult, | 304 IPC_MESSAGE_HANDLER(PpapiHostMsg_SetDefaultPermissionResult, |
262 OnSetDefaultPermissionResult) | 305 OnSetDefaultPermissionResult) |
263 IPC_MESSAGE_HANDLER(PpapiHostMsg_SetSitePermissionResult, | 306 IPC_MESSAGE_HANDLER(PpapiHostMsg_SetSitePermissionResult, |
264 OnSetSitePermissionResult) | 307 OnSetSitePermissionResult) |
| 308 IPC_MESSAGE_HANDLER(PpapiHostMsg_GetSitesWithDataResult, |
| 309 OnGetSitesWithDataResult) |
| 310 IPC_MESSAGE_HANDLER(PpapiHostMsg_ClearSiteDataResult, |
| 311 OnClearSiteDataResult) |
265 IPC_MESSAGE_UNHANDLED_ERROR() | 312 IPC_MESSAGE_UNHANDLED_ERROR() |
266 IPC_END_MESSAGE_MAP() | 313 IPC_END_MESSAGE_MAP() |
267 | 314 |
268 return true; | 315 return true; |
269 } | 316 } |
270 | 317 |
271 void PepperFlashSettingsManager::Core::OnChannelError() { | 318 void PepperFlashSettingsManager::Core::OnChannelError() { |
272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 319 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
273 if (detached_) | 320 if (detached_) |
274 return; | 321 return; |
(...skipping 25 matching lines...) Expand all Loading... |
300 } | 347 } |
301 | 348 |
302 initialized_ = true; | 349 initialized_ = true; |
303 | 350 |
304 std::vector<PendingRequest> temp_pending_requests; | 351 std::vector<PendingRequest> temp_pending_requests; |
305 temp_pending_requests.swap(pending_requests_); | 352 temp_pending_requests.swap(pending_requests_); |
306 for (std::vector<PendingRequest>::iterator iter = | 353 for (std::vector<PendingRequest>::iterator iter = |
307 temp_pending_requests.begin(); | 354 temp_pending_requests.begin(); |
308 iter != temp_pending_requests.end(); ++iter) { | 355 iter != temp_pending_requests.end(); ++iter) { |
309 switch (iter->type) { | 356 switch (iter->type) { |
| 357 case INVALID_REQUEST_TYPE: |
| 358 NOTREACHED(); |
| 359 break; |
310 case DEAUTHORIZE_CONTENT_LICENSES: | 360 case DEAUTHORIZE_CONTENT_LICENSES: |
311 DeauthorizeContentLicensesOnIOThread(iter->id); | 361 DeauthorizeContentLicensesOnIOThread(iter->id); |
312 break; | 362 break; |
313 case GET_PERMISSION_SETTINGS: | 363 case GET_PERMISSION_SETTINGS: |
314 GetPermissionSettingsOnIOThread(iter->id, iter->setting_type); | 364 GetPermissionSettingsOnIOThread(iter->id, iter->setting_type); |
315 break; | 365 break; |
316 case SET_DEFAULT_PERMISSION: | 366 case SET_DEFAULT_PERMISSION: |
317 SetDefaultPermissionOnIOThread( | 367 SetDefaultPermissionOnIOThread( |
318 iter->id, iter->setting_type, iter->permission, | 368 iter->id, iter->setting_type, iter->permission, |
319 iter->clear_site_specific); | 369 iter->clear_site_specific); |
320 break; | 370 break; |
321 case SET_SITE_PERMISSION: | 371 case SET_SITE_PERMISSION: |
322 SetSitePermissionOnIOThread(iter->id, iter->setting_type, iter->sites); | 372 SetSitePermissionOnIOThread(iter->id, iter->setting_type, iter->sites); |
323 break; | 373 break; |
324 default: | 374 case GET_SITES_WITH_DATA: |
325 NOTREACHED(); | 375 GetSitesWithDataOnIOThread(iter->id); |
| 376 break; |
| 377 case CLEAR_SITE_DATA: |
| 378 ClearSiteDataOnIOThread(iter->id, iter->site, iter->flags, |
| 379 iter->max_age); |
326 break; | 380 break; |
327 } | 381 } |
328 } | 382 } |
329 } | 383 } |
330 | 384 |
331 void PepperFlashSettingsManager::Core::InitializeOnIOThread() { | 385 void PepperFlashSettingsManager::Core::InitializeOnIOThread() { |
332 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
333 DCHECK(!initialized_); | 387 DCHECK(!initialized_); |
334 | 388 |
335 if (detached_) | 389 if (detached_) |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 IPC::Message* msg = new PpapiMsg_SetSitePermission( | 518 IPC::Message* msg = new PpapiMsg_SetSitePermission( |
465 request_id, plugin_data_path_, setting_type, sites); | 519 request_id, plugin_data_path_, setting_type, sites); |
466 if (!channel_->Send(msg)) { | 520 if (!channel_->Send(msg)) { |
467 DLOG(ERROR) << "Couldn't send SetSitePermission message"; | 521 DLOG(ERROR) << "Couldn't send SetSitePermission message"; |
468 // A failure notification for the current request will be sent since | 522 // A failure notification for the current request will be sent since |
469 // |pending_responses_| has been updated. | 523 // |pending_responses_| has been updated. |
470 NotifyErrorFromIOThread(); | 524 NotifyErrorFromIOThread(); |
471 } | 525 } |
472 } | 526 } |
473 | 527 |
| 528 void PepperFlashSettingsManager::Core::GetSitesWithDataOnIOThread( |
| 529 uint32 request_id) { |
| 530 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 531 if (detached_) |
| 532 return; |
| 533 |
| 534 if (!initialized_) { |
| 535 pending_requests_.push_back(PendingRequest()); |
| 536 PendingRequest& request = pending_requests_.back(); |
| 537 request.id = request_id; |
| 538 request.type = GET_SITES_WITH_DATA; |
| 539 return; |
| 540 } |
| 541 |
| 542 pending_responses_.insert(std::make_pair(request_id, GET_SITES_WITH_DATA)); |
| 543 IPC::Message* msg = new PpapiMsg_GetSitesWithData( |
| 544 request_id, plugin_data_path_); |
| 545 if (!channel_->Send(msg)) { |
| 546 DLOG(ERROR) << "Couldn't send GetSitesWithData message"; |
| 547 // A failure notification for the current request will be sent since |
| 548 // |pending_responses_| has been updated. |
| 549 NotifyErrorFromIOThread(); |
| 550 } |
| 551 } |
| 552 |
| 553 void PepperFlashSettingsManager::Core::ClearSiteDataOnIOThread( |
| 554 uint32 request_id, |
| 555 const std::string& site, |
| 556 uint64 flags, |
| 557 uint64 max_age) { |
| 558 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 559 if (detached_) |
| 560 return; |
| 561 |
| 562 if (!initialized_) { |
| 563 pending_requests_.push_back(PendingRequest()); |
| 564 PendingRequest& request = pending_requests_.back(); |
| 565 request.id = request_id; |
| 566 request.type = CLEAR_SITE_DATA; |
| 567 request.site = site; |
| 568 request.flags = flags; |
| 569 request.max_age = max_age; |
| 570 return; |
| 571 } |
| 572 |
| 573 pending_responses_.insert(std::make_pair(request_id, CLEAR_SITE_DATA)); |
| 574 IPC::Message* msg = new PpapiMsg_ClearSiteData( |
| 575 request_id, plugin_data_path_, site, flags, max_age); |
| 576 if (!channel_->Send(msg)) { |
| 577 DLOG(ERROR) << "Couldn't send ClearSiteData message"; |
| 578 // A failure notification for the current request will be sent since |
| 579 // |pending_responses_| has been updated. |
| 580 NotifyErrorFromIOThread(); |
| 581 } |
| 582 } |
| 583 |
474 void PepperFlashSettingsManager::Core::DetachOnIOThread() { | 584 void PepperFlashSettingsManager::Core::DetachOnIOThread() { |
475 detached_ = true; | 585 detached_ = true; |
476 } | 586 } |
477 | 587 |
478 void PepperFlashSettingsManager::Core::NotifyErrorFromIOThread() { | 588 void PepperFlashSettingsManager::Core::NotifyErrorFromIOThread() { |
479 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 589 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
480 if (detached_) | 590 if (detached_) |
481 return; | 591 return; |
482 | 592 |
483 std::vector<std::pair<uint32, RequestType> > notifications; | 593 std::vector<std::pair<uint32, RequestType> > notifications; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 uint32 request_id, | 645 uint32 request_id, |
536 bool success) { | 646 bool success) { |
537 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 647 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
538 | 648 |
539 if (manager_) { | 649 if (manager_) { |
540 manager_->client_->OnSetSitePermissionCompleted( | 650 manager_->client_->OnSetSitePermissionCompleted( |
541 request_id, success); | 651 request_id, success); |
542 } | 652 } |
543 } | 653 } |
544 | 654 |
| 655 void PepperFlashSettingsManager::Core::NotifyGetSitesWithDataCompleted( |
| 656 uint32 request_id, |
| 657 const std::vector<std::string>& sites) { |
| 658 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 659 |
| 660 if (manager_) { |
| 661 manager_->client_->OnGetSitesWithDataCompleted( |
| 662 request_id, sites); |
| 663 } |
| 664 } |
| 665 |
| 666 void PepperFlashSettingsManager::Core::NotifyClearSiteDataCompleted( |
| 667 uint32 request_id, |
| 668 bool success) { |
| 669 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 670 |
| 671 if (manager_) |
| 672 manager_->client_->OnClearSiteDataCompleted(request_id, success); |
| 673 } |
| 674 |
545 void PepperFlashSettingsManager::Core::NotifyError( | 675 void PepperFlashSettingsManager::Core::NotifyError( |
546 const std::vector<std::pair<uint32, RequestType> >& notifications) { | 676 const std::vector<std::pair<uint32, RequestType> >& notifications) { |
547 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 677 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
548 | 678 |
549 scoped_refptr<Core> protector(this); | 679 scoped_refptr<Core> protector(this); |
550 for (std::vector<std::pair<uint32, RequestType> >::const_iterator iter = | 680 for (std::vector<std::pair<uint32, RequestType> >::const_iterator iter = |
551 notifications.begin(); iter != notifications.end(); ++iter) { | 681 notifications.begin(); iter != notifications.end(); ++iter) { |
552 // Check |manager_| for each iteration in case Detach() happens in one of | 682 // Check |manager_| for each iteration in case Detach() happens in one of |
553 // the callbacks. | 683 // the callbacks. |
554 if (manager_) { | 684 if (!manager_) |
555 switch (iter->second) { | 685 return; |
556 case DEAUTHORIZE_CONTENT_LICENSES: | 686 |
557 manager_->client_->OnDeauthorizeContentLicensesCompleted( | 687 switch (iter->second) { |
558 iter->first, false); | 688 case INVALID_REQUEST_TYPE: |
559 break; | 689 NOTREACHED(); |
560 case GET_PERMISSION_SETTINGS: | 690 break; |
561 manager_->client_->OnGetPermissionSettingsCompleted( | 691 case DEAUTHORIZE_CONTENT_LICENSES: |
562 iter->first, false, PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT, | 692 manager_->client_->OnDeauthorizeContentLicensesCompleted( |
563 ppapi::FlashSiteSettings()); | 693 iter->first, false); |
564 break; | 694 break; |
565 case SET_DEFAULT_PERMISSION: | 695 case GET_PERMISSION_SETTINGS: |
566 manager_->client_->OnSetDefaultPermissionCompleted( | 696 manager_->client_->OnGetPermissionSettingsCompleted( |
567 iter->first, false); | 697 iter->first, false, PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT, |
568 break; | 698 ppapi::FlashSiteSettings()); |
569 case SET_SITE_PERMISSION: | 699 break; |
570 manager_->client_->OnSetSitePermissionCompleted(iter->first, false); | 700 case SET_DEFAULT_PERMISSION: |
571 break; | 701 manager_->client_->OnSetDefaultPermissionCompleted( |
572 default: | 702 iter->first, false); |
573 NOTREACHED(); | 703 break; |
574 break; | 704 case SET_SITE_PERMISSION: |
575 } | 705 manager_->client_->OnSetSitePermissionCompleted(iter->first, false); |
| 706 break; |
| 707 case GET_SITES_WITH_DATA: |
| 708 manager_->client_->OnGetSitesWithDataCompleted( |
| 709 iter->first, std::vector<std::string>()); |
| 710 break; |
| 711 case CLEAR_SITE_DATA: |
| 712 manager_->client_->OnClearSiteDataCompleted(iter->first, false); |
| 713 break; |
576 } | 714 } |
577 } | 715 } |
578 | 716 |
579 if (manager_) | 717 if (manager_) |
580 manager_->OnError(); | 718 manager_->OnError(); |
581 } | 719 } |
582 | 720 |
583 void PepperFlashSettingsManager::Core::OnDeauthorizeContentLicensesResult( | 721 void PepperFlashSettingsManager::Core::OnDeauthorizeContentLicensesResult( |
584 uint32 request_id, | 722 uint32 request_id, |
585 bool success) { | 723 bool success) { |
586 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 724 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
587 if (detached_) | 725 if (detached_) |
588 return; | 726 return; |
589 | 727 |
590 DLOG_IF(ERROR, !success) << "DeauthorizeContentLicenses returned error"; | 728 DLOG_IF(ERROR, !success) << "DeauthorizeContentLicenses returned error"; |
591 | 729 |
592 std::map<uint32, RequestType>::iterator iter = | 730 std::map<uint32, RequestType>::iterator iter = |
593 pending_responses_.find(request_id); | 731 pending_responses_.find(request_id); |
594 if (iter != pending_responses_.end()) { | 732 if (iter == pending_responses_.end()) |
595 DCHECK_EQ(iter->second, DEAUTHORIZE_CONTENT_LICENSES); | 733 return; |
596 | 734 |
597 pending_responses_.erase(iter); | 735 DCHECK_EQ(iter->second, DEAUTHORIZE_CONTENT_LICENSES); |
598 BrowserThread::PostTask( | 736 |
599 BrowserThread::UI, FROM_HERE, | 737 pending_responses_.erase(iter); |
600 base::Bind(&Core::NotifyDeauthorizeContentLicensesCompleted, this, | 738 BrowserThread::PostTask( |
601 request_id, success)); | 739 BrowserThread::UI, FROM_HERE, |
602 } | 740 base::Bind(&Core::NotifyDeauthorizeContentLicensesCompleted, this, |
| 741 request_id, success)); |
603 } | 742 } |
604 | 743 |
605 void PepperFlashSettingsManager::Core::OnGetPermissionSettingsResult( | 744 void PepperFlashSettingsManager::Core::OnGetPermissionSettingsResult( |
606 uint32 request_id, | 745 uint32 request_id, |
607 bool success, | 746 bool success, |
608 PP_Flash_BrowserOperations_Permission default_permission, | 747 PP_Flash_BrowserOperations_Permission default_permission, |
609 const ppapi::FlashSiteSettings& sites) { | 748 const ppapi::FlashSiteSettings& sites) { |
610 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 749 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
611 if (detached_) | 750 if (detached_) |
612 return; | 751 return; |
613 | 752 |
614 DLOG_IF(ERROR, !success) << "GetPermissionSettings returned error"; | 753 DLOG_IF(ERROR, !success) << "GetPermissionSettings returned error"; |
615 | 754 |
616 std::map<uint32, RequestType>::iterator iter = | 755 std::map<uint32, RequestType>::iterator iter = |
617 pending_responses_.find(request_id); | 756 pending_responses_.find(request_id); |
618 if (iter != pending_responses_.end()) { | 757 if (iter == pending_responses_.end()) |
619 DCHECK_EQ(iter->second, GET_PERMISSION_SETTINGS); | 758 return; |
620 | 759 |
621 pending_responses_.erase(iter); | 760 DCHECK_EQ(iter->second, GET_PERMISSION_SETTINGS); |
622 BrowserThread::PostTask( | 761 |
623 BrowserThread::UI, FROM_HERE, | 762 pending_responses_.erase(iter); |
624 base::Bind(&Core::NotifyGetPermissionSettingsCompleted, this, | 763 BrowserThread::PostTask( |
625 request_id, success, default_permission, sites)); | 764 BrowserThread::UI, FROM_HERE, |
626 } | 765 base::Bind(&Core::NotifyGetPermissionSettingsCompleted, this, |
| 766 request_id, success, default_permission, sites)); |
627 } | 767 } |
628 | 768 |
629 void PepperFlashSettingsManager::Core::OnSetDefaultPermissionResult( | 769 void PepperFlashSettingsManager::Core::OnSetDefaultPermissionResult( |
630 uint32 request_id, | 770 uint32 request_id, |
631 bool success) { | 771 bool success) { |
632 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 772 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
633 if (detached_) | 773 if (detached_) |
634 return; | 774 return; |
635 | 775 |
636 DLOG_IF(ERROR, !success) << "SetDefaultPermission returned error"; | 776 DLOG_IF(ERROR, !success) << "SetDefaultPermission returned error"; |
637 | 777 |
638 std::map<uint32, RequestType>::iterator iter = | 778 std::map<uint32, RequestType>::iterator iter = |
639 pending_responses_.find(request_id); | 779 pending_responses_.find(request_id); |
640 if (iter != pending_responses_.end()) { | 780 if (iter == pending_responses_.end()) |
641 DCHECK_EQ(iter->second, SET_DEFAULT_PERMISSION); | 781 return; |
642 | 782 |
643 pending_responses_.erase(iter); | 783 DCHECK_EQ(iter->second, SET_DEFAULT_PERMISSION); |
644 BrowserThread::PostTask( | 784 |
645 BrowserThread::UI, FROM_HERE, | 785 pending_responses_.erase(iter); |
646 base::Bind(&Core::NotifySetDefaultPermissionCompleted, this, | 786 BrowserThread::PostTask( |
647 request_id, success)); | 787 BrowserThread::UI, FROM_HERE, |
648 } | 788 base::Bind(&Core::NotifySetDefaultPermissionCompleted, this, |
| 789 request_id, success)); |
649 } | 790 } |
650 | 791 |
651 void PepperFlashSettingsManager::Core::OnSetSitePermissionResult( | 792 void PepperFlashSettingsManager::Core::OnSetSitePermissionResult( |
652 uint32 request_id, | 793 uint32 request_id, |
653 bool success) { | 794 bool success) { |
654 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 795 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
655 if (detached_) | 796 if (detached_) |
656 return; | 797 return; |
657 | 798 |
658 DLOG_IF(ERROR, !success) << "SetSitePermission returned error"; | 799 DLOG_IF(ERROR, !success) << "SetSitePermission returned error"; |
659 | 800 |
660 std::map<uint32, RequestType>::iterator iter = | 801 std::map<uint32, RequestType>::iterator iter = |
661 pending_responses_.find(request_id); | 802 pending_responses_.find(request_id); |
662 if (iter != pending_responses_.end()) { | 803 if (iter == pending_responses_.end()) |
663 DCHECK_EQ(iter->second, SET_SITE_PERMISSION); | 804 return; |
664 | 805 |
665 pending_responses_.erase(iter); | 806 DCHECK_EQ(iter->second, SET_SITE_PERMISSION); |
666 BrowserThread::PostTask( | 807 |
667 BrowserThread::UI, FROM_HERE, | 808 pending_responses_.erase(iter); |
668 base::Bind(&Core::NotifySetSitePermissionCompleted, this, request_id, | 809 BrowserThread::PostTask( |
669 success)); | 810 BrowserThread::UI, FROM_HERE, |
670 } | 811 base::Bind(&Core::NotifySetSitePermissionCompleted, this, request_id, |
| 812 success)); |
| 813 } |
| 814 |
| 815 void PepperFlashSettingsManager::Core::OnGetSitesWithDataResult( |
| 816 uint32 request_id, |
| 817 const std::vector<std::string>& sites) { |
| 818 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 819 if (detached_) |
| 820 return; |
| 821 |
| 822 std::map<uint32, RequestType>::iterator iter = |
| 823 pending_responses_.find(request_id); |
| 824 if (iter == pending_responses_.end()) |
| 825 return; |
| 826 |
| 827 DCHECK_EQ(iter->second, GET_SITES_WITH_DATA); |
| 828 |
| 829 pending_responses_.erase(iter); |
| 830 BrowserThread::PostTask( |
| 831 BrowserThread::UI, FROM_HERE, |
| 832 base::Bind(&Core::NotifyGetSitesWithDataCompleted, this, request_id, |
| 833 sites)); |
| 834 } |
| 835 |
| 836 void PepperFlashSettingsManager::Core::OnClearSiteDataResult( |
| 837 uint32 request_id, |
| 838 bool success) { |
| 839 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 840 if (detached_) |
| 841 return; |
| 842 |
| 843 DLOG_IF(ERROR, !success) << "ClearSiteData returned error"; |
| 844 |
| 845 std::map<uint32, RequestType>::iterator iter = |
| 846 pending_responses_.find(request_id); |
| 847 if (iter == pending_responses_.end()) |
| 848 return; |
| 849 |
| 850 DCHECK_EQ(iter->second, CLEAR_SITE_DATA); |
| 851 |
| 852 pending_responses_.erase(iter); |
| 853 BrowserThread::PostTask( |
| 854 BrowserThread::UI, FROM_HERE, |
| 855 base::Bind(&Core::NotifyClearSiteDataCompleted, this, request_id, |
| 856 success)); |
671 } | 857 } |
672 | 858 |
673 PepperFlashSettingsManager::PepperFlashSettingsManager( | 859 PepperFlashSettingsManager::PepperFlashSettingsManager( |
674 Client* client, | 860 Client* client, |
675 content::BrowserContext* browser_context) | 861 content::BrowserContext* browser_context) |
676 : client_(client), | 862 : client_(client), |
677 browser_context_(browser_context), | 863 browser_context_(browser_context), |
678 next_request_id_(1) { | 864 next_request_id_(1) { |
679 DCHECK(client); | 865 DCHECK(client); |
680 DCHECK(browser_context); | 866 DCHECK(browser_context); |
681 } | 867 } |
682 | 868 |
683 PepperFlashSettingsManager::~PepperFlashSettingsManager() { | 869 PepperFlashSettingsManager::~PepperFlashSettingsManager() { |
684 if (core_.get()) { | 870 if (core_.get()) |
685 core_->Detach(); | 871 core_->Detach(); |
686 core_ = NULL; | |
687 } | |
688 } | 872 } |
689 | 873 |
690 // static | 874 // static |
691 bool PepperFlashSettingsManager::IsPepperFlashInUse( | 875 bool PepperFlashSettingsManager::IsPepperFlashInUse( |
692 PluginPrefs* plugin_prefs, | 876 PluginPrefs* plugin_prefs, |
693 webkit::WebPluginInfo* plugin_info) { | 877 webkit::WebPluginInfo* plugin_info) { |
694 if (!plugin_prefs) | 878 if (!plugin_prefs) |
695 return false; | 879 return false; |
696 | 880 |
697 content::PluginService* plugin_service = | 881 content::PluginService* plugin_service = |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 PP_Flash_BrowserOperations_SettingType setting_type, | 942 PP_Flash_BrowserOperations_SettingType setting_type, |
759 const ppapi::FlashSiteSettings& sites) { | 943 const ppapi::FlashSiteSettings& sites) { |
760 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 944 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
761 | 945 |
762 EnsureCoreExists(); | 946 EnsureCoreExists(); |
763 uint32 id = GetNextRequestId(); | 947 uint32 id = GetNextRequestId(); |
764 core_->SetSitePermission(id, setting_type, sites); | 948 core_->SetSitePermission(id, setting_type, sites); |
765 return id; | 949 return id; |
766 } | 950 } |
767 | 951 |
| 952 uint32 PepperFlashSettingsManager::GetSitesWithData() { |
| 953 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 954 |
| 955 EnsureCoreExists(); |
| 956 uint32 id = GetNextRequestId(); |
| 957 core_->GetSitesWithData(id); |
| 958 return id; |
| 959 } |
| 960 |
| 961 uint32 PepperFlashSettingsManager::ClearSiteData(const std::string& site, |
| 962 uint64 flags, |
| 963 uint64 max_age) { |
| 964 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 965 |
| 966 EnsureCoreExists(); |
| 967 uint32 id = GetNextRequestId(); |
| 968 core_->ClearSiteData(id, site, flags, max_age); |
| 969 return id; |
| 970 } |
| 971 |
768 uint32 PepperFlashSettingsManager::GetNextRequestId() { | 972 uint32 PepperFlashSettingsManager::GetNextRequestId() { |
769 return next_request_id_++; | 973 return next_request_id_++; |
770 } | 974 } |
771 | 975 |
772 void PepperFlashSettingsManager::EnsureCoreExists() { | 976 void PepperFlashSettingsManager::EnsureCoreExists() { |
773 if (!core_.get()) { | 977 if (!core_.get()) { |
774 core_ = new Core(this, browser_context_); | 978 core_ = new Core(this, browser_context_); |
775 core_->Initialize(); | 979 core_->Initialize(); |
776 } | 980 } |
777 } | 981 } |
778 | 982 |
779 void PepperFlashSettingsManager::OnError() { | 983 void PepperFlashSettingsManager::OnError() { |
780 if (core_.get()) { | 984 if (core_.get()) { |
781 core_->Detach(); | 985 core_->Detach(); |
782 core_ = NULL; | 986 core_ = NULL; |
783 } else { | 987 } else { |
784 NOTREACHED(); | 988 NOTREACHED(); |
785 } | 989 } |
786 } | 990 } |
787 | 991 |
OLD | NEW |