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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 const base::string16& description, | 199 const base::string16& description, |
199 bool blocked_by_policy) { | 200 bool blocked_by_policy) { |
200 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 201 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
201 TabSpecificContentSettings* settings = GetForFrame( | 202 TabSpecificContentSettings* settings = GetForFrame( |
202 render_process_id, render_frame_id); | 203 render_process_id, render_frame_id); |
203 if (settings) | 204 if (settings) |
204 settings->OnIndexedDBAccessed(url, description, blocked_by_policy); | 205 settings->OnIndexedDBAccessed(url, description, blocked_by_policy); |
205 } | 206 } |
206 | 207 |
207 // static | 208 // static |
208 void TabSpecificContentSettings::FileSystemAccessed(int render_process_id, | 209 void TabSpecificContentSettings::FileSystemAccessedSync( |
209 int render_frame_id, | 210 int render_process_id, |
210 const GURL& url, | 211 int render_frame_id, |
211 bool blocked_by_policy) { | 212 const GURL& url, |
| 213 bool blocked_by_policy) { |
212 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 214 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
213 TabSpecificContentSettings* settings = GetForFrame( | 215 TabSpecificContentSettings* settings = GetForFrame( |
214 render_process_id, render_frame_id); | 216 render_process_id, render_frame_id); |
215 if (settings) | 217 if (settings) |
216 settings->OnFileSystemAccessed(url, blocked_by_policy); | 218 settings->OnFileSystemAccessed(url, blocked_by_policy); |
217 } | 219 } |
218 | 220 |
| 221 // static |
| 222 void TabSpecificContentSettings::FileSystemAccessedSyncDelayReply( |
| 223 int render_process_id, |
| 224 int render_frame_id, |
| 225 const GURL& url, |
| 226 IPC::Message* reply_msg, |
| 227 bool blocked_by_policy) { |
| 228 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 229 content::RenderFrameHost* render_frame_host = |
| 230 content::RenderFrameHost::FromID(render_process_id, render_frame_id); |
| 231 WebViewGuest* guest = GetWebViewGuest(render_frame_host); |
| 232 DCHECK(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 } |
| 242 |
| 243 // static |
| 244 void TabSpecificContentSettings::FileSystemAccessedAsync( |
| 245 int render_process_id, |
| 246 int render_frame_id, |
| 247 int request_id, |
| 248 const GURL& url, |
| 249 bool blocked_by_policy) { |
| 250 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 251 content::RenderFrameHost* render_frame_host = |
| 252 content::RenderFrameHost::FromID(render_process_id, render_frame_id); |
| 253 WebViewGuest* guest = GetWebViewGuest(render_frame_host); |
| 254 if (guest) { |
| 255 guest->RequestFileSystemPermission( |
| 256 url, |
| 257 base::Bind(&TabSpecificContentSettings::FileSystemAccessedAsyncInternal, |
| 258 render_process_id, |
| 259 render_frame_id, |
| 260 request_id, |
| 261 url)); |
| 262 } else { |
| 263 FileSystemAccessedAsyncInternal( |
| 264 render_process_id, render_frame_id, request_id, url, blocked_by_policy); |
| 265 } |
| 266 } |
| 267 |
| 268 // static |
| 269 WebViewGuest* TabSpecificContentSettings::GetWebViewGuest( |
| 270 content::RenderFrameHost* render_frame_host) { |
| 271 WebContents* web_contents = |
| 272 WebContents::FromRenderFrameHost(render_frame_host); |
| 273 return WebViewGuest::FromWebContents(web_contents); |
| 274 } |
| 275 |
| 276 // static |
| 277 void TabSpecificContentSettings::FileSystemAccessedAsyncInternal( |
| 278 int render_process_id, |
| 279 int render_frame_id, |
| 280 int request_id, |
| 281 const GURL& url, |
| 282 bool blocked_by_policy) { |
| 283 FileSystemAccessedSync( |
| 284 render_process_id, render_frame_id, url, blocked_by_policy); |
| 285 content::RenderFrameHost* render_frame_host = |
| 286 content::RenderFrameHost::FromID(render_process_id, render_frame_id); |
| 287 render_frame_host->Send( |
| 288 new ChromeViewMsg_RequestFileSystemAccessAsyncResponse( |
| 289 render_frame_id, request_id, !blocked_by_policy)); |
| 290 } |
| 291 |
| 292 // static |
| 293 void TabSpecificContentSettings::UpdateSettingsOnFileSystemAccessedDelayReply( |
| 294 int render_process_id, |
| 295 int render_frame_id, |
| 296 const GURL& url, |
| 297 IPC::Message* reply_msg, |
| 298 bool blocked_by_policy) { |
| 299 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 300 FileSystemAccessedSync( |
| 301 render_process_id, render_frame_id, url, blocked_by_policy); |
| 302 ChromeViewHostMsg_RequestFileSystemAccessSync::WriteReplyParams( |
| 303 reply_msg, !blocked_by_policy); |
| 304 content::RenderFrameHost* render_frame_host = |
| 305 content::RenderFrameHost::FromID(render_process_id, render_frame_id); |
| 306 render_frame_host->Send(reply_msg); |
| 307 } |
| 308 |
219 bool TabSpecificContentSettings::IsContentBlocked( | 309 bool TabSpecificContentSettings::IsContentBlocked( |
220 ContentSettingsType content_type) const { | 310 ContentSettingsType content_type) const { |
221 DCHECK(content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION) | 311 DCHECK(content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION) |
222 << "Geolocation settings handled by ContentSettingGeolocationImageModel"; | 312 << "Geolocation settings handled by ContentSettingGeolocationImageModel"; |
223 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS) | 313 DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS) |
224 << "Notifications settings handled by " | 314 << "Notifications settings handled by " |
225 << "ContentSettingsNotificationsImageModel"; | 315 << "ContentSettingsNotificationsImageModel"; |
226 | 316 |
227 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || | 317 if (content_type == CONTENT_SETTINGS_TYPE_IMAGES || |
228 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || | 318 content_type == CONTENT_SETTINGS_TYPE_JAVASCRIPT || |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 } | 813 } |
724 | 814 |
725 void TabSpecificContentSettings::RemoveSiteDataObserver( | 815 void TabSpecificContentSettings::RemoveSiteDataObserver( |
726 SiteDataObserver* observer) { | 816 SiteDataObserver* observer) { |
727 observer_list_.RemoveObserver(observer); | 817 observer_list_.RemoveObserver(observer); |
728 } | 818 } |
729 | 819 |
730 void TabSpecificContentSettings::NotifySiteDataObservers() { | 820 void TabSpecificContentSettings::NotifySiteDataObservers() { |
731 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); | 821 FOR_EACH_OBSERVER(SiteDataObserver, observer_list_, OnSiteDataAccessed()); |
732 } | 822 } |
OLD | NEW |