OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/views/ash/launcher/chrome_launcher_delegate.h" | 5 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.h" |
6 | 6 |
7 #include "ash/launcher/launcher_model.h" | 7 #include "ash/launcher/launcher_model.h" |
8 #include "ash/launcher/launcher_types.h" | 8 #include "ash/launcher/launcher_types.h" |
9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 id_to_item_map_[id].pinned = updater == NULL; | 195 id_to_item_map_[id].pinned = updater == NULL; |
196 | 196 |
197 if (app_type != APP_TYPE_PANEL) | 197 if (app_type != APP_TYPE_PANEL) |
198 app_icon_loader_->FetchImage(app_id); | 198 app_icon_loader_->FetchImage(app_id); |
199 return id; | 199 return id; |
200 } | 200 } |
201 | 201 |
202 void ChromeLauncherDelegate::SetItemStatus(ash::LauncherID id, | 202 void ChromeLauncherDelegate::SetItemStatus(ash::LauncherID id, |
203 ash::LauncherItemStatus status) { | 203 ash::LauncherItemStatus status) { |
204 int index = model_->ItemIndexByID(id); | 204 int index = model_->ItemIndexByID(id); |
205 ash::LauncherItem item = model_->items()[index]; | 205 if (index >= 0) { |
sky
2012/03/13 17:14:42
Why is this conditional needed?
| |
206 item.status = status; | 206 ash::LauncherItem item = model_->items()[index]; |
207 model_->Set(index, item); | 207 item.status = status; |
208 model_->Set(index, item); | |
209 } | |
208 } | 210 } |
209 | 211 |
210 void ChromeLauncherDelegate::ConvertAppToTabbed(ash::LauncherID id) { | 212 void ChromeLauncherDelegate::ConvertAppToTabbed(ash::LauncherID id) { |
211 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end()); | 213 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end()); |
212 DCHECK_EQ(TYPE_APP, id_to_item_map_[id].item_type); | 214 DCHECK_EQ(TYPE_APP, id_to_item_map_[id].item_type); |
213 DCHECK(!id_to_item_map_[id].pinned); | 215 DCHECK(!id_to_item_map_[id].pinned); |
214 id_to_item_map_[id].item_type = TYPE_TABBED_BROWSER; | 216 id_to_item_map_[id].item_type = TYPE_TABBED_BROWSER; |
215 id_to_item_map_[id].app_id.clear(); | 217 id_to_item_map_[id].app_id.clear(); |
216 } | 218 } |
217 | 219 |
(...skipping 12 matching lines...) Expand all Loading... | |
230 model_->Set(model_->ItemIndexByID(id), item); | 232 model_->Set(model_->ItemIndexByID(id), item); |
231 | 233 |
232 app_icon_loader_->FetchImage(app_id); | 234 app_icon_loader_->FetchImage(app_id); |
233 } | 235 } |
234 | 236 |
235 void ChromeLauncherDelegate::LauncherItemClosed(ash::LauncherID id) { | 237 void ChromeLauncherDelegate::LauncherItemClosed(ash::LauncherID id) { |
236 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end()); | 238 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end()); |
237 if (id_to_item_map_[id].pinned) { | 239 if (id_to_item_map_[id].pinned) { |
238 // The item is pinned, leave it in the launcher. | 240 // The item is pinned, leave it in the launcher. |
239 id_to_item_map_[id].updater = NULL; | 241 id_to_item_map_[id].updater = NULL; |
240 printf("ChromeLauncherDelegate::LauncherItemClosed\n"); | |
241 SetItemStatus(id, ash::STATUS_CLOSED); | 242 SetItemStatus(id, ash::STATUS_CLOSED); |
242 } else { | 243 } else { |
243 id_to_item_map_.erase(id); | 244 id_to_item_map_.erase(id); |
244 model_->RemoveItemAt(model_->ItemIndexByID(id)); | 245 model_->RemoveItemAt(model_->ItemIndexByID(id)); |
245 } | 246 } |
246 } | 247 } |
247 | 248 |
248 void ChromeLauncherDelegate::AppIDChanged(ash::LauncherID id, | 249 void ChromeLauncherDelegate::AppIDChanged(ash::LauncherID id, |
249 const std::string& app_id) { | 250 const std::string& app_id) { |
250 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end()); | 251 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end()); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
503 Profile* ChromeLauncherDelegate::GetProfileForNewWindows() { | 504 Profile* ChromeLauncherDelegate::GetProfileForNewWindows() { |
504 Profile* profile = ProfileManager::GetDefaultProfile(); | 505 Profile* profile = ProfileManager::GetDefaultProfile(); |
505 if (browser_defaults::kAlwaysOpenIncognitoWindow && | 506 if (browser_defaults::kAlwaysOpenIncognitoWindow && |
506 IncognitoModePrefs::ShouldLaunchIncognito( | 507 IncognitoModePrefs::ShouldLaunchIncognito( |
507 *CommandLine::ForCurrentProcess(), | 508 *CommandLine::ForCurrentProcess(), |
508 profile->GetPrefs())) { | 509 profile->GetPrefs())) { |
509 profile = profile->GetOffTheRecordProfile(); | 510 profile = profile->GetOffTheRecordProfile(); |
510 } | 511 } |
511 return profile; | 512 return profile; |
512 } | 513 } |
OLD | NEW |