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" |
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 HWND window) { | 841 HWND window) { |
842 // Windows sends a WM_ACTIVATE message not only when a user clicks this | 842 // Windows sends a WM_ACTIVATE message not only when a user clicks this |
843 // window (i.e. this window gains the thumbnail focus) but also a user clicks | 843 // window (i.e. this window gains the thumbnail focus) but also a user clicks |
844 // another window (i.e. this window loses the thumbnail focus.) | 844 // another window (i.e. this window loses the thumbnail focus.) |
845 // Return when this window loses the thumbnail focus since we don't have to | 845 // Return when this window loses the thumbnail focus since we don't have to |
846 // do anything for this case. | 846 // do anything for this case. |
847 if (action == WA_INACTIVE) | 847 if (action == WA_INACTIVE) |
848 return; | 848 return; |
849 | 849 |
850 // Ask Chrome to activate the tab associated with this thumbnail window. | 850 // Ask Chrome to activate the tab associated with this thumbnail window. |
851 // Since TabStripModel calls AeroPeekManager::TabSelectedAt() when it | 851 // Since TabStripModel calls AeroPeekManager::ActiveTabChanged() when it |
852 // finishes activating the tab. We will move the tab focus of AeroPeek there. | 852 // finishes activating the tab. We will move the tab focus of AeroPeek there. |
853 if (delegate_) | 853 if (delegate_) |
854 delegate_->ActivateTab(tab_id_); | 854 delegate_->ActivateTab(tab_id_); |
855 } | 855 } |
856 | 856 |
857 LRESULT AeroPeekWindow::OnCreate(LPCREATESTRUCT create_struct) { | 857 LRESULT AeroPeekWindow::OnCreate(LPCREATESTRUCT create_struct) { |
858 // Initialize the window title now since WindowImpl::Init() always calls | 858 // Initialize the window title now since WindowImpl::Init() always calls |
859 // CreateWindowEx() with its window name NULL. | 859 // CreateWindowEx() with its window name NULL. |
860 if (!title_.empty()) { | 860 if (!title_.empty()) { |
861 SendMessage(hwnd(), WM_SETTEXT, 0, | 861 SendMessage(hwnd(), WM_SETTEXT, 0, |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 void AeroPeekManager::TabDetachedAt(TabContentsWrapper* contents, int index) { | 1104 void AeroPeekManager::TabDetachedAt(TabContentsWrapper* contents, int index) { |
1105 if (!contents) | 1105 if (!contents) |
1106 return; | 1106 return; |
1107 | 1107 |
1108 // Chrome will call TabInsertedAt() when this tab is inserted to another | 1108 // Chrome will call TabInsertedAt() when this tab is inserted to another |
1109 // TabStrip. We will re-create an AeroPeekWindow object for this tab and | 1109 // TabStrip. We will re-create an AeroPeekWindow object for this tab and |
1110 // re-add it to the tab list there. | 1110 // re-add it to the tab list there. |
1111 DeleteAeroPeekWindowForTab(contents); | 1111 DeleteAeroPeekWindowForTab(contents); |
1112 } | 1112 } |
1113 | 1113 |
1114 void AeroPeekManager::TabSelectedAt(TabContentsWrapper* old_contents, | 1114 void AeroPeekManager::ActiveTabChanged(TabContentsWrapper* old_contents, |
1115 TabContentsWrapper* new_contents, | 1115 TabContentsWrapper* new_contents, |
1116 int index, | 1116 int index, |
1117 bool user_gesture) { | 1117 bool user_gesture) { |
1118 if (old_contents == new_contents) | 1118 if (old_contents == new_contents) |
1119 return; | 1119 return; |
1120 | 1120 |
1121 // Deactivate the old window in the thumbnail list and activate the new one | 1121 // Deactivate the old window in the thumbnail list and activate the new one |
1122 // to synchronize the thumbnail list with TabStrip. | 1122 // to synchronize the thumbnail list with TabStrip. |
1123 if (old_contents) { | 1123 if (old_contents) { |
1124 AeroPeekWindow* old_window = | 1124 AeroPeekWindow* old_window = |
1125 GetAeroPeekWindow(GetTabID(old_contents->tab_contents())); | 1125 GetAeroPeekWindow(GetTabID(old_contents->tab_contents())); |
1126 if (old_window) | 1126 if (old_window) |
1127 old_window->Deactivate(); | 1127 old_window->Deactivate(); |
1128 } | 1128 } |
1129 | 1129 |
1130 if (new_contents) { | 1130 if (new_contents) { |
1131 AeroPeekWindow* new_window = | 1131 AeroPeekWindow* new_window = |
1132 GetAeroPeekWindow(GetTabID(new_contents->tab_contents())); | 1132 GetAeroPeekWindow(GetTabID(new_contents->tab_contents())); |
1133 if (new_window) | 1133 if (new_window) |
1134 new_window->Activate(); | 1134 new_window->Activate(); |
1135 } | 1135 } |
1136 } | 1136 } |
1137 | 1137 |
1138 void AeroPeekManager::TabReplacedAt(TabStripModel* tab_strip_model, | 1138 void AeroPeekManager::TabReplacedAt(TabStripModel* tab_strip_model, |
1139 TabContentsWrapper* old_contents, | 1139 TabContentsWrapper* old_contents, |
1140 TabContentsWrapper* new_contents, | 1140 TabContentsWrapper* new_contents, |
1141 int index) { | 1141 int index) { |
1142 DeleteAeroPeekWindowForTab(old_contents); | 1142 DeleteAeroPeekWindowForTab(old_contents); |
1143 | 1143 |
1144 CreateAeroPeekWindowIfNecessary(new_contents, | 1144 CreateAeroPeekWindowIfNecessary(new_contents, |
1145 (index == tab_strip_model->active_index())); | 1145 (index == tab_strip_model->active_index())); |
1146 // We don't need to update the selection as if |new_contents| is selected the | 1146 // We don't need to update the selection as if |new_contents| is selected the |
1147 // TabStripModel will send TabSelectedAt. | 1147 // TabStripModel will send ActiveTabChanged. |
1148 } | 1148 } |
1149 | 1149 |
1150 void AeroPeekManager::TabMoved(TabContentsWrapper* contents, | 1150 void AeroPeekManager::TabMoved(TabContentsWrapper* contents, |
1151 int from_index, | 1151 int from_index, |
1152 int to_index, | 1152 int to_index, |
1153 bool pinned_state_changed) { | 1153 bool pinned_state_changed) { |
1154 // TODO(hbono): we need to reorder the thumbnail list of Windows here? | 1154 // TODO(hbono): we need to reorder the thumbnail list of Windows here? |
1155 // (Unfortunately, it is not so trivial to reorder the thumbnail list when | 1155 // (Unfortunately, it is not so trivial to reorder the thumbnail list when |
1156 // we detach/attach tabs.) | 1156 // we detach/attach tabs.) |
1157 } | 1157 } |
(...skipping 20 matching lines...) Expand all Loading... |
1178 window->SetFavicon(contents->favicon_tab_helper()->GetFavicon()); | 1178 window->SetFavicon(contents->favicon_tab_helper()->GetFavicon()); |
1179 window->Update(contents->tab_contents()->is_loading()); | 1179 window->Update(contents->tab_contents()->is_loading()); |
1180 } | 1180 } |
1181 | 1181 |
1182 /////////////////////////////////////////////////////////////////////////////// | 1182 /////////////////////////////////////////////////////////////////////////////// |
1183 // AeroPeekManager, AeroPeekWindowDelegate implementation: | 1183 // AeroPeekManager, AeroPeekWindowDelegate implementation: |
1184 | 1184 |
1185 void AeroPeekManager::ActivateTab(int tab_id) { | 1185 void AeroPeekManager::ActivateTab(int tab_id) { |
1186 // Ask TabStrip to activate this tab. | 1186 // Ask TabStrip to activate this tab. |
1187 // We don't have to update thumbnails now since TabStrip will call | 1187 // We don't have to update thumbnails now since TabStrip will call |
1188 // TabSelectedAt() when it actually activates this tab. | 1188 // ActiveTabChanged() when it actually activates this tab. |
1189 TabContents* contents = GetTabContents(tab_id); | 1189 TabContents* contents = GetTabContents(tab_id); |
1190 if (contents && contents->delegate()) | 1190 if (contents && contents->delegate()) |
1191 contents->delegate()->ActivateContents(contents); | 1191 contents->delegate()->ActivateContents(contents); |
1192 } | 1192 } |
1193 | 1193 |
1194 void AeroPeekManager::CloseTab(int tab_id) { | 1194 void AeroPeekManager::CloseTab(int tab_id) { |
1195 // Ask TabStrip to close this tab. | 1195 // Ask TabStrip to close this tab. |
1196 // TabStrip will call TabClosingAt() when it actually closes this tab. We | 1196 // TabStrip will call TabClosingAt() when it actually closes this tab. We |
1197 // will delete the AeroPeekWindow object attached to this tab there. | 1197 // will delete the AeroPeekWindow object attached to this tab there. |
1198 TabContents* contents = GetTabContents(tab_id); | 1198 TabContents* contents = GetTabContents(tab_id); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 // This code is just copied from "thumbnail_generator.cc". | 1241 // This code is just copied from "thumbnail_generator.cc". |
1242 skia::PlatformCanvas canvas; | 1242 skia::PlatformCanvas canvas; |
1243 if (!backing_store->CopyFromBackingStore(gfx::Rect(backing_store->size()), | 1243 if (!backing_store->CopyFromBackingStore(gfx::Rect(backing_store->size()), |
1244 &canvas)) | 1244 &canvas)) |
1245 return false; | 1245 return false; |
1246 | 1246 |
1247 const SkBitmap& bitmap = canvas.getTopPlatformDevice().accessBitmap(false); | 1247 const SkBitmap& bitmap = canvas.getTopPlatformDevice().accessBitmap(false); |
1248 bitmap.copyTo(preview, SkBitmap::kARGB_8888_Config); | 1248 bitmap.copyTo(preview, SkBitmap::kARGB_8888_Config); |
1249 return true; | 1249 return true; |
1250 } | 1250 } |
OLD | NEW |