OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/net/url_fixer_upper.h" | 24 #include "chrome/browser/net/url_fixer_upper.h" |
25 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 25 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
26 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
27 #include "chrome/browser/sessions/restore_tab_helper.h" | 27 #include "chrome/browser/sessions/restore_tab_helper.h" |
28 #include "chrome/browser/tabs/tab_strip_model.h" | 28 #include "chrome/browser/tabs/tab_strip_model.h" |
29 #include "chrome/browser/translate/translate_tab_helper.h" | 29 #include "chrome/browser/translate/translate_tab_helper.h" |
30 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
31 #include "chrome/browser/ui/browser_list.h" | 31 #include "chrome/browser/ui/browser_list.h" |
32 #include "chrome/browser/ui/browser_navigator.h" | 32 #include "chrome/browser/ui/browser_navigator.h" |
33 #include "chrome/browser/ui/browser_window.h" | 33 #include "chrome/browser/ui/browser_window.h" |
| 34 #include "chrome/browser/ui/snapshot_tab_helper.h" |
34 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 35 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
35 #include "chrome/browser/ui/window_sizer.h" | 36 #include "chrome/browser/ui/window_sizer.h" |
36 #include "chrome/browser/web_applications/web_app.h" | 37 #include "chrome/browser/web_applications/web_app.h" |
37 #include "chrome/common/chrome_notification_types.h" | 38 #include "chrome/common/chrome_notification_types.h" |
38 #include "chrome/common/chrome_switches.h" | 39 #include "chrome/common/chrome_switches.h" |
39 #include "chrome/common/extensions/extension.h" | 40 #include "chrome/common/extensions/extension.h" |
40 #include "chrome/common/extensions/extension_error_utils.h" | 41 #include "chrome/common/extensions/extension_error_utils.h" |
41 #include "chrome/common/extensions/extension_messages.h" | 42 #include "chrome/common/extensions/extension_messages.h" |
42 #include "chrome/common/pref_names.h" | 43 #include "chrome/common/pref_names.h" |
43 #include "chrome/common/url_constants.h" | 44 #include "chrome/common/url_constants.h" |
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 RenderViewHost* render_view_host = tab_contents->render_view_host(); | 1441 RenderViewHost* render_view_host = tab_contents->render_view_host(); |
1441 | 1442 |
1442 // If a backing store is cached for the tab we want to capture, | 1443 // If a backing store is cached for the tab we want to capture, |
1443 // and it can be copied into a bitmap, then use it to generate the image. | 1444 // and it can be copied into a bitmap, then use it to generate the image. |
1444 BackingStore* backing_store = render_view_host->GetBackingStore(false); | 1445 BackingStore* backing_store = render_view_host->GetBackingStore(false); |
1445 if (backing_store && CaptureSnapshotFromBackingStore(backing_store)) | 1446 if (backing_store && CaptureSnapshotFromBackingStore(backing_store)) |
1446 return true; | 1447 return true; |
1447 | 1448 |
1448 // Ask the renderer for a snapshot of the tab. | 1449 // Ask the renderer for a snapshot of the tab. |
1449 TabContentsWrapper* wrapper = browser->GetSelectedTabContentsWrapper(); | 1450 TabContentsWrapper* wrapper = browser->GetSelectedTabContentsWrapper(); |
1450 wrapper->CaptureSnapshot(); | 1451 wrapper->snapshot_tab_helper()->CaptureSnapshot(); |
1451 registrar_.Add(this, | 1452 registrar_.Add(this, |
1452 chrome::NOTIFICATION_TAB_SNAPSHOT_TAKEN, | 1453 chrome::NOTIFICATION_TAB_SNAPSHOT_TAKEN, |
1453 content::Source<TabContentsWrapper>(wrapper)); | 1454 content::Source<TabContentsWrapper>(wrapper)); |
1454 AddRef(); // Balanced in CaptureVisibleTabFunction::Observe(). | 1455 AddRef(); // Balanced in CaptureVisibleTabFunction::Observe(). |
1455 | 1456 |
1456 return true; | 1457 return true; |
1457 } | 1458 } |
1458 | 1459 |
1459 // Build the image of a tab's contents out of a backing store. | 1460 // Build the image of a tab's contents out of a backing store. |
1460 // This may fail if we can not copy a backing store into a bitmap. | 1461 // This may fail if we can not copy a backing store into a bitmap. |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1615 // called for every API call the extension made. | 1616 // called for every API call the extension made. |
1616 GotLanguage(language); | 1617 GotLanguage(language); |
1617 } | 1618 } |
1618 | 1619 |
1619 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { | 1620 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { |
1620 result_.reset(Value::CreateStringValue(language.c_str())); | 1621 result_.reset(Value::CreateStringValue(language.c_str())); |
1621 SendResponse(true); | 1622 SendResponse(true); |
1622 | 1623 |
1623 Release(); // Balanced in Run() | 1624 Release(); // Balanced in Run() |
1624 } | 1625 } |
OLD | NEW |