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/browser/renderer_host/render_view_host_impl.h" | 5 #include "content/browser/renderer_host/render_view_host_impl.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 using blink::WebDragOperation; | 106 using blink::WebDragOperation; |
107 using blink::WebDragOperationNone; | 107 using blink::WebDragOperationNone; |
108 using blink::WebDragOperationsMask; | 108 using blink::WebDragOperationsMask; |
109 using blink::WebInputEvent; | 109 using blink::WebInputEvent; |
110 using blink::WebMediaPlayerAction; | 110 using blink::WebMediaPlayerAction; |
111 using blink::WebPluginAction; | 111 using blink::WebPluginAction; |
112 | 112 |
113 namespace content { | 113 namespace content { |
114 namespace { | 114 namespace { |
115 | 115 |
| 116 void GetPlatformSpecificPrefs(RendererPreferences* prefs) { |
116 #if defined(OS_WIN) | 117 #if defined(OS_WIN) |
117 void GetWindowsSpecificPrefs(RendererPreferences* prefs) { | |
118 NONCLIENTMETRICS_XP metrics = {0}; | 118 NONCLIENTMETRICS_XP metrics = {0}; |
119 base::win::GetNonClientMetrics(&metrics); | 119 base::win::GetNonClientMetrics(&metrics); |
120 | 120 |
121 prefs->caption_font_family_name = metrics.lfCaptionFont.lfFaceName; | 121 prefs->caption_font_family_name = metrics.lfCaptionFont.lfFaceName; |
122 prefs->caption_font_height = gfx::PlatformFontWin::GetFontSize( | 122 prefs->caption_font_height = gfx::PlatformFontWin::GetFontSize( |
123 metrics.lfCaptionFont); | 123 metrics.lfCaptionFont); |
124 | 124 |
125 prefs->small_caption_font_family_name = metrics.lfSmCaptionFont.lfFaceName; | 125 prefs->small_caption_font_family_name = metrics.lfSmCaptionFont.lfFaceName; |
126 prefs->small_caption_font_height = gfx::PlatformFontWin::GetFontSize( | 126 prefs->small_caption_font_height = gfx::PlatformFontWin::GetFontSize( |
127 metrics.lfSmCaptionFont); | 127 metrics.lfSmCaptionFont); |
(...skipping 11 matching lines...) Expand all Loading... |
139 metrics.lfMessageFont); | 139 metrics.lfMessageFont); |
140 | 140 |
141 prefs->vertical_scroll_bar_width_in_dips = | 141 prefs->vertical_scroll_bar_width_in_dips = |
142 display::win::ScreenWin::GetSystemMetricsInDIP(SM_CXVSCROLL); | 142 display::win::ScreenWin::GetSystemMetricsInDIP(SM_CXVSCROLL); |
143 prefs->horizontal_scroll_bar_height_in_dips = | 143 prefs->horizontal_scroll_bar_height_in_dips = |
144 display::win::ScreenWin::GetSystemMetricsInDIP(SM_CYHSCROLL); | 144 display::win::ScreenWin::GetSystemMetricsInDIP(SM_CYHSCROLL); |
145 prefs->arrow_bitmap_height_vertical_scroll_bar_in_dips = | 145 prefs->arrow_bitmap_height_vertical_scroll_bar_in_dips = |
146 display::win::ScreenWin::GetSystemMetricsInDIP(SM_CYVSCROLL); | 146 display::win::ScreenWin::GetSystemMetricsInDIP(SM_CYVSCROLL); |
147 prefs->arrow_bitmap_width_horizontal_scroll_bar_in_dips = | 147 prefs->arrow_bitmap_width_horizontal_scroll_bar_in_dips = |
148 display::win::ScreenWin::GetSystemMetricsInDIP(SM_CXHSCROLL); | 148 display::win::ScreenWin::GetSystemMetricsInDIP(SM_CXHSCROLL); |
| 149 #elif defined(OS_LINUX) |
| 150 prefs->system_font_family_name = gfx::Font().GetFontName(); |
| 151 #endif |
149 } | 152 } |
150 #endif | |
151 | 153 |
152 std::vector<DropData::Metadata> DropDataToMetaData(const DropData& drop_data) { | 154 std::vector<DropData::Metadata> DropDataToMetaData(const DropData& drop_data) { |
153 std::vector<DropData::Metadata> metadata; | 155 std::vector<DropData::Metadata> metadata; |
154 if (!drop_data.text.is_null()) { | 156 if (!drop_data.text.is_null()) { |
155 metadata.push_back(DropData::Metadata::CreateForMimeType( | 157 metadata.push_back(DropData::Metadata::CreateForMimeType( |
156 DropData::Kind::STRING, | 158 DropData::Kind::STRING, |
157 base::ASCIIToUTF16(ui::Clipboard::kMimeTypeText))); | 159 base::ASCIIToUTF16(ui::Clipboard::kMimeTypeText))); |
158 } | 160 } |
159 | 161 |
160 if (drop_data.url.is_valid()) { | 162 if (drop_data.url.is_valid()) { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 // TODO(creis): Remove this once we've found the cause. | 330 // TODO(creis): Remove this once we've found the cause. |
329 if (main_frame_routing_id_ != MSG_ROUTING_NONE && | 331 if (main_frame_routing_id_ != MSG_ROUTING_NONE && |
330 proxy_route_id != MSG_ROUTING_NONE) | 332 proxy_route_id != MSG_ROUTING_NONE) |
331 base::debug::DumpWithoutCrashing(); | 333 base::debug::DumpWithoutCrashing(); |
332 | 334 |
333 GetWidget()->set_renderer_initialized(true); | 335 GetWidget()->set_renderer_initialized(true); |
334 | 336 |
335 mojom::CreateViewParamsPtr params = mojom::CreateViewParams::New(); | 337 mojom::CreateViewParamsPtr params = mojom::CreateViewParams::New(); |
336 params->renderer_preferences = | 338 params->renderer_preferences = |
337 delegate_->GetRendererPrefs(GetProcess()->GetBrowserContext()); | 339 delegate_->GetRendererPrefs(GetProcess()->GetBrowserContext()); |
338 #if defined(OS_WIN) | 340 GetPlatformSpecificPrefs(¶ms->renderer_preferences); |
339 GetWindowsSpecificPrefs(¶ms->renderer_preferences); | |
340 #endif | |
341 params->web_preferences = GetWebkitPreferences(); | 341 params->web_preferences = GetWebkitPreferences(); |
342 params->view_id = GetRoutingID(); | 342 params->view_id = GetRoutingID(); |
343 params->main_frame_routing_id = main_frame_routing_id_; | 343 params->main_frame_routing_id = main_frame_routing_id_; |
344 if (main_frame_routing_id_ != MSG_ROUTING_NONE) { | 344 if (main_frame_routing_id_ != MSG_ROUTING_NONE) { |
345 RenderFrameHostImpl* main_rfh = RenderFrameHostImpl::FromID( | 345 RenderFrameHostImpl* main_rfh = RenderFrameHostImpl::FromID( |
346 GetProcess()->GetID(), main_frame_routing_id_); | 346 GetProcess()->GetID(), main_frame_routing_id_); |
347 DCHECK(main_rfh); | 347 DCHECK(main_rfh); |
348 RenderWidgetHostImpl* main_rwh = main_rfh->GetRenderWidgetHost(); | 348 RenderWidgetHostImpl* main_rwh = main_rfh->GetRenderWidgetHost(); |
349 params->main_frame_widget_routing_id = main_rwh->GetRoutingID(); | 349 params->main_frame_widget_routing_id = main_rwh->GetRoutingID(); |
350 } | 350 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 return true; | 396 return true; |
397 } | 397 } |
398 | 398 |
399 bool RenderViewHostImpl::IsRenderViewLive() const { | 399 bool RenderViewHostImpl::IsRenderViewLive() const { |
400 return GetProcess()->HasConnection() && GetWidget()->renderer_initialized(); | 400 return GetProcess()->HasConnection() && GetWidget()->renderer_initialized(); |
401 } | 401 } |
402 | 402 |
403 void RenderViewHostImpl::SyncRendererPrefs() { | 403 void RenderViewHostImpl::SyncRendererPrefs() { |
404 RendererPreferences renderer_preferences = | 404 RendererPreferences renderer_preferences = |
405 delegate_->GetRendererPrefs(GetProcess()->GetBrowserContext()); | 405 delegate_->GetRendererPrefs(GetProcess()->GetBrowserContext()); |
406 #if defined(OS_WIN) | 406 GetPlatformSpecificPrefs(&renderer_preferences); |
407 GetWindowsSpecificPrefs(&renderer_preferences); | |
408 #endif | |
409 Send(new ViewMsg_SetRendererPrefs(GetRoutingID(), renderer_preferences)); | 407 Send(new ViewMsg_SetRendererPrefs(GetRoutingID(), renderer_preferences)); |
410 } | 408 } |
411 | 409 |
412 WebPreferences RenderViewHostImpl::ComputeWebkitPrefs() { | 410 WebPreferences RenderViewHostImpl::ComputeWebkitPrefs() { |
413 TRACE_EVENT0("browser", "RenderViewHostImpl::GetWebkitPrefs"); | 411 TRACE_EVENT0("browser", "RenderViewHostImpl::GetWebkitPrefs"); |
414 WebPreferences prefs; | 412 WebPreferences prefs; |
415 | 413 |
416 const base::CommandLine& command_line = | 414 const base::CommandLine& command_line = |
417 *base::CommandLine::ForCurrentProcess(); | 415 *base::CommandLine::ForCurrentProcess(); |
418 | 416 |
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 // Note: We are using the origin URL provided by the sender here. It may be | 1311 // Note: We are using the origin URL provided by the sender here. It may be |
1314 // different from the receiver's. | 1312 // different from the receiver's. |
1315 file_system_file.url = | 1313 file_system_file.url = |
1316 GURL(storage::GetIsolatedFileSystemRootURIString( | 1314 GURL(storage::GetIsolatedFileSystemRootURIString( |
1317 file_system_url.origin(), filesystem_id, std::string()) | 1315 file_system_url.origin(), filesystem_id, std::string()) |
1318 .append(register_name)); | 1316 .append(register_name)); |
1319 } | 1317 } |
1320 } | 1318 } |
1321 | 1319 |
1322 } // namespace content | 1320 } // namespace content |
OLD | NEW |