| 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/aeropeek_manager.h" | 5 #include "chrome/browser/aeropeek_manager.h" |
| 6 | 6 |
| 7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
| 8 #include <shobjidl.h> | 8 #include <shobjidl.h> |
| 9 | 9 |
| 10 #include "app/win/shell.h" | 10 #include "app/win/shell.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/memory/scoped_native_library.h" | 12 #include "base/memory/scoped_native_library.h" |
| 13 #include "base/scoped_comptr_win.h" | 13 #include "base/scoped_comptr_win.h" |
| 14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
| 15 #include "base/win/scoped_gdi_object.h" | 15 #include "base/win/scoped_gdi_object.h" |
| 16 #include "base/win/scoped_hdc.h" | 16 #include "base/win/scoped_hdc.h" |
| 17 #include "base/win/windows_version.h" | 17 #include "base/win/windows_version.h" |
| 18 #include "chrome/browser/app_icon_win.h" | 18 #include "chrome/browser/app_icon_win.h" |
| 19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/favicon_tab_helper.h" | |
| 21 #include "chrome/browser/tab_contents/thumbnail_generator.h" | 20 #include "chrome/browser/tab_contents/thumbnail_generator.h" |
| 22 #include "chrome/browser/tabs/tab_strip_model.h" | 21 #include "chrome/browser/tabs/tab_strip_model.h" |
| 23 #include "chrome/browser/ui/browser_list.h" | 22 #include "chrome/browser/ui/browser_list.h" |
| 24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 23 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 25 #include "chrome/common/chrome_constants.h" | 24 #include "chrome/common/chrome_constants.h" |
| 26 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 27 #include "chrome/installer/util/browser_distribution.h" | 26 #include "chrome/installer/util/browser_distribution.h" |
| 28 #include "content/browser/browser_thread.h" | 27 #include "content/browser/browser_thread.h" |
| 29 #include "content/browser/renderer_host/backing_store.h" | 28 #include "content/browser/renderer_host/backing_store.h" |
| 30 #include "content/browser/renderer_host/render_view_host.h" | 29 #include "content/browser/renderer_host/render_view_host.h" |
| (...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 bool foreground) { | 1062 bool foreground) { |
| 1064 if (GetAeroPeekWindow(GetTabID(tab->tab_contents()))) | 1063 if (GetAeroPeekWindow(GetTabID(tab->tab_contents()))) |
| 1065 return; | 1064 return; |
| 1066 | 1065 |
| 1067 AeroPeekWindow* window = | 1066 AeroPeekWindow* window = |
| 1068 new AeroPeekWindow(application_window_, | 1067 new AeroPeekWindow(application_window_, |
| 1069 this, | 1068 this, |
| 1070 GetTabID(tab->tab_contents()), | 1069 GetTabID(tab->tab_contents()), |
| 1071 foreground, | 1070 foreground, |
| 1072 tab->tab_contents()->GetTitle(), | 1071 tab->tab_contents()->GetTitle(), |
| 1073 tab->favicon_tab_helper()->GetFavicon()); | 1072 tab->tab_contents()->GetFavicon()); |
| 1074 tab_list_.push_back(window); | 1073 tab_list_.push_back(window); |
| 1075 } | 1074 } |
| 1076 | 1075 |
| 1077 TabContents* AeroPeekManager::GetTabContents(int tab_id) const { | 1076 TabContents* AeroPeekManager::GetTabContents(int tab_id) const { |
| 1078 for (TabContentsIterator iterator; !iterator.done(); ++iterator) { | 1077 for (TabContentsIterator iterator; !iterator.done(); ++iterator) { |
| 1079 TabContents* target_contents = (*iterator)->tab_contents(); | 1078 TabContents* target_contents = (*iterator)->tab_contents(); |
| 1080 if (target_contents->controller().session_id().id() == tab_id) | 1079 if (target_contents->controller().session_id().id() == tab_id) |
| 1081 return target_contents; | 1080 return target_contents; |
| 1082 } | 1081 } |
| 1083 return NULL; | 1082 return NULL; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 GetAeroPeekWindow(GetTabID(contents->tab_contents())); | 1167 GetAeroPeekWindow(GetTabID(contents->tab_contents())); |
| 1169 if (!window) | 1168 if (!window) |
| 1170 return; | 1169 return; |
| 1171 | 1170 |
| 1172 // Update the title, the favicon, and the thumbnail used for AeroPeek. | 1171 // Update the title, the favicon, and the thumbnail used for AeroPeek. |
| 1173 // These function don't actually update the icon and the thumbnail until | 1172 // These function don't actually update the icon and the thumbnail until |
| 1174 // Windows needs them (e.g. when a user hovers a taskbar icon) to avoid | 1173 // Windows needs them (e.g. when a user hovers a taskbar icon) to avoid |
| 1175 // hurting the rendering performance. (These functions just save the | 1174 // hurting the rendering performance. (These functions just save the |
| 1176 // information needed for handling update requests from Windows.) | 1175 // information needed for handling update requests from Windows.) |
| 1177 window->SetTitle(contents->tab_contents()->GetTitle()); | 1176 window->SetTitle(contents->tab_contents()->GetTitle()); |
| 1178 window->SetFavicon(contents->favicon_tab_helper()->GetFavicon()); | 1177 window->SetFavicon(contents->tab_contents()->GetFavicon()); |
| 1179 window->Update(contents->tab_contents()->is_loading()); | 1178 window->Update(contents->tab_contents()->is_loading()); |
| 1180 } | 1179 } |
| 1181 | 1180 |
| 1182 /////////////////////////////////////////////////////////////////////////////// | 1181 /////////////////////////////////////////////////////////////////////////////// |
| 1183 // AeroPeekManager, AeroPeekWindowDelegate implementation: | 1182 // AeroPeekManager, AeroPeekWindowDelegate implementation: |
| 1184 | 1183 |
| 1185 void AeroPeekManager::ActivateTab(int tab_id) { | 1184 void AeroPeekManager::ActivateTab(int tab_id) { |
| 1186 // Ask TabStrip to activate this tab. | 1185 // Ask TabStrip to activate this tab. |
| 1187 // We don't have to update thumbnails now since TabStrip will call | 1186 // We don't have to update thumbnails now since TabStrip will call |
| 1188 // TabSelectedAt() when it actually activates this tab. | 1187 // TabSelectedAt() when it actually activates this tab. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 // This code is just copied from "thumbnail_generator.cc". | 1240 // This code is just copied from "thumbnail_generator.cc". |
| 1242 skia::PlatformCanvas canvas; | 1241 skia::PlatformCanvas canvas; |
| 1243 if (!backing_store->CopyFromBackingStore(gfx::Rect(backing_store->size()), | 1242 if (!backing_store->CopyFromBackingStore(gfx::Rect(backing_store->size()), |
| 1244 &canvas)) | 1243 &canvas)) |
| 1245 return false; | 1244 return false; |
| 1246 | 1245 |
| 1247 const SkBitmap& bitmap = canvas.getTopPlatformDevice().accessBitmap(false); | 1246 const SkBitmap& bitmap = canvas.getTopPlatformDevice().accessBitmap(false); |
| 1248 bitmap.copyTo(preview, SkBitmap::kARGB_8888_Config); | 1247 bitmap.copyTo(preview, SkBitmap::kARGB_8888_Config); |
| 1249 return true; | 1248 return true; |
| 1250 } | 1249 } |
| OLD | NEW |