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 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1646 return false; | 1646 return false; |
1647 | 1647 |
1648 RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); | 1648 RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); |
1649 | 1649 |
1650 // If a backing store is cached for the tab we want to capture, | 1650 // If a backing store is cached for the tab we want to capture, |
1651 // and it can be copied into a bitmap, then use it to generate the image. | 1651 // and it can be copied into a bitmap, then use it to generate the image. |
1652 // This may fail if we can not copy a backing store into a bitmap. | 1652 // This may fail if we can not copy a backing store into a bitmap. |
1653 // For example, some uncommon X11 visual modes are not supported by | 1653 // For example, some uncommon X11 visual modes are not supported by |
1654 // CopyFromBackingStore(). | 1654 // CopyFromBackingStore(). |
1655 skia::PlatformCanvas temp_canvas; | 1655 skia::PlatformCanvas temp_canvas; |
1656 if (render_view_host->CopyFromBackingStore(&temp_canvas)) { | 1656 if (render_view_host->CopyFromBackingStore(gfx::Size(), &temp_canvas)) { |
1657 VLOG(1) << "captureVisibleTab() got image from backing store."; | 1657 VLOG(1) << "captureVisibleTab() got image from backing store."; |
1658 SendResultFromBitmap(skia::GetTopDevice(temp_canvas)->accessBitmap(false)); | 1658 SendResultFromBitmap(skia::GetTopDevice(temp_canvas)->accessBitmap(false)); |
1659 return true; | 1659 return true; |
1660 } | 1660 } |
1661 | 1661 |
1662 // Ask the renderer for a snapshot of the tab. | 1662 // Ask the renderer for a snapshot of the tab. |
1663 TabContentsWrapper* wrapper = browser->GetSelectedTabContentsWrapper(); | 1663 TabContentsWrapper* wrapper = browser->GetSelectedTabContentsWrapper(); |
1664 registrar_.Add(this, | 1664 registrar_.Add(this, |
1665 chrome::NOTIFICATION_TAB_SNAPSHOT_TAKEN, | 1665 chrome::NOTIFICATION_TAB_SNAPSHOT_TAKEN, |
1666 content::Source<WebContents>(wrapper->web_contents())); | 1666 content::Source<WebContents>(wrapper->web_contents())); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1812 // called for every API call the extension made. | 1812 // called for every API call the extension made. |
1813 GotLanguage(language); | 1813 GotLanguage(language); |
1814 } | 1814 } |
1815 | 1815 |
1816 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1816 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
1817 result_.reset(Value::CreateStringValue(language.c_str())); | 1817 result_.reset(Value::CreateStringValue(language.c_str())); |
1818 SendResponse(true); | 1818 SendResponse(true); |
1819 | 1819 |
1820 Release(); // Balanced in Run() | 1820 Release(); // Balanced in Run() |
1821 } | 1821 } |
OLD | NEW |