OLD | NEW |
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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 std::string error; | 245 std::string error; |
246 base::LoadNativeLibrary(FilePath(L"crypt32.dll"), &error); | 246 base::LoadNativeLibrary(FilePath(L"crypt32.dll"), &error); |
247 #endif | 247 #endif |
248 | 248 |
249 // Note that under Linux, the media library will normally already have | 249 // Note that under Linux, the media library will normally already have |
250 // been initialized by the Zygote before this instance became a Renderer. | 250 // been initialized by the Zygote before this instance became a Renderer. |
251 FilePath media_path; | 251 FilePath media_path; |
252 PathService::Get(chrome::DIR_MEDIA_LIBS, &media_path); | 252 PathService::Get(chrome::DIR_MEDIA_LIBS, &media_path); |
253 if (!media_path.empty()) | 253 if (!media_path.empty()) |
254 media::InitializeMediaLibrary(media_path); | 254 media::InitializeMediaLibrary(media_path); |
| 255 |
| 256 client_->SetImageSettingRules(&image_setting_rules_); |
255 } | 257 } |
256 | 258 |
257 ChromeRenderProcessObserver::~ChromeRenderProcessObserver() { | 259 ChromeRenderProcessObserver::~ChromeRenderProcessObserver() { |
258 } | 260 } |
259 | 261 |
260 bool ChromeRenderProcessObserver::OnControlMessageReceived( | 262 bool ChromeRenderProcessObserver::OnControlMessageReceived( |
261 const IPC::Message& message) { | 263 const IPC::Message& message) { |
262 bool handled = true; | 264 bool handled = true; |
263 IPC_BEGIN_MESSAGE_MAP(ChromeRenderProcessObserver, message) | 265 IPC_BEGIN_MESSAGE_MAP(ChromeRenderProcessObserver, message) |
264 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetIsIncognitoProcess, | 266 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetIsIncognitoProcess, |
265 OnSetIsIncognitoProcess) | 267 OnSetIsIncognitoProcess) |
266 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetDefaultContentSettings, | 268 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetDefaultContentSettings, |
267 OnSetDefaultContentSettings) | 269 OnSetDefaultContentSettings) |
268 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetContentSettingsForCurrentURL, | 270 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetContentSettingsForCurrentURL, |
269 OnSetContentSettingsForCurrentURL) | 271 OnSetContentSettingsForCurrentURL) |
| 272 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetImageSettingRules, |
| 273 OnSetImageSettingRules) |
270 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetCacheCapacities, OnSetCacheCapacities) | 274 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetCacheCapacities, OnSetCacheCapacities) |
271 IPC_MESSAGE_HANDLER(ChromeViewMsg_ClearCache, OnClearCache) | 275 IPC_MESSAGE_HANDLER(ChromeViewMsg_ClearCache, OnClearCache) |
272 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetFieldTrialGroup, OnSetFieldTrialGroup) | 276 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetFieldTrialGroup, OnSetFieldTrialGroup) |
273 #if defined(USE_TCMALLOC) | 277 #if defined(USE_TCMALLOC) |
274 IPC_MESSAGE_HANDLER(ChromeViewMsg_GetRendererTcmalloc, | 278 IPC_MESSAGE_HANDLER(ChromeViewMsg_GetRendererTcmalloc, |
275 OnGetRendererTcmalloc) | 279 OnGetRendererTcmalloc) |
276 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetTcmallocHeapProfiling, | 280 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetTcmallocHeapProfiling, |
277 OnSetTcmallocHeapProfiling) | 281 OnSetTcmallocHeapProfiling) |
278 IPC_MESSAGE_HANDLER(ChromeViewMsg_WriteTcmallocHeapProfile, | 282 IPC_MESSAGE_HANDLER(ChromeViewMsg_WriteTcmallocHeapProfile, |
279 OnWriteTcmallocHeapProfile) | 283 OnWriteTcmallocHeapProfile) |
(...skipping 21 matching lines...) Expand all Loading... |
301 const ContentSettings& content_settings) { | 305 const ContentSettings& content_settings) { |
302 RenderViewContentSettingsSetter setter(url, content_settings); | 306 RenderViewContentSettingsSetter setter(url, content_settings); |
303 content::RenderView::ForEach(&setter); | 307 content::RenderView::ForEach(&setter); |
304 } | 308 } |
305 | 309 |
306 void ChromeRenderProcessObserver::OnSetDefaultContentSettings( | 310 void ChromeRenderProcessObserver::OnSetDefaultContentSettings( |
307 const ContentSettings& content_settings) { | 311 const ContentSettings& content_settings) { |
308 ContentSettingsObserver::SetDefaultContentSettings(content_settings); | 312 ContentSettingsObserver::SetDefaultContentSettings(content_settings); |
309 } | 313 } |
310 | 314 |
| 315 void ChromeRenderProcessObserver::OnSetImageSettingRules( |
| 316 const ContentSettingsForOneType& settings) { |
| 317 image_setting_rules_ = settings; |
| 318 } |
| 319 |
311 void ChromeRenderProcessObserver::OnSetCacheCapacities(size_t min_dead_capacity, | 320 void ChromeRenderProcessObserver::OnSetCacheCapacities(size_t min_dead_capacity, |
312 size_t max_dead_capacity, | 321 size_t max_dead_capacity, |
313 size_t capacity) { | 322 size_t capacity) { |
314 WebCache::setCapacities( | 323 WebCache::setCapacities( |
315 min_dead_capacity, max_dead_capacity, capacity); | 324 min_dead_capacity, max_dead_capacity, capacity); |
316 } | 325 } |
317 | 326 |
318 void ChromeRenderProcessObserver::OnClearCache(bool on_navigation) { | 327 void ChromeRenderProcessObserver::OnClearCache(bool on_navigation) { |
319 if (on_navigation) { | 328 if (on_navigation) { |
320 clear_cache_pending_ = true; | 329 clear_cache_pending_ = true; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 if (client_) | 424 if (client_) |
416 client_->OnPurgeMemory(); | 425 client_->OnPurgeMemory(); |
417 } | 426 } |
418 | 427 |
419 void ChromeRenderProcessObserver::ExecutePendingClearCache() { | 428 void ChromeRenderProcessObserver::ExecutePendingClearCache() { |
420 if (clear_cache_pending_) { | 429 if (clear_cache_pending_) { |
421 clear_cache_pending_ = false; | 430 clear_cache_pending_ = false; |
422 WebCache::clear(); | 431 WebCache::clear(); |
423 } | 432 } |
424 } | 433 } |
OLD | NEW |