| 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 15 matching lines...) Expand all Loading... |
| 26 #include "ppapi/proxy/ppapi_messages.h" | 26 #include "ppapi/proxy/ppapi_messages.h" |
| 27 #include "webkit/plugins/plugin_constants.h" | 27 #include "webkit/plugins/plugin_constants.h" |
| 28 #include "webkit/plugins/webplugininfo.h" | 28 #include "webkit/plugins/webplugininfo.h" |
| 29 | 29 |
| 30 using content::BrowserThread; | 30 using content::BrowserThread; |
| 31 | 31 |
| 32 class PepperFlashSettingsManager::Core | 32 class PepperFlashSettingsManager::Core |
| 33 : public IPC::Listener, | 33 : public IPC::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(base::WeakPtr<PepperFlashSettingsManager> manager, |
| 37 content::BrowserContext* browser_context); | 37 content::BrowserContext* browser_context); |
| 38 | 38 |
| 39 void Initialize(); | 39 void Initialize(); |
| 40 // Stops sending notifications to |manager_| and sets it to NULL. | 40 |
| 41 // Notifies the core that it has been detached. Afterwards, no method should |
| 42 // be called any more. |
| 41 void Detach(); | 43 void Detach(); |
| 42 | 44 |
| 43 void DeauthorizeContentLicenses(uint32 request_id); | 45 void DeauthorizeContentLicenses(uint32 request_id); |
| 44 void GetPermissionSettings( | 46 void GetPermissionSettings( |
| 45 uint32 request_id, | 47 uint32 request_id, |
| 46 PP_Flash_BrowserOperations_SettingType setting_type); | 48 PP_Flash_BrowserOperations_SettingType setting_type); |
| 47 void SetDefaultPermission( | 49 void SetDefaultPermission( |
| 48 uint32 request_id, | 50 uint32 request_id, |
| 49 PP_Flash_BrowserOperations_SettingType setting_type, | 51 PP_Flash_BrowserOperations_SettingType setting_type, |
| 50 PP_Flash_BrowserOperations_Permission permission, | 52 PP_Flash_BrowserOperations_Permission permission, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 69 enum RequestType { | 71 enum RequestType { |
| 70 INVALID_REQUEST_TYPE = 0, | 72 INVALID_REQUEST_TYPE = 0, |
| 71 DEAUTHORIZE_CONTENT_LICENSES, | 73 DEAUTHORIZE_CONTENT_LICENSES, |
| 72 GET_PERMISSION_SETTINGS, | 74 GET_PERMISSION_SETTINGS, |
| 73 SET_DEFAULT_PERMISSION, | 75 SET_DEFAULT_PERMISSION, |
| 74 SET_SITE_PERMISSION, | 76 SET_SITE_PERMISSION, |
| 75 GET_SITES_WITH_DATA, | 77 GET_SITES_WITH_DATA, |
| 76 CLEAR_SITE_DATA, | 78 CLEAR_SITE_DATA, |
| 77 }; | 79 }; |
| 78 | 80 |
| 81 enum State { |
| 82 STATE_UNINITIALIZED = 0, |
| 83 STATE_INITIALIZED, |
| 84 STATE_ERROR, |
| 85 STATE_DETACHED, |
| 86 }; |
| 87 |
| 79 struct PendingRequest { | 88 struct PendingRequest { |
| 80 PendingRequest() | 89 PendingRequest() |
| 81 : id(0), | 90 : id(0), |
| 82 type(INVALID_REQUEST_TYPE), | 91 type(INVALID_REQUEST_TYPE), |
| 83 setting_type(PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC), | 92 setting_type(PP_FLASH_BROWSEROPERATIONS_SETTINGTYPE_CAMERAMIC), |
| 84 permission(PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT), | 93 permission(PP_FLASH_BROWSEROPERATIONS_PERMISSION_DEFAULT), |
| 85 clear_site_specific(false), | 94 clear_site_specific(false), |
| 86 flags(0), | 95 flags(0), |
| 87 max_age(0) { | 96 max_age(0) { |
| 88 } | 97 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 bool success, | 166 bool success, |
| 158 PP_Flash_BrowserOperations_Permission default_permission, | 167 PP_Flash_BrowserOperations_Permission default_permission, |
| 159 const ppapi::FlashSiteSettings& sites); | 168 const ppapi::FlashSiteSettings& sites); |
| 160 void OnSetDefaultPermissionResult(uint32 request_id, bool success); | 169 void OnSetDefaultPermissionResult(uint32 request_id, bool success); |
| 161 void OnSetSitePermissionResult(uint32 request_id, bool success); | 170 void OnSetSitePermissionResult(uint32 request_id, bool success); |
| 162 void OnGetSitesWithDataResult(uint32 request_id, | 171 void OnGetSitesWithDataResult(uint32 request_id, |
| 163 const std::vector<std::string>& sites); | 172 const std::vector<std::string>& sites); |
| 164 void OnClearSiteDataResult(uint32 request_id, bool success); | 173 void OnClearSiteDataResult(uint32 request_id, bool success); |
| 165 | 174 |
| 166 // Used only on the UI thread. | 175 // Used only on the UI thread. |
| 167 PepperFlashSettingsManager* manager_; | 176 base::WeakPtr<PepperFlashSettingsManager> manager_; |
| 168 | 177 |
| 169 // Used only on the I/O thread. | 178 // Used only on the I/O thread. |
| 170 FilePath plugin_data_path_; | 179 FilePath plugin_data_path_; |
| 171 | 180 |
| 172 // The channel is NULL until we have opened a connection to the broker | 181 // The channel is NULL until we have opened a connection to the broker |
| 173 // process. Used only on the I/O thread. | 182 // process. Used only on the I/O thread. |
| 174 scoped_ptr<IPC::Channel> channel_; | 183 scoped_ptr<IPC::Channel> channel_; |
| 175 | 184 |
| 176 // Used only on the I/O thread. | 185 // Used only on the I/O thread. |
| 177 bool initialized_; | 186 State state_; |
| 178 // Whether Detach() has been called on the UI thread. When it is true, further | |
| 179 // work is not necessary. Used only on the I/O thread. | |
| 180 bool detached_; | |
| 181 | 187 |
| 182 // Requests that need to be sent once the channel to the broker process is | 188 // Requests that need to be sent once the channel to the broker process is |
| 183 // established. Used only on the I/O thread. | 189 // established. Used only on the I/O thread. |
| 184 std::vector<PendingRequest> pending_requests_; | 190 std::vector<PendingRequest> pending_requests_; |
| 185 // Requests that have been sent but haven't got replied. Used only on the | 191 // Requests that have been sent but haven't got replied. Used only on the |
| 186 // I/O thread. | 192 // I/O thread. |
| 187 std::map<uint32, RequestType> pending_responses_; | 193 std::map<uint32, RequestType> pending_responses_; |
| 188 | 194 |
| 189 // Used only on the I/O thread. | 195 // Used only on the I/O thread. |
| 190 scoped_refptr<content::PepperFlashSettingsHelper> helper_; | 196 scoped_refptr<content::PepperFlashSettingsHelper> helper_; |
| 191 | 197 |
| 192 // Path for the current profile. Must be retrieved on the UI thread from the | 198 // Path for the current profile. Must be retrieved on the UI thread from the |
| 193 // browser context when we start so we can use it later on the I/O thread. | 199 // browser context when we start so we can use it later on the I/O thread. |
| 194 FilePath browser_context_path_; | 200 FilePath browser_context_path_; |
| 195 | 201 |
| 196 scoped_refptr<PluginPrefs> plugin_prefs_; | 202 scoped_refptr<PluginPrefs> plugin_prefs_; |
| 197 }; | 203 }; |
| 198 | 204 |
| 199 PepperFlashSettingsManager::Core::Core(PepperFlashSettingsManager* manager, | 205 PepperFlashSettingsManager::Core::Core( |
| 200 content::BrowserContext* browser_context) | 206 base::WeakPtr<PepperFlashSettingsManager> manager, |
| 207 content::BrowserContext* browser_context) |
| 201 : manager_(manager), | 208 : manager_(manager), |
| 202 initialized_(false), | 209 state_(STATE_UNINITIALIZED), |
| 203 detached_(false), | |
| 204 browser_context_path_(browser_context->GetPath()), | 210 browser_context_path_(browser_context->GetPath()), |
| 205 plugin_prefs_(PluginPrefs::GetForProfile( | 211 plugin_prefs_(PluginPrefs::GetForProfile( |
| 206 Profile::FromBrowserContext(browser_context))) { | 212 Profile::FromBrowserContext(browser_context))) { |
| 207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 213 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 208 } | 214 } |
| 209 | 215 |
| 210 PepperFlashSettingsManager::Core::~Core() { | 216 PepperFlashSettingsManager::Core::~Core() { |
| 211 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 212 } | 218 } |
| 213 | 219 |
| 214 void PepperFlashSettingsManager::Core::Initialize() { | 220 void PepperFlashSettingsManager::Core::Initialize() { |
| 215 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 221 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 216 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 222 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 217 base::Bind(&Core::InitializeOnIOThread, this)); | 223 base::Bind(&Core::InitializeOnIOThread, this)); |
| 218 } | 224 } |
| 219 | 225 |
| 220 void PepperFlashSettingsManager::Core::Detach() { | 226 void PepperFlashSettingsManager::Core::Detach() { |
| 221 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 222 | 228 |
| 223 manager_ = NULL; | 229 // This call guarantees that one ref is retained until we get to the DETACHED |
| 224 // This call guarantees that one ref is retained until |detached_| is set to | 230 // state. This is important. Otherwise, if the ref count drops to zero on the |
| 225 // true. This is important. Otherwise, if the ref count drops to zero on the | |
| 226 // UI thread (which posts a task to delete this object on the I/O thread) | 231 // UI thread (which posts a task to delete this object on the I/O thread) |
| 227 // while the I/O thread doesn't know about it, methods on the I/O thread might | 232 // while the I/O thread doesn't know about it, methods on the I/O thread might |
| 228 // increase the ref count again and cause double deletion. | 233 // increase the ref count again and cause double deletion. |
| 229 BrowserThread::PostTask( | 234 BrowserThread::PostTask( |
| 230 BrowserThread::IO, FROM_HERE, base::Bind(&Core::DetachOnIOThread, this)); | 235 BrowserThread::IO, FROM_HERE, base::Bind(&Core::DetachOnIOThread, this)); |
| 231 } | 236 } |
| 232 | 237 |
| 233 void PepperFlashSettingsManager::Core::DeauthorizeContentLicenses( | 238 void PepperFlashSettingsManager::Core::DeauthorizeContentLicenses( |
| 234 uint32 request_id) { | 239 uint32 request_id) { |
| 235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 258 bool clear_site_specific) { | 263 bool clear_site_specific) { |
| 259 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 264 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 260 | 265 |
| 261 BrowserThread::PostTask( | 266 BrowserThread::PostTask( |
| 262 BrowserThread::IO, FROM_HERE, | 267 BrowserThread::IO, FROM_HERE, |
| 263 base::Bind(&Core::SetDefaultPermissionOnIOThread, this, request_id, | 268 base::Bind(&Core::SetDefaultPermissionOnIOThread, this, request_id, |
| 264 setting_type, permission, clear_site_specific)); | 269 setting_type, permission, clear_site_specific)); |
| 265 } | 270 } |
| 266 | 271 |
| 267 void PepperFlashSettingsManager::Core::SetSitePermission( | 272 void PepperFlashSettingsManager::Core::SetSitePermission( |
| 268 uint32 request_id, | 273 uint32 request_id, |
| 269 PP_Flash_BrowserOperations_SettingType setting_type, | 274 PP_Flash_BrowserOperations_SettingType setting_type, |
| 270 const ppapi::FlashSiteSettings& sites) { | 275 const ppapi::FlashSiteSettings& sites) { |
| 271 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 276 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 272 | 277 |
| 273 BrowserThread::PostTask( | 278 BrowserThread::PostTask( |
| 274 BrowserThread::IO, FROM_HERE, | 279 BrowserThread::IO, FROM_HERE, |
| 275 base::Bind(&Core::SetSitePermissionOnIOThread, this, request_id, | 280 base::Bind(&Core::SetSitePermissionOnIOThread, this, request_id, |
| 276 setting_type, sites)); | 281 setting_type, sites)); |
| 277 } | 282 } |
| 278 | 283 |
| 279 void PepperFlashSettingsManager::Core::GetSitesWithData(uint32 request_id) { | 284 void PepperFlashSettingsManager::Core::GetSitesWithData(uint32 request_id) { |
| 280 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 285 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 IPC_MESSAGE_HANDLER(PpapiHostMsg_ClearSiteDataResult, | 317 IPC_MESSAGE_HANDLER(PpapiHostMsg_ClearSiteDataResult, |
| 313 OnClearSiteDataResult) | 318 OnClearSiteDataResult) |
| 314 IPC_MESSAGE_UNHANDLED_ERROR() | 319 IPC_MESSAGE_UNHANDLED_ERROR() |
| 315 IPC_END_MESSAGE_MAP() | 320 IPC_END_MESSAGE_MAP() |
| 316 | 321 |
| 317 return true; | 322 return true; |
| 318 } | 323 } |
| 319 | 324 |
| 320 void PepperFlashSettingsManager::Core::OnChannelError() { | 325 void PepperFlashSettingsManager::Core::OnChannelError() { |
| 321 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 326 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 322 if (detached_) | 327 if (state_ == STATE_DETACHED) |
| 323 return; | 328 return; |
| 324 | 329 |
| 325 NotifyErrorFromIOThread(); | 330 NotifyErrorFromIOThread(); |
| 326 } | 331 } |
| 327 | 332 |
| 328 void PepperFlashSettingsManager::Core::ConnectToChannel( | 333 void PepperFlashSettingsManager::Core::ConnectToChannel( |
| 329 bool success, | 334 bool success, |
| 330 const IPC::ChannelHandle& handle) { | 335 const IPC::ChannelHandle& handle) { |
| 331 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 336 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 332 if (detached_) | 337 if (state_ == STATE_DETACHED) |
| 333 return; | 338 return; |
| 334 | 339 |
| 335 DCHECK(!initialized_); | 340 DCHECK(state_ == STATE_UNINITIALIZED); |
| 336 DCHECK(!channel_.get()); | 341 DCHECK(!channel_.get()); |
| 337 | 342 |
| 338 if (!success) { | 343 if (!success) { |
| 339 DLOG(ERROR) << "Couldn't open plugin channel"; | 344 DLOG(ERROR) << "Couldn't open plugin channel"; |
| 340 NotifyErrorFromIOThread(); | 345 NotifyErrorFromIOThread(); |
| 341 return; | 346 return; |
| 342 } | 347 } |
| 343 | 348 |
| 344 channel_.reset(new IPC::Channel(handle, IPC::Channel::MODE_CLIENT, this)); | 349 channel_.reset(new IPC::Channel(handle, IPC::Channel::MODE_CLIENT, this)); |
| 345 if (!channel_->Connect()) { | 350 if (!channel_->Connect()) { |
| 346 DLOG(ERROR) << "Couldn't connect to plugin"; | 351 DLOG(ERROR) << "Couldn't connect to plugin"; |
| 347 NotifyErrorFromIOThread(); | 352 NotifyErrorFromIOThread(); |
| 348 return; | 353 return; |
| 349 } | 354 } |
| 350 | 355 |
| 351 initialized_ = true; | 356 state_ = STATE_INITIALIZED; |
| 352 | 357 |
| 353 std::vector<PendingRequest> temp_pending_requests; | 358 std::vector<PendingRequest> temp_pending_requests; |
| 354 temp_pending_requests.swap(pending_requests_); | 359 temp_pending_requests.swap(pending_requests_); |
| 355 for (std::vector<PendingRequest>::iterator iter = | 360 for (std::vector<PendingRequest>::iterator iter = |
| 356 temp_pending_requests.begin(); | 361 temp_pending_requests.begin(); |
| 357 iter != temp_pending_requests.end(); ++iter) { | 362 iter != temp_pending_requests.end(); ++iter) { |
| 358 switch (iter->type) { | 363 switch (iter->type) { |
| 359 case INVALID_REQUEST_TYPE: | 364 case INVALID_REQUEST_TYPE: |
| 360 NOTREACHED(); | 365 NOTREACHED(); |
| 361 break; | 366 break; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 379 case CLEAR_SITE_DATA: | 384 case CLEAR_SITE_DATA: |
| 380 ClearSiteDataOnIOThread(iter->id, iter->site, iter->flags, | 385 ClearSiteDataOnIOThread(iter->id, iter->site, iter->flags, |
| 381 iter->max_age); | 386 iter->max_age); |
| 382 break; | 387 break; |
| 383 } | 388 } |
| 384 } | 389 } |
| 385 } | 390 } |
| 386 | 391 |
| 387 void PepperFlashSettingsManager::Core::InitializeOnIOThread() { | 392 void PepperFlashSettingsManager::Core::InitializeOnIOThread() { |
| 388 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 393 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 389 DCHECK(!initialized_); | 394 DCHECK_EQ(STATE_UNINITIALIZED, state_); |
| 390 | |
| 391 if (detached_) | |
| 392 return; | |
| 393 | 395 |
| 394 webkit::WebPluginInfo plugin_info; | 396 webkit::WebPluginInfo plugin_info; |
| 395 if (!PepperFlashSettingsManager::IsPepperFlashInUse(plugin_prefs_.get(), | 397 if (!PepperFlashSettingsManager::IsPepperFlashInUse(plugin_prefs_.get(), |
| 396 &plugin_info)) { | 398 &plugin_info)) { |
| 397 NotifyErrorFromIOThread(); | 399 NotifyErrorFromIOThread(); |
| 398 return; | 400 return; |
| 399 } | 401 } |
| 400 | 402 |
| 401 FilePath profile_path = | 403 FilePath profile_path = |
| 402 browser_context_path_.Append(content::kPepperDataDirname); | 404 browser_context_path_.Append(content::kPepperDataDirname); |
| 403 #if defined(OS_WIN) | 405 #if defined(OS_WIN) |
| 404 plugin_data_path_ = profile_path.Append(plugin_info.name); | 406 plugin_data_path_ = profile_path.Append(plugin_info.name); |
| 405 #else | 407 #else |
| 406 plugin_data_path_ = profile_path.Append(UTF16ToUTF8(plugin_info.name)); | 408 plugin_data_path_ = profile_path.Append(UTF16ToUTF8(plugin_info.name)); |
| 407 #endif | 409 #endif |
| 408 | 410 |
| 409 helper_ = content::PepperFlashSettingsHelper::Create(); | 411 helper_ = content::PepperFlashSettingsHelper::Create(); |
| 410 content::PepperFlashSettingsHelper::OpenChannelCallback callback = | 412 content::PepperFlashSettingsHelper::OpenChannelCallback callback = |
| 411 base::Bind(&Core::ConnectToChannel, this); | 413 base::Bind(&Core::ConnectToChannel, this); |
| 412 helper_->OpenChannelToBroker(plugin_info.path, callback); | 414 helper_->OpenChannelToBroker(plugin_info.path, callback); |
| 413 } | 415 } |
| 414 | 416 |
| 415 void PepperFlashSettingsManager::Core::DeauthorizeContentLicensesOnIOThread( | 417 void PepperFlashSettingsManager::Core::DeauthorizeContentLicensesOnIOThread( |
| 416 uint32 request_id) { | 418 uint32 request_id) { |
| 417 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 419 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 418 if (detached_) | 420 DCHECK_NE(STATE_DETACHED, state_); |
| 419 return; | |
| 420 | 421 |
| 421 if (!initialized_) { | 422 if (state_ == STATE_UNINITIALIZED) { |
| 422 PendingRequest request; | 423 PendingRequest request; |
| 423 request.id = request_id; | 424 request.id = request_id; |
| 424 request.type = DEAUTHORIZE_CONTENT_LICENSES; | 425 request.type = DEAUTHORIZE_CONTENT_LICENSES; |
| 425 pending_requests_.push_back(request); | 426 pending_requests_.push_back(request); |
| 426 return; | 427 return; |
| 427 } | 428 } |
| 428 | 429 |
| 429 pending_responses_.insert( | 430 pending_responses_.insert( |
| 430 std::make_pair(request_id, DEAUTHORIZE_CONTENT_LICENSES)); | 431 std::make_pair(request_id, DEAUTHORIZE_CONTENT_LICENSES)); |
| 432 if (state_ == STATE_ERROR) { |
| 433 NotifyErrorFromIOThread(); |
| 434 return; |
| 435 } |
| 436 |
| 431 IPC::Message* msg = | 437 IPC::Message* msg = |
| 432 new PpapiMsg_DeauthorizeContentLicenses(request_id, plugin_data_path_); | 438 new PpapiMsg_DeauthorizeContentLicenses(request_id, plugin_data_path_); |
| 433 if (!channel_->Send(msg)) { | 439 if (!channel_->Send(msg)) { |
| 434 DLOG(ERROR) << "Couldn't send DeauthorizeContentLicenses message"; | 440 DLOG(ERROR) << "Couldn't send DeauthorizeContentLicenses message"; |
| 435 // A failure notification for the current request will be sent since | 441 // A failure notification for the current request will be sent since |
| 436 // |pending_responses_| has been updated. | 442 // |pending_responses_| has been updated. |
| 437 NotifyErrorFromIOThread(); | 443 NotifyErrorFromIOThread(); |
| 438 } | 444 } |
| 439 } | 445 } |
| 440 | 446 |
| 441 void PepperFlashSettingsManager::Core::GetPermissionSettingsOnIOThread( | 447 void PepperFlashSettingsManager::Core::GetPermissionSettingsOnIOThread( |
| 442 uint32 request_id, | 448 uint32 request_id, |
| 443 PP_Flash_BrowserOperations_SettingType setting_type) { | 449 PP_Flash_BrowserOperations_SettingType setting_type) { |
| 444 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 450 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 445 if (detached_) | 451 DCHECK_NE(STATE_DETACHED, state_); |
| 446 return; | |
| 447 | 452 |
| 448 if (!initialized_) { | 453 if (state_ == STATE_UNINITIALIZED) { |
| 449 PendingRequest request; | 454 PendingRequest request; |
| 450 request.id = request_id; | 455 request.id = request_id; |
| 451 request.type = GET_PERMISSION_SETTINGS; | 456 request.type = GET_PERMISSION_SETTINGS; |
| 452 request.setting_type = setting_type; | 457 request.setting_type = setting_type; |
| 453 pending_requests_.push_back(request); | 458 pending_requests_.push_back(request); |
| 454 return; | 459 return; |
| 455 } | 460 } |
| 456 | 461 |
| 457 pending_responses_.insert( | 462 pending_responses_.insert( |
| 458 std::make_pair(request_id, GET_PERMISSION_SETTINGS)); | 463 std::make_pair(request_id, GET_PERMISSION_SETTINGS)); |
| 464 if (state_ == STATE_ERROR) { |
| 465 NotifyErrorFromIOThread(); |
| 466 return; |
| 467 } |
| 468 |
| 459 IPC::Message* msg = new PpapiMsg_GetPermissionSettings( | 469 IPC::Message* msg = new PpapiMsg_GetPermissionSettings( |
| 460 request_id, plugin_data_path_, setting_type); | 470 request_id, plugin_data_path_, setting_type); |
| 461 if (!channel_->Send(msg)) { | 471 if (!channel_->Send(msg)) { |
| 462 DLOG(ERROR) << "Couldn't send GetPermissionSettings message"; | 472 DLOG(ERROR) << "Couldn't send GetPermissionSettings message"; |
| 463 // A failure notification for the current request will be sent since | 473 // A failure notification for the current request will be sent since |
| 464 // |pending_responses_| has been updated. | 474 // |pending_responses_| has been updated. |
| 465 NotifyErrorFromIOThread(); | 475 NotifyErrorFromIOThread(); |
| 466 } | 476 } |
| 467 } | 477 } |
| 468 | 478 |
| 469 void PepperFlashSettingsManager::Core::SetDefaultPermissionOnIOThread( | 479 void PepperFlashSettingsManager::Core::SetDefaultPermissionOnIOThread( |
| 470 uint32 request_id, | 480 uint32 request_id, |
| 471 PP_Flash_BrowserOperations_SettingType setting_type, | 481 PP_Flash_BrowserOperations_SettingType setting_type, |
| 472 PP_Flash_BrowserOperations_Permission permission, | 482 PP_Flash_BrowserOperations_Permission permission, |
| 473 bool clear_site_specific) { | 483 bool clear_site_specific) { |
| 474 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 484 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 475 if (detached_) | 485 DCHECK_NE(STATE_DETACHED, state_); |
| 476 return; | |
| 477 | 486 |
| 478 if (!initialized_) { | 487 if (state_ == STATE_UNINITIALIZED) { |
| 479 PendingRequest request; | 488 PendingRequest request; |
| 480 request.id = request_id; | 489 request.id = request_id; |
| 481 request.type = SET_DEFAULT_PERMISSION; | 490 request.type = SET_DEFAULT_PERMISSION; |
| 482 request.setting_type = setting_type; | 491 request.setting_type = setting_type; |
| 483 request.permission = permission; | 492 request.permission = permission; |
| 484 request.clear_site_specific = clear_site_specific; | 493 request.clear_site_specific = clear_site_specific; |
| 485 pending_requests_.push_back(request); | 494 pending_requests_.push_back(request); |
| 486 return; | 495 return; |
| 487 } | 496 } |
| 488 | 497 |
| 489 pending_responses_.insert(std::make_pair(request_id, SET_DEFAULT_PERMISSION)); | 498 pending_responses_.insert(std::make_pair(request_id, SET_DEFAULT_PERMISSION)); |
| 499 if (state_ == STATE_ERROR) { |
| 500 NotifyErrorFromIOThread(); |
| 501 return; |
| 502 } |
| 503 |
| 490 IPC::Message* msg = new PpapiMsg_SetDefaultPermission( | 504 IPC::Message* msg = new PpapiMsg_SetDefaultPermission( |
| 491 request_id, plugin_data_path_, setting_type, permission, | 505 request_id, plugin_data_path_, setting_type, permission, |
| 492 clear_site_specific); | 506 clear_site_specific); |
| 493 if (!channel_->Send(msg)) { | 507 if (!channel_->Send(msg)) { |
| 494 DLOG(ERROR) << "Couldn't send SetDefaultPermission message"; | 508 DLOG(ERROR) << "Couldn't send SetDefaultPermission message"; |
| 495 // A failure notification for the current request will be sent since | 509 // A failure notification for the current request will be sent since |
| 496 // |pending_responses_| has been updated. | 510 // |pending_responses_| has been updated. |
| 497 NotifyErrorFromIOThread(); | 511 NotifyErrorFromIOThread(); |
| 498 } | 512 } |
| 499 } | 513 } |
| 500 | 514 |
| 501 void PepperFlashSettingsManager::Core::SetSitePermissionOnIOThread( | 515 void PepperFlashSettingsManager::Core::SetSitePermissionOnIOThread( |
| 502 uint32 request_id, | 516 uint32 request_id, |
| 503 PP_Flash_BrowserOperations_SettingType setting_type, | 517 PP_Flash_BrowserOperations_SettingType setting_type, |
| 504 const ppapi::FlashSiteSettings& sites) { | 518 const ppapi::FlashSiteSettings& sites) { |
| 505 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 519 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 506 if (detached_) | 520 DCHECK_NE(STATE_DETACHED, state_); |
| 507 return; | |
| 508 | 521 |
| 509 if (!initialized_) { | 522 if (state_ == STATE_UNINITIALIZED) { |
| 510 pending_requests_.push_back(PendingRequest()); | 523 pending_requests_.push_back(PendingRequest()); |
| 511 PendingRequest& request = pending_requests_.back(); | 524 PendingRequest& request = pending_requests_.back(); |
| 512 request.id = request_id; | 525 request.id = request_id; |
| 513 request.type = SET_SITE_PERMISSION; | 526 request.type = SET_SITE_PERMISSION; |
| 514 request.setting_type = setting_type; | 527 request.setting_type = setting_type; |
| 515 request.sites = sites; | 528 request.sites = sites; |
| 516 return; | 529 return; |
| 517 } | 530 } |
| 518 | 531 |
| 519 pending_responses_.insert(std::make_pair(request_id, SET_SITE_PERMISSION)); | 532 pending_responses_.insert(std::make_pair(request_id, SET_SITE_PERMISSION)); |
| 533 if (state_ == STATE_ERROR) { |
| 534 NotifyErrorFromIOThread(); |
| 535 return; |
| 536 } |
| 537 |
| 520 IPC::Message* msg = new PpapiMsg_SetSitePermission( | 538 IPC::Message* msg = new PpapiMsg_SetSitePermission( |
| 521 request_id, plugin_data_path_, setting_type, sites); | 539 request_id, plugin_data_path_, setting_type, sites); |
| 522 if (!channel_->Send(msg)) { | 540 if (!channel_->Send(msg)) { |
| 523 DLOG(ERROR) << "Couldn't send SetSitePermission message"; | 541 DLOG(ERROR) << "Couldn't send SetSitePermission message"; |
| 524 // A failure notification for the current request will be sent since | 542 // A failure notification for the current request will be sent since |
| 525 // |pending_responses_| has been updated. | 543 // |pending_responses_| has been updated. |
| 526 NotifyErrorFromIOThread(); | 544 NotifyErrorFromIOThread(); |
| 527 } | 545 } |
| 528 } | 546 } |
| 529 | 547 |
| 530 void PepperFlashSettingsManager::Core::GetSitesWithDataOnIOThread( | 548 void PepperFlashSettingsManager::Core::GetSitesWithDataOnIOThread( |
| 531 uint32 request_id) { | 549 uint32 request_id) { |
| 532 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 550 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 533 if (detached_) | 551 DCHECK_NE(STATE_DETACHED, state_); |
| 534 return; | |
| 535 | 552 |
| 536 if (!initialized_) { | 553 if (state_ == STATE_UNINITIALIZED) { |
| 537 pending_requests_.push_back(PendingRequest()); | 554 pending_requests_.push_back(PendingRequest()); |
| 538 PendingRequest& request = pending_requests_.back(); | 555 PendingRequest& request = pending_requests_.back(); |
| 539 request.id = request_id; | 556 request.id = request_id; |
| 540 request.type = GET_SITES_WITH_DATA; | 557 request.type = GET_SITES_WITH_DATA; |
| 541 return; | 558 return; |
| 542 } | 559 } |
| 543 | 560 |
| 544 pending_responses_.insert(std::make_pair(request_id, GET_SITES_WITH_DATA)); | 561 pending_responses_.insert(std::make_pair(request_id, GET_SITES_WITH_DATA)); |
| 562 if (state_ == STATE_ERROR) { |
| 563 NotifyErrorFromIOThread(); |
| 564 return; |
| 565 } |
| 566 |
| 545 IPC::Message* msg = new PpapiMsg_GetSitesWithData( | 567 IPC::Message* msg = new PpapiMsg_GetSitesWithData( |
| 546 request_id, plugin_data_path_); | 568 request_id, plugin_data_path_); |
| 547 if (!channel_->Send(msg)) { | 569 if (!channel_->Send(msg)) { |
| 548 DLOG(ERROR) << "Couldn't send GetSitesWithData message"; | 570 DLOG(ERROR) << "Couldn't send GetSitesWithData message"; |
| 549 // A failure notification for the current request will be sent since | 571 // A failure notification for the current request will be sent since |
| 550 // |pending_responses_| has been updated. | 572 // |pending_responses_| has been updated. |
| 551 NotifyErrorFromIOThread(); | 573 NotifyErrorFromIOThread(); |
| 552 } | 574 } |
| 553 } | 575 } |
| 554 | 576 |
| 555 void PepperFlashSettingsManager::Core::ClearSiteDataOnIOThread( | 577 void PepperFlashSettingsManager::Core::ClearSiteDataOnIOThread( |
| 556 uint32 request_id, | 578 uint32 request_id, |
| 557 const std::string& site, | 579 const std::string& site, |
| 558 uint64 flags, | 580 uint64 flags, |
| 559 uint64 max_age) { | 581 uint64 max_age) { |
| 560 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 582 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 561 if (detached_) | 583 DCHECK_NE(STATE_DETACHED, state_); |
| 562 return; | |
| 563 | 584 |
| 564 if (!initialized_) { | 585 if (state_ == STATE_UNINITIALIZED) { |
| 565 pending_requests_.push_back(PendingRequest()); | 586 pending_requests_.push_back(PendingRequest()); |
| 566 PendingRequest& request = pending_requests_.back(); | 587 PendingRequest& request = pending_requests_.back(); |
| 567 request.id = request_id; | 588 request.id = request_id; |
| 568 request.type = CLEAR_SITE_DATA; | 589 request.type = CLEAR_SITE_DATA; |
| 569 request.site = site; | 590 request.site = site; |
| 570 request.flags = flags; | 591 request.flags = flags; |
| 571 request.max_age = max_age; | 592 request.max_age = max_age; |
| 572 return; | 593 return; |
| 573 } | 594 } |
| 574 | 595 |
| 575 pending_responses_.insert(std::make_pair(request_id, CLEAR_SITE_DATA)); | 596 pending_responses_.insert(std::make_pair(request_id, CLEAR_SITE_DATA)); |
| 597 if (state_ == STATE_ERROR) { |
| 598 NotifyErrorFromIOThread(); |
| 599 return; |
| 600 } |
| 601 |
| 576 IPC::Message* msg = new PpapiMsg_ClearSiteData( | 602 IPC::Message* msg = new PpapiMsg_ClearSiteData( |
| 577 request_id, plugin_data_path_, site, flags, max_age); | 603 request_id, plugin_data_path_, site, flags, max_age); |
| 578 if (!channel_->Send(msg)) { | 604 if (!channel_->Send(msg)) { |
| 579 DLOG(ERROR) << "Couldn't send ClearSiteData message"; | 605 DLOG(ERROR) << "Couldn't send ClearSiteData message"; |
| 580 // A failure notification for the current request will be sent since | 606 // A failure notification for the current request will be sent since |
| 581 // |pending_responses_| has been updated. | 607 // |pending_responses_| has been updated. |
| 582 NotifyErrorFromIOThread(); | 608 NotifyErrorFromIOThread(); |
| 583 } | 609 } |
| 584 } | 610 } |
| 585 | 611 |
| 586 void PepperFlashSettingsManager::Core::DetachOnIOThread() { | 612 void PepperFlashSettingsManager::Core::DetachOnIOThread() { |
| 587 detached_ = true; | 613 state_ = STATE_DETACHED; |
| 588 } | 614 } |
| 589 | 615 |
| 590 void PepperFlashSettingsManager::Core::NotifyErrorFromIOThread() { | 616 void PepperFlashSettingsManager::Core::NotifyErrorFromIOThread() { |
| 591 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 617 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 592 if (detached_) | 618 if (state_ == STATE_DETACHED) |
| 593 return; | 619 return; |
| 594 | 620 |
| 621 state_ = STATE_ERROR; |
| 595 std::vector<std::pair<uint32, RequestType> > notifications; | 622 std::vector<std::pair<uint32, RequestType> > notifications; |
| 596 for (std::vector<PendingRequest>::iterator iter = pending_requests_.begin(); | 623 for (std::vector<PendingRequest>::iterator iter = pending_requests_.begin(); |
| 597 iter != pending_requests_.end(); ++iter) { | 624 iter != pending_requests_.end(); ++iter) { |
| 598 notifications.push_back(std::make_pair(iter->id, iter->type)); | 625 notifications.push_back(std::make_pair(iter->id, iter->type)); |
| 599 } | 626 } |
| 600 pending_requests_.clear(); | 627 pending_requests_.clear(); |
| 601 notifications.insert(notifications.end(), pending_responses_.begin(), | 628 notifications.insert(notifications.end(), pending_responses_.begin(), |
| 602 pending_responses_.end()); | 629 pending_responses_.end()); |
| 603 pending_responses_.clear(); | 630 pending_responses_.clear(); |
| 604 | 631 |
| 605 BrowserThread::PostTask( | 632 BrowserThread::PostTask( |
| 606 BrowserThread::UI, FROM_HERE, | 633 BrowserThread::UI, FROM_HERE, |
| 607 base::Bind(&Core::NotifyError, this, notifications)); | 634 base::Bind(&Core::NotifyError, this, notifications)); |
| 608 } | 635 } |
| 609 | 636 |
| 610 void | 637 void |
| 611 PepperFlashSettingsManager::Core::NotifyDeauthorizeContentLicensesCompleted( | 638 PepperFlashSettingsManager::Core::NotifyDeauthorizeContentLicensesCompleted( |
| 612 uint32 request_id, | 639 uint32 request_id, |
| 613 bool success) { | 640 bool success) { |
| 614 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 641 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 615 | 642 |
| 616 if (manager_) { | 643 if (manager_.get()) { |
| 617 manager_->client_->OnDeauthorizeContentLicensesCompleted( | 644 manager_->client_->OnDeauthorizeContentLicensesCompleted( |
| 618 request_id, success); | 645 request_id, success); |
| 619 } | 646 } |
| 620 } | 647 } |
| 621 | 648 |
| 622 void PepperFlashSettingsManager::Core::NotifyGetPermissionSettingsCompleted( | 649 void PepperFlashSettingsManager::Core::NotifyGetPermissionSettingsCompleted( |
| 623 uint32 request_id, | 650 uint32 request_id, |
| 624 bool success, | 651 bool success, |
| 625 PP_Flash_BrowserOperations_Permission default_permission, | 652 PP_Flash_BrowserOperations_Permission default_permission, |
| 626 const ppapi::FlashSiteSettings& sites) { | 653 const ppapi::FlashSiteSettings& sites) { |
| 627 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 654 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 628 | 655 |
| 629 if (manager_) { | 656 if (manager_.get()) { |
| 630 manager_->client_->OnGetPermissionSettingsCompleted( | 657 manager_->client_->OnGetPermissionSettingsCompleted( |
| 631 request_id, success, default_permission, sites); | 658 request_id, success, default_permission, sites); |
| 632 } | 659 } |
| 633 } | 660 } |
| 634 | 661 |
| 635 void PepperFlashSettingsManager::Core::NotifySetDefaultPermissionCompleted( | 662 void PepperFlashSettingsManager::Core::NotifySetDefaultPermissionCompleted( |
| 636 uint32 request_id, | 663 uint32 request_id, |
| 637 bool success) { | 664 bool success) { |
| 638 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 665 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 639 | 666 |
| 640 if (manager_) { | 667 if (manager_.get()) { |
| 641 manager_->client_->OnSetDefaultPermissionCompleted( | 668 manager_->client_->OnSetDefaultPermissionCompleted( |
| 642 request_id, success); | 669 request_id, success); |
| 643 } | 670 } |
| 644 } | 671 } |
| 645 | 672 |
| 646 void PepperFlashSettingsManager::Core::NotifySetSitePermissionCompleted( | 673 void PepperFlashSettingsManager::Core::NotifySetSitePermissionCompleted( |
| 647 uint32 request_id, | 674 uint32 request_id, |
| 648 bool success) { | 675 bool success) { |
| 649 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 676 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 650 | 677 |
| 651 if (manager_) { | 678 if (manager_.get()) { |
| 652 manager_->client_->OnSetSitePermissionCompleted( | 679 manager_->client_->OnSetSitePermissionCompleted( |
| 653 request_id, success); | 680 request_id, success); |
| 654 } | 681 } |
| 655 } | 682 } |
| 656 | 683 |
| 657 void PepperFlashSettingsManager::Core::NotifyGetSitesWithDataCompleted( | 684 void PepperFlashSettingsManager::Core::NotifyGetSitesWithDataCompleted( |
| 658 uint32 request_id, | 685 uint32 request_id, |
| 659 const std::vector<std::string>& sites) { | 686 const std::vector<std::string>& sites) { |
| 660 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 687 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 661 | 688 |
| 662 if (manager_) { | 689 if (manager_.get()) { |
| 663 manager_->client_->OnGetSitesWithDataCompleted( | 690 manager_->client_->OnGetSitesWithDataCompleted( |
| 664 request_id, sites); | 691 request_id, sites); |
| 665 } | 692 } |
| 666 } | 693 } |
| 667 | 694 |
| 668 void PepperFlashSettingsManager::Core::NotifyClearSiteDataCompleted( | 695 void PepperFlashSettingsManager::Core::NotifyClearSiteDataCompleted( |
| 669 uint32 request_id, | 696 uint32 request_id, |
| 670 bool success) { | 697 bool success) { |
| 671 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 698 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 672 | 699 |
| 673 if (manager_) | 700 if (manager_.get()) |
| 674 manager_->client_->OnClearSiteDataCompleted(request_id, success); | 701 manager_->client_->OnClearSiteDataCompleted(request_id, success); |
| 675 } | 702 } |
| 676 | 703 |
| 677 void PepperFlashSettingsManager::Core::NotifyError( | 704 void PepperFlashSettingsManager::Core::NotifyError( |
| 678 const std::vector<std::pair<uint32, RequestType> >& notifications) { | 705 const std::vector<std::pair<uint32, RequestType> >& notifications) { |
| 679 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 706 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 680 | 707 |
| 681 scoped_refptr<Core> protector(this); | 708 scoped_refptr<Core> protector(this); |
| 682 for (std::vector<std::pair<uint32, RequestType> >::const_iterator iter = | 709 for (std::vector<std::pair<uint32, RequestType> >::const_iterator iter = |
| 683 notifications.begin(); iter != notifications.end(); ++iter) { | 710 notifications.begin(); iter != notifications.end(); ++iter) { |
| 684 // Check |manager_| for each iteration in case Detach() happens in one of | 711 // Check |manager_| for each iteration in case it is destroyed in one of |
| 685 // the callbacks. | 712 // the callbacks. |
| 686 if (!manager_) | 713 if (!manager_.get()) |
| 687 return; | 714 return; |
| 688 | 715 |
| 689 switch (iter->second) { | 716 switch (iter->second) { |
| 690 case INVALID_REQUEST_TYPE: | 717 case INVALID_REQUEST_TYPE: |
| 691 NOTREACHED(); | 718 NOTREACHED(); |
| 692 break; | 719 break; |
| 693 case DEAUTHORIZE_CONTENT_LICENSES: | 720 case DEAUTHORIZE_CONTENT_LICENSES: |
| 694 manager_->client_->OnDeauthorizeContentLicensesCompleted( | 721 manager_->client_->OnDeauthorizeContentLicensesCompleted( |
| 695 iter->first, false); | 722 iter->first, false); |
| 696 break; | 723 break; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 709 case GET_SITES_WITH_DATA: | 736 case GET_SITES_WITH_DATA: |
| 710 manager_->client_->OnGetSitesWithDataCompleted( | 737 manager_->client_->OnGetSitesWithDataCompleted( |
| 711 iter->first, std::vector<std::string>()); | 738 iter->first, std::vector<std::string>()); |
| 712 break; | 739 break; |
| 713 case CLEAR_SITE_DATA: | 740 case CLEAR_SITE_DATA: |
| 714 manager_->client_->OnClearSiteDataCompleted(iter->first, false); | 741 manager_->client_->OnClearSiteDataCompleted(iter->first, false); |
| 715 break; | 742 break; |
| 716 } | 743 } |
| 717 } | 744 } |
| 718 | 745 |
| 719 if (manager_) | 746 if (manager_.get()) |
| 720 manager_->OnError(); | 747 manager_->OnError(this); |
| 721 } | 748 } |
| 722 | 749 |
| 723 void PepperFlashSettingsManager::Core::OnDeauthorizeContentLicensesResult( | 750 void PepperFlashSettingsManager::Core::OnDeauthorizeContentLicensesResult( |
| 724 uint32 request_id, | 751 uint32 request_id, |
| 725 bool success) { | 752 bool success) { |
| 726 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 753 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 727 if (detached_) | 754 if (state_ == STATE_DETACHED) |
| 728 return; | 755 return; |
| 729 | 756 |
| 730 DLOG_IF(ERROR, !success) << "DeauthorizeContentLicenses returned error"; | 757 DLOG_IF(ERROR, !success) << "DeauthorizeContentLicenses returned error"; |
| 731 | 758 |
| 732 std::map<uint32, RequestType>::iterator iter = | 759 std::map<uint32, RequestType>::iterator iter = |
| 733 pending_responses_.find(request_id); | 760 pending_responses_.find(request_id); |
| 734 if (iter == pending_responses_.end()) | 761 if (iter == pending_responses_.end()) |
| 735 return; | 762 return; |
| 736 | 763 |
| 737 DCHECK_EQ(iter->second, DEAUTHORIZE_CONTENT_LICENSES); | 764 DCHECK_EQ(iter->second, DEAUTHORIZE_CONTENT_LICENSES); |
| 738 | 765 |
| 739 pending_responses_.erase(iter); | 766 pending_responses_.erase(iter); |
| 740 BrowserThread::PostTask( | 767 BrowserThread::PostTask( |
| 741 BrowserThread::UI, FROM_HERE, | 768 BrowserThread::UI, FROM_HERE, |
| 742 base::Bind(&Core::NotifyDeauthorizeContentLicensesCompleted, this, | 769 base::Bind(&Core::NotifyDeauthorizeContentLicensesCompleted, this, |
| 743 request_id, success)); | 770 request_id, success)); |
| 744 } | 771 } |
| 745 | 772 |
| 746 void PepperFlashSettingsManager::Core::OnGetPermissionSettingsResult( | 773 void PepperFlashSettingsManager::Core::OnGetPermissionSettingsResult( |
| 747 uint32 request_id, | 774 uint32 request_id, |
| 748 bool success, | 775 bool success, |
| 749 PP_Flash_BrowserOperations_Permission default_permission, | 776 PP_Flash_BrowserOperations_Permission default_permission, |
| 750 const ppapi::FlashSiteSettings& sites) { | 777 const ppapi::FlashSiteSettings& sites) { |
| 751 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 778 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 752 if (detached_) | 779 if (state_ == STATE_DETACHED) |
| 753 return; | 780 return; |
| 754 | 781 |
| 755 DLOG_IF(ERROR, !success) << "GetPermissionSettings returned error"; | 782 DLOG_IF(ERROR, !success) << "GetPermissionSettings returned error"; |
| 756 | 783 |
| 757 std::map<uint32, RequestType>::iterator iter = | 784 std::map<uint32, RequestType>::iterator iter = |
| 758 pending_responses_.find(request_id); | 785 pending_responses_.find(request_id); |
| 759 if (iter == pending_responses_.end()) | 786 if (iter == pending_responses_.end()) |
| 760 return; | 787 return; |
| 761 | 788 |
| 762 DCHECK_EQ(iter->second, GET_PERMISSION_SETTINGS); | 789 DCHECK_EQ(iter->second, GET_PERMISSION_SETTINGS); |
| 763 | 790 |
| 764 pending_responses_.erase(iter); | 791 pending_responses_.erase(iter); |
| 765 BrowserThread::PostTask( | 792 BrowserThread::PostTask( |
| 766 BrowserThread::UI, FROM_HERE, | 793 BrowserThread::UI, FROM_HERE, |
| 767 base::Bind(&Core::NotifyGetPermissionSettingsCompleted, this, | 794 base::Bind(&Core::NotifyGetPermissionSettingsCompleted, this, |
| 768 request_id, success, default_permission, sites)); | 795 request_id, success, default_permission, sites)); |
| 769 } | 796 } |
| 770 | 797 |
| 771 void PepperFlashSettingsManager::Core::OnSetDefaultPermissionResult( | 798 void PepperFlashSettingsManager::Core::OnSetDefaultPermissionResult( |
| 772 uint32 request_id, | 799 uint32 request_id, |
| 773 bool success) { | 800 bool success) { |
| 774 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 801 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 775 if (detached_) | 802 if (state_ == STATE_DETACHED) |
| 776 return; | 803 return; |
| 777 | 804 |
| 778 DLOG_IF(ERROR, !success) << "SetDefaultPermission returned error"; | 805 DLOG_IF(ERROR, !success) << "SetDefaultPermission returned error"; |
| 779 | 806 |
| 780 std::map<uint32, RequestType>::iterator iter = | 807 std::map<uint32, RequestType>::iterator iter = |
| 781 pending_responses_.find(request_id); | 808 pending_responses_.find(request_id); |
| 782 if (iter == pending_responses_.end()) | 809 if (iter == pending_responses_.end()) |
| 783 return; | 810 return; |
| 784 | 811 |
| 785 DCHECK_EQ(iter->second, SET_DEFAULT_PERMISSION); | 812 DCHECK_EQ(iter->second, SET_DEFAULT_PERMISSION); |
| 786 | 813 |
| 787 pending_responses_.erase(iter); | 814 pending_responses_.erase(iter); |
| 788 BrowserThread::PostTask( | 815 BrowserThread::PostTask( |
| 789 BrowserThread::UI, FROM_HERE, | 816 BrowserThread::UI, FROM_HERE, |
| 790 base::Bind(&Core::NotifySetDefaultPermissionCompleted, this, | 817 base::Bind(&Core::NotifySetDefaultPermissionCompleted, this, |
| 791 request_id, success)); | 818 request_id, success)); |
| 792 } | 819 } |
| 793 | 820 |
| 794 void PepperFlashSettingsManager::Core::OnSetSitePermissionResult( | 821 void PepperFlashSettingsManager::Core::OnSetSitePermissionResult( |
| 795 uint32 request_id, | 822 uint32 request_id, |
| 796 bool success) { | 823 bool success) { |
| 797 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 824 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 798 if (detached_) | 825 if (state_ == STATE_DETACHED) |
| 799 return; | 826 return; |
| 800 | 827 |
| 801 DLOG_IF(ERROR, !success) << "SetSitePermission returned error"; | 828 DLOG_IF(ERROR, !success) << "SetSitePermission returned error"; |
| 802 | 829 |
| 803 std::map<uint32, RequestType>::iterator iter = | 830 std::map<uint32, RequestType>::iterator iter = |
| 804 pending_responses_.find(request_id); | 831 pending_responses_.find(request_id); |
| 805 if (iter == pending_responses_.end()) | 832 if (iter == pending_responses_.end()) |
| 806 return; | 833 return; |
| 807 | 834 |
| 808 DCHECK_EQ(iter->second, SET_SITE_PERMISSION); | 835 DCHECK_EQ(iter->second, SET_SITE_PERMISSION); |
| 809 | 836 |
| 810 pending_responses_.erase(iter); | 837 pending_responses_.erase(iter); |
| 811 BrowserThread::PostTask( | 838 BrowserThread::PostTask( |
| 812 BrowserThread::UI, FROM_HERE, | 839 BrowserThread::UI, FROM_HERE, |
| 813 base::Bind(&Core::NotifySetSitePermissionCompleted, this, request_id, | 840 base::Bind(&Core::NotifySetSitePermissionCompleted, this, request_id, |
| 814 success)); | 841 success)); |
| 815 } | 842 } |
| 816 | 843 |
| 817 void PepperFlashSettingsManager::Core::OnGetSitesWithDataResult( | 844 void PepperFlashSettingsManager::Core::OnGetSitesWithDataResult( |
| 818 uint32 request_id, | 845 uint32 request_id, |
| 819 const std::vector<std::string>& sites) { | 846 const std::vector<std::string>& sites) { |
| 820 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 847 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 821 if (detached_) | 848 if (state_ == STATE_DETACHED) |
| 822 return; | 849 return; |
| 823 | 850 |
| 824 std::map<uint32, RequestType>::iterator iter = | 851 std::map<uint32, RequestType>::iterator iter = |
| 825 pending_responses_.find(request_id); | 852 pending_responses_.find(request_id); |
| 826 if (iter == pending_responses_.end()) | 853 if (iter == pending_responses_.end()) |
| 827 return; | 854 return; |
| 828 | 855 |
| 829 DCHECK_EQ(iter->second, GET_SITES_WITH_DATA); | 856 DCHECK_EQ(iter->second, GET_SITES_WITH_DATA); |
| 830 | 857 |
| 831 pending_responses_.erase(iter); | 858 pending_responses_.erase(iter); |
| 832 BrowserThread::PostTask( | 859 BrowserThread::PostTask( |
| 833 BrowserThread::UI, FROM_HERE, | 860 BrowserThread::UI, FROM_HERE, |
| 834 base::Bind(&Core::NotifyGetSitesWithDataCompleted, this, request_id, | 861 base::Bind(&Core::NotifyGetSitesWithDataCompleted, this, request_id, |
| 835 sites)); | 862 sites)); |
| 836 } | 863 } |
| 837 | 864 |
| 838 void PepperFlashSettingsManager::Core::OnClearSiteDataResult( | 865 void PepperFlashSettingsManager::Core::OnClearSiteDataResult( |
| 839 uint32 request_id, | 866 uint32 request_id, |
| 840 bool success) { | 867 bool success) { |
| 841 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 868 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 842 if (detached_) | 869 if (state_ == STATE_DETACHED) |
| 843 return; | 870 return; |
| 844 | 871 |
| 845 DLOG_IF(ERROR, !success) << "ClearSiteData returned error"; | 872 DLOG_IF(ERROR, !success) << "ClearSiteData returned error"; |
| 846 | 873 |
| 847 std::map<uint32, RequestType>::iterator iter = | 874 std::map<uint32, RequestType>::iterator iter = |
| 848 pending_responses_.find(request_id); | 875 pending_responses_.find(request_id); |
| 849 if (iter == pending_responses_.end()) | 876 if (iter == pending_responses_.end()) |
| 850 return; | 877 return; |
| 851 | 878 |
| 852 DCHECK_EQ(iter->second, CLEAR_SITE_DATA); | 879 DCHECK_EQ(iter->second, CLEAR_SITE_DATA); |
| 853 | 880 |
| 854 pending_responses_.erase(iter); | 881 pending_responses_.erase(iter); |
| 855 BrowserThread::PostTask( | 882 BrowserThread::PostTask( |
| 856 BrowserThread::UI, FROM_HERE, | 883 BrowserThread::UI, FROM_HERE, |
| 857 base::Bind(&Core::NotifyClearSiteDataCompleted, this, request_id, | 884 base::Bind(&Core::NotifyClearSiteDataCompleted, this, request_id, |
| 858 success)); | 885 success)); |
| 859 } | 886 } |
| 860 | 887 |
| 861 PepperFlashSettingsManager::PepperFlashSettingsManager( | 888 PepperFlashSettingsManager::PepperFlashSettingsManager( |
| 862 Client* client, | 889 Client* client, |
| 863 content::BrowserContext* browser_context) | 890 content::BrowserContext* browser_context) |
| 864 : client_(client), | 891 : ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), |
| 892 client_(client), |
| 865 browser_context_(browser_context), | 893 browser_context_(browser_context), |
| 866 next_request_id_(1) { | 894 next_request_id_(1) { |
| 867 DCHECK(client); | 895 DCHECK(client); |
| 868 DCHECK(browser_context); | 896 DCHECK(browser_context); |
| 869 } | 897 } |
| 870 | 898 |
| 871 PepperFlashSettingsManager::~PepperFlashSettingsManager() { | 899 PepperFlashSettingsManager::~PepperFlashSettingsManager() { |
| 872 if (core_.get()) | 900 if (core_.get()) |
| 873 core_->Detach(); | 901 core_->Detach(); |
| 874 } | 902 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 core_->ClearSiteData(id, site, flags, max_age); | 998 core_->ClearSiteData(id, site, flags, max_age); |
| 971 return id; | 999 return id; |
| 972 } | 1000 } |
| 973 | 1001 |
| 974 uint32 PepperFlashSettingsManager::GetNextRequestId() { | 1002 uint32 PepperFlashSettingsManager::GetNextRequestId() { |
| 975 return next_request_id_++; | 1003 return next_request_id_++; |
| 976 } | 1004 } |
| 977 | 1005 |
| 978 void PepperFlashSettingsManager::EnsureCoreExists() { | 1006 void PepperFlashSettingsManager::EnsureCoreExists() { |
| 979 if (!core_.get()) { | 1007 if (!core_.get()) { |
| 980 core_ = new Core(this, browser_context_); | 1008 core_ = new Core(weak_ptr_factory_.GetWeakPtr(), browser_context_); |
| 981 core_->Initialize(); | 1009 core_->Initialize(); |
| 982 } | 1010 } |
| 983 } | 1011 } |
| 984 | 1012 |
| 985 void PepperFlashSettingsManager::OnError() { | 1013 void PepperFlashSettingsManager::OnError(Core* core) { |
| 986 if (core_.get()) { | 1014 DCHECK(core); |
| 987 core_->Detach(); | 1015 if (core != core_.get()) |
| 988 core_ = NULL; | 1016 return; |
| 989 } else { | 1017 |
| 990 NOTREACHED(); | 1018 core_->Detach(); |
| 991 } | 1019 core_ = NULL; |
| 992 } | 1020 } |
| 993 | |
| OLD | NEW |