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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 updater->Append(app_value); | 834 updater->Append(app_value); |
835 } | 835 } |
836 } | 836 } |
837 } | 837 } |
838 pref_change_registrar_.Add( | 838 pref_change_registrar_.Add( |
839 prefs::kPinnedLauncherApps, | 839 prefs::kPinnedLauncherApps, |
840 base::Bind(&ChromeLauncherController::UpdateAppLaunchersFromPref, | 840 base::Bind(&ChromeLauncherController::UpdateAppLaunchersFromPref, |
841 base::Unretained(this))); | 841 base::Unretained(this))); |
842 } | 842 } |
843 | 843 |
844 ash::ShelfModel* ChromeLauncherController::model() { | |
845 return model_; | |
846 } | |
847 | |
848 Profile* ChromeLauncherController::profile() { | 844 Profile* ChromeLauncherController::profile() { |
849 return profile_; | 845 return profile_; |
850 } | 846 } |
851 | 847 |
852 void ChromeLauncherController::UpdateAppState(content::WebContents* contents, | 848 void ChromeLauncherController::UpdateAppState(content::WebContents* contents, |
853 AppState app_state) { | 849 AppState app_state) { |
854 std::string app_id = launcher_controller_helper_->GetAppID(contents); | 850 std::string app_id = launcher_controller_helper_->GetAppID(contents); |
855 | 851 |
856 // Check if the gMail app is loaded and it matches the given content. | 852 // Check if the gMail app is loaded and it matches the given content. |
857 // This special treatment is needed to address crbug.com/234268. | 853 // This special treatment is needed to address crbug.com/234268. |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1697 | 1693 |
1698 BrowserShortcutLauncherItemController* | 1694 BrowserShortcutLauncherItemController* |
1699 ChromeLauncherController::GetBrowserShortcutLauncherItemController() { | 1695 ChromeLauncherController::GetBrowserShortcutLauncherItemController() { |
1700 for (IDToItemControllerMap::iterator i = id_to_item_controller_map_.begin(); | 1696 for (IDToItemControllerMap::iterator i = id_to_item_controller_map_.begin(); |
1701 i != id_to_item_controller_map_.end(); ++i) { | 1697 i != id_to_item_controller_map_.end(); ++i) { |
1702 int index = model_->ItemIndexByID(i->first); | 1698 int index = model_->ItemIndexByID(i->first); |
1703 const ash::ShelfItem& item = model_->items()[index]; | 1699 const ash::ShelfItem& item = model_->items()[index]; |
1704 if (item.type == ash::TYPE_BROWSER_SHORTCUT) | 1700 if (item.type == ash::TYPE_BROWSER_SHORTCUT) |
1705 return static_cast<BrowserShortcutLauncherItemController*>(i->second); | 1701 return static_cast<BrowserShortcutLauncherItemController*>(i->second); |
1706 } | 1702 } |
1707 NOTREACHED() << "There should be always a BrowserLauncherItemController."; | 1703 NOTREACHED() |
| 1704 << "There should be always be a BrowserShortcutLauncherItemController."; |
1708 return nullptr; | 1705 return nullptr; |
1709 } | 1706 } |
1710 | 1707 |
1711 ash::ShelfID ChromeLauncherController::CreateBrowserShortcutLauncherItem() { | 1708 ash::ShelfID ChromeLauncherController::CreateBrowserShortcutLauncherItem() { |
1712 ash::ShelfItem browser_shortcut; | 1709 ash::ShelfItem browser_shortcut; |
1713 browser_shortcut.type = ash::TYPE_BROWSER_SHORTCUT; | 1710 browser_shortcut.type = ash::TYPE_BROWSER_SHORTCUT; |
1714 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 1711 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
1715 browser_shortcut.image = *rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_32); | 1712 browser_shortcut.image = *rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_32); |
1716 ash::ShelfID id = model_->next_id(); | 1713 ash::ShelfID id = model_->next_id(); |
1717 size_t index = GetChromeIconIndexForCreation(); | 1714 size_t index = GetChromeIconIndexForCreation(); |
1718 model_->AddAt(index, browser_shortcut); | 1715 model_->AddAt(index, browser_shortcut); |
1719 id_to_item_controller_map_[id] = | 1716 id_to_item_controller_map_[id] = |
1720 new BrowserShortcutLauncherItemController(this); | 1717 new BrowserShortcutLauncherItemController(this, model_); |
1721 id_to_item_controller_map_[id]->set_shelf_id(id); | 1718 id_to_item_controller_map_[id]->set_shelf_id(id); |
1722 // ShelfItemDelegateManager owns BrowserShortcutLauncherItemController. | 1719 // ShelfItemDelegateManager owns BrowserShortcutLauncherItemController. |
1723 SetShelfItemDelegate(id, id_to_item_controller_map_[id]); | 1720 SetShelfItemDelegate(id, id_to_item_controller_map_[id]); |
1724 return id; | 1721 return id; |
1725 } | 1722 } |
1726 | 1723 |
1727 void ChromeLauncherController::PersistChromeItemIndex(int index) { | 1724 void ChromeLauncherController::PersistChromeItemIndex(int index) { |
1728 profile_->GetPrefs()->SetInteger(prefs::kShelfChromeIconIndex, index); | 1725 profile_->GetPrefs()->SetInteger(prefs::kShelfChromeIconIndex, index); |
1729 } | 1726 } |
1730 | 1727 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1912 | 1909 |
1913 AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp( | 1910 AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp( |
1914 const std::string& app_id) { | 1911 const std::string& app_id) { |
1915 for (const auto& app_icon_loader : app_icon_loaders_) { | 1912 for (const auto& app_icon_loader : app_icon_loaders_) { |
1916 if (app_icon_loader->CanLoadImageForApp(app_id)) | 1913 if (app_icon_loader->CanLoadImageForApp(app_id)) |
1917 return app_icon_loader.get(); | 1914 return app_icon_loader.get(); |
1918 } | 1915 } |
1919 | 1916 |
1920 return nullptr; | 1917 return nullptr; |
1921 } | 1918 } |
OLD | NEW |