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

Side by Side Diff: chrome/renderer/chrome_render_process_observer.cc

Issue 8538004: Take script URLs into account when applying script content settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/renderer/chrome_render_process_observer.h" 5 #include "chrome/renderer/chrome_render_process_observer.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 WebCache::UsageStats stats; 99 WebCache::UsageStats stats;
100 WebCache::getUsageStats(&stats); 100 WebCache::getUsageStats(&stats);
101 RenderThread::Get()->Send(new ChromeViewHostMsg_UpdatedCacheStats(stats)); 101 RenderThread::Get()->Send(new ChromeViewHostMsg_UpdatedCacheStats(stats));
102 } 102 }
103 103
104 ScopedRunnableMethodFactory<RendererResourceDelegate> method_factory_; 104 ScopedRunnableMethodFactory<RendererResourceDelegate> method_factory_;
105 105
106 DISALLOW_COPY_AND_ASSIGN(RendererResourceDelegate); 106 DISALLOW_COPY_AND_ASSIGN(RendererResourceDelegate);
107 }; 107 };
108 108
109 class RenderViewContentSettingsSetter : public content::RenderViewVisitor {
110 public:
111 RenderViewContentSettingsSetter(const GURL& url,
112 const ContentSettings& content_settings)
113 : url_(url),
114 content_settings_(content_settings) {
115 }
116
117 virtual bool Visit(content::RenderView* render_view) {
118 if (GURL(render_view->GetWebView()->mainFrame()->document().url()) ==
119 url_) {
120 ContentSettingsObserver::Get(render_view)->SetContentSettings(
121 content_settings_);
122 }
123 return true;
124 }
125
126 private:
127 GURL url_;
128 ContentSettings content_settings_;
129
130 DISALLOW_COPY_AND_ASSIGN(RenderViewContentSettingsSetter);
131 };
132
133 #if defined(OS_WIN) 109 #if defined(OS_WIN)
134 static base::win::IATPatchFunction g_iat_patch_createdca; 110 static base::win::IATPatchFunction g_iat_patch_createdca;
135 HDC WINAPI CreateDCAPatch(LPCSTR driver_name, 111 HDC WINAPI CreateDCAPatch(LPCSTR driver_name,
136 LPCSTR device_name, 112 LPCSTR device_name,
137 LPCSTR output, 113 LPCSTR output,
138 const void* init_data) { 114 const void* init_data) {
139 DCHECK(std::string("DISPLAY") == std::string(driver_name)); 115 DCHECK(std::string("DISPLAY") == std::string(driver_name));
140 DCHECK(!device_name); 116 DCHECK(!device_name);
141 DCHECK(!output); 117 DCHECK(!output);
142 DCHECK(!init_data); 118 DCHECK(!init_data);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 232
257 ChromeRenderProcessObserver::~ChromeRenderProcessObserver() { 233 ChromeRenderProcessObserver::~ChromeRenderProcessObserver() {
258 } 234 }
259 235
260 bool ChromeRenderProcessObserver::OnControlMessageReceived( 236 bool ChromeRenderProcessObserver::OnControlMessageReceived(
261 const IPC::Message& message) { 237 const IPC::Message& message) {
262 bool handled = true; 238 bool handled = true;
263 IPC_BEGIN_MESSAGE_MAP(ChromeRenderProcessObserver, message) 239 IPC_BEGIN_MESSAGE_MAP(ChromeRenderProcessObserver, message)
264 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetIsIncognitoProcess, 240 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetIsIncognitoProcess,
265 OnSetIsIncognitoProcess) 241 OnSetIsIncognitoProcess)
266 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetDefaultContentSettings,
267 OnSetDefaultContentSettings)
268 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetContentSettingsForCurrentURL,
269 OnSetContentSettingsForCurrentURL)
270 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetImageSettingRules,
271 OnSetImageSettingRules)
272 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetCacheCapacities, OnSetCacheCapacities) 242 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetCacheCapacities, OnSetCacheCapacities)
273 IPC_MESSAGE_HANDLER(ChromeViewMsg_ClearCache, OnClearCache) 243 IPC_MESSAGE_HANDLER(ChromeViewMsg_ClearCache, OnClearCache)
274 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetFieldTrialGroup, OnSetFieldTrialGroup) 244 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetFieldTrialGroup, OnSetFieldTrialGroup)
275 #if defined(USE_TCMALLOC) 245 #if defined(USE_TCMALLOC)
276 IPC_MESSAGE_HANDLER(ChromeViewMsg_GetRendererTcmalloc, 246 IPC_MESSAGE_HANDLER(ChromeViewMsg_GetRendererTcmalloc,
277 OnGetRendererTcmalloc) 247 OnGetRendererTcmalloc)
278 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetTcmallocHeapProfiling, 248 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetTcmallocHeapProfiling,
279 OnSetTcmallocHeapProfiling) 249 OnSetTcmallocHeapProfiling)
280 IPC_MESSAGE_HANDLER(ChromeViewMsg_WriteTcmallocHeapProfile, 250 IPC_MESSAGE_HANDLER(ChromeViewMsg_WriteTcmallocHeapProfile,
281 OnWriteTcmallocHeapProfile) 251 OnWriteTcmallocHeapProfile)
282 #endif 252 #endif
283 IPC_MESSAGE_HANDLER(ChromeViewMsg_GetV8HeapStats, OnGetV8HeapStats) 253 IPC_MESSAGE_HANDLER(ChromeViewMsg_GetV8HeapStats, OnGetV8HeapStats)
284 IPC_MESSAGE_HANDLER(ChromeViewMsg_GetCacheResourceStats, 254 IPC_MESSAGE_HANDLER(ChromeViewMsg_GetCacheResourceStats,
285 OnGetCacheResourceStats) 255 OnGetCacheResourceStats)
286 IPC_MESSAGE_HANDLER(ChromeViewMsg_PurgeMemory, OnPurgeMemory) 256 IPC_MESSAGE_HANDLER(ChromeViewMsg_PurgeMemory, OnPurgeMemory)
257 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetContentSettingRules,
258 OnSetContentSettingRules)
287 IPC_MESSAGE_UNHANDLED(handled = false) 259 IPC_MESSAGE_UNHANDLED(handled = false)
288 IPC_END_MESSAGE_MAP() 260 IPC_END_MESSAGE_MAP()
289 return handled; 261 return handled;
290 } 262 }
291 263
292 void ChromeRenderProcessObserver::WebKitInitialized() { 264 void ChromeRenderProcessObserver::WebKitInitialized() {
293 WebRuntimeFeatures::enableMediaPlayer(media::IsMediaLibraryInitialized()); 265 WebRuntimeFeatures::enableMediaPlayer(media::IsMediaLibraryInitialized());
294 } 266 }
295 267
296 void ChromeRenderProcessObserver::OnSetIsIncognitoProcess( 268 void ChromeRenderProcessObserver::OnSetIsIncognitoProcess(
297 bool is_incognito_process) { 269 bool is_incognito_process) {
298 is_incognito_process_ = is_incognito_process; 270 is_incognito_process_ = is_incognito_process;
299 } 271 }
300 272
301 void ChromeRenderProcessObserver::OnSetContentSettingsForCurrentURL( 273 void ChromeRenderProcessObserver::OnSetContentSettingRules(
302 const GURL& url, 274 const RendererContentSettingRules& rules) {
303 const ContentSettings& content_settings) { 275 content_setting_rules_ = rules;
304 RenderViewContentSettingsSetter setter(url, content_settings);
305 content::RenderView::ForEach(&setter);
306 }
307
308 void ChromeRenderProcessObserver::OnSetDefaultContentSettings(
309 const ContentSettings& content_settings) {
310 default_content_settings_ = content_settings;
311 }
312
313 void ChromeRenderProcessObserver::OnSetImageSettingRules(
314 const ContentSettingsForOneType& settings) {
315 image_setting_rules_ = settings;
316 } 276 }
317 277
318 void ChromeRenderProcessObserver::OnSetCacheCapacities(size_t min_dead_capacity, 278 void ChromeRenderProcessObserver::OnSetCacheCapacities(size_t min_dead_capacity,
319 size_t max_dead_capacity, 279 size_t max_dead_capacity,
320 size_t capacity) { 280 size_t capacity) {
321 WebCache::setCapacities( 281 WebCache::setCapacities(
322 min_dead_capacity, max_dead_capacity, capacity); 282 min_dead_capacity, max_dead_capacity, capacity);
323 } 283 }
324 284
325 void ChromeRenderProcessObserver::OnClearCache(bool on_navigation) { 285 void ChromeRenderProcessObserver::OnClearCache(bool on_navigation) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 client_->OnPurgeMemory(); 378 client_->OnPurgeMemory();
419 } 379 }
420 380
421 void ChromeRenderProcessObserver::ExecutePendingClearCache() { 381 void ChromeRenderProcessObserver::ExecutePendingClearCache() {
422 if (clear_cache_pending_) { 382 if (clear_cache_pending_) {
423 clear_cache_pending_ = false; 383 clear_cache_pending_ = false;
424 WebCache::clear(); 384 WebCache::clear();
425 } 385 }
426 } 386 }
427 387
428 const ContentSettingsForOneType* 388 const RendererContentSettingRules*
429 ChromeRenderProcessObserver::image_setting_rules() const { 389 ChromeRenderProcessObserver::content_setting_rules() const {
430 return &image_setting_rules_; 390 return &content_setting_rules_;
431 } 391 }
432
433 const ContentSettings*
434 ChromeRenderProcessObserver::default_content_settings() const {
435 return &default_content_settings_;
436 }
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_render_process_observer.h ('k') | chrome/renderer/chrome_render_view_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698