| OLD | NEW |
| 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 "chrome/browser/extensions/api/capture_web_contents_function.h" | 5 #include "chrome/browser/extensions/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 "chrome/browser/extensions/api/tabs/tabs_constants.h" | 9 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
| 10 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 RenderWidgetHostView* view = render_view_host->GetView(); | 70 RenderWidgetHostView* view = render_view_host->GetView(); |
| 71 if (!view) { | 71 if (!view) { |
| 72 OnCaptureFailure(FAILURE_REASON_VIEW_INVISIBLE); | 72 OnCaptureFailure(FAILURE_REASON_VIEW_INVISIBLE); |
| 73 return false; | 73 return false; |
| 74 } | 74 } |
| 75 render_view_host->CopyFromBackingStore( | 75 render_view_host->CopyFromBackingStore( |
| 76 gfx::Rect(), | 76 gfx::Rect(), |
| 77 view->GetViewBounds().size(), | 77 view->GetViewBounds().size(), |
| 78 base::Bind(&CaptureWebContentsFunction::CopyFromBackingStoreComplete, | 78 base::Bind(&CaptureWebContentsFunction::CopyFromBackingStoreComplete, |
| 79 this), | 79 this), |
| 80 SkBitmap::kARGB_8888_Config); | 80 kN32_SkColorType); |
| 81 return true; | 81 return true; |
| 82 } | 82 } |
| 83 | 83 |
| 84 void CaptureWebContentsFunction::CopyFromBackingStoreComplete( | 84 void CaptureWebContentsFunction::CopyFromBackingStoreComplete( |
| 85 bool succeeded, | 85 bool succeeded, |
| 86 const SkBitmap& bitmap) { | 86 const SkBitmap& bitmap) { |
| 87 if (succeeded) { | 87 if (succeeded) { |
| 88 OnCaptureSuccess(bitmap); | 88 OnCaptureSuccess(bitmap); |
| 89 return; | 89 return; |
| 90 } | 90 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 reinterpret_cast<const char*>(vector_as_array(&data)), data.size()); | 129 reinterpret_cast<const char*>(vector_as_array(&data)), data.size()); |
| 130 | 130 |
| 131 base::Base64Encode(stream_as_string, &base64_result); | 131 base::Base64Encode(stream_as_string, &base64_result); |
| 132 base64_result.insert(0, base::StringPrintf("data:%s;base64,", | 132 base64_result.insert(0, base::StringPrintf("data:%s;base64,", |
| 133 mime_type.c_str())); | 133 mime_type.c_str())); |
| 134 SetResult(new base::StringValue(base64_result)); | 134 SetResult(new base::StringValue(base64_result)); |
| 135 SendResponse(true); | 135 SendResponse(true); |
| 136 } | 136 } |
| 137 | 137 |
| 138 } // namespace extensions | 138 } // namespace extensions |
| OLD | NEW |