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

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

Issue 7631063: Prefix all IPC messages used by src\chrome with Chrome. For e.g ChromeViewMsg_, ChromeViewHostMsg... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 if (!command_line.HasSwitch(switches::kDisableClientSidePhishingDetection)) 211 if (!command_line.HasSwitch(switches::kDisableClientSidePhishingDetection))
212 OnSetClientSidePhishingDetection(true); 212 OnSetClientSidePhishingDetection(true);
213 } 213 }
214 214
215 ChromeRenderViewObserver::~ChromeRenderViewObserver() { 215 ChromeRenderViewObserver::~ChromeRenderViewObserver() {
216 } 216 }
217 217
218 bool ChromeRenderViewObserver::OnMessageReceived(const IPC::Message& message) { 218 bool ChromeRenderViewObserver::OnMessageReceived(const IPC::Message& message) {
219 bool handled = true; 219 bool handled = true;
220 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewObserver, message) 220 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewObserver, message)
221 IPC_MESSAGE_HANDLER(ViewMsg_WebUIJavaScript, OnWebUIJavaScript) 221 IPC_MESSAGE_HANDLER(ChromeViewMsg_WebUIJavaScript, OnWebUIJavaScript)
222 IPC_MESSAGE_HANDLER(ViewMsg_CaptureSnapshot, OnCaptureSnapshot) 222 IPC_MESSAGE_HANDLER(ChromeViewMsg_CaptureSnapshot, OnCaptureSnapshot)
223 IPC_MESSAGE_HANDLER(ViewMsg_HandleMessageFromExternalHost, 223 IPC_MESSAGE_HANDLER(ChromeViewMsg_HandleMessageFromExternalHost,
224 OnHandleMessageFromExternalHost) 224 OnHandleMessageFromExternalHost)
225 IPC_MESSAGE_HANDLER(ViewMsg_JavaScriptStressTestControl, 225 IPC_MESSAGE_HANDLER(ChromeViewMsg_JavaScriptStressTestControl,
226 OnJavaScriptStressTestControl) 226 OnJavaScriptStressTestControl)
227 IPC_MESSAGE_HANDLER(IconMsg_DownloadFavicon, OnDownloadFavicon) 227 IPC_MESSAGE_HANDLER(IconMsg_DownloadFavicon, OnDownloadFavicon)
228 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) 228 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode)
229 IPC_MESSAGE_HANDLER(ViewMsg_SetAllowDisplayingInsecureContent, 229 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAllowDisplayingInsecureContent,
230 OnSetAllowDisplayingInsecureContent) 230 OnSetAllowDisplayingInsecureContent)
231 IPC_MESSAGE_HANDLER(ViewMsg_SetAllowRunningInsecureContent, 231 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAllowRunningInsecureContent,
232 OnSetAllowRunningInsecureContent) 232 OnSetAllowRunningInsecureContent)
233 IPC_MESSAGE_HANDLER(ViewMsg_SetClientSidePhishingDetection, 233 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetClientSidePhishingDetection,
234 OnSetClientSidePhishingDetection) 234 OnSetClientSidePhishingDetection)
235 IPC_MESSAGE_UNHANDLED(handled = false) 235 IPC_MESSAGE_UNHANDLED(handled = false)
236 IPC_END_MESSAGE_MAP() 236 IPC_END_MESSAGE_MAP()
237 237
238 // Filter only. 238 // Filter only.
239 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewObserver, message) 239 IPC_BEGIN_MESSAGE_MAP(ChromeRenderViewObserver, message)
240 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) 240 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate)
241 IPC_MESSAGE_HANDLER(ViewMsg_SetIsPrerendering, OnSetIsPrerendering); 241 IPC_MESSAGE_HANDLER(ChromeViewMsg_SetIsPrerendering, OnSetIsPrerendering);
242 IPC_END_MESSAGE_MAP() 242 IPC_END_MESSAGE_MAP()
243 243
244 return handled; 244 return handled;
245 } 245 }
246 246
247 void ChromeRenderViewObserver::OnWebUIJavaScript( 247 void ChromeRenderViewObserver::OnWebUIJavaScript(
248 const string16& frame_xpath, 248 const string16& frame_xpath,
249 const string16& jscript, 249 const string16& jscript,
250 int id, 250 int id,
251 bool notify_result) { 251 bool notify_result) {
(...skipping 12 matching lines...) Expand all
264 if (!main_frame) 264 if (!main_frame)
265 error = true; 265 error = true;
266 266
267 if (!error && !CaptureSnapshot(render_view()->webview(), &snapshot)) 267 if (!error && !CaptureSnapshot(render_view()->webview(), &snapshot))
268 error = true; 268 error = true;
269 269
270 DCHECK(error == snapshot.empty()) << 270 DCHECK(error == snapshot.empty()) <<
271 "Snapshot should be empty on error, non-empty otherwise."; 271 "Snapshot should be empty on error, non-empty otherwise.";
272 272
273 // Send the snapshot to the browser process. 273 // Send the snapshot to the browser process.
274 Send(new ViewHostMsg_Snapshot(routing_id(), snapshot)); 274 Send(new ChromeViewHostMsg_Snapshot(routing_id(), snapshot));
275 } 275 }
276 276
277 void ChromeRenderViewObserver::OnHandleMessageFromExternalHost( 277 void ChromeRenderViewObserver::OnHandleMessageFromExternalHost(
278 const std::string& message, 278 const std::string& message,
279 const std::string& origin, 279 const std::string& origin,
280 const std::string& target) { 280 const std::string& target) {
281 if (message.empty()) 281 if (message.empty())
282 return; 282 return;
283 GetExternalHostBindings()->ForwardMessageFromExternalHost(message, origin, 283 GetExternalHostBindings()->ForwardMessageFromExternalHost(message, origin,
284 target); 284 target);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 frame, extension_name.utf8(), extension_group); 384 frame, extension_name.utf8(), extension_group);
385 } 385 }
386 386
387 bool ChromeRenderViewObserver::allowStorage(WebFrame* frame, bool local) { 387 bool ChromeRenderViewObserver::allowStorage(WebFrame* frame, bool local) {
388 return content_settings_->AllowStorage(frame, local); 388 return content_settings_->AllowStorage(frame, local);
389 } 389 }
390 390
391 bool ChromeRenderViewObserver::allowReadFromClipboard(WebFrame* frame, 391 bool ChromeRenderViewObserver::allowReadFromClipboard(WebFrame* frame,
392 bool default_value) { 392 bool default_value) {
393 bool allowed = false; 393 bool allowed = false;
394 Send(new ViewHostMsg_CanTriggerClipboardRead( 394 Send(new ChromeViewHostMsg_CanTriggerClipboardRead(
395 routing_id(), frame->document().url(), &allowed)); 395 routing_id(), frame->document().url(), &allowed));
396 return allowed; 396 return allowed;
397 } 397 }
398 398
399 bool ChromeRenderViewObserver::allowWriteToClipboard(WebFrame* frame, 399 bool ChromeRenderViewObserver::allowWriteToClipboard(WebFrame* frame,
400 bool default_value) { 400 bool default_value) {
401 bool allowed = false; 401 bool allowed = false;
402 Send(new ViewHostMsg_CanTriggerClipboardWrite( 402 Send(new ChromeViewHostMsg_CanTriggerClipboardWrite(
403 routing_id(), frame->document().url(), &allowed)); 403 routing_id(), frame->document().url(), &allowed));
404 return allowed; 404 return allowed;
405 } 405 }
406 406
407 bool ChromeRenderViewObserver::allowDisplayingInsecureContent( 407 bool ChromeRenderViewObserver::allowDisplayingInsecureContent(
408 WebKit::WebFrame* frame, 408 WebKit::WebFrame* frame,
409 bool allowed_per_settings, 409 bool allowed_per_settings,
410 const WebKit::WebSecurityOrigin& origin, 410 const WebKit::WebSecurityOrigin& origin,
411 const WebKit::WebURL& url) { 411 const WebKit::WebURL& url) {
412 UMA_HISTOGRAM_ENUMERATION(kSSLInsecureContent, 412 UMA_HISTOGRAM_ENUMERATION(kSSLInsecureContent,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 GURL gurl(url); 479 GURL gurl(url);
480 if (EndsWith(gurl.path(), kDotHTML, false)) { 480 if (EndsWith(gurl.path(), kDotHTML, false)) {
481 UMA_HISTOGRAM_ENUMERATION(kSSLInsecureContent, 481 UMA_HISTOGRAM_ENUMERATION(kSSLInsecureContent,
482 INSECURE_CONTENT_DISPLAY_HTML, 482 INSECURE_CONTENT_DISPLAY_HTML,
483 INSECURE_CONTENT_NUM_EVENTS); 483 INSECURE_CONTENT_NUM_EVENTS);
484 } 484 }
485 485
486 if (allowed_per_settings || allow_displaying_insecure_content_) 486 if (allowed_per_settings || allow_displaying_insecure_content_)
487 return true; 487 return true;
488 488
489 Send(new ViewHostMsg_DidBlockDisplayingInsecureContent(routing_id())); 489 Send(new ChromeViewHostMsg_DidBlockDisplayingInsecureContent(routing_id()));
490 return false; 490 return false;
491 } 491 }
492 492
493 bool ChromeRenderViewObserver::allowRunningInsecureContent( 493 bool ChromeRenderViewObserver::allowRunningInsecureContent(
494 WebKit::WebFrame* frame, 494 WebKit::WebFrame* frame,
495 bool allowed_per_settings, 495 bool allowed_per_settings,
496 const WebKit::WebSecurityOrigin& origin, 496 const WebKit::WebSecurityOrigin& origin,
497 const WebKit::WebURL& url) { 497 const WebKit::WebURL& url) {
498 UMA_HISTOGRAM_ENUMERATION(kSSLInsecureContent, 498 UMA_HISTOGRAM_ENUMERATION(kSSLInsecureContent,
499 INSECURE_CONTENT_RUN, 499 INSECURE_CONTENT_RUN,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 INSECURE_CONTENT_NUM_EVENTS); 582 INSECURE_CONTENT_NUM_EVENTS);
583 } else if (EndsWith(gurl.path(), kDotSWF, false)) { 583 } else if (EndsWith(gurl.path(), kDotSWF, false)) {
584 UMA_HISTOGRAM_ENUMERATION(kSSLInsecureContent, 584 UMA_HISTOGRAM_ENUMERATION(kSSLInsecureContent,
585 INSECURE_CONTENT_RUN_SWF, 585 INSECURE_CONTENT_RUN_SWF,
586 INSECURE_CONTENT_NUM_EVENTS); 586 INSECURE_CONTENT_NUM_EVENTS);
587 } 587 }
588 588
589 if (allowed_per_settings || allow_running_insecure_content_) 589 if (allowed_per_settings || allow_running_insecure_content_)
590 return true; 590 return true;
591 591
592 Send(new ViewHostMsg_DidBlockRunningInsecureContent(routing_id())); 592 Send(new ChromeViewHostMsg_DidBlockRunningInsecureContent(routing_id()));
593 return false; 593 return false;
594 } 594 }
595 595
596 void ChromeRenderViewObserver::didNotAllowPlugins(WebFrame* frame) { 596 void ChromeRenderViewObserver::didNotAllowPlugins(WebFrame* frame) {
597 content_settings_->DidNotAllowPlugins(frame); 597 content_settings_->DidNotAllowPlugins(frame);
598 } 598 }
599 599
600 void ChromeRenderViewObserver::didNotAllowScript(WebFrame* frame) { 600 void ChromeRenderViewObserver::didNotAllowScript(WebFrame* frame) {
601 content_settings_->DidNotAllowScript(frame); 601 content_settings_->DidNotAllowScript(frame);
602 } 602 }
(...skipping 26 matching lines...) Expand all
629 MessageLoop::current()->PostDelayedTask( 629 MessageLoop::current()->PostDelayedTask(
630 FROM_HERE, 630 FROM_HERE,
631 page_info_method_factory_.NewRunnableMethod( 631 page_info_method_factory_.NewRunnableMethod(
632 &ChromeRenderViewObserver::CapturePageInfo, render_view()->page_id(), 632 &ChromeRenderViewObserver::CapturePageInfo, render_view()->page_id(),
633 false), 633 false),
634 render_view()->content_state_immediately() ? 0 : kDelayForCaptureMs); 634 render_view()->content_state_immediately() ? 0 : kDelayForCaptureMs);
635 635
636 WebFrame* main_frame = render_view()->webview()->mainFrame(); 636 WebFrame* main_frame = render_view()->webview()->mainFrame();
637 GURL osd_url = main_frame->document().openSearchDescriptionURL(); 637 GURL osd_url = main_frame->document().openSearchDescriptionURL();
638 if (!osd_url.is_empty()) { 638 if (!osd_url.is_empty()) {
639 Send(new ViewHostMsg_PageHasOSDD( 639 Send(new ChromeViewHostMsg_PageHasOSDD(
640 routing_id(), render_view()->page_id(), osd_url, 640 routing_id(), render_view()->page_id(), osd_url,
641 search_provider::AUTODETECTED_PROVIDER)); 641 search_provider::AUTODETECTED_PROVIDER));
642 } 642 }
643 643
644 int icon_types = WebIconURL::TypeFavicon; 644 int icon_types = WebIconURL::TypeFavicon;
645 if (chrome::kEnableTouchIcon) 645 if (chrome::kEnableTouchIcon)
646 icon_types |= WebIconURL::TypeTouchPrecomposed | WebIconURL::TypeTouch; 646 icon_types |= WebIconURL::TypeTouchPrecomposed | WebIconURL::TypeTouch;
647 647
648 WebVector<WebIconURL> icon_urls = 648 WebVector<WebIconURL> icon_urls =
649 render_view()->webview()->mainFrame()->iconURLs(icon_types); 649 render_view()->webview()->mainFrame()->iconURLs(icon_types);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 return; 739 return;
740 740
741 // Retrieve the frame's full text. 741 // Retrieve the frame's full text.
742 string16 contents; 742 string16 contents;
743 CaptureText(main_frame, &contents); 743 CaptureText(main_frame, &contents);
744 if (translate_helper_) 744 if (translate_helper_)
745 translate_helper_->PageCaptured(contents); 745 translate_helper_->PageCaptured(contents);
746 if (contents.size()) { 746 if (contents.size()) {
747 // Send the text to the browser for indexing (the browser might decide not 747 // Send the text to the browser for indexing (the browser might decide not
748 // to index, if the URL is HTTPS for instance) and language discovery. 748 // to index, if the URL is HTTPS for instance) and language discovery.
749 Send(new ViewHostMsg_PageContents(routing_id(), url, load_id, contents)); 749 Send(new ChromeViewHostMsg_PageContents(routing_id(), url, load_id,
750 contents));
750 } 751 }
751 752
752 // Generate the thumbnail here if the in-browser thumbnailing isn't 753 // Generate the thumbnail here if the in-browser thumbnailing isn't
753 // enabled. TODO(satorux): Remove this and related code once 754 // enabled. TODO(satorux): Remove this and related code once
754 // crbug.com/65936 is complete. 755 // crbug.com/65936 is complete.
755 if (!switches::IsInBrowserThumbnailingEnabled()) { 756 if (!switches::IsInBrowserThumbnailingEnabled()) {
756 CaptureThumbnail(); 757 CaptureThumbnail();
757 } 758 }
758 759
759 #if defined(ENABLE_SAFE_BROWSING) 760 #if defined(ENABLE_SAFE_BROWSING)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 if (render_view()->size().IsEmpty()) 809 if (render_view()->size().IsEmpty())
809 return; // Don't create an empty thumbnail! 810 return; // Don't create an empty thumbnail!
810 811
811 ThumbnailScore score; 812 ThumbnailScore score;
812 SkBitmap thumbnail; 813 SkBitmap thumbnail;
813 if (!CaptureFrameThumbnail(render_view()->webview(), kThumbnailWidth, 814 if (!CaptureFrameThumbnail(render_view()->webview(), kThumbnailWidth,
814 kThumbnailHeight, &thumbnail, &score)) 815 kThumbnailHeight, &thumbnail, &score))
815 return; 816 return;
816 817
817 // send the thumbnail message to the browser process 818 // send the thumbnail message to the browser process
818 Send(new ViewHostMsg_Thumbnail(routing_id(), url, score, thumbnail)); 819 Send(new ChromeViewHostMsg_Thumbnail(routing_id(), url, score, thumbnail));
819 } 820 }
820 821
821 bool ChromeRenderViewObserver::CaptureFrameThumbnail(WebView* view, 822 bool ChromeRenderViewObserver::CaptureFrameThumbnail(WebView* view,
822 int w, 823 int w,
823 int h, 824 int h,
824 SkBitmap* thumbnail, 825 SkBitmap* thumbnail,
825 ThumbnailScore* score) { 826 ThumbnailScore* score) {
826 base::TimeTicks beginning_time = base::TimeTicks::Now(); 827 base::TimeTicks beginning_time = base::TimeTicks::Now();
827 828
828 skia::PlatformCanvas canvas; 829 skia::PlatformCanvas canvas;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 if (net::DataURL::Parse(url, &mime_type, &char_set, &data) && !data.empty()) { 964 if (net::DataURL::Parse(url, &mime_type, &char_set, &data) && !data.empty()) {
964 // Decode the favicon using WebKit's image decoder. 965 // Decode the favicon using WebKit's image decoder.
965 webkit_glue::ImageDecoder decoder(gfx::Size(kFaviconSize, kFaviconSize)); 966 webkit_glue::ImageDecoder decoder(gfx::Size(kFaviconSize, kFaviconSize));
966 const unsigned char* src_data = 967 const unsigned char* src_data =
967 reinterpret_cast<const unsigned char*>(&data[0]); 968 reinterpret_cast<const unsigned char*>(&data[0]);
968 969
969 return decoder.Decode(src_data, data.size()); 970 return decoder.Decode(src_data, data.size());
970 } 971 }
971 return SkBitmap(); 972 return SkBitmap();
972 } 973 }
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_render_process_observer.cc ('k') | chrome/renderer/content_settings_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698