| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/ui/ash/launcher/chrome_launcher_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
| 10 #include "ash/launcher/launcher.h" | 10 #include "ash/launcher/launcher.h" |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 ash::LauncherID launcher_id, | 624 ash::LauncherID launcher_id, |
| 625 const gfx::ImageSkia& image) { | 625 const gfx::ImageSkia& image) { |
| 626 int index = model_->ItemIndexByID(launcher_id); | 626 int index = model_->ItemIndexByID(launcher_id); |
| 627 if (index == -1) | 627 if (index == -1) |
| 628 return; | 628 return; |
| 629 ash::LauncherItem item = model_->items()[index]; | 629 ash::LauncherItem item = model_->items()[index]; |
| 630 item.image = image; | 630 item.image = image; |
| 631 model_->Set(index, item); | 631 model_->Set(index, item); |
| 632 } | 632 } |
| 633 | 633 |
| 634 bool ChromeLauncherController::CanPin() const { |
| 635 const PrefService::Preference* pref = |
| 636 profile_->GetPrefs()->FindPreference(prefs::kPinnedLauncherApps); |
| 637 return pref && pref->IsUserModifiable(); |
| 638 } |
| 639 |
| 634 bool ChromeLauncherController::IsAppPinned(const std::string& app_id) { | 640 bool ChromeLauncherController::IsAppPinned(const std::string& app_id) { |
| 635 for (IDToItemControllerMap::const_iterator i = | 641 for (IDToItemControllerMap::const_iterator i = |
| 636 id_to_item_controller_map_.begin(); | 642 id_to_item_controller_map_.begin(); |
| 637 i != id_to_item_controller_map_.end(); ++i) { | 643 i != id_to_item_controller_map_.end(); ++i) { |
| 638 if (IsPinned(i->first) && i->second->app_id() == app_id) | 644 if (IsPinned(i->first) && i->second->app_id() == app_id) |
| 639 return true; | 645 return true; |
| 640 } | 646 } |
| 641 return false; | 647 return false; |
| 642 } | 648 } |
| 643 | 649 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 void ChromeLauncherController::CreateNewWindow() { | 688 void ChromeLauncherController::CreateNewWindow() { |
| 683 chrome::NewEmptyWindow( | 689 chrome::NewEmptyWindow( |
| 684 GetProfileForNewWindows(), chrome::HOST_DESKTOP_TYPE_ASH); | 690 GetProfileForNewWindows(), chrome::HOST_DESKTOP_TYPE_ASH); |
| 685 } | 691 } |
| 686 | 692 |
| 687 void ChromeLauncherController::CreateNewIncognitoWindow() { | 693 void ChromeLauncherController::CreateNewIncognitoWindow() { |
| 688 chrome::NewEmptyWindow(GetProfileForNewWindows()->GetOffTheRecordProfile(), | 694 chrome::NewEmptyWindow(GetProfileForNewWindows()->GetOffTheRecordProfile(), |
| 689 chrome::HOST_DESKTOP_TYPE_ASH); | 695 chrome::HOST_DESKTOP_TYPE_ASH); |
| 690 } | 696 } |
| 691 | 697 |
| 692 bool ChromeLauncherController::CanPin() const { | |
| 693 const PrefService::Preference* pref = | |
| 694 profile_->GetPrefs()->FindPreference(prefs::kPinnedLauncherApps); | |
| 695 return pref && pref->IsUserModifiable(); | |
| 696 } | |
| 697 | |
| 698 void ChromeLauncherController::PersistPinnedState() { | 698 void ChromeLauncherController::PersistPinnedState() { |
| 699 if (ignore_persist_pinned_state_change_) | 699 if (ignore_persist_pinned_state_change_) |
| 700 return; | 700 return; |
| 701 // It is a coding error to call PersistPinnedState() if the pinned apps are | 701 // It is a coding error to call PersistPinnedState() if the pinned apps are |
| 702 // not user-editable. The code should check earlier and not perform any | 702 // not user-editable. The code should check earlier and not perform any |
| 703 // modification actions that trigger persisting the state. | 703 // modification actions that trigger persisting the state. |
| 704 if (!CanPin()) { | 704 if (!CanPin()) { |
| 705 NOTREACHED() << "Can't pin but pinned state being updated"; | 705 NOTREACHED() << "Can't pin but pinned state being updated"; |
| 706 return; | 706 return; |
| 707 } | 707 } |
| (...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1583 // TODO(simon.hong81): Register LauncherItemDelegate when LauncherItemDelegate | 1583 // TODO(simon.hong81): Register LauncherItemDelegate when LauncherItemDelegate |
| 1584 // is created. | 1584 // is created. |
| 1585 ash::LauncherItemDelegateManager* manager = | 1585 ash::LauncherItemDelegateManager* manager = |
| 1586 ash::Shell::GetInstance()->launcher_item_delegate_manager(); | 1586 ash::Shell::GetInstance()->launcher_item_delegate_manager(); |
| 1587 manager->RegisterLauncherItemDelegate(ash::TYPE_APP_PANEL, this); | 1587 manager->RegisterLauncherItemDelegate(ash::TYPE_APP_PANEL, this); |
| 1588 manager->RegisterLauncherItemDelegate(ash::TYPE_APP_SHORTCUT, this); | 1588 manager->RegisterLauncherItemDelegate(ash::TYPE_APP_SHORTCUT, this); |
| 1589 manager->RegisterLauncherItemDelegate(ash::TYPE_BROWSER_SHORTCUT, this); | 1589 manager->RegisterLauncherItemDelegate(ash::TYPE_BROWSER_SHORTCUT, this); |
| 1590 manager->RegisterLauncherItemDelegate(ash::TYPE_PLATFORM_APP, this); | 1590 manager->RegisterLauncherItemDelegate(ash::TYPE_PLATFORM_APP, this); |
| 1591 manager->RegisterLauncherItemDelegate(ash::TYPE_WINDOWED_APP, this); | 1591 manager->RegisterLauncherItemDelegate(ash::TYPE_WINDOWED_APP, this); |
| 1592 } | 1592 } |
| OLD | NEW |