OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chromeos/extensions/wallpaper_private_api.h" | 5 #include "chrome/browser/chromeos/extensions/wallpaper_private_api.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 // Unminimize all the stored windows for |user_id_hash|. | 141 // Unminimize all the stored windows for |user_id_hash|. |
142 void RestoreMinimizedWindows(const std::string& user_id_hash); | 142 void RestoreMinimizedWindows(const std::string& user_id_hash); |
143 | 143 |
144 // Remove the observer from |window| if |window| is no longer referenced in | 144 // Remove the observer from |window| if |window| is no longer referenced in |
145 // user_id_hash_window_list_map_. | 145 // user_id_hash_window_list_map_. |
146 void RemoveObserverIfUnreferenced(aura::Window* window); | 146 void RemoveObserverIfUnreferenced(aura::Window* window); |
147 | 147 |
148 // aura::WindowObserver overrides. | 148 // aura::WindowObserver overrides. |
149 void OnWindowDestroyed(aura::Window* window) override; | 149 void OnWindowDestroyed(aura::Window* window) override; |
150 | 150 |
151 // aura::WindowObserver overrides. | |
152 void OnWindowStackingChanged(aura::Window* window) override; | |
153 | |
151 // Map of user id hash and associated list of minimized windows. | 154 // Map of user id hash and associated list of minimized windows. |
152 UserIDHashWindowListMap user_id_hash_window_list_map_; | 155 UserIDHashWindowListMap user_id_hash_window_list_map_; |
153 | 156 |
154 DISALLOW_COPY_AND_ASSIGN(WindowStateManager); | 157 DISALLOW_COPY_AND_ASSIGN(WindowStateManager); |
155 }; | 158 }; |
156 | 159 |
157 // static | 160 // static |
158 WindowStateManager* g_window_state_manager = NULL; | 161 WindowStateManager* g_window_state_manager = NULL; |
159 | 162 |
160 // static | 163 // static |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 | 199 |
197 std::vector<aura::Window*> windows = ash::Shell::GetInstance()-> | 200 std::vector<aura::Window*> windows = ash::Shell::GetInstance()-> |
198 mru_window_tracker()->BuildWindowListIgnoreModal(); | 201 mru_window_tracker()->BuildWindowListIgnoreModal(); |
199 | 202 |
200 for (std::vector<aura::Window*>::iterator iter = windows.begin(); | 203 for (std::vector<aura::Window*>::iterator iter = windows.begin(); |
201 iter != windows.end(); ++iter) { | 204 iter != windows.end(); ++iter) { |
202 // Ignore active window and minimized windows. | 205 // Ignore active window and minimized windows. |
203 if (*iter == active_window || ash::wm::GetWindowState(*iter)->IsMinimized()) | 206 if (*iter == active_window || ash::wm::GetWindowState(*iter)->IsMinimized()) |
204 continue; | 207 continue; |
205 | 208 |
206 // TODO(bshe): Add WindowStateObserver too. http://crbug.com/323252 | |
207 if (!(*iter)->HasObserver(this)) | 209 if (!(*iter)->HasObserver(this)) |
208 (*iter)->AddObserver(this); | 210 (*iter)->AddObserver(this); |
209 | 211 |
210 results->insert(*iter); | 212 results->insert(*iter); |
211 ash::wm::GetWindowState(*iter)->Minimize(); | 213 ash::wm::GetWindowState(*iter)->Minimize(); |
212 } | 214 } |
213 } | 215 } |
214 | 216 |
215 void WindowStateManager::RestoreMinimizedWindows( | 217 void WindowStateManager::RestoreMinimizedWindows( |
216 const std::string& user_id_hash) { | 218 const std::string& user_id_hash) { |
(...skipping 30 matching lines...) Expand all Loading... | |
247 | 249 |
248 void WindowStateManager::OnWindowDestroyed(aura::Window* window) { | 250 void WindowStateManager::OnWindowDestroyed(aura::Window* window) { |
249 for (UserIDHashWindowListMap::iterator iter = | 251 for (UserIDHashWindowListMap::iterator iter = |
250 user_id_hash_window_list_map_.begin(); | 252 user_id_hash_window_list_map_.begin(); |
251 iter != user_id_hash_window_list_map_.end(); | 253 iter != user_id_hash_window_list_map_.end(); |
252 ++iter) { | 254 ++iter) { |
253 iter->second.erase(window); | 255 iter->second.erase(window); |
254 } | 256 } |
255 } | 257 } |
256 | 258 |
259 void WindowStateManager::OnWindowStackingChanged(aura::Window* window) { | |
bshe
2015/03/24 17:21:42
I am not familiar with this function and when will
| |
260 // If user interacted with the |window| while wallpaper picker is opening, | |
261 // removes the |window| from observed list. | |
262 for (UserIDHashWindowListMap::iterator iter = | |
bshe
2015/03/24 17:21:41
you can probably use auto here since it is allowed
| |
263 user_id_hash_window_list_map_.begin(); | |
264 iter != user_id_hash_window_list_map_.end(); ++iter) { | |
265 if (iter->second.find(window) != iter->second.end()) | |
bshe
2015/03/24 17:21:41
you can directly call erase here. If it's not foun
| |
266 iter->second.erase(window); | |
267 } | |
268 window->RemoveObserver(this); | |
269 } | |
270 | |
257 } // namespace | 271 } // namespace |
258 | 272 |
259 bool WallpaperPrivateGetStringsFunction::RunSync() { | 273 bool WallpaperPrivateGetStringsFunction::RunSync() { |
260 base::DictionaryValue* dict = new base::DictionaryValue(); | 274 base::DictionaryValue* dict = new base::DictionaryValue(); |
261 SetResult(dict); | 275 SetResult(dict); |
262 | 276 |
263 #define SET_STRING(id, idr) \ | 277 #define SET_STRING(id, idr) \ |
264 dict->SetString(id, l10n_util::GetStringUTF16(idr)) | 278 dict->SetString(id, l10n_util::GetStringUTF16(idr)) |
265 SET_STRING("webFontFamily", IDS_WEB_FONT_FAMILY); | 279 SET_STRING("webFontFamily", IDS_WEB_FONT_FAMILY); |
266 SET_STRING("webFontSize", IDS_WEB_FONT_SIZE); | 280 SET_STRING("webFontSize", IDS_WEB_FONT_SIZE); |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
916 this, file_list)); | 930 this, file_list)); |
917 } | 931 } |
918 | 932 |
919 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( | 933 void WallpaperPrivateGetOfflineWallpaperListFunction::OnComplete( |
920 const std::vector<std::string>& file_list) { | 934 const std::vector<std::string>& file_list) { |
921 base::ListValue* results = new base::ListValue(); | 935 base::ListValue* results = new base::ListValue(); |
922 results->AppendStrings(file_list); | 936 results->AppendStrings(file_list); |
923 SetResult(results); | 937 SetResult(results); |
924 SendResponse(true); | 938 SendResponse(true); |
925 } | 939 } |
OLD | NEW |