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

Side by Side Diff: chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc

Issue 9649013: Show a different icon in the launcher for incognito windows (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 9 months 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
OLDNEW
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
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, bool is_private) {
sky 2012/03/09 18:18:08 Wrap is_private
Zachary Kuznia 2012/03/09 22:17:35 Done.
126 // Tabbed items always get a new item. Put the tabbed item before the app 126 // 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. 127 // tabs. If there are no app tabs put it at the end.
128 int index = static_cast<int>(model_->items().size()); 128 int index = static_cast<int>(model_->items().size());
129 for (IDToItemMap::const_iterator i = id_to_item_map_.begin(); 129 for (IDToItemMap::const_iterator i = id_to_item_map_.begin();
130 i != id_to_item_map_.end(); ++i) { 130 i != id_to_item_map_.end(); ++i) {
131 if (i->second.updater == updater) { 131 if (i->second.updater == updater) {
132 DCHECK_EQ(TYPE_APP, i->second.item_type); 132 DCHECK_EQ(TYPE_APP, i->second.item_type);
133 index = std::min(index, model_->ItemIndexByID(i->first)); 133 index = std::min(index, model_->ItemIndexByID(i->first));
134 } 134 }
135 } 135 }
136 ash::LauncherID id = model_->next_id(); 136 ash::LauncherID id = model_->next_id();
137 ash::LauncherItem item(ash::TYPE_TABBED); 137 ash::LauncherItem item(ash::TYPE_TABBED, is_private);
138 model_->Add(index, item); 138 model_->Add(index, item);
139 DCHECK(id_to_item_map_.find(id) == id_to_item_map_.end()); 139 DCHECK(id_to_item_map_.find(id) == id_to_item_map_.end());
140 id_to_item_map_[id].item_type = TYPE_TABBED_BROWSER; 140 id_to_item_map_[id].item_type = TYPE_TABBED_BROWSER;
141 id_to_item_map_[id].updater = updater; 141 id_to_item_map_[id].updater = updater;
142 return id; 142 return id;
143 } 143 }
144 144
145 ash::LauncherID ChromeLauncherDelegate::CreateAppLauncherItem( 145 ash::LauncherID ChromeLauncherDelegate::CreateAppLauncherItem(
146 LauncherUpdater* updater, 146 LauncherUpdater* updater,
147 const std::string& app_id, 147 const std::string& app_id,
(...skipping 25 matching lines...) Expand all
173 } else { 173 } else {
174 min_tab_index = 174 min_tab_index =
175 std::min(min_app_index, model_->ItemIndexByID(i->first)); 175 std::min(min_app_index, model_->ItemIndexByID(i->first));
176 } 176 }
177 } 177 }
178 } 178 }
179 } 179 }
180 int insert_index = min_app_index != item_count ? 180 int insert_index = min_app_index != item_count ?
181 min_app_index : std::min(item_count, min_tab_index + 1); 181 min_app_index : std::min(item_count, min_tab_index + 1);
182 ash::LauncherID id = model_->next_id(); 182 ash::LauncherID id = model_->next_id();
183 ash::LauncherItem item(ash::TYPE_APP); 183 ash::LauncherItem item(ash::TYPE_APP, false);
184 item.image = Extension::GetDefaultIcon(true); 184 item.image = Extension::GetDefaultIcon(true);
185 model_->Add(insert_index, item); 185 model_->Add(insert_index, item);
186 DCHECK(id_to_item_map_.find(id) == id_to_item_map_.end()); 186 DCHECK(id_to_item_map_.find(id) == id_to_item_map_.end());
187 id_to_item_map_[id].item_type = TYPE_APP; 187 id_to_item_map_[id].item_type = TYPE_APP;
188 id_to_item_map_[id].app_type = app_type; 188 id_to_item_map_[id].app_type = app_type;
189 id_to_item_map_[id].app_id = app_id; 189 id_to_item_map_[id].app_id = app_id;
190 id_to_item_map_[id].updater = updater; 190 id_to_item_map_[id].updater = updater;
191 id_to_item_map_[id].pinned = updater == NULL; 191 id_to_item_map_[id].pinned = updater == NULL;
192 192
193 if (app_type != APP_TYPE_PANEL) 193 if (app_type != APP_TYPE_PANEL)
(...skipping 12 matching lines...) Expand all
206 void ChromeLauncherDelegate::ConvertTabbedToApp(ash::LauncherID id, 206 void ChromeLauncherDelegate::ConvertTabbedToApp(ash::LauncherID id,
207 const std::string& app_id, 207 const std::string& app_id,
208 AppType app_type) { 208 AppType app_type) {
209 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end()); 209 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end());
210 DCHECK_EQ(TYPE_TABBED_BROWSER, id_to_item_map_[id].item_type); 210 DCHECK_EQ(TYPE_TABBED_BROWSER, id_to_item_map_[id].item_type);
211 DCHECK(!id_to_item_map_[id].pinned); 211 DCHECK(!id_to_item_map_[id].pinned);
212 id_to_item_map_[id].item_type = TYPE_APP; 212 id_to_item_map_[id].item_type = TYPE_APP;
213 id_to_item_map_[id].app_type = app_type; 213 id_to_item_map_[id].app_type = app_type;
214 id_to_item_map_[id].app_id = app_id; 214 id_to_item_map_[id].app_id = app_id;
215 215
216 ash::LauncherItem item(ash::TYPE_APP); 216 ash::LauncherItem item(ash::TYPE_APP, false);
217 item.id = id; 217 item.id = id;
218 model_->Set(model_->ItemIndexByID(id), item); 218 model_->Set(model_->ItemIndexByID(id), item);
219 219
220 app_icon_loader_->FetchImage(app_id); 220 app_icon_loader_->FetchImage(app_id);
221 } 221 }
222 222
223 void ChromeLauncherDelegate::LauncherItemClosed(ash::LauncherID id) { 223 void ChromeLauncherDelegate::LauncherItemClosed(ash::LauncherID id) {
224 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end()); 224 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end());
225 if (id_to_item_map_[id].pinned) { 225 if (id_to_item_map_[id].pinned) {
226 // The item is pinned, leave it in the launcher. 226 // The item is pinned, leave it in the launcher.
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 Profile* ChromeLauncherDelegate::GetProfileForNewWindows() { 489 Profile* ChromeLauncherDelegate::GetProfileForNewWindows() {
490 Profile* profile = ProfileManager::GetDefaultProfile(); 490 Profile* profile = ProfileManager::GetDefaultProfile();
491 if (browser_defaults::kAlwaysOpenIncognitoWindow && 491 if (browser_defaults::kAlwaysOpenIncognitoWindow &&
492 IncognitoModePrefs::ShouldLaunchIncognito( 492 IncognitoModePrefs::ShouldLaunchIncognito(
493 *CommandLine::ForCurrentProcess(), 493 *CommandLine::ForCurrentProcess(),
494 profile->GetPrefs())) { 494 profile->GetPrefs())) {
495 profile = profile->GetOffTheRecordProfile(); 495 profile = profile->GetOffTheRecordProfile();
496 } 496 }
497 return profile; 497 return profile;
498 } 498 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698