| 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/renderer_host/pepper/pepper_flash_browser_host.h" | 5 #include "chrome/browser/renderer_host/pepper/pepper_flash_browser_host.h" |
| 6 | 6 |
| 7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 8 #include "chrome/browser/content_settings/cookie_settings.h" | 8 #include "chrome/browser/content_settings/cookie_settings.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 using content::BrowserPpapiHost; | 29 using content::BrowserPpapiHost; |
| 30 using content::BrowserThread; | 30 using content::BrowserThread; |
| 31 using content::RenderProcessHost; | 31 using content::RenderProcessHost; |
| 32 | 32 |
| 33 namespace chrome { | 33 namespace chrome { |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 // Get the CookieSettings on the UI thread for the given render process ID. | 37 // Get the CookieSettings on the UI thread for the given render process ID. |
| 38 scoped_refptr<CookieSettings> GetCookieSettings(int render_process_id) { | 38 scoped_refptr<CookieSettings> GetCookieSettings(int render_process_id) { |
| 39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 39 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 40 RenderProcessHost* render_process_host = | 40 RenderProcessHost* render_process_host = |
| 41 RenderProcessHost::FromID(render_process_id); | 41 RenderProcessHost::FromID(render_process_id); |
| 42 if (render_process_host && render_process_host->GetBrowserContext()) { | 42 if (render_process_host && render_process_host->GetBrowserContext()) { |
| 43 Profile* profile = | 43 Profile* profile = |
| 44 Profile::FromBrowserContext(render_process_host->GetBrowserContext()); | 44 Profile::FromBrowserContext(render_process_host->GetBrowserContext()); |
| 45 return CookieSettings::Factory::GetForProfile(profile); | 45 return CookieSettings::Factory::GetForProfile(profile); |
| 46 } | 46 } |
| 47 return NULL; | 47 return NULL; |
| 48 } | 48 } |
| 49 | 49 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 plugin_url)); | 129 plugin_url)); |
| 130 } | 130 } |
| 131 return PP_OK_COMPLETIONPENDING; | 131 return PP_OK_COMPLETIONPENDING; |
| 132 } | 132 } |
| 133 | 133 |
| 134 void PepperFlashBrowserHost::GetLocalDataRestrictions( | 134 void PepperFlashBrowserHost::GetLocalDataRestrictions( |
| 135 ppapi::host::ReplyMessageContext reply_context, | 135 ppapi::host::ReplyMessageContext reply_context, |
| 136 const GURL& document_url, | 136 const GURL& document_url, |
| 137 const GURL& plugin_url, | 137 const GURL& plugin_url, |
| 138 scoped_refptr<CookieSettings> cookie_settings) { | 138 scoped_refptr<CookieSettings> cookie_settings) { |
| 139 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 139 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 140 | 140 |
| 141 // Lazily initialize |cookie_settings_|. The cookie settings are thread-safe | 141 // Lazily initialize |cookie_settings_|. The cookie settings are thread-safe |
| 142 // ref-counted so as long as we hold a reference to them we can safely access | 142 // ref-counted so as long as we hold a reference to them we can safely access |
| 143 // them on the IO thread. | 143 // them on the IO thread. |
| 144 if (!cookie_settings_.get()) { | 144 if (!cookie_settings_.get()) { |
| 145 cookie_settings_ = cookie_settings; | 145 cookie_settings_ = cookie_settings; |
| 146 } else { | 146 } else { |
| 147 DCHECK(cookie_settings_.get() == cookie_settings.get()); | 147 DCHECK(cookie_settings_.get() == cookie_settings.get()); |
| 148 } | 148 } |
| 149 | 149 |
| 150 PP_FlashLSORestrictions restrictions = PP_FLASHLSORESTRICTIONS_NONE; | 150 PP_FlashLSORestrictions restrictions = PP_FLASHLSORESTRICTIONS_NONE; |
| 151 if (cookie_settings_.get() && document_url.is_valid() && | 151 if (cookie_settings_.get() && document_url.is_valid() && |
| 152 plugin_url.is_valid()) { | 152 plugin_url.is_valid()) { |
| 153 if (!cookie_settings_->IsReadingCookieAllowed(document_url, plugin_url)) | 153 if (!cookie_settings_->IsReadingCookieAllowed(document_url, plugin_url)) |
| 154 restrictions = PP_FLASHLSORESTRICTIONS_BLOCK; | 154 restrictions = PP_FLASHLSORESTRICTIONS_BLOCK; |
| 155 else if (cookie_settings_->IsCookieSessionOnly(plugin_url)) | 155 else if (cookie_settings_->IsCookieSessionOnly(plugin_url)) |
| 156 restrictions = PP_FLASHLSORESTRICTIONS_IN_MEMORY; | 156 restrictions = PP_FLASHLSORESTRICTIONS_IN_MEMORY; |
| 157 } | 157 } |
| 158 SendReply(reply_context, | 158 SendReply(reply_context, |
| 159 PpapiPluginMsg_Flash_GetLocalDataRestrictionsReply( | 159 PpapiPluginMsg_Flash_GetLocalDataRestrictionsReply( |
| 160 static_cast<int32_t>(restrictions))); | 160 static_cast<int32_t>(restrictions))); |
| 161 } | 161 } |
| 162 | 162 |
| 163 } // namespace chrome | 163 } // namespace chrome |
| OLD | NEW |