| 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 "content/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
| 16 #include "base/json/json_value_serializer.h" | 16 #include "base/json/json_value_serializer.h" |
| 17 #include "base/json/json_writer.h" | 17 #include "base/json/json_writer.h" |
| 18 #include "base/lazy_instance.h" | 18 #include "base/lazy_instance.h" |
| 19 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
| 20 #include "base/path_service.h" | 20 #include "base/path_service.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_number_conversions.h" |
| 23 #include "base/string_split.h" | 24 #include "base/string_split.h" |
| 24 #include "base/string_util.h" | 25 #include "base/string_util.h" |
| 25 #include "base/sys_string_conversions.h" | 26 #include "base/sys_string_conversions.h" |
| 26 #include "base/time.h" | 27 #include "base/time.h" |
| 27 #include "base/utf_string_conversions.h" | 28 #include "base/utf_string_conversions.h" |
| 28 #include "content/common/appcache/appcache_dispatcher.h" | 29 #include "content/common/appcache/appcache_dispatcher.h" |
| 29 #include "content/common/clipboard_messages.h" | 30 #include "content/common/clipboard_messages.h" |
| 30 #include "content/common/database_messages.h" | 31 #include "content/common/database_messages.h" |
| 31 #include "content/common/drag_messages.h" | 32 #include "content/common/drag_messages.h" |
| 32 #include "content/common/file_system/file_system_dispatcher.h" | 33 #include "content/common/file_system/file_system_dispatcher.h" |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 renderer_accessibility_ = new RendererAccessibility(this); | 521 renderer_accessibility_ = new RendererAccessibility(this); |
| 521 mouse_lock_dispatcher_ = new MouseLockDispatcher(this); | 522 mouse_lock_dispatcher_ = new MouseLockDispatcher(this); |
| 522 intents_host_ = new WebIntentsHost(this); | 523 intents_host_ = new WebIntentsHost(this); |
| 523 | 524 |
| 524 new IdleUserDetector(this); | 525 new IdleUserDetector(this); |
| 525 | 526 |
| 526 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 527 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 527 if (command_line.HasSwitch(switches::kDomAutomationController)) | 528 if (command_line.HasSwitch(switches::kDomAutomationController)) |
| 528 enabled_bindings_ |= content::BINDINGS_POLICY_DOM_AUTOMATION; | 529 enabled_bindings_ |= content::BINDINGS_POLICY_DOM_AUTOMATION; |
| 529 | 530 |
| 531 bool enable_fixed_layout = |
| 532 command_line.HasSwitch(switches::kEnableFixedLayout); |
| 533 webview()->enableFixedLayoutMode(enable_fixed_layout); |
| 534 if (enable_fixed_layout) |
| 535 webview()->settings()->setFixedElementsLayoutRelativeToFrame(true); |
| 536 base::StringToInt(command_line.GetSwitchValueASCII( |
| 537 switches::kDefaultDeviceScaleFactor), |
| 538 &default_device_scale_factor_); |
| 539 |
| 530 content::GetContentClient()->renderer()->RenderViewCreated(this); | 540 content::GetContentClient()->renderer()->RenderViewCreated(this); |
| 531 } | 541 } |
| 532 | 542 |
| 533 RenderViewImpl::~RenderViewImpl() { | 543 RenderViewImpl::~RenderViewImpl() { |
| 534 history_page_ids_.clear(); | 544 history_page_ids_.clear(); |
| 535 | 545 |
| 536 if (decrement_shared_popup_at_destruction_) | 546 if (decrement_shared_popup_at_destruction_) |
| 537 shared_popup_counter_->data--; | 547 shared_popup_counter_->data--; |
| 538 | 548 |
| 539 // If file chooser is still waiting for answer, dispatch empty answer. | 549 // If file chooser is still waiting for answer, dispatch empty answer. |
| (...skipping 3820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4360 | 4370 |
| 4361 void RenderViewImpl::OnMoveOrResizeStarted() { | 4371 void RenderViewImpl::OnMoveOrResizeStarted() { |
| 4362 if (webview()) | 4372 if (webview()) |
| 4363 webview()->hidePopups(); | 4373 webview()->hidePopups(); |
| 4364 } | 4374 } |
| 4365 | 4375 |
| 4366 void RenderViewImpl::OnResize(const gfx::Size& new_size, | 4376 void RenderViewImpl::OnResize(const gfx::Size& new_size, |
| 4367 const gfx::Rect& resizer_rect, | 4377 const gfx::Rect& resizer_rect, |
| 4368 bool is_fullscreen) { | 4378 bool is_fullscreen) { |
| 4369 if (webview()) { | 4379 if (webview()) { |
| 4380 // This setting has no effect if fixed layout is not enabled. |
| 4381 if (default_device_scale_factor_) |
| 4382 webview()->settings()->setLayoutFallbackWidth( |
| 4383 new_size.width() / default_device_scale_factor_); |
| 4370 webview()->hidePopups(); | 4384 webview()->hidePopups(); |
| 4371 if (send_preferred_size_changes_) { | 4385 if (send_preferred_size_changes_) { |
| 4372 webview()->mainFrame()->setCanHaveScrollbars( | 4386 webview()->mainFrame()->setCanHaveScrollbars( |
| 4373 ShouldDisplayScrollbars(new_size.width(), new_size.height())); | 4387 ShouldDisplayScrollbars(new_size.width(), new_size.height())); |
| 4374 } | 4388 } |
| 4375 UpdateScrollState(webview()->mainFrame()); | 4389 UpdateScrollState(webview()->mainFrame()); |
| 4376 } | 4390 } |
| 4377 | 4391 |
| 4378 RenderWidget::OnResize(new_size, resizer_rect, is_fullscreen); | 4392 RenderWidget::OnResize(new_size, resizer_rect, is_fullscreen); |
| 4379 } | 4393 } |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5045 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { | 5059 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
| 5046 return !!RenderThreadImpl::current()->compositor_thread(); | 5060 return !!RenderThreadImpl::current()->compositor_thread(); |
| 5047 } | 5061 } |
| 5048 | 5062 |
| 5049 void RenderViewImpl::OnJavaBridgeInit() { | 5063 void RenderViewImpl::OnJavaBridgeInit() { |
| 5050 DCHECK(!java_bridge_dispatcher_.get()); | 5064 DCHECK(!java_bridge_dispatcher_.get()); |
| 5051 #if defined(ENABLE_JAVA_BRIDGE) | 5065 #if defined(ENABLE_JAVA_BRIDGE) |
| 5052 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); | 5066 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); |
| 5053 #endif | 5067 #endif |
| 5054 } | 5068 } |
| OLD | NEW |