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

Side by Side Diff: extensions/browser/api/capture_web_contents_function.cc

Issue 1608733002: Remove ui/gfx/screen_type_delegate.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@metro-mode-4
Patch Set: and another rebase Created 4 years, 11 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "extensions/browser/api/capture_web_contents_function.h" 5 #include "extensions/browser/api/capture_web_contents_function.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "content/public/browser/render_widget_host.h" 9 #include "content/public/browser/render_widget_host.h"
10 #include "content/public/browser/render_widget_host_view.h" 10 #include "content/public/browser/render_widget_host_view.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 OnCaptureFailure(FAILURE_REASON_VIEW_INVISIBLE); 71 OnCaptureFailure(FAILURE_REASON_VIEW_INVISIBLE);
72 return false; 72 return false;
73 } 73 }
74 74
75 // By default, the requested bitmap size is the view size in screen 75 // By default, the requested bitmap size is the view size in screen
76 // coordinates. However, if there's more pixel detail available on the 76 // coordinates. However, if there's more pixel detail available on the
77 // current system, increase the requested bitmap size to capture it all. 77 // current system, increase the requested bitmap size to capture it all.
78 const gfx::Size view_size = view->GetViewBounds().size(); 78 const gfx::Size view_size = view->GetViewBounds().size();
79 gfx::Size bitmap_size = view_size; 79 gfx::Size bitmap_size = view_size;
80 const gfx::NativeView native_view = view->GetNativeView(); 80 const gfx::NativeView native_view = view->GetNativeView();
81 gfx::Screen* const screen = gfx::Screen::GetScreenFor(native_view); 81 gfx::Screen* const screen = gfx::Screen::GetScreen();
82 const float scale = 82 const float scale =
83 screen->GetDisplayNearestWindow(native_view).device_scale_factor(); 83 screen->GetDisplayNearestWindow(native_view).device_scale_factor();
84 if (scale > 1.0f) 84 if (scale > 1.0f)
85 bitmap_size = gfx::ScaleToCeiledSize(view_size, scale); 85 bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
86 86
87 host->CopyFromBackingStore( 87 host->CopyFromBackingStore(
88 gfx::Rect(view_size), 88 gfx::Rect(view_size),
89 bitmap_size, 89 bitmap_size,
90 base::Bind(&CaptureWebContentsFunction::CopyFromBackingStoreComplete, 90 base::Bind(&CaptureWebContentsFunction::CopyFromBackingStoreComplete,
91 this), 91 this),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 data.size()); 141 data.size());
142 142
143 base::Base64Encode(stream_as_string, &base64_result); 143 base::Base64Encode(stream_as_string, &base64_result);
144 base64_result.insert( 144 base64_result.insert(
145 0, base::StringPrintf("data:%s;base64,", mime_type.c_str())); 145 0, base::StringPrintf("data:%s;base64,", mime_type.c_str()));
146 SetResult(new base::StringValue(base64_result)); 146 SetResult(new base::StringValue(base64_result));
147 SendResponse(true); 147 SendResponse(true);
148 } 148 }
149 149
150 } // namespace extensions 150 } // namespace extensions
OLDNEW
« no previous file with comments | « content/shell/browser/shell_views.cc ('k') | extensions/browser/api/system_display/display_info_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698