| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 115 |
| 116 // static | 116 // static |
| 117 void ChromeLauncherDelegate::RegisterUserPrefs(PrefService* user_prefs) { | 117 void ChromeLauncherDelegate::RegisterUserPrefs(PrefService* user_prefs) { |
| 118 // TODO: If we want to support multiple profiles this will likely need to be | 118 // TODO: If we want to support multiple profiles this will likely need to be |
| 119 // pushed to local state and we'll need to track profile per item. | 119 // pushed to local state and we'll need to track profile per item. |
| 120 user_prefs->RegisterListPref(prefs::kPinnedLauncherApps, | 120 user_prefs->RegisterListPref(prefs::kPinnedLauncherApps, |
| 121 PrefService::SYNCABLE_PREF); | 121 PrefService::SYNCABLE_PREF); |
| 122 } | 122 } |
| 123 | 123 |
| 124 ash::LauncherID ChromeLauncherDelegate::CreateTabbedLauncherItem( | 124 ash::LauncherID ChromeLauncherDelegate::CreateTabbedLauncherItem( |
| 125 LauncherUpdater* updater) { | 125 LauncherUpdater* updater, |
| 126 IncognitoState is_incognito) { |
| 126 // Tabbed items always get a new item. Put the tabbed item before the app | 127 // Tabbed items always get a new item. Put the tabbed item before the app |
| 127 // tabs. If there are no app tabs put it at the end. | 128 // tabs. If there are no app tabs put it at the end. |
| 128 int index = static_cast<int>(model_->items().size()); | 129 int index = static_cast<int>(model_->items().size()); |
| 129 for (IDToItemMap::const_iterator i = id_to_item_map_.begin(); | 130 for (IDToItemMap::const_iterator i = id_to_item_map_.begin(); |
| 130 i != id_to_item_map_.end(); ++i) { | 131 i != id_to_item_map_.end(); ++i) { |
| 131 if (i->second.updater == updater) { | 132 if (i->second.updater == updater) { |
| 132 DCHECK_EQ(TYPE_APP, i->second.item_type); | 133 DCHECK_EQ(TYPE_APP, i->second.item_type); |
| 133 index = std::min(index, model_->ItemIndexByID(i->first)); | 134 index = std::min(index, model_->ItemIndexByID(i->first)); |
| 134 } | 135 } |
| 135 } | 136 } |
| 136 ash::LauncherID id = model_->next_id(); | 137 ash::LauncherID id = model_->next_id(); |
| 137 ash::LauncherItem item(ash::TYPE_TABBED); | 138 ash::LauncherItem item; |
| 139 item.type = ash::TYPE_TABBED; |
| 140 item.is_incognito = (is_incognito == STATE_INCOGNITO); |
| 138 item.status = ash::STATUS_RUNNING; | 141 item.status = ash::STATUS_RUNNING; |
| 139 model_->Add(index, item); | 142 model_->Add(index, item); |
| 140 DCHECK(id_to_item_map_.find(id) == id_to_item_map_.end()); | 143 DCHECK(id_to_item_map_.find(id) == id_to_item_map_.end()); |
| 141 id_to_item_map_[id].item_type = TYPE_TABBED_BROWSER; | 144 id_to_item_map_[id].item_type = TYPE_TABBED_BROWSER; |
| 142 id_to_item_map_[id].updater = updater; | 145 id_to_item_map_[id].updater = updater; |
| 143 return id; | 146 return id; |
| 144 } | 147 } |
| 145 | 148 |
| 146 ash::LauncherID ChromeLauncherDelegate::CreateAppLauncherItem( | 149 ash::LauncherID ChromeLauncherDelegate::CreateAppLauncherItem( |
| 147 LauncherUpdater* updater, | 150 LauncherUpdater* updater, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 176 } else { | 179 } else { |
| 177 min_tab_index = | 180 min_tab_index = |
| 178 std::min(min_app_index, model_->ItemIndexByID(i->first)); | 181 std::min(min_app_index, model_->ItemIndexByID(i->first)); |
| 179 } | 182 } |
| 180 } | 183 } |
| 181 } | 184 } |
| 182 } | 185 } |
| 183 int insert_index = min_app_index != item_count ? | 186 int insert_index = min_app_index != item_count ? |
| 184 min_app_index : std::min(item_count, min_tab_index + 1); | 187 min_app_index : std::min(item_count, min_tab_index + 1); |
| 185 ash::LauncherID id = model_->next_id(); | 188 ash::LauncherID id = model_->next_id(); |
| 186 ash::LauncherItem item(ash::TYPE_APP); | 189 ash::LauncherItem item; |
| 190 item.type = ash::TYPE_APP; |
| 191 item.is_incognito = false; |
| 187 item.image = Extension::GetDefaultIcon(true); | 192 item.image = Extension::GetDefaultIcon(true); |
| 188 item.status = status; | 193 item.status = status; |
| 189 model_->Add(insert_index, item); | 194 model_->Add(insert_index, item); |
| 190 DCHECK(id_to_item_map_.find(id) == id_to_item_map_.end()); | 195 DCHECK(id_to_item_map_.find(id) == id_to_item_map_.end()); |
| 191 id_to_item_map_[id].item_type = TYPE_APP; | 196 id_to_item_map_[id].item_type = TYPE_APP; |
| 192 id_to_item_map_[id].app_type = app_type; | 197 id_to_item_map_[id].app_type = app_type; |
| 193 id_to_item_map_[id].app_id = app_id; | 198 id_to_item_map_[id].app_id = app_id; |
| 194 id_to_item_map_[id].updater = updater; | 199 id_to_item_map_[id].updater = updater; |
| 195 id_to_item_map_[id].pinned = updater == NULL; | 200 id_to_item_map_[id].pinned = updater == NULL; |
| 196 | 201 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 218 void ChromeLauncherDelegate::ConvertTabbedToApp(ash::LauncherID id, | 223 void ChromeLauncherDelegate::ConvertTabbedToApp(ash::LauncherID id, |
| 219 const std::string& app_id, | 224 const std::string& app_id, |
| 220 AppType app_type) { | 225 AppType app_type) { |
| 221 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end()); | 226 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end()); |
| 222 DCHECK_EQ(TYPE_TABBED_BROWSER, id_to_item_map_[id].item_type); | 227 DCHECK_EQ(TYPE_TABBED_BROWSER, id_to_item_map_[id].item_type); |
| 223 DCHECK(!id_to_item_map_[id].pinned); | 228 DCHECK(!id_to_item_map_[id].pinned); |
| 224 id_to_item_map_[id].item_type = TYPE_APP; | 229 id_to_item_map_[id].item_type = TYPE_APP; |
| 225 id_to_item_map_[id].app_type = app_type; | 230 id_to_item_map_[id].app_type = app_type; |
| 226 id_to_item_map_[id].app_id = app_id; | 231 id_to_item_map_[id].app_id = app_id; |
| 227 | 232 |
| 228 ash::LauncherItem item(ash::TYPE_APP); | 233 ash::LauncherItem item; |
| 234 item.type = ash::TYPE_APP; |
| 235 item.is_incognito = false; |
| 229 item.id = id; | 236 item.id = id; |
| 230 model_->Set(model_->ItemIndexByID(id), item); | 237 model_->Set(model_->ItemIndexByID(id), item); |
| 231 | 238 |
| 232 app_icon_loader_->FetchImage(app_id); | 239 app_icon_loader_->FetchImage(app_id); |
| 233 } | 240 } |
| 234 | 241 |
| 235 void ChromeLauncherDelegate::LauncherItemClosed(ash::LauncherID id) { | 242 void ChromeLauncherDelegate::LauncherItemClosed(ash::LauncherID id) { |
| 236 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end()); | 243 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end()); |
| 237 if (id_to_item_map_[id].pinned) { | 244 if (id_to_item_map_[id].pinned) { |
| 238 // The item is pinned, leave it in the launcher. | 245 // The item is pinned, leave it in the launcher. |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 Profile* ChromeLauncherDelegate::GetProfileForNewWindows() { | 510 Profile* ChromeLauncherDelegate::GetProfileForNewWindows() { |
| 504 Profile* profile = ProfileManager::GetDefaultProfile(); | 511 Profile* profile = ProfileManager::GetDefaultProfile(); |
| 505 if (browser_defaults::kAlwaysOpenIncognitoWindow && | 512 if (browser_defaults::kAlwaysOpenIncognitoWindow && |
| 506 IncognitoModePrefs::ShouldLaunchIncognito( | 513 IncognitoModePrefs::ShouldLaunchIncognito( |
| 507 *CommandLine::ForCurrentProcess(), | 514 *CommandLine::ForCurrentProcess(), |
| 508 profile->GetPrefs())) { | 515 profile->GetPrefs())) { |
| 509 profile = profile->GetOffTheRecordProfile(); | 516 profile = profile->GetOffTheRecordProfile(); |
| 510 } | 517 } |
| 511 return profile; | 518 return profile; |
| 512 } | 519 } |
| OLD | NEW |