Chromium Code Reviews| 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/content_settings/tab_specific_content_settings.h" | 5 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 #include "content/public/browser/render_frame_host.h" | 32 #include "content/public/browser/render_frame_host.h" |
| 33 #include "content/public/browser/render_view_host.h" | 33 #include "content/public/browser/render_view_host.h" |
| 34 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
| 35 #include "content/public/browser/web_contents_delegate.h" | 35 #include "content/public/browser/web_contents_delegate.h" |
| 36 #include "net/cookies/canonical_cookie.h" | 36 #include "net/cookies/canonical_cookie.h" |
| 37 #include "webkit/common/fileapi/file_system_types.h" | 37 #include "webkit/common/fileapi/file_system_types.h" |
| 38 | 38 |
| 39 using content::BrowserThread; | 39 using content::BrowserThread; |
| 40 using content::NavigationController; | 40 using content::NavigationController; |
| 41 using content::NavigationEntry; | 41 using content::NavigationEntry; |
| 42 using content::RenderFrameHost; | |
| 42 using content::RenderViewHost; | 43 using content::RenderViewHost; |
| 43 using content::WebContents; | 44 using content::WebContents; |
| 44 | 45 |
| 45 DEFINE_WEB_CONTENTS_USER_DATA_KEY(TabSpecificContentSettings); | 46 DEFINE_WEB_CONTENTS_USER_DATA_KEY(TabSpecificContentSettings); |
| 46 | 47 |
| 47 TabSpecificContentSettings::SiteDataObserver::SiteDataObserver( | 48 TabSpecificContentSettings::SiteDataObserver::SiteDataObserver( |
| 48 TabSpecificContentSettings* tab_specific_content_settings) | 49 TabSpecificContentSettings* tab_specific_content_settings) |
| 49 : tab_specific_content_settings_(tab_specific_content_settings) { | 50 : tab_specific_content_settings_(tab_specific_content_settings) { |
| 50 tab_specific_content_settings_->AddSiteDataObserver(this); | 51 tab_specific_content_settings_->AddSiteDataObserver(this); |
| 51 } | 52 } |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 int render_frame_id, | 210 int render_frame_id, |
| 210 const GURL& url, | 211 const GURL& url, |
| 211 bool blocked_by_policy) { | 212 bool blocked_by_policy) { |
| 212 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 213 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 213 TabSpecificContentSettings* settings = GetForFrame( | 214 TabSpecificContentSettings* settings = GetForFrame( |
| 214 render_process_id, render_frame_id); | 215 render_process_id, render_frame_id); |
| 215 if (settings) | 216 if (settings) |
| 216 settings->OnFileSystemAccessed(url, blocked_by_policy); | 217 settings->OnFileSystemAccessed(url, blocked_by_policy); |
| 217 } | 218 } |
| 218 | 219 |
| 220 // static | |
| 221 void TabSpecificContentSettings::FileSystemAccessedSyncDelayReply( | |
| 222 int render_process_id, | |
| 223 int render_frame_id, | |
| 224 const GURL& url, | |
| 225 IPC::Message* reply_msg, | |
| 226 bool blocked_by_policy) { | |
| 227 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 228 content::RenderFrameHost* render_frame_host = | |
| 229 content::RenderFrameHost::FromID(render_process_id, render_frame_id); | |
| 230 | |
| 231 WebViewGuest* guest = GetWebViewGuest(render_frame_host); | |
| 232 if (guest) { | |
| 233 guest->RequestFileSystemPermission( | |
| 234 url, | |
| 235 base::Bind(&TabSpecificContentSettings:: | |
| 236 UpdateSettingsOnFileSystemAccessedDelayReply, | |
| 237 render_process_id, | |
| 238 render_frame_id, | |
| 239 url, | |
| 240 reply_msg)); | |
| 241 } else { | |
| 242 FileSystemAccessed( | |
| 243 render_process_id, render_frame_id, url, blocked_by_policy); | |
| 244 } | |
| 245 } | |
| 246 | |
| 247 // static | |
| 248 void TabSpecificContentSettings::FileSystemAccessedAsync( | |
| 249 int render_process_id, | |
| 250 int render_frame_id, | |
| 251 int request_id, | |
| 252 const GURL& url, | |
| 253 bool blocked_by_policy) { | |
| 254 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 255 content::RenderFrameHost* render_frame_host = | |
| 256 content::RenderFrameHost::FromID(render_process_id, render_frame_id); | |
| 257 | |
| 258 WebViewGuest* guest = GetWebViewGuest(render_frame_host); | |
| 259 if (guest) { | |
| 260 guest->RequestFileSystemPermission( | |
| 261 url, | |
| 262 base::Bind(&TabSpecificContentSettings::FileSystemAccessedAsyncInternal, | |
| 263 render_process_id, | |
| 264 render_frame_id, | |
| 265 request_id, | |
| 266 url)); | |
| 267 } else { | |
| 268 FileSystemAccessedAsyncInternal( | |
| 269 render_process_id, render_frame_id, request_id, url, blocked_by_policy); | |
| 270 } | |
| 271 } | |
| 272 | |
| 273 // static | |
| 274 WebViewGuest* TabSpecificContentSettings::GetWebViewGuest( | |
| 275 content::RenderFrameHost* render_frame_host) { | |
| 276 WebContents* web_contents = | |
| 277 WebContents::FromRenderFrameHost(render_frame_host); | |
| 278 | |
| 279 return WebViewGuest::FromWebContents(web_contents); | |
| 280 } | |
| 281 | |
| 282 // static | |
| 283 void TabSpecificContentSettings::FileSystemAccessedAsyncInternal( | |
| 284 int render_process_id, | |
| 285 int render_frame_id, | |
| 286 int request_id, | |
| 287 const GURL& url, | |
| 288 bool blocked_by_policy) { | |
| 289 FileSystemAccessed( | |
| 290 render_process_id, render_frame_id, url, blocked_by_policy); | |
| 291 SendMessage( | |
|
Fady Samuel
2014/05/29 19:04:32
This appears to be only called once. This doesn't
Xi Han
2014/05/29 21:10:21
Done.
| |
| 292 render_process_id, render_frame_id, request_id, url, blocked_by_policy); | |
| 293 } | |
| 294 | |
| 295 // static | |
| 296 void TabSpecificContentSettings::UpdateSettingsOnFileSystemAccessedDelayReply( | |
| 297 int render_process_id, | |
| 298 int render_frame_id, | |
| 299 const GURL& url, | |
| 300 IPC::Message* reply_msg, | |
| 301 bool blocked_by_policy) { | |
| 302 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 303 FileSystemAccessed( | |
| 304 render_process_id, render_frame_id, url, blocked_by_policy); | |
| 305 ChromeViewHostMsg_RequestFileSystemAccessSync::WriteReplyParams( | |
| 306 reply_msg, !blocked_by_policy); | |
| 307 content::RenderFrameHost* render_frame_host = | |
| 308 content::RenderFrameHost::FromID(render_process_id, render_frame_id); | |
| 309 render_frame_host->Send(reply_msg); | |
| 310 } | |
| 311 | |
| 312 // static | |
| 313 void TabSpecificContentSettings::SendMessage(int render_process_id, | |
| 314 int render_frame_id, | |
| 315 int request_id, | |
| 316 const GURL& url, | |
| 317 bool blocked_by_policy) { | |
| 318 content::RenderFrameHost* render_frame_host = | |
| 319 content::RenderFrameHost::FromID(render_process_id, render_frame_id); | |
| 320 render_frame_host->Send( | |
| 321 new ChromeViewMsg_RequestFileSystemAccessAsyncResponse( | |
| 322 render_frame_id, request_id, !blocked_by_policy)); | |
| 323 } | |
| 324 | |
| 219 bool TabSpecificContentSettings::IsContentBlocked( | 325 bool TabSpecificContentSettings::IsContentBlocked( |
| 220 ContentSettingsType content_type) const { | 326 ContentSettingsType content_type) const { |
| 221 DCHECK(content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION) | 327 DCHECK(content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION) |
| 222 << "Geolocation settings handled by ContentSettingGeolocationImageModel"; | 328 << "Geolocation settings handled by ContentSettingGeolocationImageModel"; |
| 223 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS) | 329 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS) |
| 224 << "Notifications settings handled by " | 330 << "Notifications settings handled by " |
| 225 << "ContentSettingsNotificationsImageModel"; | 331 << "ContentSettingsNotificationsImageModel"; |
| 226 | 332 |
| 227 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || | 333 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || |
| 228 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || | 334 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 723 } | 829 } |
| 724 | 830 |
| 725 void TabSpecificContentSettings::RemoveSiteDataObserver( | 831 void TabSpecificContentSettings::RemoveSiteDataObserver( |
| 726 SiteDataObserver* observer) { | 832 SiteDataObserver* observer) { |
| 727 observer_list_.RemoveObserver(observer); | 833 observer_list_.RemoveObserver(observer); |
| 728 } | 834 } |
| 729 | 835 |
| 730 void TabSpecificContentSettings::NotifySiteDataObservers() { | 836 void TabSpecificContentSettings::NotifySiteDataObservers() { |
| 731 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); | 837 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); |
| 732 } | 838 } |
| OLD | NEW |