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/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
36 #include "grit/theme_resources.h" | 36 #include "grit/theme_resources.h" |
37 #include "ui/aura/client/activation_client.h" | 37 #include "ui/aura/client/activation_client.h" |
38 #include "ui/aura/window.h" | 38 #include "ui/aura/window.h" |
39 #include "ui/views/widget/widget.h" | 39 #include "ui/views/widget/widget.h" |
40 | 40 |
41 namespace { | 41 namespace { |
42 | 42 |
43 // See description in PersistPinnedState(). | 43 // See description in PersistPinnedState(). |
44 const char kAppIDPath[] = "id"; | 44 const char kAppIDPath[] = "id"; |
45 const char kAppTypePanel[] = "panel"; | |
46 const char kAppTypePath[] = "type"; | |
47 const char kAppTypeTab[] = "tab"; | |
48 const char kAppTypeWindow[] = "window"; | |
49 | 45 |
50 // Values used for prefs::kShelfAutoHideBehavior. | 46 // Values used for prefs::kShelfAutoHideBehavior. |
51 const char kShelfAutoHideBehaviorAlways[] = "Always"; | 47 const char kShelfAutoHideBehaviorAlways[] = "Always"; |
52 const char kShelfAutoHideBehaviorDefault[] = "Default"; | 48 const char kShelfAutoHideBehaviorDefault[] = "Default"; |
53 const char kShelfAutoHideBehaviorNever[] = "Never"; | 49 const char kShelfAutoHideBehaviorNever[] = "Never"; |
54 | 50 |
55 // App ID of default pinned apps. | 51 // App ID of default pinned apps. |
56 const char* kDefaultPinnedApps[] = { | 52 const char* kDefaultPinnedApps[] = { |
57 "pjkljhegncpnkpknbcohdijeoejaedia", // Gamil | 53 "pjkljhegncpnkpknbcohdijeoejaedia", // Gamil |
58 "coobgpohoikkiipiblmjeljniedjpjpf", // Search | 54 "coobgpohoikkiipiblmjeljniedjpjpf", // Search |
59 "apdfllckaahabafndbhieahigkjlhalf", // Doc | 55 "apdfllckaahabafndbhieahigkjlhalf", // Doc |
60 "blpcfgokakmgnkcojhhkbfbldkacnbeo", // YouTube | 56 "blpcfgokakmgnkcojhhkbfbldkacnbeo", // YouTube |
61 }; | 57 }; |
62 | 58 |
63 base::DictionaryValue* CreateAppDict( | 59 base::DictionaryValue* CreateAppDict(const std::string& app_id) { |
64 const std::string& app_id, | |
65 ChromeLauncherDelegate::AppType app_type) { | |
66 scoped_ptr<base::DictionaryValue> app_value(new base::DictionaryValue); | 60 scoped_ptr<base::DictionaryValue> app_value(new base::DictionaryValue); |
67 app_value->SetString(kAppIDPath, app_id); | 61 app_value->SetString(kAppIDPath, app_id); |
68 const char* app_type_string; | |
69 if (app_type == ChromeLauncherDelegate::APP_TYPE_WINDOW) { | |
70 app_type_string = kAppTypeWindow; | |
71 } else if (app_type == ChromeLauncherDelegate::APP_TYPE_APP_PANEL) { | |
72 app_type_string = kAppTypePanel; | |
73 } else if (app_type == ChromeLauncherDelegate::APP_TYPE_TAB) { | |
74 app_type_string = kAppTypeTab; | |
75 } else { | |
76 LOG(ERROR) << "Unsupported pinned type: " << app_type; | |
77 return NULL; | |
78 } | |
79 app_value->SetString(kAppTypePath, app_type_string); | |
80 return app_value.release(); | 62 return app_value.release(); |
81 } | 63 } |
82 | 64 |
83 base::ListValue* CreateDefaultPinnedAppsList() { | 65 base::ListValue* CreateDefaultPinnedAppsList() { |
84 scoped_ptr<base::ListValue> apps(new base::ListValue); | 66 scoped_ptr<base::ListValue> apps(new base::ListValue); |
85 for (size_t i = 0; i < arraysize(kDefaultPinnedApps); ++i) { | 67 for (size_t i = 0; i < arraysize(kDefaultPinnedApps); ++i) |
86 apps->Append(CreateAppDict( | 68 apps->Append(CreateAppDict(kDefaultPinnedApps[i])); |
87 kDefaultPinnedApps[i], | 69 |
88 ChromeLauncherDelegate::APP_TYPE_TAB)); | |
89 } | |
90 return apps.release(); | 70 return apps.release(); |
91 } | 71 } |
92 | 72 |
93 } // namespace | 73 } // namespace |
94 | 74 |
95 // ChromeLauncherDelegate::Item ------------------------------------------------ | 75 // ChromeLauncherDelegate::Item ------------------------------------------------ |
96 | 76 |
97 ChromeLauncherDelegate::Item::Item() | 77 ChromeLauncherDelegate::Item::Item() |
98 : item_type(TYPE_TABBED_BROWSER), | 78 : item_type(TYPE_TABBED_BROWSER), |
99 app_type(APP_TYPE_WINDOW), | |
100 updater(NULL) { | 79 updater(NULL) { |
101 } | 80 } |
102 | 81 |
103 ChromeLauncherDelegate::Item::~Item() { | 82 ChromeLauncherDelegate::Item::~Item() { |
104 } | 83 } |
105 | 84 |
106 // ChromeLauncherDelegate ------------------------------------------------------ | 85 // ChromeLauncherDelegate ------------------------------------------------------ |
107 | 86 |
108 // static | 87 // static |
109 ChromeLauncherDelegate* ChromeLauncherDelegate::instance_ = NULL; | 88 ChromeLauncherDelegate* ChromeLauncherDelegate::instance_ = NULL; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 !profile_->GetPrefs()->GetBoolean(prefs::kUseDefaultPinnedApps)) { | 140 !profile_->GetPrefs()->GetBoolean(prefs::kUseDefaultPinnedApps)) { |
162 ListPrefUpdate updater(profile_->GetPrefs(), prefs::kPinnedLauncherApps); | 141 ListPrefUpdate updater(profile_->GetPrefs(), prefs::kPinnedLauncherApps); |
163 updater.Get()->Clear(); | 142 updater.Get()->Clear(); |
164 } | 143 } |
165 | 144 |
166 const base::ListValue* pinned_apps = | 145 const base::ListValue* pinned_apps = |
167 profile_->GetPrefs()->GetList(prefs::kPinnedLauncherApps); | 146 profile_->GetPrefs()->GetList(prefs::kPinnedLauncherApps); |
168 for (size_t i = 0; i < pinned_apps->GetSize(); ++i) { | 147 for (size_t i = 0; i < pinned_apps->GetSize(); ++i) { |
169 DictionaryValue* app = NULL; | 148 DictionaryValue* app = NULL; |
170 if (pinned_apps->GetDictionary(i, &app)) { | 149 if (pinned_apps->GetDictionary(i, &app)) { |
171 std::string app_id, type_string; | 150 std::string app_id; |
172 if (app->GetString(kAppIDPath, &app_id) && | 151 if (app->GetString(kAppIDPath, &app_id)) { |
173 app->GetString(kAppTypePath, &type_string)) { | |
174 AppType app_type; | |
175 if (type_string == kAppTypeWindow) | |
176 app_type = APP_TYPE_WINDOW; | |
177 else if (type_string == kAppTypePanel) | |
178 app_type = APP_TYPE_APP_PANEL; | |
179 else | |
180 app_type = APP_TYPE_TAB; | |
181 | |
182 if (app_icon_loader_->IsValidID(app_id)) { | 152 if (app_icon_loader_->IsValidID(app_id)) { |
183 CreateAppLauncherItem(NULL, app_id, app_type, ash::STATUS_CLOSED); | 153 CreateAppLauncherItem(NULL, app_id, ash::STATUS_CLOSED); |
184 } else { | 154 } else { |
185 Item pending_item; | 155 Item pending_item; |
186 pending_item.item_type = TYPE_APP; | 156 pending_item.item_type = TYPE_APP; |
187 pending_item.app_type = app_type; | |
188 pending_item.app_id = app_id; | 157 pending_item.app_id = app_id; |
189 pending_pinned_apps_.push(pending_item); | 158 pending_pinned_apps_.push(pending_item); |
190 } | 159 } |
191 } | 160 } |
192 } | 161 } |
193 } | 162 } |
194 // TODO(sky): update unit test so that this test isn't necessary. | 163 // TODO(sky): update unit test so that this test isn't necessary. |
195 if (ash::Shell::HasInstance()) { | 164 if (ash::Shell::HasInstance()) { |
196 std::string behavior_value( | 165 std::string behavior_value( |
197 profile_->GetPrefs()->GetString(prefs::kShelfAutoHideBehavior)); | 166 profile_->GetPrefs()->GetString(prefs::kShelfAutoHideBehavior)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 model_->Add(item); | 201 model_->Add(item); |
233 DCHECK(id_to_item_map_.find(id) == id_to_item_map_.end()); | 202 DCHECK(id_to_item_map_.find(id) == id_to_item_map_.end()); |
234 id_to_item_map_[id].item_type = TYPE_TABBED_BROWSER; | 203 id_to_item_map_[id].item_type = TYPE_TABBED_BROWSER; |
235 id_to_item_map_[id].updater = updater; | 204 id_to_item_map_[id].updater = updater; |
236 return id; | 205 return id; |
237 } | 206 } |
238 | 207 |
239 ash::LauncherID ChromeLauncherDelegate::CreateAppLauncherItem( | 208 ash::LauncherID ChromeLauncherDelegate::CreateAppLauncherItem( |
240 LauncherUpdater* updater, | 209 LauncherUpdater* updater, |
241 const std::string& app_id, | 210 const std::string& app_id, |
242 AppType app_type, | |
243 ash::LauncherItemStatus status) { | 211 ash::LauncherItemStatus status) { |
244 ash::LauncherID id = model_->next_id(); | 212 ash::LauncherID id = model_->next_id(); |
245 ash::LauncherItem item; | 213 ash::LauncherItem item; |
246 if (!updater) { | 214 if (!updater) { |
247 item.type = ash::TYPE_APP_SHORTCUT; | 215 item.type = ash::TYPE_APP_SHORTCUT; |
248 } else if (app_type == APP_TYPE_APP_PANEL || | 216 } else if (updater->type() == LauncherUpdater::TYPE_APP_PANEL || |
249 app_type == APP_TYPE_EXTENSION_PANEL) { | 217 updater->type() == LauncherUpdater::TYPE_EXTENSION_PANEL) { |
250 item.type = ash::TYPE_APP_PANEL; | 218 item.type = ash::TYPE_APP_PANEL; |
251 } else { | 219 } else { |
252 item.type = ash::TYPE_TABBED; | 220 item.type = ash::TYPE_TABBED; |
253 } | 221 } |
254 item.is_incognito = false; | 222 item.is_incognito = false; |
255 item.image = Extension::GetDefaultIcon(true); | 223 item.image = Extension::GetDefaultIcon(true); |
256 item.status = status; | 224 item.status = status; |
257 model_->Add(item); | 225 model_->Add(item); |
258 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()); |
259 id_to_item_map_[id].item_type = TYPE_APP; | 227 id_to_item_map_[id].item_type = TYPE_APP; |
260 id_to_item_map_[id].app_type = app_type; | |
261 id_to_item_map_[id].app_id = app_id; | 228 id_to_item_map_[id].app_id = app_id; |
262 id_to_item_map_[id].updater = updater; | 229 id_to_item_map_[id].updater = updater; |
263 | 230 |
264 if (app_type != APP_TYPE_EXTENSION_PANEL) | 231 if (!updater || updater->type() != LauncherUpdater::TYPE_EXTENSION_PANEL) |
265 app_icon_loader_->FetchImage(app_id); | 232 app_icon_loader_->FetchImage(app_id); |
266 return id; | 233 return id; |
267 } | 234 } |
268 | 235 |
269 void ChromeLauncherDelegate::SetItemStatus(ash::LauncherID id, | 236 void ChromeLauncherDelegate::SetItemStatus(ash::LauncherID id, |
270 ash::LauncherItemStatus status) { | 237 ash::LauncherItemStatus status) { |
271 int index = model_->ItemIndexByID(id); | 238 int index = model_->ItemIndexByID(id); |
272 DCHECK_GE(index, 0); | 239 DCHECK_GE(index, 0); |
273 ash::LauncherItem item = model_->items()[index]; | 240 ash::LauncherItem item = model_->items()[index]; |
274 item.status = status; | 241 item.status = status; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 void ChromeLauncherDelegate::Open(ash::LauncherID id) { | 277 void ChromeLauncherDelegate::Open(ash::LauncherID id) { |
311 if (id_to_item_map_.find(id) == id_to_item_map_.end()) | 278 if (id_to_item_map_.find(id) == id_to_item_map_.end()) |
312 return; // In case invoked from menu and item closed while menu up. | 279 return; // In case invoked from menu and item closed while menu up. |
313 | 280 |
314 LauncherUpdater* updater = id_to_item_map_[id].updater; | 281 LauncherUpdater* updater = id_to_item_map_[id].updater; |
315 if (updater) { | 282 if (updater) { |
316 updater->window()->Show(); | 283 updater->window()->Show(); |
317 ash::wm::ActivateWindow(updater->window()); | 284 ash::wm::ActivateWindow(updater->window()); |
318 } else { | 285 } else { |
319 DCHECK_EQ(TYPE_APP, id_to_item_map_[id].item_type); | 286 DCHECK_EQ(TYPE_APP, id_to_item_map_[id].item_type); |
320 AppType app_type = id_to_item_map_[id].app_type; | 287 |
321 extension_misc::LaunchContainer launch_container; | |
322 if (app_type == APP_TYPE_TAB) { | |
323 launch_container = extension_misc::LAUNCH_TAB; | |
324 } else if (app_type == APP_TYPE_APP_PANEL) { | |
325 launch_container = extension_misc::LAUNCH_PANEL; | |
326 } else if (app_type == APP_TYPE_WINDOW) { | |
327 launch_container = extension_misc::LAUNCH_WINDOW; | |
328 } else { | |
329 LOG(ERROR) << "Unsupported launcher item type: " << app_type; | |
330 return; | |
331 } | |
332 const Extension* extension = | 288 const Extension* extension = |
333 profile_->GetExtensionService()->GetInstalledExtension( | 289 profile_->GetExtensionService()->GetInstalledExtension( |
334 id_to_item_map_[id].app_id); | 290 id_to_item_map_[id].app_id); |
335 DCHECK(extension); | 291 DCHECK(extension); |
| 292 |
| 293 extension_misc::LaunchContainer launch_container = |
| 294 profile_->GetExtensionService()->extension_prefs()->GetLaunchContainer( |
| 295 extension, ExtensionPrefs::LAUNCH_DEFAULT); |
| 296 |
336 Browser::OpenApplication(GetProfileForNewWindows(), | 297 Browser::OpenApplication(GetProfileForNewWindows(), |
337 extension, | 298 extension, |
338 launch_container, | 299 launch_container, |
339 GURL(), | 300 GURL(), |
340 NEW_FOREGROUND_TAB); | 301 NEW_FOREGROUND_TAB); |
341 } | 302 } |
342 } | 303 } |
343 | 304 |
344 void ChromeLauncherDelegate::Close(ash::LauncherID id) { | 305 void ChromeLauncherDelegate::Close(ash::LauncherID id) { |
345 if (id_to_item_map_.find(id) == id_to_item_map_.end()) | 306 if (id_to_item_map_.find(id) == id_to_item_map_.end()) |
346 return; // May happen if menu closed. | 307 return; // May happen if menu closed. |
347 | 308 |
348 if (!id_to_item_map_[id].updater) | 309 if (!id_to_item_map_[id].updater) |
349 return; // TODO: maybe should treat as unpin? | 310 return; // TODO: maybe should treat as unpin? |
350 | 311 |
351 views::Widget* widget = views::Widget::GetWidgetForNativeView( | 312 views::Widget* widget = views::Widget::GetWidgetForNativeView( |
352 id_to_item_map_[id].updater->window()); | 313 id_to_item_map_[id].updater->window()); |
353 if (widget) | 314 if (widget) |
354 widget->Close(); | 315 widget->Close(); |
355 } | 316 } |
356 | 317 |
357 bool ChromeLauncherDelegate::IsOpen(ash::LauncherID id) { | 318 bool ChromeLauncherDelegate::IsOpen(ash::LauncherID id) { |
358 return id_to_item_map_.find(id) != id_to_item_map_.end() && | 319 return id_to_item_map_.find(id) != id_to_item_map_.end() && |
359 id_to_item_map_[id].updater != NULL; | 320 id_to_item_map_[id].updater != NULL; |
360 } | 321 } |
361 | 322 |
362 ChromeLauncherDelegate::AppType ChromeLauncherDelegate::GetAppType( | 323 ExtensionPrefs::LaunchType ChromeLauncherDelegate::GetLaunchType( |
363 ash::LauncherID id) { | 324 ash::LauncherID id) { |
364 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end()); | 325 DCHECK(id_to_item_map_.find(id) != id_to_item_map_.end()); |
365 return id_to_item_map_[id].app_type; | 326 |
| 327 return profile_->GetExtensionService()->extension_prefs()->GetLaunchType( |
| 328 id_to_item_map_[id].app_id, ExtensionPrefs::LAUNCH_DEFAULT); |
366 } | 329 } |
367 | 330 |
368 std::string ChromeLauncherDelegate::GetAppID(TabContentsWrapper* tab) { | 331 std::string ChromeLauncherDelegate::GetAppID(TabContentsWrapper* tab) { |
369 return app_icon_loader_->GetAppID(tab); | 332 return app_icon_loader_->GetAppID(tab); |
370 } | 333 } |
371 | 334 |
372 void ChromeLauncherDelegate::SetAppImage(const std::string& id, | 335 void ChromeLauncherDelegate::SetAppImage(const std::string& id, |
373 const SkBitmap* image) { | 336 const SkBitmap* image) { |
374 // TODO: need to get this working for shortcuts. | 337 // TODO: need to get this working for shortcuts. |
375 | 338 |
376 for (IDToItemMap::const_iterator i = id_to_item_map_.begin(); | 339 for (IDToItemMap::const_iterator i = id_to_item_map_.begin(); |
377 i != id_to_item_map_.end(); ++i) { | 340 i != id_to_item_map_.end(); ++i) { |
378 if (i->second.app_id != id) | 341 if (i->second.app_id != id) |
379 continue; | 342 continue; |
| 343 |
380 // Panel items may share the same app_id as the app that created them, | 344 // Panel items may share the same app_id as the app that created them, |
381 // but they set their icon image in LauncherUpdater::UpdateLauncher(), | 345 // but they set their icon image in LauncherUpdater::UpdateLauncher(), |
382 // so do not set panel images here. | 346 // so do not set panel images here. |
383 if (i->second.app_type == APP_TYPE_EXTENSION_PANEL) | 347 if (i->second.updater && |
| 348 i->second.updater->type() == LauncherUpdater::TYPE_EXTENSION_PANEL) { |
384 continue; | 349 continue; |
| 350 } |
| 351 |
385 int index = model_->ItemIndexByID(i->first); | 352 int index = model_->ItemIndexByID(i->first); |
386 ash::LauncherItem item = model_->items()[index]; | 353 ash::LauncherItem item = model_->items()[index]; |
387 item.image = image ? *image : Extension::GetDefaultIcon(true); | 354 item.image = image ? *image : Extension::GetDefaultIcon(true); |
388 model_->Set(index, item); | 355 model_->Set(index, item); |
389 // It's possible we're waiting on more than one item, so don't break. | 356 // It's possible we're waiting on more than one item, so don't break. |
390 } | 357 } |
391 } | 358 } |
392 | 359 |
393 bool ChromeLauncherDelegate::IsAppPinned(const std::string& app_id) { | 360 bool ChromeLauncherDelegate::IsAppPinned(const std::string& app_id) { |
394 for (IDToItemMap::const_iterator i = id_to_item_map_.begin(); | 361 for (IDToItemMap::const_iterator i = id_to_item_map_.begin(); |
395 i != id_to_item_map_.end(); ++i) { | 362 i != id_to_item_map_.end(); ++i) { |
396 if (IsPinned(i->first) && i->second.app_id == app_id) | 363 if (IsPinned(i->first) && i->second.app_id == app_id) |
397 return true; | 364 return true; |
398 } | 365 } |
399 return false; | 366 return false; |
400 } | 367 } |
401 | 368 |
402 void ChromeLauncherDelegate::PinAppWithID(const std::string& app_id, | 369 void ChromeLauncherDelegate::PinAppWithID(const std::string& app_id) { |
403 AppType app_type) { | 370 // If there is an item, do nothing and return. |
404 // If there is an item, update the app_type and return. | 371 if (IsAppPinned(app_id)) |
405 for (IDToItemMap::iterator i = id_to_item_map_.begin(); | 372 return; |
406 i != id_to_item_map_.end(); ++i) { | |
407 if (i->second.app_id == app_id && IsPinned(i->first)) { | |
408 DCHECK_EQ(ash::TYPE_APP_SHORTCUT, | |
409 model_->ItemByID(i->first)->type); | |
410 i->second.app_type = app_type; | |
411 return; | |
412 } | |
413 } | |
414 | 373 |
415 // Otherwise, create an item for it. | 374 // Otherwise, create an item for it. |
416 CreateAppLauncherItem(NULL, app_id, app_type, ash::STATUS_CLOSED); | 375 CreateAppLauncherItem(NULL, app_id, ash::STATUS_CLOSED); |
417 PersistPinnedState(); | 376 PersistPinnedState(); |
418 } | 377 } |
419 | 378 |
420 void ChromeLauncherDelegate::SetAppType(ash::LauncherID id, AppType app_type) { | 379 void ChromeLauncherDelegate::SetLaunchType( |
| 380 ash::LauncherID id, |
| 381 ExtensionPrefs::LaunchType launch_type) { |
421 if (id_to_item_map_.find(id) == id_to_item_map_.end()) | 382 if (id_to_item_map_.find(id) == id_to_item_map_.end()) |
422 return; | 383 return; |
423 | 384 |
424 id_to_item_map_[id].app_type = app_type; | 385 return profile_->GetExtensionService()->extension_prefs()->SetLaunchType( |
| 386 id_to_item_map_[id].app_id, launch_type); |
425 } | 387 } |
426 | 388 |
427 void ChromeLauncherDelegate::UnpinAppsWithID(const std::string& app_id) { | 389 void ChromeLauncherDelegate::UnpinAppsWithID(const std::string& app_id) { |
428 for (IDToItemMap::iterator i = id_to_item_map_.begin(); | 390 for (IDToItemMap::iterator i = id_to_item_map_.begin(); |
429 i != id_to_item_map_.end(); ) { | 391 i != id_to_item_map_.end(); ) { |
430 IDToItemMap::iterator current(i); | 392 IDToItemMap::iterator current(i); |
431 ++i; | 393 ++i; |
432 if (current->second.app_id == app_id && IsPinned(current->first)) | 394 if (current->second.app_id == app_id && IsPinned(current->first)) |
433 Unpin(current->first); | 395 Unpin(current->first); |
434 } | 396 } |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 profile_->GetPrefs()->SetBoolean(prefs::kUseDefaultPinnedApps, false); | 547 profile_->GetPrefs()->SetBoolean(prefs::kUseDefaultPinnedApps, false); |
586 | 548 |
587 ListPrefUpdate updater(profile_->GetPrefs(), prefs::kPinnedLauncherApps); | 549 ListPrefUpdate updater(profile_->GetPrefs(), prefs::kPinnedLauncherApps); |
588 updater->Clear(); | 550 updater->Clear(); |
589 for (size_t i = 0; i < model_->items().size(); ++i) { | 551 for (size_t i = 0; i < model_->items().size(); ++i) { |
590 if (model_->items()[i].type == ash::TYPE_APP_SHORTCUT) { | 552 if (model_->items()[i].type == ash::TYPE_APP_SHORTCUT) { |
591 ash::LauncherID id = model_->items()[i].id; | 553 ash::LauncherID id = model_->items()[i].id; |
592 if (id_to_item_map_.find(id) != id_to_item_map_.end() && | 554 if (id_to_item_map_.find(id) != id_to_item_map_.end() && |
593 IsPinned(id)) { | 555 IsPinned(id)) { |
594 base::DictionaryValue* app_value = CreateAppDict( | 556 base::DictionaryValue* app_value = CreateAppDict( |
595 id_to_item_map_[id].app_id, | 557 id_to_item_map_[id].app_id); |
596 id_to_item_map_[id].app_type); | |
597 if (app_value) | 558 if (app_value) |
598 updater->Append(app_value); | 559 updater->Append(app_value); |
599 } | 560 } |
600 } | 561 } |
601 } | 562 } |
602 } | 563 } |
603 | 564 |
604 void ChromeLauncherDelegate::SetAppIconLoaderForTest(AppIconLoader* loader) { | 565 void ChromeLauncherDelegate::SetAppIconLoaderForTest(AppIconLoader* loader) { |
605 app_icon_loader_.reset(loader); | 566 app_icon_loader_.reset(loader); |
606 } | 567 } |
607 | 568 |
608 Profile* ChromeLauncherDelegate::GetProfileForNewWindows() { | 569 Profile* ChromeLauncherDelegate::GetProfileForNewWindows() { |
609 return ProfileManager::GetDefaultProfileOrOffTheRecord(); | 570 return ProfileManager::GetDefaultProfileOrOffTheRecord(); |
610 } | 571 } |
611 | 572 |
612 void ChromeLauncherDelegate::ProcessPendingPinnedApps() { | 573 void ChromeLauncherDelegate::ProcessPendingPinnedApps() { |
613 while (!pending_pinned_apps_.empty()) { | 574 while (!pending_pinned_apps_.empty()) { |
614 const Item& item = pending_pinned_apps_.front(); | 575 const Item& item = pending_pinned_apps_.front(); |
615 | 576 |
616 if (!app_icon_loader_->IsValidID(item.app_id)) | 577 if (!app_icon_loader_->IsValidID(item.app_id)) |
617 return; | 578 return; |
618 | 579 |
619 PinAppWithID(item.app_id, item.app_type); | 580 PinAppWithID(item.app_id); |
620 pending_pinned_apps_.pop(); | 581 pending_pinned_apps_.pop(); |
621 } | 582 } |
622 } | 583 } |
OLD | NEW |