| 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 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1698 error_ = keys::kInternalVisibleTabCaptureError; | 1698 error_ = keys::kInternalVisibleTabCaptureError; |
| 1699 SendResponse(false); | 1699 SendResponse(false); |
| 1700 return; | 1700 return; |
| 1701 } | 1701 } |
| 1702 | 1702 |
| 1703 // Ask the renderer for a snapshot of the tab. | 1703 // Ask the renderer for a snapshot of the tab. |
| 1704 registrar_.Add(this, | 1704 registrar_.Add(this, |
| 1705 chrome::NOTIFICATION_TAB_SNAPSHOT_TAKEN, | 1705 chrome::NOTIFICATION_TAB_SNAPSHOT_TAKEN, |
| 1706 content::Source<WebContents>(web_contents)); | 1706 content::Source<WebContents>(web_contents)); |
| 1707 AddRef(); // Balanced in CaptureVisibleTabFunction::Observe(). | 1707 AddRef(); // Balanced in CaptureVisibleTabFunction::Observe(). |
| 1708 TabContents::FromWebContents(web_contents)->snapshot_tab_helper()-> | 1708 SnapshotTabHelper::FromWebContents(web_contents)->CaptureSnapshot(); |
| 1709 CaptureSnapshot(); | |
| 1710 } | 1709 } |
| 1711 | 1710 |
| 1712 // If a backing store was not available in CaptureVisibleTabFunction::RunImpl, | 1711 // If a backing store was not available in CaptureVisibleTabFunction::RunImpl, |
| 1713 // than the renderer was asked for a snapshot. Listen for a notification | 1712 // than the renderer was asked for a snapshot. Listen for a notification |
| 1714 // that the snapshot is available. | 1713 // that the snapshot is available. |
| 1715 void CaptureVisibleTabFunction::Observe( | 1714 void CaptureVisibleTabFunction::Observe( |
| 1716 int type, | 1715 int type, |
| 1717 const content::NotificationSource& source, | 1716 const content::NotificationSource& source, |
| 1718 const content::NotificationDetails& details) { | 1717 const content::NotificationDetails& details) { |
| 1719 DCHECK(type == chrome::NOTIFICATION_TAB_SNAPSHOT_TAKEN); | 1718 DCHECK(type == chrome::NOTIFICATION_TAB_SNAPSHOT_TAKEN); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1856 // called for every API call the extension made. | 1855 // called for every API call the extension made. |
| 1857 GotLanguage(language); | 1856 GotLanguage(language); |
| 1858 } | 1857 } |
| 1859 | 1858 |
| 1860 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1859 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
| 1861 SetResult(Value::CreateStringValue(language.c_str())); | 1860 SetResult(Value::CreateStringValue(language.c_str())); |
| 1862 SendResponse(true); | 1861 SendResponse(true); |
| 1863 | 1862 |
| 1864 Release(); // Balanced in Run() | 1863 Release(); // Balanced in Run() |
| 1865 } | 1864 } |
| OLD | NEW |