Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(503)

Side by Side Diff: content/browser/renderer_host/render_view_host_impl.cc

Issue 23694031: Fix race conditions in window snapshot code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "content/public/common/drop_data.h" 59 #include "content/public/common/drop_data.h"
60 #include "content/public/common/result_codes.h" 60 #include "content/public/common/result_codes.h"
61 #include "content/public/common/url_constants.h" 61 #include "content/public/common/url_constants.h"
62 #include "content/public/common/url_utils.h" 62 #include "content/public/common/url_utils.h"
63 #include "net/base/net_util.h" 63 #include "net/base/net_util.h"
64 #include "net/url_request/url_request_context_getter.h" 64 #include "net/url_request/url_request_context_getter.h"
65 #include "third_party/skia/include/core/SkBitmap.h" 65 #include "third_party/skia/include/core/SkBitmap.h"
66 #include "ui/gfx/image/image_skia.h" 66 #include "ui/gfx/image/image_skia.h"
67 #include "ui/gfx/native_widget_types.h" 67 #include "ui/gfx/native_widget_types.h"
68 #include "ui/shell_dialogs/selected_file_info.h" 68 #include "ui/shell_dialogs/selected_file_info.h"
69 #include "ui/snapshot/snapshot.h"
70 #include "webkit/browser/fileapi/isolated_context.h" 69 #include "webkit/browser/fileapi/isolated_context.h"
71 70
72 #if defined(OS_MACOSX) 71 #if defined(OS_MACOSX)
73 #include "content/browser/renderer_host/popup_menu_helper_mac.h" 72 #include "content/browser/renderer_host/popup_menu_helper_mac.h"
74 #elif defined(OS_ANDROID) 73 #elif defined(OS_ANDROID)
75 #include "content/browser/android/browser_media_player_manager.h" 74 #include "content/browser/android/browser_media_player_manager.h"
76 #endif 75 #endif
77 76
78 using base::TimeDelta; 77 using base::TimeDelta;
79 using WebKit::WebConsoleMessage; 78 using WebKit::WebConsoleMessage;
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged) 981 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnFocusedNodeChanged)
983 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) 982 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole)
984 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnShouldCloseACK) 983 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnShouldCloseACK)
985 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK) 984 IPC_MESSAGE_HANDLER(ViewHostMsg_ClosePage_ACK, OnClosePageACK)
986 IPC_MESSAGE_HANDLER(ViewHostMsg_SwapOut_ACK, OnSwapOutACK) 985 IPC_MESSAGE_HANDLER(ViewHostMsg_SwapOut_ACK, OnSwapOutACK)
987 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnSelectionChanged) 986 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnSelectionChanged)
988 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged, 987 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionBoundsChanged,
989 OnSelectionBoundsChanged) 988 OnSelectionBoundsChanged)
990 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) 989 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse)
991 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL) 990 IPC_MESSAGE_HANDLER(ViewHostMsg_DidZoomURL, OnDidZoomURL)
992 IPC_MESSAGE_HANDLER(ViewHostMsg_GetWindowSnapshot, OnGetWindowSnapshot)
993 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission, 991 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_RequestPermission,
994 OnRequestDesktopNotificationPermission) 992 OnRequestDesktopNotificationPermission)
995 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show, 993 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show,
996 OnShowDesktopNotification) 994 OnShowDesktopNotification)
997 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel, 995 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel,
998 OnCancelDesktopNotification) 996 OnCancelDesktopNotification)
999 #if defined(OS_MACOSX) || defined(OS_ANDROID) 997 #if defined(OS_MACOSX) || defined(OS_ANDROID)
1000 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup) 998 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup)
1001 #endif 999 #endif
1002 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) 1000 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser)
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
1988 1986
1989 void RenderViewHostImpl::OnDomOperationResponse( 1987 void RenderViewHostImpl::OnDomOperationResponse(
1990 const std::string& json_string, int automation_id) { 1988 const std::string& json_string, int automation_id) {
1991 DomOperationNotificationDetails details(json_string, automation_id); 1989 DomOperationNotificationDetails details(json_string, automation_id);
1992 NotificationService::current()->Notify( 1990 NotificationService::current()->Notify(
1993 NOTIFICATION_DOM_OPERATION_RESPONSE, 1991 NOTIFICATION_DOM_OPERATION_RESPONSE,
1994 Source<RenderViewHost>(this), 1992 Source<RenderViewHost>(this),
1995 Details<DomOperationNotificationDetails>(&details)); 1993 Details<DomOperationNotificationDetails>(&details));
1996 } 1994 }
1997 1995
1998 void RenderViewHostImpl::OnGetWindowSnapshot(const int snapshot_id) {
1999 std::vector<unsigned char> png;
2000
2001 // This feature is behind the kEnableGpuBenchmarking command line switch
2002 // because it poses security concerns and should only be used for testing.
2003 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
2004 if (command_line.HasSwitch(switches::kEnableGpuBenchmarking)) {
2005 gfx::Rect view_bounds = GetView()->GetViewBounds();
2006 gfx::Rect snapshot_bounds(view_bounds.size());
2007 gfx::Size snapshot_size = snapshot_bounds.size();
2008
2009 if (ui::GrabViewSnapshot(GetView()->GetNativeView(),
2010 &png, snapshot_bounds)) {
2011 Send(new ViewMsg_WindowSnapshotCompleted(
2012 GetRoutingID(), snapshot_id, snapshot_size, png));
2013 return;
2014 }
2015 }
2016
2017 Send(new ViewMsg_WindowSnapshotCompleted(
2018 GetRoutingID(), snapshot_id, gfx::Size(), png));
2019 }
2020
2021 #if defined(OS_MACOSX) || defined(OS_ANDROID) 1996 #if defined(OS_MACOSX) || defined(OS_ANDROID)
2022 void RenderViewHostImpl::OnShowPopup( 1997 void RenderViewHostImpl::OnShowPopup(
2023 const ViewHostMsg_ShowPopup_Params& params) { 1998 const ViewHostMsg_ShowPopup_Params& params) {
2024 RenderViewHostDelegateView* view = delegate_->GetDelegateView(); 1999 RenderViewHostDelegateView* view = delegate_->GetDelegateView();
2025 if (view) { 2000 if (view) {
2026 view->ShowPopupMenu(params.bounds, 2001 view->ShowPopupMenu(params.bounds,
2027 params.item_height, 2002 params.item_height,
2028 params.item_font_size, 2003 params.item_font_size,
2029 params.selected_item, 2004 params.selected_item,
2030 params.popup_items, 2005 params.popup_items,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2065 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles(); 2040 const std::vector<base::FilePath>& file_paths = state.GetReferencedFiles();
2066 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin(); 2041 for (std::vector<base::FilePath>::const_iterator file = file_paths.begin();
2067 file != file_paths.end(); ++file) { 2042 file != file_paths.end(); ++file) {
2068 if (!policy->CanReadFile(GetProcess()->GetID(), *file)) 2043 if (!policy->CanReadFile(GetProcess()->GetID(), *file))
2069 return false; 2044 return false;
2070 } 2045 }
2071 return true; 2046 return true;
2072 } 2047 }
2073 2048
2074 } // namespace content 2049 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698