Chromium Code Reviews| Index: chrome/browser/ui/views/aura/launcher/chrome_launcher_delegate.cc |
| diff --git a/chrome/browser/ui/views/aura/launcher/chrome_launcher_delegate.cc b/chrome/browser/ui/views/aura/launcher/chrome_launcher_delegate.cc |
| index 625452eaaed882b553765f6f7a06ac179a392857..0f4ed13b1302736686959a275f894edd2ea9f2ec 100644 |
| --- a/chrome/browser/ui/views/aura/launcher/chrome_launcher_delegate.cc |
| +++ b/chrome/browser/ui/views/aura/launcher/chrome_launcher_delegate.cc |
| @@ -42,6 +42,7 @@ const char kAppIDPath[] = "id"; |
| const char kAppTypePath[] = "type"; |
| const char kAppTypeTab[] = "tab"; |
| const char kAppTypeWindow[] = "window"; |
| +const char kAppTypePanel[] = "panel"; |
|
sky
2012/03/02 23:08:53
sort.
stevenjb
2012/03/03 00:02:06
Done.
|
| } // namespace |
| @@ -99,8 +100,13 @@ void ChromeLauncherDelegate::Init() { |
| if (app->GetString(kAppIDPath, &app_id) && |
| app->GetString(kAppTypePath, &type_string) && |
| app_icon_loader_->IsValidID(app_id)) { |
| - AppType app_type = (type_string == kAppTypeWindow) ? |
| - APP_TYPE_WINDOW : APP_TYPE_TAB; |
| + AppType app_type; |
| + if (type_string == kAppTypeWindow) |
| + app_type = APP_TYPE_WINDOW; |
| + else if (type_string == kAppTypePanel) |
| + app_type = APP_TYPE_PANEL; |
| + else |
| + app_type = APP_TYPE_TAB; |
| CreateAppLauncherItem(NULL, app_id, app_type); |
| } |
| } |
| @@ -174,7 +180,9 @@ ash::LauncherID ChromeLauncherDelegate::CreateAppLauncherItem( |
| int insert_index = min_app_index != item_count ? |
| min_app_index : std::min(item_count, min_tab_index + 1); |
| ash::LauncherID id = model_->next_id(); |
| - ash::LauncherItem item(ash::TYPE_APP); |
| + ash::LauncherItem item( |
| + app_type == APP_TYPE_PANEL ? ash::TYPE_PANEL : ash::TYPE_APP); |
| + item.image = Extension::GetDefaultIcon(true); |
| model_->Add(insert_index, item); |
| DCHECK(id_to_item_map_.find(id) == id_to_item_map_.end()); |
| id_to_item_map_[id].item_type = TYPE_APP; |
| @@ -292,7 +300,8 @@ void ChromeLauncherDelegate::Open(ash::LauncherID id) { |
| } |
| } else { |
| DCHECK_EQ(TYPE_APP, id_to_item_map_[id].item_type); |
| - if (id_to_item_map_[id].app_type == APP_TYPE_TAB) { |
| + AppType app_type = id_to_item_map_[id].app_type; |
| + if (app_type == APP_TYPE_TAB) { |
| const Extension* extension = |
| profile_->GetExtensionService()->GetInstalledExtension( |
| id_to_item_map_[id].app_id); |
| @@ -304,9 +313,10 @@ void ChromeLauncherDelegate::Open(ash::LauncherID id) { |
| } else { |
| std::string app_name = web_app::GenerateApplicationNameFromExtensionId( |
| id_to_item_map_[id].app_id); |
| + Browser::Type browser_type = (app_type == APP_TYPE_PANEL) ? |
| + Browser::TYPE_PANEL : Browser::TYPE_POPUP; |
| Browser* browser = Browser::CreateForApp( |
| - Browser::TYPE_POPUP, app_name, gfx::Rect(), |
| - GetProfileForNewWindows()); |
| + browser_type, app_name, gfx::Rect(), GetProfileForNewWindows()); |
| browser->window()->Show(); |
| } |
| } |
| @@ -352,13 +362,17 @@ std::string ChromeLauncherDelegate::GetAppID(TabContentsWrapper* tab) { |
| void ChromeLauncherDelegate::SetAppImage(const std::string& id, |
| SkBitmap* image) { |
| + if (!image) |
| + return; |
| for (IDToItemMap::const_iterator i = id_to_item_map_.begin(); |
| i != id_to_item_map_.end(); ++i) { |
| if (i->second.app_id == id) { |
| int index = model_->ItemIndexByID(i->first); |
| ash::LauncherItem item = model_->items()[index]; |
| - item.image = image ? *image : Extension::GetDefaultIcon(true); |
| - model_->Set(index, item); |
| + if (item.type == ash::TYPE_APP) { |
| + item.image = *image; |
| + model_->Set(index, item); |
| + } |
| // It's possible we're waiting on more than one item, so don't break. |
| } |
| } |
| @@ -443,9 +457,13 @@ void ChromeLauncherDelegate::PersistPinnedState() { |
| id_to_item_map_[id].pinned) { |
| base::DictionaryValue* app_value = new base::DictionaryValue; |
| app_value->SetString(kAppIDPath, id_to_item_map_[id].app_id); |
| - const char* app_type_string = |
| - id_to_item_map_[id].app_type == APP_TYPE_WINDOW ? |
| - kAppTypeWindow : kAppTypeTab; |
| + const char* app_type_string; |
| + if (id_to_item_map_[id].app_type == APP_TYPE_WINDOW) |
| + app_type_string = kAppTypeWindow; |
| + else if (id_to_item_map_[id].app_type == APP_TYPE_PANEL) |
| + app_type_string = kAppTypePanel; |
| + else |
| + app_type_string = kAppTypeTab; |
| app_value->SetString(kAppTypePath, app_type_string); |
| updater.Get()->Append(app_value); |
| } |