OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "app/gfx/color_utils.h" | 11 #include "app/gfx/color_utils.h" |
12 #include "app/gfx/favicon_size.h" | 12 #include "app/gfx/favicon_size.h" |
13 #include "app/l10n_util.h" | 13 #include "app/l10n_util.h" |
14 #include "app/message_box_flags.h" | 14 #include "app/message_box_flags.h" |
15 #include "app/resource_bundle.h" | 15 #include "app/resource_bundle.h" |
16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
17 #include "base/compiler_specific.h" | 17 #include "base/compiler_specific.h" |
18 #include "base/field_trial.h" | 18 #include "base/field_trial.h" |
19 #include "base/gfx/png_encoder.h" | 19 #include "base/gfx/png_encoder.h" |
20 #include "base/gfx/native_widget_types.h" | 20 #include "base/gfx/native_widget_types.h" |
21 #include "base/process_util.h" | 21 #include "base/process_util.h" |
22 #include "base/string_piece.h" | 22 #include "base/string_piece.h" |
23 #include "base/string_util.h" | 23 #include "base/string_util.h" |
24 #include "build/build_config.h" | 24 #include "build/build_config.h" |
25 #include "chrome/common/bindings_policy.h" | 25 #include "chrome/common/bindings_policy.h" |
| 26 #include "chrome/common/child_process_logging.h" |
26 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
27 #include "chrome/common/chrome_constants.h" | 28 #include "chrome/common/chrome_constants.h" |
28 #include "chrome/common/jstemplate_builder.h" | 29 #include "chrome/common/jstemplate_builder.h" |
29 #include "chrome/common/page_zoom.h" | 30 #include "chrome/common/page_zoom.h" |
30 #include "chrome/common/render_messages.h" | 31 #include "chrome/common/render_messages.h" |
31 #include "chrome/common/renderer_preferences.h" | 32 #include "chrome/common/renderer_preferences.h" |
32 #include "chrome/common/thumbnail_score.h" | 33 #include "chrome/common/thumbnail_score.h" |
33 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
34 #include "chrome/renderer/about_handler.h" | 35 #include "chrome/renderer/about_handler.h" |
35 #include "chrome/renderer/audio_message_filter.h" | 36 #include "chrome/renderer/audio_message_filter.h" |
36 #include "chrome/renderer/devtools_agent.h" | 37 #include "chrome/renderer/devtools_agent.h" |
37 #include "chrome/renderer/devtools_client.h" | 38 #include "chrome/renderer/devtools_client.h" |
38 #include "chrome/renderer/extensions/event_bindings.h" | 39 #include "chrome/renderer/extensions/event_bindings.h" |
39 #include "chrome/renderer/localized_error.h" | 40 #include "chrome/renderer/localized_error.h" |
40 #include "chrome/renderer/media/audio_renderer_impl.h" | 41 #include "chrome/renderer/media/audio_renderer_impl.h" |
41 #include "chrome/renderer/media/buffered_data_source.h" | 42 #include "chrome/renderer/media/buffered_data_source.h" |
42 #include "chrome/renderer/navigation_state.h" | 43 #include "chrome/renderer/navigation_state.h" |
43 #include "chrome/renderer/print_web_view_helper.h" | 44 #include "chrome/renderer/print_web_view_helper.h" |
44 #include "chrome/renderer/render_process.h" | 45 #include "chrome/renderer/render_process.h" |
45 #include "chrome/renderer/renderer_logging.h" | |
46 #include "chrome/renderer/user_script_slave.h" | 46 #include "chrome/renderer/user_script_slave.h" |
47 #include "chrome/renderer/visitedlink_slave.h" | 47 #include "chrome/renderer/visitedlink_slave.h" |
48 #include "chrome/renderer/webplugin_delegate_proxy.h" | 48 #include "chrome/renderer/webplugin_delegate_proxy.h" |
49 #include "chrome/renderer/webworker_proxy.h" | 49 #include "chrome/renderer/webworker_proxy.h" |
50 #include "grit/generated_resources.h" | 50 #include "grit/generated_resources.h" |
51 #include "grit/renderer_resources.h" | 51 #include "grit/renderer_resources.h" |
52 #include "net/base/data_url.h" | 52 #include "net/base/data_url.h" |
53 #include "net/base/escape.h" | 53 #include "net/base/escape.h" |
54 #include "net/base/net_errors.h" | 54 #include "net/base/net_errors.h" |
55 #include "skia/ext/bitmap_platform_device.h" | 55 #include "skia/ext/bitmap_platform_device.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 318 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
319 if (command_line.HasSwitch(switches::kDomAutomationController)) | 319 if (command_line.HasSwitch(switches::kDomAutomationController)) |
320 enabled_bindings_ |= BindingsPolicy::DOM_AUTOMATION; | 320 enabled_bindings_ |= BindingsPolicy::DOM_AUTOMATION; |
321 | 321 |
322 audio_message_filter_ = new AudioMessageFilter(routing_id_); | 322 audio_message_filter_ = new AudioMessageFilter(routing_id_); |
323 render_thread_->AddFilter(audio_message_filter_); | 323 render_thread_->AddFilter(audio_message_filter_); |
324 } | 324 } |
325 | 325 |
326 void RenderView::OnMessageReceived(const IPC::Message& message) { | 326 void RenderView::OnMessageReceived(const IPC::Message& message) { |
327 WebFrame* main_frame = webview() ? webview()->GetMainFrame() : NULL; | 327 WebFrame* main_frame = webview() ? webview()->GetMainFrame() : NULL; |
328 renderer_logging::ScopedActiveRenderingURLSetter url_setter( | 328 child_process_logging::ScopedActiveURLSetter url_setter( |
329 main_frame ? main_frame->GetURL() : GURL()); | 329 main_frame ? main_frame->GetURL() : GURL()); |
330 | 330 |
331 // If this is developer tools renderer intercept tools messages first. | 331 // If this is developer tools renderer intercept tools messages first. |
332 if (devtools_client_.get() && devtools_client_->OnMessageReceived(message)) | 332 if (devtools_client_.get() && devtools_client_->OnMessageReceived(message)) |
333 return; | 333 return; |
334 if (devtools_agent_.get() && devtools_agent_->OnMessageReceived(message)) | 334 if (devtools_agent_.get() && devtools_agent_->OnMessageReceived(message)) |
335 return; | 335 return; |
336 | 336 |
337 IPC_BEGIN_MESSAGE_MAP(RenderView, message) | 337 IPC_BEGIN_MESSAGE_MAP(RenderView, message) |
338 IPC_MESSAGE_HANDLER(ViewMsg_CaptureThumbnail, SendThumbnail) | 338 IPC_MESSAGE_HANDLER(ViewMsg_CaptureThumbnail, SendThumbnail) |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 | 619 |
620 int color_count = *std::max_element(histogram, histogram + 256); | 620 int color_count = *std::max_element(histogram, histogram + 256); |
621 int pixel_count = bitmap->width() * bitmap->height(); | 621 int pixel_count = bitmap->width() * bitmap->height(); |
622 return static_cast<double>(color_count) / pixel_count; | 622 return static_cast<double>(color_count) / pixel_count; |
623 } | 623 } |
624 | 624 |
625 void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { | 625 void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { |
626 if (!webview()) | 626 if (!webview()) |
627 return; | 627 return; |
628 | 628 |
629 renderer_logging::ScopedActiveRenderingURLSetter url_setter(params.url); | 629 child_process_logging::ScopedActiveURLSetter url_setter(params.url); |
630 | 630 |
631 AboutHandler::MaybeHandle(params.url); | 631 AboutHandler::MaybeHandle(params.url); |
632 | 632 |
633 bool is_reload = params.reload; | 633 bool is_reload = params.reload; |
634 | 634 |
635 WebFrame* main_frame = webview()->GetMainFrame(); | 635 WebFrame* main_frame = webview()->GetMainFrame(); |
636 if (is_reload && main_frame->GetCurrentHistoryItem().isNull()) { | 636 if (is_reload && main_frame->GetCurrentHistoryItem().isNull()) { |
637 // We cannot reload if we do not have any history state. This happens, for | 637 // We cannot reload if we do not have any history state. This happens, for |
638 // example, when recovering from a crash. Our workaround here is a bit of | 638 // example, when recovering from a crash. Our workaround here is a bit of |
639 // a hack since it means that reload after a crashed tab does not cause an | 639 // a hack since it means that reload after a crashed tab does not cause an |
(...skipping 2318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2958 Send(new ViewHostMsg_PasswordFormsSeen(routing_id_, password_forms)); | 2958 Send(new ViewHostMsg_PasswordFormsSeen(routing_id_, password_forms)); |
2959 } | 2959 } |
2960 | 2960 |
2961 void RenderView::Print(WebFrame* frame, bool script_initiated) { | 2961 void RenderView::Print(WebFrame* frame, bool script_initiated) { |
2962 DCHECK(frame); | 2962 DCHECK(frame); |
2963 if (print_helper_.get() == NULL) { | 2963 if (print_helper_.get() == NULL) { |
2964 print_helper_.reset(new PrintWebViewHelper(this)); | 2964 print_helper_.reset(new PrintWebViewHelper(this)); |
2965 } | 2965 } |
2966 print_helper_->Print(frame, script_initiated); | 2966 print_helper_->Print(frame, script_initiated); |
2967 } | 2967 } |
OLD | NEW |