Chromium Code Reviews| Index: chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc |
| diff --git a/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc b/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc |
| index a528729a91842c2118eb44a91183bb4261bde714..4acc8f614ce49231a52583ce789fe5d144ad1828 100644 |
| --- a/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc |
| +++ b/chrome/browser/ui/views/ash/launcher/chrome_launcher_delegate.cc |
| @@ -39,6 +39,7 @@ namespace { |
| // See description in PersistPinnedState(). |
| const char kAppIDPath[] = "id"; |
| +const char kAppTypePanel[] = "panel"; |
| const char kAppTypePath[] = "type"; |
| const char kAppTypeTab[] = "tab"; |
| const char kAppTypeWindow[] = "window"; |
| @@ -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); |
| } |
| } |
| @@ -175,6 +181,7 @@ ash::LauncherID ChromeLauncherDelegate::CreateAppLauncherItem( |
| min_app_index : std::min(item_count, min_tab_index + 1); |
| ash::LauncherID id = model_->next_id(); |
| ash::LauncherItem item(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; |
| @@ -183,7 +190,8 @@ ash::LauncherID ChromeLauncherDelegate::CreateAppLauncherItem( |
| id_to_item_map_[id].updater = updater; |
| id_to_item_map_[id].pinned = updater == NULL; |
| - app_icon_loader_->FetchImage(app_id); |
| + if (app_type != APP_TYPE_PANEL) |
| + app_icon_loader_->FetchImage(app_id); |
| return id; |
| } |
| @@ -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,12 +362,14 @@ std::string ChromeLauncherDelegate::GetAppID(TabContentsWrapper* tab) { |
| void ChromeLauncherDelegate::SetAppImage(const std::string& id, |
| const SkBitmap* image) { |
| + if (!image) |
| + return; |
|
sky
2012/03/05 22:19:04
This could cause problems if the app id of a tab c
stevenjb
2012/03/05 23:03:23
Ah. Right, I see. This should be a problem with th
|
| for (IDToItemMap::const_iterator i = id_to_item_map_.begin(); |
| i != id_to_item_map_.end(); ++i) { |
| - if (i->second.app_id == id) { |
| + if (i->second.app_id == id && i->second.app_type != APP_TYPE_PANEL) { |
|
sky
2012/03/05 22:19:04
Add a comment as to why it's ok to skip panel.
stevenjb
2012/03/05 23:03:23
Done.
|
| int index = model_->ItemIndexByID(i->first); |
| ash::LauncherItem item = model_->items()[index]; |
| - item.image = image ? *image : Extension::GetDefaultIcon(true); |
| + item.image = *image; |
| model_->Set(index, item); |
| // It's possible we're waiting on more than one item, so don't break. |
| } |
| @@ -443,9 +455,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); |
| } |