Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: chrome/browser/aeropeek_manager.cc

Issue 4694008: Make pink's TabContentsWrapper change compile on Windows.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_util.h" 10 #include "app/win_util.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/scoped_comptr_win.h" 12 #include "base/scoped_comptr_win.h"
13 #include "base/scoped_handle_win.h" 13 #include "base/scoped_handle_win.h"
14 #include "base/scoped_native_library.h" 14 #include "base/scoped_native_library.h"
15 #include "base/waitable_event.h" 15 #include "base/waitable_event.h"
16 #include "base/win/windows_version.h" 16 #include "base/win/windows_version.h"
17 #include "chrome/browser/app_icon_win.h" 17 #include "chrome/browser/app_icon_win.h"
18 #include "chrome/browser/browser_list.h" 18 #include "chrome/browser/browser_list.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/browser_thread.h" 20 #include "chrome/browser/browser_thread.h"
21 #include "chrome/browser/renderer_host/backing_store.h" 21 #include "chrome/browser/renderer_host/backing_store.h"
22 #include "chrome/browser/renderer_host/render_view_host.h" 22 #include "chrome/browser/renderer_host/render_view_host.h"
23 #include "chrome/browser/tab_contents/tab_contents.h" 23 #include "chrome/browser/tab_contents/tab_contents.h"
24 #include "chrome/browser/tab_contents/tab_contents_delegate.h" 24 #include "chrome/browser/tab_contents/tab_contents_delegate.h"
25 #include "chrome/browser/tab_contents/tab_contents_view.h" 25 #include "chrome/browser/tab_contents/tab_contents_view.h"
26 #include "chrome/browser/tab_contents/thumbnail_generator.h" 26 #include "chrome/browser/tab_contents/thumbnail_generator.h"
27 #include "chrome/browser/tab_contents_wrapper.h"
27 #include "chrome/browser/tabs/tab_strip_model.h" 28 #include "chrome/browser/tabs/tab_strip_model.h"
28 #include "chrome/common/chrome_constants.h" 29 #include "chrome/common/chrome_constants.h"
29 #include "chrome/common/chrome_switches.h" 30 #include "chrome/common/chrome_switches.h"
30 #include "chrome/installer/util/browser_distribution.h" 31 #include "chrome/installer/util/browser_distribution.h"
31 #include "gfx/gdi_util.h" 32 #include "gfx/gdi_util.h"
32 #include "gfx/icon_util.h" 33 #include "gfx/icon_util.h"
33 #include "gfx/window_impl.h" 34 #include "gfx/window_impl.h"
34 #include "skia/ext/image_operations.h" 35 #include "skia/ext/image_operations.h"
35 #include "skia/ext/platform_canvas.h" 36 #include "skia/ext/platform_canvas.h"
36 #include "third_party/skia/include/core/SkBitmap.h" 37 #include "third_party/skia/include/core/SkBitmap.h"
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 1052
1052 int AeroPeekManager::GetTabID(TabContents* contents) const { 1053 int AeroPeekManager::GetTabID(TabContents* contents) const {
1053 if (!contents) 1054 if (!contents)
1054 return -1; 1055 return -1;
1055 return contents->controller().session_id().id(); 1056 return contents->controller().session_id().id();
1056 } 1057 }
1057 1058
1058 /////////////////////////////////////////////////////////////////////////////// 1059 ///////////////////////////////////////////////////////////////////////////////
1059 // AeroPeekManager, TabStripModelObserver implementation: 1060 // AeroPeekManager, TabStripModelObserver implementation:
1060 1061
1061 void AeroPeekManager::TabInsertedAt(TabContents* contents, 1062 void AeroPeekManager::TabInsertedAt(TabContentsWrapper* contents,
1062 int index, 1063 int index,
1063 bool foreground) { 1064 bool foreground) {
1064 // If there are not any AeroPeekWindow objects associated with the given 1065 // If there are not any AeroPeekWindow objects associated with the given
1065 // tab, Create a new AeroPeekWindow object and add it to the list. 1066 // tab, Create a new AeroPeekWindow object and add it to the list.
1066 if (GetAeroPeekWindow(GetTabID(contents))) 1067 if (GetAeroPeekWindow(GetTabID(contents->tab_contents())))
1067 return; 1068 return;
1068 1069
1069 AeroPeekWindow* window = new AeroPeekWindow(application_window_, 1070 AeroPeekWindow* window =
1070 this, 1071 new AeroPeekWindow(application_window_,
1071 GetTabID(contents), 1072 this,
1072 foreground, 1073 GetTabID(contents->tab_contents()),
1073 contents->GetTitle(), 1074 foreground,
1074 contents->GetFavIcon()); 1075 contents->tab_contents()->GetTitle(),
1076 contents->tab_contents()->GetFavIcon());
1075 if (!window) 1077 if (!window)
1076 return; 1078 return;
1077 1079
1078 tab_list_.push_back(window); 1080 tab_list_.push_back(window);
1079 } 1081 }
1080 1082
1081 void AeroPeekManager::TabClosingAt(TabStripModel* tab_strip_model, 1083 void AeroPeekManager::TabClosingAt(TabStripModel* tab_strip_model,
1082 TabContents* contents, 1084 TabContentsWrapper* contents,
1083 int index) { 1085 int index) {
1084 // |tab_strip_model| is NULL when this is being called from TabDetachedAt 1086 // |tab_strip_model| is NULL when this is being called from TabDetachedAt
1085 // below. 1087 // below.
1086 // Delete the AeroPeekWindow object associated with this tab and all its 1088 // Delete the AeroPeekWindow object associated with this tab and all its
1087 // resources. (AeroPeekWindow::Destory() also removes this tab from the tab 1089 // resources. (AeroPeekWindow::Destory() also removes this tab from the tab
1088 // list of Windows.) 1090 // list of Windows.)
1089 AeroPeekWindow* window = GetAeroPeekWindow(GetTabID(contents)); 1091 AeroPeekWindow* window =
1092 GetAeroPeekWindow(GetTabID(contents->tab_contents()));
1090 if (!window) 1093 if (!window)
1091 return; 1094 return;
1092 1095
1093 window->Destroy(); 1096 window->Destroy();
1094 DeleteAeroPeekWindow(GetTabID(contents)); 1097 DeleteAeroPeekWindow(GetTabID(contents->tab_contents()));
1095 } 1098 }
1096 1099
1097 void AeroPeekManager::TabDetachedAt(TabContents* contents, int index) { 1100 void AeroPeekManager::TabDetachedAt(TabContentsWrapper* contents, int index) {
1098 // Same as TabClosingAt(), we remove this tab from the tab list and delete 1101 // Same as TabClosingAt(), we remove this tab from the tab list and delete
1099 // its AeroPeekWindow. 1102 // its AeroPeekWindow.
1100 // Chrome will call TabInsertedAt() when this tab is inserted to another 1103 // Chrome will call TabInsertedAt() when this tab is inserted to another
1101 // TabStrip. We will re-create an AeroPeekWindow object for this tab and 1104 // TabStrip. We will re-create an AeroPeekWindow object for this tab and
1102 // re-add it to the tab list there. 1105 // re-add it to the tab list there.
1103 TabClosingAt(NULL, contents, index); 1106 TabClosingAt(NULL, contents, index);
1104 } 1107 }
1105 1108
1106 void AeroPeekManager::TabSelectedAt(TabContents* old_contents, 1109 void AeroPeekManager::TabSelectedAt(TabContentsWrapper* old_contents,
1107 TabContents* new_contents, 1110 TabContentsWrapper* new_contents,
1108 int index, 1111 int index,
1109 bool user_gesture) { 1112 bool user_gesture) {
1110 // Deactivate the old window in the thumbnail list and activate the new one 1113 // Deactivate the old window in the thumbnail list and activate the new one
1111 // to synchronize the thumbnail list with TabStrip. 1114 // to synchronize the thumbnail list with TabStrip.
1112 AeroPeekWindow* old_window = GetAeroPeekWindow(GetTabID(old_contents)); 1115 AeroPeekWindow* old_window =
1116 GetAeroPeekWindow(GetTabID(old_contents->tab_contents()));
1113 if (old_window) 1117 if (old_window)
1114 old_window->Deactivate(); 1118 old_window->Deactivate();
1115 1119
1116 AeroPeekWindow* new_window = GetAeroPeekWindow(GetTabID(new_contents)); 1120 AeroPeekWindow* new_window =
1121 GetAeroPeekWindow(GetTabID(new_contents->tab_contents()));
1117 if (new_window) 1122 if (new_window)
1118 new_window->Activate(); 1123 new_window->Activate();
1119 } 1124 }
1120 1125
1121 void AeroPeekManager::TabMoved(TabContents* contents, 1126 void AeroPeekManager::TabMoved(TabContentsWrapper* contents,
1122 int from_index, 1127 int from_index,
1123 int to_index, 1128 int to_index,
1124 bool pinned_state_changed) { 1129 bool pinned_state_changed) {
1125 // TODO(hbono): we need to reorder the thumbnail list of Windows here? 1130 // TODO(hbono): we need to reorder the thumbnail list of Windows here?
1126 // (Unfortunately, it is not so trivial to reorder the thumbnail list when 1131 // (Unfortunately, it is not so trivial to reorder the thumbnail list when
1127 // we detach/attach tabs.) 1132 // we detach/attach tabs.)
1128 } 1133 }
1129 1134
1130 void AeroPeekManager::TabChangedAt(TabContents* contents, 1135 void AeroPeekManager::TabChangedAt(TabContentsWrapper* contents,
1131 int index, 1136 int index,
1132 TabChangeType change_type) { 1137 TabChangeType change_type) {
1133 // Retrieve the AeroPeekWindow object associated with this tab, update its 1138 // Retrieve the AeroPeekWindow object associated with this tab, update its
1134 // title, and post a task that update its thumbnail image if necessary. 1139 // title, and post a task that update its thumbnail image if necessary.
1135 AeroPeekWindow* window = GetAeroPeekWindow(GetTabID(contents)); 1140 AeroPeekWindow* window =
1141 GetAeroPeekWindow(GetTabID(contents->tab_contents()));
1136 if (!window) 1142 if (!window)
1137 return; 1143 return;
1138 1144
1139 // Update the title, the favicon, and the thumbnail used for AeroPeek. 1145 // Update the title, the favicon, and the thumbnail used for AeroPeek.
1140 // These function don't actually update the icon and the thumbnail until 1146 // These function don't actually update the icon and the thumbnail until
1141 // Windows needs them (e.g. when a user hovers a taskbar icon) to avoid 1147 // Windows needs them (e.g. when a user hovers a taskbar icon) to avoid
1142 // hurting the rendering performance. (These functions just save the 1148 // hurting the rendering performance. (These functions just save the
1143 // information needed for handling update requests from Windows.) 1149 // information needed for handling update requests from Windows.)
1144 window->SetTitle(contents->GetTitle()); 1150 window->SetTitle(contents->tab_contents()->GetTitle());
1145 window->SetFavIcon(contents->GetFavIcon()); 1151 window->SetFavIcon(contents->tab_contents()->GetFavIcon());
1146 window->Update(contents->is_loading()); 1152 window->Update(contents->tab_contents()->is_loading());
1147 } 1153 }
1148 1154
1149 /////////////////////////////////////////////////////////////////////////////// 1155 ///////////////////////////////////////////////////////////////////////////////
1150 // AeroPeekManager, AeroPeekWindowDelegate implementation: 1156 // AeroPeekManager, AeroPeekWindowDelegate implementation:
1151 1157
1152 void AeroPeekManager::ActivateTab(int tab_id) { 1158 void AeroPeekManager::ActivateTab(int tab_id) {
1153 // Ask TabStrip to activate this tab. 1159 // Ask TabStrip to activate this tab.
1154 // We don't have to update thumbnails now since TabStrip will call 1160 // We don't have to update thumbnails now since TabStrip will call
1155 // TabSelectedAt() when it actually activates this tab. 1161 // TabSelectedAt() when it actually activates this tab.
1156 TabContents* contents = GetTabContents(tab_id); 1162 TabContents* contents = GetTabContents(tab_id);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 // This code is just copied from "thumbnail_generator.cc". 1214 // This code is just copied from "thumbnail_generator.cc".
1209 skia::PlatformCanvas canvas; 1215 skia::PlatformCanvas canvas;
1210 if (!backing_store->CopyFromBackingStore(gfx::Rect(backing_store->size()), 1216 if (!backing_store->CopyFromBackingStore(gfx::Rect(backing_store->size()),
1211 &canvas)) 1217 &canvas))
1212 return false; 1218 return false;
1213 1219
1214 const SkBitmap& bitmap = canvas.getTopPlatformDevice().accessBitmap(false); 1220 const SkBitmap& bitmap = canvas.getTopPlatformDevice().accessBitmap(false);
1215 bitmap.copyTo(preview, SkBitmap::kARGB_8888_Config); 1221 bitmap.copyTo(preview, SkBitmap::kARGB_8888_Config);
1216 return true; 1222 return true;
1217 } 1223 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698