| 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/extension_tabs_module.h" | 5 #include "chrome/browser/extensions/extension_tabs_module.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base64.h" | 10 #include "base/base64.h" |
| (...skipping 1652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 if (!GetExtension()->CanCaptureVisiblePage(web_contents->GetURL(), &error_)) | 1663 if (!GetExtension()->CanCaptureVisiblePage(web_contents->GetURL(), &error_)) |
| 1664 return false; | 1664 return false; |
| 1665 | 1665 |
| 1666 RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); | 1666 RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); |
| 1667 content::RenderWidgetHostView* view = render_view_host->GetView(); | 1667 content::RenderWidgetHostView* view = render_view_host->GetView(); |
| 1668 if (!view) { | 1668 if (!view) { |
| 1669 error_ = keys::kInternalVisibleTabCaptureError; | 1669 error_ = keys::kInternalVisibleTabCaptureError; |
| 1670 return false; | 1670 return false; |
| 1671 } | 1671 } |
| 1672 skia::PlatformCanvas* temp_canvas = new skia::PlatformCanvas; | 1672 skia::PlatformCanvas* temp_canvas = new skia::PlatformCanvas; |
| 1673 render_view_host->AsyncCopyFromBackingStore( | 1673 render_view_host->CopyFromBackingStore( |
| 1674 gfx::Rect(), | 1674 gfx::Rect(), |
| 1675 view->GetViewBounds().size(), | 1675 view->GetViewBounds().size(), |
| 1676 temp_canvas, | 1676 temp_canvas, |
| 1677 base::Bind(&CaptureVisibleTabFunction::CopyFromBackingStoreComplete, | 1677 base::Bind(&CaptureVisibleTabFunction::CopyFromBackingStoreComplete, |
| 1678 this, | 1678 this, |
| 1679 base::Owned(temp_canvas))); | 1679 base::Owned(temp_canvas))); |
| 1680 return true; | 1680 return true; |
| 1681 } | 1681 } |
| 1682 | 1682 |
| 1683 void CaptureVisibleTabFunction::CopyFromBackingStoreComplete( | 1683 void CaptureVisibleTabFunction::CopyFromBackingStoreComplete( |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1847 // called for every API call the extension made. | 1847 // called for every API call the extension made. |
| 1848 GotLanguage(language); | 1848 GotLanguage(language); |
| 1849 } | 1849 } |
| 1850 | 1850 |
| 1851 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1851 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
| 1852 result_.reset(Value::CreateStringValue(language.c_str())); | 1852 result_.reset(Value::CreateStringValue(language.c_str())); |
| 1853 SendResponse(true); | 1853 SendResponse(true); |
| 1854 | 1854 |
| 1855 Release(); // Balanced in Run() | 1855 Release(); // Balanced in Run() |
| 1856 } | 1856 } |
| OLD | NEW |