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

Side by Side Diff: chrome/browser/pepper_flash_settings_manager.cc

Issue 10536103: Revert 141482 - Pepper Flash settings integration - camera and microphone. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
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
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);
54 43
55 // IPC::Channel::Listener implementation. 44 // IPC::Channel::Listener implementation.
56 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 45 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
57 virtual void OnChannelError() OVERRIDE; 46 virtual void OnChannelError() OVERRIDE;
58 47
59 private: 48 private:
60 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>; 49 friend struct BrowserThread::DeleteOnThread<BrowserThread::IO>;
61 friend class base::DeleteHelper<Core>; 50 friend class base::DeleteHelper<Core>;
62 51
63 enum RequestType { 52 enum RequestType {
64 INVALID_REQUEST_TYPE = 0, 53 INVALID_REQUEST_TYPE = 0,
65 DEAUTHORIZE_CONTENT_LICENSES, 54 DEAUTHORIZE_CONTENT_LICENSES
66 GET_PERMISSION_SETTINGS,
67 SET_DEFAULT_PERMISSION,
68 SET_SITE_PERMISSION
69 }; 55 };
70 56
71 struct PendingRequest { 57 struct PendingRequest {
72 PendingRequest() 58 PendingRequest() : id(0), type(INVALID_REQUEST_TYPE) {}
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 }
79 59
80 uint32 id; 60 uint32 id;
81 RequestType type; 61 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;
93 }; 62 };
94 63
95 virtual ~Core(); 64 virtual ~Core();
96 65
97 void Initialize(); 66 void Initialize();
98 void ConnectToChannel(bool success, const IPC::ChannelHandle& handle); 67 void ConnectToChannel(bool success, const IPC::ChannelHandle& handle);
99 68
100 void DeauthorizeContentLicensesOnIOThread(uint32 request_id); 69 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
114 void NotifyErrorFromIOThread(); 70 void NotifyErrorFromIOThread();
115 71
116 void NotifyDeauthorizeContentLicensesCompleted(uint32 request_id, 72 void NotifyDeauthorizeContentLicensesCompleted(uint32 request_id,
117 bool success); 73 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
126 void NotifyError( 74 void NotifyError(
127 const std::vector<std::pair<uint32, RequestType> >& notifications); 75 const std::vector<std::pair<uint32, RequestType> >& notifications);
128 76
129 // Message handlers. 77 // Message handlers.
130 void OnDeauthorizeContentLicensesResult(uint32 request_id, bool success); 78 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);
138 79
139 // Used only on the UI thread. 80 // Used only on the UI thread.
140 PepperFlashSettingsManager* manager_; 81 PepperFlashSettingsManager* manager_;
141 82
142 // Used only on the I/O thread. 83 // Used only on the I/O thread.
143 FilePath plugin_data_path_; 84 FilePath plugin_data_path_;
144 85
145 // The channel is NULL until we have opened a connection to the broker 86 // The channel is NULL until we have opened a connection to the broker
146 // process. Used only on the I/O thread. 87 // process. Used only on the I/O thread.
147 scoped_ptr<IPC::Channel> channel_; 88 scoped_ptr<IPC::Channel> channel_;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 void PepperFlashSettingsManager::Core::DeauthorizeContentLicenses( 133 void PepperFlashSettingsManager::Core::DeauthorizeContentLicenses(
193 uint32 request_id) { 134 uint32 request_id) {
194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
195 136
196 BrowserThread::PostTask( 137 BrowserThread::PostTask(
197 BrowserThread::IO, FROM_HERE, 138 BrowserThread::IO, FROM_HERE,
198 base::Bind(&Core::DeauthorizeContentLicensesOnIOThread, this, 139 base::Bind(&Core::DeauthorizeContentLicensesOnIOThread, this,
199 request_id)); 140 request_id));
200 } 141 }
201 142
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
238 bool PepperFlashSettingsManager::Core::OnMessageReceived( 143 bool PepperFlashSettingsManager::Core::OnMessageReceived(
239 const IPC::Message& message) { 144 const IPC::Message& message) {
240 IPC_BEGIN_MESSAGE_MAP(Core, message) 145 IPC_BEGIN_MESSAGE_MAP(Core, message)
241 IPC_MESSAGE_HANDLER(PpapiHostMsg_DeauthorizeContentLicensesResult, 146 IPC_MESSAGE_HANDLER(PpapiHostMsg_DeauthorizeContentLicensesResult,
242 OnDeauthorizeContentLicensesResult) 147 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)
249 IPC_MESSAGE_UNHANDLED_ERROR() 148 IPC_MESSAGE_UNHANDLED_ERROR()
250 IPC_END_MESSAGE_MAP() 149 IPC_END_MESSAGE_MAP()
251 150
252 return true; 151 return true;
253 } 152 }
254 153
255 void PepperFlashSettingsManager::Core::OnChannelError() { 154 void PepperFlashSettingsManager::Core::OnChannelError() {
256 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
257 156
258 NotifyErrorFromIOThread(); 157 NotifyErrorFromIOThread();
(...skipping 25 matching lines...) Expand all
284 } 183 }
285 184
286 void PepperFlashSettingsManager::Core::ConnectToChannel( 185 void PepperFlashSettingsManager::Core::ConnectToChannel(
287 bool success, 186 bool success,
288 const IPC::ChannelHandle& handle) { 187 const IPC::ChannelHandle& handle) {
289 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 188 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
290 DCHECK(!initialized_); 189 DCHECK(!initialized_);
291 DCHECK(!channel_.get()); 190 DCHECK(!channel_.get());
292 191
293 if (!success) { 192 if (!success) {
294 DLOG(ERROR) << "Couldn't open plugin channel"; 193 LOG(ERROR) << "Couldn't open plugin channel";
295 NotifyErrorFromIOThread(); 194 NotifyErrorFromIOThread();
296 return; 195 return;
297 } 196 }
298 197
299 channel_.reset(new IPC::Channel(handle, IPC::Channel::MODE_CLIENT, this)); 198 channel_.reset(new IPC::Channel(handle, IPC::Channel::MODE_CLIENT, this));
300 if (!channel_->Connect()) { 199 if (!channel_->Connect()) {
301 DLOG(ERROR) << "Couldn't connect to plugin"; 200 LOG(ERROR) << "Couldn't connect to plugin";
302 NotifyErrorFromIOThread(); 201 NotifyErrorFromIOThread();
303 return; 202 return;
304 } 203 }
305 204
306 initialized_ = true; 205 initialized_ = true;
307 206
308 std::vector<PendingRequest> temp_pending_requests; 207 std::vector<PendingRequest> temp_pending_requests;
309 temp_pending_requests.swap(pending_requests_); 208 temp_pending_requests.swap(pending_requests_);
310 for (std::vector<PendingRequest>::iterator iter = 209 for (std::vector<PendingRequest>::iterator iter =
311 temp_pending_requests.begin(); 210 temp_pending_requests.begin();
312 iter != temp_pending_requests.end(); ++iter) { 211 iter != temp_pending_requests.end(); ++iter) {
313 switch (iter->type) { 212 switch (iter->type) {
314 case DEAUTHORIZE_CONTENT_LICENSES: 213 case DEAUTHORIZE_CONTENT_LICENSES:
315 DeauthorizeContentLicensesOnIOThread(iter->id); 214 DeauthorizeContentLicensesOnIOThread(iter->id);
316 break; 215 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;
328 default: 216 default:
329 NOTREACHED(); 217 NOTREACHED();
330 break; 218 break;
331 } 219 }
332 } 220 }
333 } 221 }
334 222
335 void PepperFlashSettingsManager::Core::DeauthorizeContentLicensesOnIOThread( 223 void PepperFlashSettingsManager::Core::DeauthorizeContentLicensesOnIOThread(
336 uint32 request_id) { 224 uint32 request_id) {
337 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 225 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
338 226
339 if (!initialized_) { 227 if (!initialized_) {
340 PendingRequest request; 228 PendingRequest request;
341 request.id = request_id; 229 request.id = request_id;
342 request.type = DEAUTHORIZE_CONTENT_LICENSES; 230 request.type = DEAUTHORIZE_CONTENT_LICENSES;
343 pending_requests_.push_back(request); 231 pending_requests_.push_back(request);
344 return; 232 return;
345 } 233 }
346 234
347 pending_responses_.insert( 235 pending_responses_.insert(
348 std::make_pair(request_id, DEAUTHORIZE_CONTENT_LICENSES)); 236 std::make_pair(request_id, DEAUTHORIZE_CONTENT_LICENSES));
349 IPC::Message* msg = 237 IPC::Message* msg =
350 new PpapiMsg_DeauthorizeContentLicenses(request_id, plugin_data_path_); 238 new PpapiMsg_DeauthorizeContentLicenses(request_id, plugin_data_path_);
351 if (!channel_->Send(msg)) { 239 if (!channel_->Send(msg)) {
352 DLOG(ERROR) << "Couldn't send DeauthorizeContentLicenses message"; 240 LOG(ERROR) << "Couldn't send DeauthorizeContentLicenses message";
353 // A failure notification for the current request will be sent since
354 // |pending_responses_| has been updated.
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 241 // A failure notification for the current request will be sent since
437 // |pending_responses_| has been updated. 242 // |pending_responses_| has been updated.
438 NotifyErrorFromIOThread(); 243 NotifyErrorFromIOThread();
439 } 244 }
440 } 245 }
441 246
442 void PepperFlashSettingsManager::Core::NotifyErrorFromIOThread() { 247 void PepperFlashSettingsManager::Core::NotifyErrorFromIOThread() {
443 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 248 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
444 249
445 std::vector<std::pair<uint32, RequestType> > notifications; 250 std::vector<std::pair<uint32, RequestType> > notifications;
(...skipping 16 matching lines...) Expand all
462 uint32 request_id, 267 uint32 request_id,
463 bool success) { 268 bool success) {
464 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 269 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
465 270
466 if (manager_) { 271 if (manager_) {
467 manager_->client_->OnDeauthorizeContentLicensesCompleted( 272 manager_->client_->OnDeauthorizeContentLicensesCompleted(
468 request_id, success); 273 request_id, success);
469 } 274 }
470 } 275 }
471 276
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
507 void PepperFlashSettingsManager::Core::NotifyError( 277 void PepperFlashSettingsManager::Core::NotifyError(
508 const std::vector<std::pair<uint32, RequestType> >& notifications) { 278 const std::vector<std::pair<uint32, RequestType> >& notifications) {
509 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 279 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
510 280
511 scoped_refptr<Core> protector(this); 281 scoped_refptr<Core> protector(this);
512 for (std::vector<std::pair<uint32, RequestType> >::const_iterator iter = 282 for (std::vector<std::pair<uint32, RequestType> >::const_iterator iter =
513 notifications.begin(); iter != notifications.end(); ++iter) { 283 notifications.begin(); iter != notifications.end(); ++iter) {
514 // Check |manager_| for each iteration in case Detach() happens in one of 284 // Check |manager_| for each iteration in case Detach() happens in one of
515 // the callbacks. 285 // the callbacks.
516 if (manager_) { 286 if (manager_) {
517 switch (iter->second) { 287 switch (iter->second) {
518 case DEAUTHORIZE_CONTENT_LICENSES: 288 case DEAUTHORIZE_CONTENT_LICENSES:
519 manager_->client_->OnDeauthorizeContentLicensesCompleted( 289 manager_->client_->OnDeauthorizeContentLicensesCompleted(iter->first,
520 iter->first, false); 290 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);
533 break; 291 break;
534 default: 292 default:
535 NOTREACHED(); 293 NOTREACHED();
536 break; 294 break;
537 } 295 }
538 } 296 }
539 } 297 }
540 298
541 if (manager_) 299 if (manager_)
542 manager_->OnError(); 300 manager_->OnError();
543 } 301 }
544 302
545 void PepperFlashSettingsManager::Core::OnDeauthorizeContentLicensesResult( 303 void PepperFlashSettingsManager::Core::OnDeauthorizeContentLicensesResult(
546 uint32 request_id, 304 uint32 request_id,
547 bool success) { 305 bool success) {
548 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 306 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
549 DLOG_IF(ERROR, !success) << "DeauthorizeContentLicenses returned error"; 307 LOG_IF(ERROR, !success) << "DeauthorizeContentLicenses returned error";
550 308
551 std::map<uint32, RequestType>::iterator iter = 309 std::map<uint32, RequestType>::iterator iter =
552 pending_responses_.find(request_id); 310 pending_responses_.find(request_id);
553 if (iter != pending_responses_.end()) { 311 if (iter != pending_responses_.end()) {
554 DCHECK_EQ(iter->second, DEAUTHORIZE_CONTENT_LICENSES); 312 DCHECK_EQ(iter->second, DEAUTHORIZE_CONTENT_LICENSES);
555 313
556 pending_responses_.erase(iter); 314 pending_responses_.erase(iter);
557 BrowserThread::PostTask( 315 BrowserThread::PostTask(
558 BrowserThread::UI, FROM_HERE, 316 BrowserThread::UI, FROM_HERE,
559 base::Bind(&Core::NotifyDeauthorizeContentLicensesCompleted, this, 317 base::Bind(&Core::NotifyDeauthorizeContentLicensesCompleted, this,
560 request_id, success)); 318 request_id, success));
561 } 319 }
562 } 320 }
563 321
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
623 PepperFlashSettingsManager::PepperFlashSettingsManager( 322 PepperFlashSettingsManager::PepperFlashSettingsManager(
624 Client* client, 323 Client* client,
625 content::BrowserContext* browser_context) 324 content::BrowserContext* browser_context)
626 : client_(client), 325 : client_(client),
627 browser_context_(browser_context), 326 browser_context_(browser_context),
628 next_request_id_(1) { 327 next_request_id_(1) {
629 DCHECK(client); 328 DCHECK(client);
630 DCHECK(browser_context); 329 DCHECK(browser_context);
631 } 330 }
632 331
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 373
675 uint32 PepperFlashSettingsManager::DeauthorizeContentLicenses() { 374 uint32 PepperFlashSettingsManager::DeauthorizeContentLicenses() {
676 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 375 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
677 376
678 EnsureCoreExists(); 377 EnsureCoreExists();
679 uint32 id = GetNextRequestId(); 378 uint32 id = GetNextRequestId();
680 core_->DeauthorizeContentLicenses(id); 379 core_->DeauthorizeContentLicenses(id);
681 return id; 380 return id;
682 } 381 }
683 382
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
718 uint32 PepperFlashSettingsManager::GetNextRequestId() { 383 uint32 PepperFlashSettingsManager::GetNextRequestId() {
719 return next_request_id_++; 384 return next_request_id_++;
720 } 385 }
721 386
722 void PepperFlashSettingsManager::EnsureCoreExists() { 387 void PepperFlashSettingsManager::EnsureCoreExists() {
723 if (!core_.get()) 388 if (!core_.get())
724 core_ = new Core(this, browser_context_); 389 core_ = new Core(this, browser_context_);
725 } 390 }
726 391
727 void PepperFlashSettingsManager::OnError() { 392 void PepperFlashSettingsManager::OnError() {
728 if (core_.get()) { 393 if (core_.get()) {
729 core_->Detach(); 394 core_->Detach();
730 core_ = NULL; 395 core_ = NULL;
731 } else { 396 } else {
732 NOTREACHED(); 397 NOTREACHED();
733 } 398 }
734 } 399 }
735 400
OLDNEW
« no previous file with comments | « chrome/browser/pepper_flash_settings_manager.h ('k') | chrome/browser/resources/options2/content_settings.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698