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

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

Issue 7134017: Make safe browsing work in a multi-profile environment. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: addressed sky's nit Created 9 years, 5 months 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_view_observer.h" 5 #include "chrome/renderer/chrome_render_view_observer.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 case WebIconURL::TypeInvalid: 151 case WebIconURL::TypeInvalid:
152 return FaviconURL::INVALID_ICON; 152 return FaviconURL::INVALID_ICON;
153 } 153 }
154 return FaviconURL::INVALID_ICON; 154 return FaviconURL::INVALID_ICON;
155 } 155 }
156 156
157 ChromeRenderViewObserver::ChromeRenderViewObserver( 157 ChromeRenderViewObserver::ChromeRenderViewObserver(
158 RenderView* render_view, 158 RenderView* render_view,
159 ContentSettingsObserver* content_settings, 159 ContentSettingsObserver* content_settings,
160 ExtensionDispatcher* extension_dispatcher, 160 ExtensionDispatcher* extension_dispatcher,
161 TranslateHelper* translate_helper, 161 TranslateHelper* translate_helper)
162 safe_browsing::PhishingClassifierDelegate* phishing_classifier)
163 : RenderViewObserver(render_view), 162 : RenderViewObserver(render_view),
164 content_settings_(content_settings), 163 content_settings_(content_settings),
165 extension_dispatcher_(extension_dispatcher), 164 extension_dispatcher_(extension_dispatcher),
166 translate_helper_(translate_helper), 165 translate_helper_(translate_helper),
167 phishing_classifier_(phishing_classifier), 166 phishing_classifier_(NULL),
168 last_indexed_page_id_(-1), 167 last_indexed_page_id_(-1),
169 allow_displaying_insecure_content_(false), 168 allow_displaying_insecure_content_(false),
170 allow_running_insecure_content_(false), 169 allow_running_insecure_content_(false),
171 ALLOW_THIS_IN_INITIALIZER_LIST(page_info_method_factory_(this)) { 170 ALLOW_THIS_IN_INITIALIZER_LIST(page_info_method_factory_(this)) {
172 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); 171 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
173 if (command_line.HasSwitch(switches::kDomAutomationController)) { 172 if (command_line.HasSwitch(switches::kDomAutomationController)) {
174 int old_bindings = render_view->enabled_bindings(); 173 int old_bindings = render_view->enabled_bindings();
175 render_view->set_enabled_bindings( 174 render_view->set_enabled_bindings(
176 old_bindings |= BindingsPolicy::DOM_AUTOMATION); 175 old_bindings |= BindingsPolicy::DOM_AUTOMATION);
177 } 176 }
178 render_view->webview()->setPermissionClient(this); 177 render_view->webview()->setPermissionClient(this);
178 if (!command_line.HasSwitch(switches::kDisableClientSidePhishingDetection))
179 OnSetClientSidePhishingDetection(true);
179 } 180 }
180 181
181 ChromeRenderViewObserver::~ChromeRenderViewObserver() { 182 ChromeRenderViewObserver::~ChromeRenderViewObserver() {
182 } 183 }
183 184
184 bool ChromeRenderViewObserver::OnMessageReceived(const IPC::Message& message) { 185 bool ChromeRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
185 bool handled = true; 186 bool handled = true;
186 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewObserver, message) 187 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewObserver, message)
187 IPC_MESSAGE_HANDLER(ViewMsg_CaptureSnapshot, OnCaptureSnapshot) 188 IPC_MESSAGE_HANDLER(ViewMsg_CaptureSnapshot, OnCaptureSnapshot)
188 IPC_MESSAGE_HANDLER(ViewMsg_HandleMessageFromExternalHost, 189 IPC_MESSAGE_HANDLER(ViewMsg_HandleMessageFromExternalHost,
189 OnHandleMessageFromExternalHost) 190 OnHandleMessageFromExternalHost)
190 IPC_MESSAGE_HANDLER(ViewMsg_JavaScriptStressTestControl, 191 IPC_MESSAGE_HANDLER(ViewMsg_JavaScriptStressTestControl,
191 OnJavaScriptStressTestControl) 192 OnJavaScriptStressTestControl)
192 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, 193 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage,
193 OnGetAllSavableResourceLinksForCurrentPage) 194 OnGetAllSavableResourceLinksForCurrentPage)
194 IPC_MESSAGE_HANDLER( 195 IPC_MESSAGE_HANDLER(
195 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, 196 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks,
196 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) 197 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks)
197 IPC_MESSAGE_HANDLER(IconMsg_DownloadFavicon, OnDownloadFavicon) 198 IPC_MESSAGE_HANDLER(IconMsg_DownloadFavicon, OnDownloadFavicon)
198 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) 199 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode)
199 IPC_MESSAGE_HANDLER(ViewMsg_SetAllowDisplayingInsecureContent, 200 IPC_MESSAGE_HANDLER(ViewMsg_SetAllowDisplayingInsecureContent,
200 OnSetAllowDisplayingInsecureContent) 201 OnSetAllowDisplayingInsecureContent)
201 IPC_MESSAGE_HANDLER(ViewMsg_SetAllowRunningInsecureContent, 202 IPC_MESSAGE_HANDLER(ViewMsg_SetAllowRunningInsecureContent,
202 OnSetAllowRunningInsecureContent) 203 OnSetAllowRunningInsecureContent)
204 IPC_MESSAGE_HANDLER(ViewMsg_SetClientSidePhishingDetection,
205 OnSetClientSidePhishingDetection)
203 IPC_MESSAGE_UNHANDLED(handled = false) 206 IPC_MESSAGE_UNHANDLED(handled = false)
204 IPC_END_MESSAGE_MAP() 207 IPC_END_MESSAGE_MAP()
205 208
206 // Filter only. 209 // Filter only.
207 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewObserver, message) 210 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewObserver, message)
208 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) 211 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate)
209 IPC_MESSAGE_HANDLER(ViewMsg_SetIsPrerendering, OnSetIsPrerendering); 212 IPC_MESSAGE_HANDLER(ViewMsg_SetIsPrerendering, OnSetIsPrerendering);
210 IPC_END_MESSAGE_MAP() 213 IPC_END_MESSAGE_MAP()
211 214
212 return handled; 215 return handled;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 WebFrame* main_frame = render_view()->webview()->mainFrame(); 335 WebFrame* main_frame = render_view()->webview()->mainFrame();
333 if (main_frame) 336 if (main_frame)
334 main_frame->reload(); 337 main_frame->reload();
335 } 338 }
336 339
337 void ChromeRenderViewObserver::OnSetAllowRunningInsecureContent(bool allow) { 340 void ChromeRenderViewObserver::OnSetAllowRunningInsecureContent(bool allow) {
338 allow_running_insecure_content_ = allow; 341 allow_running_insecure_content_ = allow;
339 OnSetAllowDisplayingInsecureContent(allow); 342 OnSetAllowDisplayingInsecureContent(allow);
340 } 343 }
341 344
345 void ChromeRenderViewObserver::OnSetClientSidePhishingDetection(
346 bool enable_phishing_detection) {
347 #if !defined(OS_CHROMEOS) || !defined(ENABLE_SAFE_BROWSING)
348 phishing_classifier_ = enable_phishing_detection ?
349 safe_browsing::PhishingClassifierDelegate::Create(
350 render_view(), NULL) :
351 NULL;
352 #endif
353 }
354
342 void ChromeRenderViewObserver::didSerializeDataForFrame( 355 void ChromeRenderViewObserver::didSerializeDataForFrame(
343 const WebURL& frame_url, 356 const WebURL& frame_url,
344 const WebCString& data, 357 const WebCString& data,
345 WebPageSerializerClient::PageSerializationStatus status) { 358 WebPageSerializerClient::PageSerializationStatus status) {
346 Send(new ViewHostMsg_SendSerializedHtmlData( 359 Send(new ViewHostMsg_SendSerializedHtmlData(
347 routing_id(), 360 routing_id(),
348 frame_url, 361 frame_url,
349 data.data(), 362 data.data(),
350 static_cast<int32>(status))); 363 static_cast<int32>(status)));
351 } 364 }
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 if (net::DataURL::Parse(url, &mime_type, &char_set, &data) && !data.empty()) { 855 if (net::DataURL::Parse(url, &mime_type, &char_set, &data) && !data.empty()) {
843 // Decode the favicon using WebKit's image decoder. 856 // Decode the favicon using WebKit's image decoder.
844 webkit_glue::ImageDecoder decoder(gfx::Size(kFaviconSize, kFaviconSize)); 857 webkit_glue::ImageDecoder decoder(gfx::Size(kFaviconSize, kFaviconSize));
845 const unsigned char* src_data = 858 const unsigned char* src_data =
846 reinterpret_cast<const unsigned char*>(&data[0]); 859 reinterpret_cast<const unsigned char*>(&data[0]);
847 860
848 return decoder.Decode(src_data, data.size()); 861 return decoder.Decode(src_data, data.size());
849 } 862 }
850 return SkBitmap(); 863 return SkBitmap();
851 } 864 }
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_render_view_observer.h ('k') | content/browser/renderer_host/resource_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698