| 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 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/debug/alias.h" | 15 #include "base/debug/alias.h" |
| 16 #include "base/debug/trace_event.h" | 16 #include "base/debug/trace_event.h" |
| 17 #include "base/files/file_path.h" | 17 #include "base/files/file_path.h" |
| 18 #include "base/i18n/char_iterator.h" | 18 #include "base/i18n/char_iterator.h" |
| 19 #include "base/json/json_writer.h" | 19 #include "base/json/json_writer.h" |
| 20 #include "base/lazy_instance.h" | 20 #include "base/lazy_instance.h" |
| 21 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
| 22 #include "base/message_loop/message_loop_proxy.h" | 22 #include "base/message_loop/message_loop_proxy.h" |
| 23 #include "base/metrics/histogram.h" | 23 #include "base/metrics/histogram.h" |
| 24 #include "base/path_service.h" | 24 #include "base/path_service.h" |
| 25 #include "base/process/kill.h" | 25 #include "base/process/kill.h" |
| 26 #include "base/process/process.h" |
| 26 #include "base/strings/string_number_conversions.h" | 27 #include "base/strings/string_number_conversions.h" |
| 27 #include "base/strings/string_piece.h" | 28 #include "base/strings/string_piece.h" |
| 28 #include "base/strings/string_split.h" | 29 #include "base/strings/string_split.h" |
| 29 #include "base/strings/string_util.h" | 30 #include "base/strings/string_util.h" |
| 30 #include "base/strings/sys_string_conversions.h" | 31 #include "base/strings/sys_string_conversions.h" |
| 31 #include "base/strings/utf_string_conversions.h" | 32 #include "base/strings/utf_string_conversions.h" |
| 32 #include "base/time/time.h" | 33 #include "base/time/time.h" |
| 33 #include "content/child/appcache/appcache_dispatcher.h" | 34 #include "content/child/appcache/appcache_dispatcher.h" |
| 34 #include "content/child/appcache/web_application_cache_host_impl.h" | 35 #include "content/child/appcache/web_application_cache_host_impl.h" |
| 35 #include "content/child/child_thread.h" | 36 #include "content/child/child_thread.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 187 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
| 187 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 188 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
| 188 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" | 189 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" |
| 189 #include "third_party/WebKit/public/web/WebSettings.h" | 190 #include "third_party/WebKit/public/web/WebSettings.h" |
| 190 #include "third_party/WebKit/public/web/WebStorageQuotaCallbacks.h" | 191 #include "third_party/WebKit/public/web/WebStorageQuotaCallbacks.h" |
| 191 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 192 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
| 192 #include "third_party/WebKit/public/web/WebUserMediaClient.h" | 193 #include "third_party/WebKit/public/web/WebUserMediaClient.h" |
| 193 #include "third_party/WebKit/public/web/WebView.h" | 194 #include "third_party/WebKit/public/web/WebView.h" |
| 194 #include "third_party/WebKit/public/web/WebWindowFeatures.h" | 195 #include "third_party/WebKit/public/web/WebWindowFeatures.h" |
| 195 #include "third_party/WebKit/public/web/default/WebRenderTheme.h" | 196 #include "third_party/WebKit/public/web/default/WebRenderTheme.h" |
| 197 #include "ui/base/latency_info.h" |
| 196 #include "ui/base/ui_base_switches_util.h" | 198 #include "ui/base/ui_base_switches_util.h" |
| 197 #include "ui/gfx/native_widget_types.h" | 199 #include "ui/gfx/native_widget_types.h" |
| 198 #include "ui/gfx/point.h" | 200 #include "ui/gfx/point.h" |
| 199 #include "ui/gfx/rect.h" | 201 #include "ui/gfx/rect.h" |
| 200 #include "ui/gfx/rect_conversions.h" | 202 #include "ui/gfx/rect_conversions.h" |
| 201 #include "ui/gfx/size_conversions.h" | 203 #include "ui/gfx/size_conversions.h" |
| 202 #include "ui/shell_dialogs/selected_file_info.h" | 204 #include "ui/shell_dialogs/selected_file_info.h" |
| 203 #include "v8/include/v8.h" | 205 #include "v8/include/v8.h" |
| 204 #include "webkit/child/weburlresponse_extradata_impl.h" | 206 #include "webkit/child/weburlresponse_extradata_impl.h" |
| 205 | 207 |
| (...skipping 2017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2223 if (RenderThreadImpl::current()) // Will be NULL during unit tests. | 2225 if (RenderThreadImpl::current()) // Will be NULL during unit tests. |
| 2224 RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop(); | 2226 RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop(); |
| 2225 | 2227 |
| 2226 message->EnableMessagePumping(); // Runs a nested message loop. | 2228 message->EnableMessagePumping(); // Runs a nested message loop. |
| 2227 return Send(message); | 2229 return Send(message); |
| 2228 } | 2230 } |
| 2229 | 2231 |
| 2230 void RenderViewImpl::GetWindowSnapshot(const WindowSnapshotCallback& callback) { | 2232 void RenderViewImpl::GetWindowSnapshot(const WindowSnapshotCallback& callback) { |
| 2231 int id = next_snapshot_id_++; | 2233 int id = next_snapshot_id_++; |
| 2232 pending_snapshots_.insert(std::make_pair(id, callback)); | 2234 pending_snapshots_.insert(std::make_pair(id, callback)); |
| 2233 Send(new ViewHostMsg_GetWindowSnapshot(routing_id_, id)); | 2235 ui::LatencyInfo latency_info; |
| 2236 latency_info.AddLatencyNumber(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, |
| 2237 GetLatencyComponentId(), |
| 2238 id); |
| 2239 if (RenderWidgetCompositor* rwc = compositor()) { |
| 2240 rwc->SetLatencyInfo(latency_info); |
| 2241 } else { |
| 2242 latency_info_.MergeWith(latency_info); |
| 2243 } |
| 2244 ScheduleCompositeWithForcedRedraw(); |
| 2234 } | 2245 } |
| 2235 | 2246 |
| 2236 void RenderViewImpl::OnWindowSnapshotCompleted(const int snapshot_id, | 2247 void RenderViewImpl::OnWindowSnapshotCompleted(const int snapshot_id, |
| 2237 const gfx::Size& size, const std::vector<unsigned char>& png) { | 2248 const gfx::Size& size, const std::vector<unsigned char>& png) { |
| 2238 PendingSnapshotMap::iterator it = pending_snapshots_.find(snapshot_id); | 2249 PendingSnapshotMap::iterator it = pending_snapshots_.find(snapshot_id); |
| 2239 DCHECK(it != pending_snapshots_.end()); | 2250 DCHECK(it != pending_snapshots_.end()); |
| 2240 it->second.Run(size, png); | 2251 it->second.Run(size, png); |
| 2241 pending_snapshots_.erase(it); | 2252 pending_snapshots_.erase(it); |
| 2242 } | 2253 } |
| 2243 | 2254 |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2707 } | 2718 } |
| 2708 } | 2719 } |
| 2709 | 2720 |
| 2710 gfx::RectF RenderViewImpl::ClientRectToPhysicalWindowRect( | 2721 gfx::RectF RenderViewImpl::ClientRectToPhysicalWindowRect( |
| 2711 const gfx::RectF& rect) const { | 2722 const gfx::RectF& rect) const { |
| 2712 gfx::RectF window_rect = rect; | 2723 gfx::RectF window_rect = rect; |
| 2713 window_rect.Scale(device_scale_factor_ * webview()->pageScaleFactor()); | 2724 window_rect.Scale(device_scale_factor_ * webview()->pageScaleFactor()); |
| 2714 return window_rect; | 2725 return window_rect; |
| 2715 } | 2726 } |
| 2716 | 2727 |
| 2728 int64 RenderViewImpl::GetLatencyComponentId() { |
| 2729 // Note: this must match the logic in RenderWidgetHostImpl. |
| 2730 return GetRoutingID() | (static_cast<int64>( |
| 2731 RenderThreadImpl::current()->renderer_process_id()) << 32); |
| 2732 } |
| 2733 |
| 2717 void RenderViewImpl::StartNavStateSyncTimerIfNecessary() { | 2734 void RenderViewImpl::StartNavStateSyncTimerIfNecessary() { |
| 2718 // No need to update state if no page has committed yet. | 2735 // No need to update state if no page has committed yet. |
| 2719 if (page_id_ == -1) | 2736 if (page_id_ == -1) |
| 2720 return; | 2737 return; |
| 2721 | 2738 |
| 2722 int delay; | 2739 int delay; |
| 2723 if (send_content_state_immediately_) | 2740 if (send_content_state_immediately_) |
| 2724 delay = 0; | 2741 delay = 0; |
| 2725 else if (is_hidden()) | 2742 else if (is_hidden()) |
| 2726 delay = kDelaySecondsForContentStateSyncHidden; | 2743 delay = kDelaySecondsForContentStateSyncHidden; |
| (...skipping 3773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6500 for (size_t i = 0; i < icon_urls.size(); i++) { | 6517 for (size_t i = 0; i < icon_urls.size(); i++) { |
| 6501 WebURL url = icon_urls[i].iconURL(); | 6518 WebURL url = icon_urls[i].iconURL(); |
| 6502 if (!url.isEmpty()) | 6519 if (!url.isEmpty()) |
| 6503 urls.push_back(FaviconURL(url, | 6520 urls.push_back(FaviconURL(url, |
| 6504 ToFaviconType(icon_urls[i].iconType()))); | 6521 ToFaviconType(icon_urls[i].iconType()))); |
| 6505 } | 6522 } |
| 6506 SendUpdateFaviconURL(urls); | 6523 SendUpdateFaviconURL(urls); |
| 6507 } | 6524 } |
| 6508 | 6525 |
| 6509 } // namespace content | 6526 } // namespace content |
| OLD | NEW |