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

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: a few tweaks in initialization &c 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 OnSetClientSidePhishingDetection(true);
179 } 179 }
180 180
181 ChromeRenderViewObserver::~ChromeRenderViewObserver() { 181 ChromeRenderViewObserver::~ChromeRenderViewObserver() {
182 } 182 }
183 183
184 bool ChromeRenderViewObserver::OnMessageReceived(const IPC::Message& message) { 184 bool ChromeRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
185 bool handled = true; 185 bool handled = true;
186 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewObserver, message) 186 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewObserver, message)
187 IPC_MESSAGE_HANDLER(ViewMsg_CaptureSnapshot, OnCaptureSnapshot) 187 IPC_MESSAGE_HANDLER(ViewMsg_CaptureSnapshot, OnCaptureSnapshot)
188 IPC_MESSAGE_HANDLER(ViewMsg_HandleMessageFromExternalHost, 188 IPC_MESSAGE_HANDLER(ViewMsg_HandleMessageFromExternalHost,
189 OnHandleMessageFromExternalHost) 189 OnHandleMessageFromExternalHost)
190 IPC_MESSAGE_HANDLER(ViewMsg_JavaScriptStressTestControl, 190 IPC_MESSAGE_HANDLER(ViewMsg_JavaScriptStressTestControl,
191 OnJavaScriptStressTestControl) 191 OnJavaScriptStressTestControl)
192 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, 192 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage,
193 OnGetAllSavableResourceLinksForCurrentPage) 193 OnGetAllSavableResourceLinksForCurrentPage)
194 IPC_MESSAGE_HANDLER( 194 IPC_MESSAGE_HANDLER(
195 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, 195 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks,
196 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) 196 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks)
197 IPC_MESSAGE_HANDLER(IconMsg_DownloadFavicon, OnDownloadFavicon) 197 IPC_MESSAGE_HANDLER(IconMsg_DownloadFavicon, OnDownloadFavicon)
198 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) 198 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode)
199 IPC_MESSAGE_HANDLER(ViewMsg_SetAllowDisplayingInsecureContent, 199 IPC_MESSAGE_HANDLER(ViewMsg_SetAllowDisplayingInsecureContent,
200 OnSetAllowDisplayingInsecureContent) 200 OnSetAllowDisplayingInsecureContent)
201 IPC_MESSAGE_HANDLER(ViewMsg_SetAllowRunningInsecureContent, 201 IPC_MESSAGE_HANDLER(ViewMsg_SetAllowRunningInsecureContent,
202 OnSetAllowRunningInsecureContent) 202 OnSetAllowRunningInsecureContent)
203 IPC_MESSAGE_HANDLER(ViewMsg_SetClientSidePhishingDetection,
204 OnSetClientSidePhishingDetection)
203 IPC_MESSAGE_UNHANDLED(handled = false) 205 IPC_MESSAGE_UNHANDLED(handled = false)
204 IPC_END_MESSAGE_MAP() 206 IPC_END_MESSAGE_MAP()
205 207
206 // Filter only. 208 // Filter only.
207 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewObserver, message) 209 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewObserver, message)
208 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) 210 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate)
209 IPC_MESSAGE_HANDLER(ViewMsg_SetIsPrerendering, OnSetIsPrerendering); 211 IPC_MESSAGE_HANDLER(ViewMsg_SetIsPrerendering, OnSetIsPrerendering);
210 IPC_END_MESSAGE_MAP() 212 IPC_END_MESSAGE_MAP()
211 213
212 return handled; 214 return handled;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 WebFrame* main_frame = render_view()->webview()->mainFrame(); 334 WebFrame* main_frame = render_view()->webview()->mainFrame();
333 if (main_frame) 335 if (main_frame)
334 main_frame->reload(); 336 main_frame->reload();
335 } 337 }
336 338
337 void ChromeRenderViewObserver::OnSetAllowRunningInsecureContent(bool allow) { 339 void ChromeRenderViewObserver::OnSetAllowRunningInsecureContent(bool allow) {
338 allow_running_insecure_content_ = allow; 340 allow_running_insecure_content_ = allow;
339 OnSetAllowDisplayingInsecureContent(allow); 341 OnSetAllowDisplayingInsecureContent(allow);
340 } 342 }
341 343
344 void ChromeRenderViewObserver::OnSetClientSidePhishingDetection(
345 bool enable_phishing_detection) {
346 #ifndef OS_CHROMEOS
347 if (!CommandLine::ForCurrentProcess()->HasSwitch(
348 switches::kDisableClientSidePhishingDetection)) {
mattm 2011/07/08 22:15:24 Hm, since we use the switch to set the initial sta
Miranda Callahan 2011/07/12 16:24:08 Done.
349 phishing_classifier_ = enable_phishing_detection ?
350 safe_browsing::PhishingClassifierDelegate::Create(
351 render_view(), NULL) :
352 NULL;
353 }
354 #endif
355 }
356
342 void ChromeRenderViewObserver::didSerializeDataForFrame( 357 void ChromeRenderViewObserver::didSerializeDataForFrame(
343 const WebURL& frame_url, 358 const WebURL& frame_url,
344 const WebCString& data, 359 const WebCString& data,
345 WebPageSerializerClient::PageSerializationStatus status) { 360 WebPageSerializerClient::PageSerializationStatus status) {
346 Send(new ViewHostMsg_SendSerializedHtmlData( 361 Send(new ViewHostMsg_SendSerializedHtmlData(
347 routing_id(), 362 routing_id(),
348 frame_url, 363 frame_url,
349 data.data(), 364 data.data(),
350 static_cast<int32>(status))); 365 static_cast<int32>(status)));
351 } 366 }
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 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()) {
841 // Decode the favicon using WebKit's image decoder. 856 // Decode the favicon using WebKit's image decoder.
842 webkit_glue::ImageDecoder decoder(gfx::Size(kFaviconSize, kFaviconSize)); 857 webkit_glue::ImageDecoder decoder(gfx::Size(kFaviconSize, kFaviconSize));
843 const unsigned char* src_data = 858 const unsigned char* src_data =
844 reinterpret_cast<const unsigned char*>(&data[0]); 859 reinterpret_cast<const unsigned char*>(&data[0]);
845 860
846 return decoder.Decode(src_data, data.size()); 861 return decoder.Decode(src_data, data.size());
847 } 862 }
848 return SkBitmap(); 863 return SkBitmap();
849 } 864 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698