| 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/chrome_render_message_filter.h" | 5 #include "chrome/browser/renderer_host/chrome_render_message_filter.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 cookie_settings_(CookieSettingsFactory::GetForProfile(profile)) {} | 56 cookie_settings_(CookieSettingsFactory::GetForProfile(profile)) {} |
| 57 | 57 |
| 58 ChromeRenderMessageFilter::~ChromeRenderMessageFilter() { | 58 ChromeRenderMessageFilter::~ChromeRenderMessageFilter() { |
| 59 } | 59 } |
| 60 | 60 |
| 61 bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message) { | 61 bool ChromeRenderMessageFilter::OnMessageReceived(const IPC::Message& message) { |
| 62 bool handled = true; | 62 bool handled = true; |
| 63 IPC_BEGIN_MESSAGE_MAP(ChromeRenderMessageFilter, message) | 63 IPC_BEGIN_MESSAGE_MAP(ChromeRenderMessageFilter, message) |
| 64 IPC_MESSAGE_HANDLER(NetworkHintsMsg_DNSPrefetch, OnDnsPrefetch) | 64 IPC_MESSAGE_HANDLER(NetworkHintsMsg_DNSPrefetch, OnDnsPrefetch) |
| 65 IPC_MESSAGE_HANDLER(NetworkHintsMsg_Preconnect, OnPreconnect) | 65 IPC_MESSAGE_HANDLER(NetworkHintsMsg_Preconnect, OnPreconnect) |
| 66 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_UpdatedCacheStats, | |
| 67 OnUpdatedCacheStats) | |
| 68 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDatabase, OnAllowDatabase) | 66 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDatabase, OnAllowDatabase) |
| 69 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDOMStorage, OnAllowDOMStorage) | 67 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowDOMStorage, OnAllowDOMStorage) |
| 70 IPC_MESSAGE_HANDLER_DELAY_REPLY( | 68 IPC_MESSAGE_HANDLER_DELAY_REPLY( |
| 71 ChromeViewHostMsg_RequestFileSystemAccessSync, | 69 ChromeViewHostMsg_RequestFileSystemAccessSync, |
| 72 OnRequestFileSystemAccessSync) | 70 OnRequestFileSystemAccessSync) |
| 73 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RequestFileSystemAccessAsync, | 71 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_RequestFileSystemAccessAsync, |
| 74 OnRequestFileSystemAccessAsync) | 72 OnRequestFileSystemAccessAsync) |
| 75 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowIndexedDB, OnAllowIndexedDB) | 73 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_AllowIndexedDB, OnAllowIndexedDB) |
| 76 #if BUILDFLAG(ENABLE_PLUGINS) | 74 #if BUILDFLAG(ENABLE_PLUGINS) |
| 77 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_IsCrashReportingEnabled, | 75 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_IsCrashReportingEnabled, |
| 78 OnIsCrashReportingEnabled) | 76 OnIsCrashReportingEnabled) |
| 79 #endif | 77 #endif |
| 80 IPC_MESSAGE_UNHANDLED(handled = false) | 78 IPC_MESSAGE_UNHANDLED(handled = false) |
| 81 IPC_END_MESSAGE_MAP() | 79 IPC_END_MESSAGE_MAP() |
| 82 | 80 |
| 83 return handled; | 81 return handled; |
| 84 } | 82 } |
| 85 | 83 |
| 86 void ChromeRenderMessageFilter::OverrideThreadForMessage( | 84 void ChromeRenderMessageFilter::OverrideThreadForMessage( |
| 87 const IPC::Message& message, BrowserThread::ID* thread) { | 85 const IPC::Message& message, BrowserThread::ID* thread) { |
| 86 #if BUILDFLAG(ENABLE_PLUGINS) |
| 88 switch (message.type()) { | 87 switch (message.type()) { |
| 89 #if BUILDFLAG(ENABLE_PLUGINS) | |
| 90 case ChromeViewHostMsg_IsCrashReportingEnabled::ID: | 88 case ChromeViewHostMsg_IsCrashReportingEnabled::ID: |
| 91 #endif | |
| 92 case ChromeViewHostMsg_UpdatedCacheStats::ID: | |
| 93 *thread = BrowserThread::UI; | 89 *thread = BrowserThread::UI; |
| 94 break; | 90 break; |
| 95 default: | 91 default: |
| 96 break; | 92 break; |
| 97 } | 93 } |
| 94 #endif |
| 98 } | 95 } |
| 99 | 96 |
| 100 void ChromeRenderMessageFilter::OnDnsPrefetch( | 97 void ChromeRenderMessageFilter::OnDnsPrefetch( |
| 101 const network_hints::LookupRequest& request) { | 98 const network_hints::LookupRequest& request) { |
| 102 if (predictor_) | 99 if (predictor_) |
| 103 predictor_->DnsPrefetchList(request.hostname_list); | 100 predictor_->DnsPrefetchList(request.hostname_list); |
| 104 } | 101 } |
| 105 | 102 |
| 106 void ChromeRenderMessageFilter::OnPreconnect(const GURL& url, | 103 void ChromeRenderMessageFilter::OnPreconnect(const GURL& url, |
| 107 bool allow_credentials, | 104 bool allow_credentials, |
| 108 int count) { | 105 int count) { |
| 109 if (count < 1) { | 106 if (count < 1) { |
| 110 LOG(WARNING) << "NetworkHintsMsg_Preconnect IPC with invalid count: " | 107 LOG(WARNING) << "NetworkHintsMsg_Preconnect IPC with invalid count: " |
| 111 << count; | 108 << count; |
| 112 return; | 109 return; |
| 113 } | 110 } |
| 114 if (predictor_ && url.is_valid() && url.has_host() && url.has_scheme() && | 111 if (predictor_ && url.is_valid() && url.has_host() && url.has_scheme() && |
| 115 url.SchemeIsHTTPOrHTTPS()) { | 112 url.SchemeIsHTTPOrHTTPS()) { |
| 116 predictor_->PreconnectUrl(url, GURL(), | 113 predictor_->PreconnectUrl(url, GURL(), |
| 117 chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED, | 114 chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED, |
| 118 allow_credentials, count); | 115 allow_credentials, count); |
| 119 } | 116 } |
| 120 } | 117 } |
| 121 | 118 |
| 122 void ChromeRenderMessageFilter::OnUpdatedCacheStats(uint64_t capacity, | |
| 123 uint64_t size) { | |
| 124 web_cache::WebCacheManager::GetInstance()->ObserveStats(render_process_id_, | |
| 125 capacity, size); | |
| 126 } | |
| 127 | |
| 128 void ChromeRenderMessageFilter::OnAllowDatabase( | 119 void ChromeRenderMessageFilter::OnAllowDatabase( |
| 129 int render_frame_id, | 120 int render_frame_id, |
| 130 const GURL& origin_url, | 121 const GURL& origin_url, |
| 131 const GURL& top_origin_url, | 122 const GURL& top_origin_url, |
| 132 const base::string16& name, | 123 const base::string16& name, |
| 133 const base::string16& display_name, | 124 const base::string16& display_name, |
| 134 bool* allowed) { | 125 bool* allowed) { |
| 135 *allowed = | 126 *allowed = |
| 136 cookie_settings_->IsCookieAccessAllowed(origin_url, top_origin_url); | 127 cookie_settings_->IsCookieAccessAllowed(origin_url, top_origin_url); |
| 137 BrowserThread::PostTask( | 128 BrowserThread::PostTask( |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 base::Bind(&TabSpecificContentSettings::IndexedDBAccessed, | 306 base::Bind(&TabSpecificContentSettings::IndexedDBAccessed, |
| 316 render_process_id_, render_frame_id, origin_url, name, | 307 render_process_id_, render_frame_id, origin_url, name, |
| 317 !*allowed)); | 308 !*allowed)); |
| 318 } | 309 } |
| 319 | 310 |
| 320 #if BUILDFLAG(ENABLE_PLUGINS) | 311 #if BUILDFLAG(ENABLE_PLUGINS) |
| 321 void ChromeRenderMessageFilter::OnIsCrashReportingEnabled(bool* enabled) { | 312 void ChromeRenderMessageFilter::OnIsCrashReportingEnabled(bool* enabled) { |
| 322 *enabled = ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); | 313 *enabled = ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); |
| 323 } | 314 } |
| 324 #endif | 315 #endif |
| OLD | NEW |