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/hwnd_util.h" | |
11 #include "app/win/window_impl.h" | |
12 #include "app/win/shell.h" | 10 #include "app/win/shell.h" |
13 #include "base/command_line.h" | 11 #include "base/command_line.h" |
14 #include "base/scoped_comptr_win.h" | 12 #include "base/scoped_comptr_win.h" |
15 #include "base/scoped_native_library.h" | 13 #include "base/scoped_native_library.h" |
16 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
17 #include "base/win/scoped_gdi_object.h" | 15 #include "base/win/scoped_gdi_object.h" |
18 #include "base/win/scoped_hdc.h" | 16 #include "base/win/scoped_hdc.h" |
19 #include "base/win/windows_version.h" | 17 #include "base/win/windows_version.h" |
20 #include "chrome/browser/app_icon_win.h" | 18 #include "chrome/browser/app_icon_win.h" |
21 #include "chrome/browser/browser_list.h" | 19 #include "chrome/browser/browser_list.h" |
22 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
23 #include "chrome/browser/browser_thread.h" | 21 #include "chrome/browser/browser_thread.h" |
24 #include "chrome/browser/renderer_host/backing_store.h" | 22 #include "chrome/browser/renderer_host/backing_store.h" |
25 #include "chrome/browser/renderer_host/render_view_host.h" | 23 #include "chrome/browser/renderer_host/render_view_host.h" |
26 #include "chrome/browser/tab_contents/tab_contents.h" | 24 #include "chrome/browser/tab_contents/tab_contents.h" |
27 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | 25 #include "chrome/browser/tab_contents/tab_contents_delegate.h" |
28 #include "chrome/browser/tab_contents/tab_contents_view.h" | 26 #include "chrome/browser/tab_contents/tab_contents_view.h" |
29 #include "chrome/browser/tab_contents/thumbnail_generator.h" | 27 #include "chrome/browser/tab_contents/thumbnail_generator.h" |
30 #include "chrome/browser/tabs/tab_strip_model.h" | 28 #include "chrome/browser/tabs/tab_strip_model.h" |
31 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 29 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
32 #include "chrome/common/chrome_constants.h" | 30 #include "chrome/common/chrome_constants.h" |
33 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
34 #include "chrome/installer/util/browser_distribution.h" | 32 #include "chrome/installer/util/browser_distribution.h" |
35 #include "gfx/gdi_util.h" | 33 #include "gfx/gdi_util.h" |
36 #include "gfx/icon_util.h" | 34 #include "gfx/icon_util.h" |
37 #include "skia/ext/image_operations.h" | 35 #include "skia/ext/image_operations.h" |
38 #include "skia/ext/platform_canvas.h" | 36 #include "skia/ext/platform_canvas.h" |
39 #include "third_party/skia/include/core/SkBitmap.h" | 37 #include "third_party/skia/include/core/SkBitmap.h" |
| 38 #include "ui/base/win/hwnd_util.h" |
| 39 #include "ui/base/win/window_impl.h" |
40 | 40 |
41 namespace { | 41 namespace { |
42 | 42 |
43 // Macros and COM interfaces used in this file. | 43 // Macros and COM interfaces used in this file. |
44 // These interface declarations are copied from Windows SDK 7. | 44 // These interface declarations are copied from Windows SDK 7. |
45 // TODO(hbono): Bug 16903: to be deleted when we use Windows SDK 7. | 45 // TODO(hbono): Bug 16903: to be deleted when we use Windows SDK 7. |
46 | 46 |
47 // Windows SDK 7 defines these macros only when _WIN32_WINNT >= 0x0601. | 47 // Windows SDK 7 defines these macros only when _WIN32_WINNT >= 0x0601. |
48 // Since Chrome currently sets _WIN32_WINNT to 0x0600, copy these defines here | 48 // Since Chrome currently sets _WIN32_WINNT to 0x0600, copy these defines here |
49 // so we can use them. | 49 // so we can use them. |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 | 541 |
542 } // namespace | 542 } // namespace |
543 | 543 |
544 // A class which implements a place-holder window used by AeroPeek. | 544 // A class which implements a place-holder window used by AeroPeek. |
545 // The major work of this class are: | 545 // The major work of this class are: |
546 // * Updating the status of Tab Thumbnails; | 546 // * Updating the status of Tab Thumbnails; |
547 // * Receiving messages from Windows, and; | 547 // * Receiving messages from Windows, and; |
548 // * Translating received messages for TabStrip. | 548 // * Translating received messages for TabStrip. |
549 // This class is used by the AeroPeekManager class, which is a proxy | 549 // This class is used by the AeroPeekManager class, which is a proxy |
550 // between TabStrip and Windows 7. | 550 // between TabStrip and Windows 7. |
551 class AeroPeekWindow : public app::win::WindowImpl { | 551 class AeroPeekWindow : public ui::WindowImpl { |
552 public: | 552 public: |
553 AeroPeekWindow(HWND frame_window, | 553 AeroPeekWindow(HWND frame_window, |
554 AeroPeekWindowDelegate* delegate, | 554 AeroPeekWindowDelegate* delegate, |
555 int tab_id, | 555 int tab_id, |
556 bool tab_active, | 556 bool tab_active, |
557 const std::wstring& title, | 557 const std::wstring& title, |
558 const SkBitmap& favicon_bitmap); | 558 const SkBitmap& favicon_bitmap); |
559 ~AeroPeekWindow(); | 559 ~AeroPeekWindow(); |
560 | 560 |
561 // Activates or deactivates this window. | 561 // Activates or deactivates this window. |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1009 // static | 1009 // static |
1010 bool AeroPeekManager::Enabled() { | 1010 bool AeroPeekManager::Enabled() { |
1011 // We enable our custom AeroPeek only when: | 1011 // We enable our custom AeroPeek only when: |
1012 // * Chrome is running on Windows 7 and Aero is enabled, | 1012 // * Chrome is running on Windows 7 and Aero is enabled, |
1013 // * Chrome is not launched in application mode, and | 1013 // * Chrome is not launched in application mode, and |
1014 // * Chrome is launched with the "--enable-aero-peek-tabs" option. | 1014 // * Chrome is launched with the "--enable-aero-peek-tabs" option. |
1015 // TODO(hbono): Bug 37957 <http://crbug.com/37957>: find solutions that avoid | 1015 // TODO(hbono): Bug 37957 <http://crbug.com/37957>: find solutions that avoid |
1016 // flooding users with tab thumbnails. | 1016 // flooding users with tab thumbnails. |
1017 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1017 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
1018 return base::win::GetVersion() >= base::win::VERSION_WIN7 && | 1018 return base::win::GetVersion() >= base::win::VERSION_WIN7 && |
1019 app::win::ShouldUseVistaFrame() && | 1019 ui::ShouldUseVistaFrame() && |
1020 !command_line->HasSwitch(switches::kApp) && | 1020 !command_line->HasSwitch(switches::kApp) && |
1021 command_line->HasSwitch(switches::kEnableAeroPeekTabs); | 1021 command_line->HasSwitch(switches::kEnableAeroPeekTabs); |
1022 } | 1022 } |
1023 | 1023 |
1024 void AeroPeekManager::DeleteAeroPeekWindow(int tab_id) { | 1024 void AeroPeekManager::DeleteAeroPeekWindow(int tab_id) { |
1025 // This function does NOT call AeroPeekWindow::Destroy() before deleting | 1025 // This function does NOT call AeroPeekWindow::Destroy() before deleting |
1026 // the AeroPeekWindow instance. | 1026 // the AeroPeekWindow instance. |
1027 for (std::list<AeroPeekWindow*>::iterator i = tab_list_.begin(); | 1027 for (std::list<AeroPeekWindow*>::iterator i = tab_list_.begin(); |
1028 i != tab_list_.end(); ++i) { | 1028 i != tab_list_.end(); ++i) { |
1029 AeroPeekWindow* window = *i; | 1029 AeroPeekWindow* window = *i; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 // This code is just copied from "thumbnail_generator.cc". | 1234 // This code is just copied from "thumbnail_generator.cc". |
1235 skia::PlatformCanvas canvas; | 1235 skia::PlatformCanvas canvas; |
1236 if (!backing_store->CopyFromBackingStore(gfx::Rect(backing_store->size()), | 1236 if (!backing_store->CopyFromBackingStore(gfx::Rect(backing_store->size()), |
1237 &canvas)) | 1237 &canvas)) |
1238 return false; | 1238 return false; |
1239 | 1239 |
1240 const SkBitmap& bitmap = canvas.getTopPlatformDevice().accessBitmap(false); | 1240 const SkBitmap& bitmap = canvas.getTopPlatformDevice().accessBitmap(false); |
1241 bitmap.copyTo(preview, SkBitmap::kARGB_8888_Config); | 1241 bitmap.copyTo(preview, SkBitmap::kARGB_8888_Config); |
1242 return true; | 1242 return true; |
1243 } | 1243 } |
OLD | NEW |