| 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 "chrome/browser/extensions/api/tabs/tabs.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1677 &error_)) { | 1677 &error_)) { |
| 1678 return false; | 1678 return false; |
| 1679 } | 1679 } |
| 1680 | 1680 |
| 1681 RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); | 1681 RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); |
| 1682 content::RenderWidgetHostView* view = render_view_host->GetView(); | 1682 content::RenderWidgetHostView* view = render_view_host->GetView(); |
| 1683 if (!view) { | 1683 if (!view) { |
| 1684 error_ = keys::kInternalVisibleTabCaptureError; | 1684 error_ = keys::kInternalVisibleTabCaptureError; |
| 1685 return false; | 1685 return false; |
| 1686 } | 1686 } |
| 1687 skia::PlatformCanvas* temp_canvas = new skia::PlatformCanvas; | 1687 skia::PlatformBitmap* temp_bitmap = new skia::PlatformBitmap; |
| 1688 render_view_host->CopyFromBackingStore( | 1688 render_view_host->CopyFromBackingStore( |
| 1689 gfx::Rect(), | 1689 gfx::Rect(), |
| 1690 view->GetViewBounds().size(), | 1690 view->GetViewBounds().size(), |
| 1691 base::Bind(&CaptureVisibleTabFunction::CopyFromBackingStoreComplete, | 1691 base::Bind(&CaptureVisibleTabFunction::CopyFromBackingStoreComplete, |
| 1692 this, | 1692 this, |
| 1693 base::Owned(temp_canvas)), | 1693 base::Owned(temp_bitmap)), |
| 1694 temp_canvas); | 1694 temp_bitmap); |
| 1695 return true; | 1695 return true; |
| 1696 } | 1696 } |
| 1697 | 1697 |
| 1698 void CaptureVisibleTabFunction::CopyFromBackingStoreComplete( | 1698 void CaptureVisibleTabFunction::CopyFromBackingStoreComplete( |
| 1699 skia::PlatformCanvas* canvas, | 1699 skia::PlatformBitmap* bitmap, |
| 1700 bool succeeded) { | 1700 bool succeeded) { |
| 1701 if (succeeded) { | 1701 if (succeeded) { |
| 1702 VLOG(1) << "captureVisibleTab() got image from backing store."; | 1702 VLOG(1) << "captureVisibleTab() got image from backing store."; |
| 1703 SendResultFromBitmap(skia::GetTopDevice(*canvas)->accessBitmap(false)); | 1703 SendResultFromBitmap(bitmap->GetBitmap()); |
| 1704 return; | 1704 return; |
| 1705 } | 1705 } |
| 1706 | 1706 |
| 1707 WebContents* web_contents = NULL; | 1707 WebContents* web_contents = NULL; |
| 1708 if (!GetTabToCapture(&web_contents)) { | 1708 if (!GetTabToCapture(&web_contents)) { |
| 1709 error_ = keys::kInternalVisibleTabCaptureError; | 1709 error_ = keys::kInternalVisibleTabCaptureError; |
| 1710 SendResponse(false); | 1710 SendResponse(false); |
| 1711 return; | 1711 return; |
| 1712 } | 1712 } |
| 1713 | 1713 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1867 // called for every API call the extension made. | 1867 // called for every API call the extension made. |
| 1868 GotLanguage(language); | 1868 GotLanguage(language); |
| 1869 } | 1869 } |
| 1870 | 1870 |
| 1871 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1871 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
| 1872 SetResult(Value::CreateStringValue(language.c_str())); | 1872 SetResult(Value::CreateStringValue(language.c_str())); |
| 1873 SendResponse(true); | 1873 SendResponse(true); |
| 1874 | 1874 |
| 1875 Release(); // Balanced in Run() | 1875 Release(); // Balanced in Run() |
| 1876 } | 1876 } |
| OLD | NEW |