OLD | NEW |
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 "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> |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "content/common/intents_messages.h" | 34 #include "content/common/intents_messages.h" |
35 #include "content/common/java_bridge_messages.h" | 35 #include "content/common/java_bridge_messages.h" |
36 #include "content/common/pepper_messages.h" | 36 #include "content/common/pepper_messages.h" |
37 #include "content/common/pepper_plugin_registry.h" | 37 #include "content/common/pepper_plugin_registry.h" |
38 #include "content/common/quota_dispatcher.h" | 38 #include "content/common/quota_dispatcher.h" |
39 #include "content/common/request_extra_data.h" | 39 #include "content/common/request_extra_data.h" |
40 #include "content/common/view_messages.h" | 40 #include "content/common/view_messages.h" |
41 #include "content/public/common/bindings_policy.h" | 41 #include "content/public/common/bindings_policy.h" |
42 #include "content/public/common/content_constants.h" | 42 #include "content/public/common/content_constants.h" |
43 #include "content/public/common/content_switches.h" | 43 #include "content/public/common/content_switches.h" |
| 44 #include "content/public/common/file_chooser_params.h" |
44 #include "content/public/common/url_constants.h" | 45 #include "content/public/common/url_constants.h" |
45 #include "content/public/renderer/content_renderer_client.h" | 46 #include "content/public/renderer/content_renderer_client.h" |
46 #include "content/public/renderer/document_state.h" | 47 #include "content/public/renderer/document_state.h" |
47 #include "content/public/renderer/navigation_state.h" | 48 #include "content/public/renderer/navigation_state.h" |
48 #include "content/public/renderer/render_view_observer.h" | 49 #include "content/public/renderer/render_view_observer.h" |
49 #include "content/public/renderer/render_view_visitor.h" | 50 #include "content/public/renderer/render_view_visitor.h" |
50 #include "content/renderer/device_orientation_dispatcher.h" | 51 #include "content/renderer/device_orientation_dispatcher.h" |
51 #include "content/renderer/devtools_agent.h" | 52 #include "content/renderer/devtools_agent.h" |
52 #include "content/renderer/external_popup_menu.h" | 53 #include "content/renderer/external_popup_menu.h" |
53 #include "content/renderer/geolocation_dispatcher.h" | 54 #include "content/renderer/geolocation_dispatcher.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 return | 299 return |
299 params.navigation_type == ViewMsg_Navigate_Type::RELOAD || | 300 params.navigation_type == ViewMsg_Navigate_Type::RELOAD || |
300 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; | 301 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; |
301 } | 302 } |
302 | 303 |
303 /////////////////////////////////////////////////////////////////////////////// | 304 /////////////////////////////////////////////////////////////////////////////// |
304 | 305 |
305 int32 RenderViewImpl::next_page_id_ = 1; | 306 int32 RenderViewImpl::next_page_id_ = 1; |
306 | 307 |
307 struct RenderViewImpl::PendingFileChooser { | 308 struct RenderViewImpl::PendingFileChooser { |
308 PendingFileChooser(const ViewHostMsg_RunFileChooser_Params& p, | 309 PendingFileChooser(const content::FileChooserParams& p, |
309 WebFileChooserCompletion* c) | 310 WebFileChooserCompletion* c) |
310 : params(p), | 311 : params(p), |
311 completion(c) { | 312 completion(c) { |
312 } | 313 } |
313 ViewHostMsg_RunFileChooser_Params params; | 314 content::FileChooserParams params; |
314 WebFileChooserCompletion* completion; // MAY BE NULL to skip callback. | 315 WebFileChooserCompletion* completion; // MAY BE NULL to skip callback. |
315 }; | 316 }; |
316 | 317 |
317 RenderViewImpl::RenderViewImpl( | 318 RenderViewImpl::RenderViewImpl( |
318 gfx::NativeViewId parent_hwnd, | 319 gfx::NativeViewId parent_hwnd, |
319 int32 opener_id, | 320 int32 opener_id, |
320 const content::RendererPreferences& renderer_prefs, | 321 const content::RendererPreferences& renderer_prefs, |
321 const WebPreferences& webkit_prefs, | 322 const WebPreferences& webkit_prefs, |
322 SharedRenderViewCounter* counter, | 323 SharedRenderViewCounter* counter, |
323 int32 routing_id, | 324 int32 routing_id, |
(...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1539 | 1540 |
1540 return did_execute_command; | 1541 return did_execute_command; |
1541 } | 1542 } |
1542 | 1543 |
1543 bool RenderViewImpl::runFileChooser( | 1544 bool RenderViewImpl::runFileChooser( |
1544 const WebKit::WebFileChooserParams& params, | 1545 const WebKit::WebFileChooserParams& params, |
1545 WebFileChooserCompletion* chooser_completion) { | 1546 WebFileChooserCompletion* chooser_completion) { |
1546 // Do not open the file dialog in a hidden RenderView. | 1547 // Do not open the file dialog in a hidden RenderView. |
1547 if (is_hidden()) | 1548 if (is_hidden()) |
1548 return false; | 1549 return false; |
1549 ViewHostMsg_RunFileChooser_Params ipc_params; | 1550 content::FileChooserParams ipc_params; |
1550 if (params.directory) | 1551 if (params.directory) |
1551 ipc_params.mode = ViewHostMsg_RunFileChooser_Mode::OpenFolder; | 1552 ipc_params.mode = content::FileChooserParams::OpenFolder; |
1552 else if (params.multiSelect) | 1553 else if (params.multiSelect) |
1553 ipc_params.mode = ViewHostMsg_RunFileChooser_Mode::OpenMultiple; | 1554 ipc_params.mode = content::FileChooserParams::OpenMultiple; |
1554 else if (params.saveAs) | 1555 else if (params.saveAs) |
1555 ipc_params.mode = ViewHostMsg_RunFileChooser_Mode::Save; | 1556 ipc_params.mode = content::FileChooserParams::Save; |
1556 else | 1557 else |
1557 ipc_params.mode = ViewHostMsg_RunFileChooser_Mode::Open; | 1558 ipc_params.mode = content::FileChooserParams::Open; |
1558 ipc_params.title = params.title; | 1559 ipc_params.title = params.title; |
1559 ipc_params.default_file_name = | 1560 ipc_params.default_file_name = |
1560 webkit_glue::WebStringToFilePath(params.initialValue); | 1561 webkit_glue::WebStringToFilePath(params.initialValue); |
1561 ipc_params.accept_types.reserve(params.acceptMIMETypes.size()); | 1562 ipc_params.accept_types.reserve(params.acceptMIMETypes.size()); |
1562 for (size_t i = 0; i < params.acceptMIMETypes.size(); ++i) | 1563 for (size_t i = 0; i < params.acceptMIMETypes.size(); ++i) |
1563 ipc_params.accept_types.push_back(params.acceptMIMETypes[i]); | 1564 ipc_params.accept_types.push_back(params.acceptMIMETypes[i]); |
1564 | 1565 |
1565 return ScheduleFileChooser(ipc_params, chooser_completion); | 1566 return ScheduleFileChooser(ipc_params, chooser_completion); |
1566 } | 1567 } |
1567 | 1568 |
(...skipping 2904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4472 } | 4473 } |
4473 | 4474 |
4474 void RenderViewImpl::AcceleratedSurfaceBuffersSwapped( | 4475 void RenderViewImpl::AcceleratedSurfaceBuffersSwapped( |
4475 gfx::PluginWindowHandle window, uint64 surface_id) { | 4476 gfx::PluginWindowHandle window, uint64 surface_id) { |
4476 Send(new ViewHostMsg_AcceleratedSurfaceBuffersSwapped( | 4477 Send(new ViewHostMsg_AcceleratedSurfaceBuffersSwapped( |
4477 routing_id(), window, surface_id)); | 4478 routing_id(), window, surface_id)); |
4478 } | 4479 } |
4479 #endif | 4480 #endif |
4480 | 4481 |
4481 bool RenderViewImpl::ScheduleFileChooser( | 4482 bool RenderViewImpl::ScheduleFileChooser( |
4482 const ViewHostMsg_RunFileChooser_Params& params, | 4483 const content::FileChooserParams& params, |
4483 WebFileChooserCompletion* completion) { | 4484 WebFileChooserCompletion* completion) { |
4484 static const size_t kMaximumPendingFileChooseRequests = 4; | 4485 static const size_t kMaximumPendingFileChooseRequests = 4; |
4485 if (file_chooser_completions_.size() > kMaximumPendingFileChooseRequests) { | 4486 if (file_chooser_completions_.size() > kMaximumPendingFileChooseRequests) { |
4486 // This sanity check prevents too many file choose requests from getting | 4487 // This sanity check prevents too many file choose requests from getting |
4487 // queued which could DoS the user. Getting these is most likely a | 4488 // queued which could DoS the user. Getting these is most likely a |
4488 // programming error (there are many ways to DoS the user so it's not | 4489 // programming error (there are many ways to DoS the user so it's not |
4489 // considered a "real" security check), either in JS requesting many file | 4490 // considered a "real" security check), either in JS requesting many file |
4490 // choosers to pop up, or in a plugin. | 4491 // choosers to pop up, or in a plugin. |
4491 // | 4492 // |
4492 // TODO(brettw) we might possibly want to require a user gesture to open | 4493 // TODO(brettw) we might possibly want to require a user gesture to open |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4728 return !!RenderThreadImpl::current()->compositor_thread(); | 4729 return !!RenderThreadImpl::current()->compositor_thread(); |
4729 } | 4730 } |
4730 | 4731 |
4731 void RenderViewImpl::OnJavaBridgeInit( | 4732 void RenderViewImpl::OnJavaBridgeInit( |
4732 const IPC::ChannelHandle& channel_handle) { | 4733 const IPC::ChannelHandle& channel_handle) { |
4733 DCHECK(!java_bridge_dispatcher_.get()); | 4734 DCHECK(!java_bridge_dispatcher_.get()); |
4734 #if defined(ENABLE_JAVA_BRIDGE) | 4735 #if defined(ENABLE_JAVA_BRIDGE) |
4735 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); | 4736 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); |
4736 #endif | 4737 #endif |
4737 } | 4738 } |
OLD | NEW |