Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc

Issue 2627533002: Replace ShelfItemDelegate::GetTitle() with ShelfItem::title. (Closed)
Patch Set: Address comments. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_impl.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "ash/common/multi_profile_uma.h" 11 #include "ash/common/multi_profile_uma.h"
12 #include "ash/common/shelf/shelf_model.h" 12 #include "ash/common/shelf/shelf_model.h"
13 #include "ash/common/shelf/wm_shelf.h" 13 #include "ash/common/shelf/wm_shelf.h"
14 #include "ash/common/strings/grit/ash_strings.h"
14 #include "ash/common/system/tray/system_tray_delegate.h" 15 #include "ash/common/system/tray/system_tray_delegate.h"
15 #include "ash/common/wm_shell.h" 16 #include "ash/common/wm_shell.h"
16 #include "ash/common/wm_window.h" 17 #include "ash/common/wm_window.h"
17 #include "ash/resources/grit/ash_resources.h" 18 #include "ash/resources/grit/ash_resources.h"
18 #include "ash/root_window_controller.h" 19 #include "ash/root_window_controller.h"
19 #include "ash/shell.h" 20 #include "ash/shell.h"
20 #include "ash/wm/window_util.h" 21 #include "ash/wm/window_util.h"
21 #include "base/command_line.h" 22 #include "base/command_line.h"
22 #include "base/macros.h" 23 #include "base/macros.h"
23 #include "base/strings/pattern.h" 24 #include "base/strings/pattern.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #include "chrome/browser/ui/browser.h" 61 #include "chrome/browser/ui/browser.h"
61 #include "chrome/browser/ui/browser_finder.h" 62 #include "chrome/browser/ui/browser_finder.h"
62 #include "chrome/browser/ui/browser_list.h" 63 #include "chrome/browser/ui/browser_list.h"
63 #include "chrome/browser/ui/browser_tabstrip.h" 64 #include "chrome/browser/ui/browser_tabstrip.h"
64 #include "chrome/browser/ui/browser_window.h" 65 #include "chrome/browser/ui/browser_window.h"
65 #include "chrome/browser/ui/tabs/tab_strip_model.h" 66 #include "chrome/browser/ui/tabs/tab_strip_model.h"
66 #include "chrome/browser/web_applications/web_app.h" 67 #include "chrome/browser/web_applications/web_app.h"
67 #include "chrome/common/chrome_switches.h" 68 #include "chrome/common/chrome_switches.h"
68 #include "chrome/common/pref_names.h" 69 #include "chrome/common/pref_names.h"
69 #include "chrome/common/url_constants.h" 70 #include "chrome/common/url_constants.h"
71 #include "chrome/grit/chromium_strings.h"
70 #include "chrome/grit/generated_resources.h" 72 #include "chrome/grit/generated_resources.h"
71 #include "chrome/grit/theme_resources.h" 73 #include "chrome/grit/theme_resources.h"
72 #include "components/favicon/content/content_favicon_driver.h" 74 #include "components/favicon/content/content_favicon_driver.h"
73 #include "components/prefs/scoped_user_pref_update.h" 75 #include "components/prefs/scoped_user_pref_update.h"
74 #include "components/signin/core/account_id/account_id.h" 76 #include "components/signin/core/account_id/account_id.h"
75 #include "components/strings/grit/components_strings.h" 77 #include "components/strings/grit/components_strings.h"
76 #include "components/user_manager/user_manager.h" 78 #include "components/user_manager/user_manager.h"
77 #include "content/public/browser/navigation_entry.h" 79 #include "content/public/browser/navigation_entry.h"
78 #include "content/public/browser/web_contents.h" 80 #include "content/public/browser/web_contents.h"
79 #include "extensions/common/extension.h" 81 #include "extensions/common/extension.h"
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 CHECK(controller); 1274 CHECK(controller);
1273 // Ash's ShelfWindowWatcher handles app panel windows separately. 1275 // Ash's ShelfWindowWatcher handles app panel windows separately.
1274 DCHECK_NE(ash::TYPE_APP_PANEL, shelf_item_type); 1276 DCHECK_NE(ash::TYPE_APP_PANEL, shelf_item_type);
1275 id_to_item_controller_map_[id] = controller; 1277 id_to_item_controller_map_[id] = controller;
1276 controller->set_shelf_id(id); 1278 controller->set_shelf_id(id);
1277 1279
1278 ash::ShelfItem item; 1280 ash::ShelfItem item;
1279 item.type = shelf_item_type; 1281 item.type = shelf_item_type;
1280 item.app_id = app_id; 1282 item.app_id = app_id;
1281 item.image = extensions::util::GetDefaultAppIcon(); 1283 item.image = extensions::util::GetDefaultAppIcon();
1284 item.title = LauncherControllerHelper::GetAppTitle(profile(), app_id);
1282 1285
1283 ash::ShelfItemStatus new_state = GetAppState(app_id); 1286 ash::ShelfItemStatus new_state = GetAppState(app_id);
1284 if (new_state != ash::STATUS_CLOSED) 1287 if (new_state != ash::STATUS_CLOSED)
1285 status = new_state; 1288 status = new_state;
1286 1289
1287 item.status = status; 1290 item.status = status;
1288 model_->AddAt(index, item); 1291 model_->AddAt(index, item);
1289 1292
1290 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); 1293 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id);
1291 if (app_icon_loader) { 1294 if (app_icon_loader) {
1292 app_icon_loader->FetchImage(app_id); 1295 app_icon_loader->FetchImage(app_id);
1293 app_icon_loader->UpdateImage(app_id); 1296 app_icon_loader->UpdateImage(app_id);
1294 } 1297 }
1295 1298
1296 SetShelfItemDelegate(id, controller); 1299 SetShelfItemDelegate(id, controller);
1297 1300
1298 return id; 1301 return id;
1299 } 1302 }
1300 1303
1301 void ChromeLauncherControllerImpl::CreateBrowserShortcutLauncherItem() { 1304 void ChromeLauncherControllerImpl::CreateBrowserShortcutLauncherItem() {
1302 ash::ShelfItem browser_shortcut; 1305 ash::ShelfItem browser_shortcut;
1303 browser_shortcut.type = ash::TYPE_BROWSER_SHORTCUT; 1306 browser_shortcut.type = ash::TYPE_BROWSER_SHORTCUT;
1304 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 1307 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
1305 browser_shortcut.image = *rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_32); 1308 browser_shortcut.image = *rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_32);
1309 browser_shortcut.title = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
1306 ash::ShelfID id = model_->next_id(); 1310 ash::ShelfID id = model_->next_id();
1307 model_->AddAt(0, browser_shortcut); 1311 model_->AddAt(0, browser_shortcut);
1308 id_to_item_controller_map_[id] = 1312 id_to_item_controller_map_[id] =
1309 new BrowserShortcutLauncherItemController(this, model_); 1313 new BrowserShortcutLauncherItemController(this, model_);
1310 id_to_item_controller_map_[id]->set_shelf_id(id); 1314 id_to_item_controller_map_[id]->set_shelf_id(id);
1311 // ShelfModel owns BrowserShortcutLauncherItemController. 1315 // ShelfModel owns BrowserShortcutLauncherItemController.
1312 SetShelfItemDelegate(id, id_to_item_controller_map_[id]); 1316 SetShelfItemDelegate(id, id_to_item_controller_map_[id]);
1313 } 1317 }
1314 1318
1315 bool ChromeLauncherControllerImpl::IsIncognito( 1319 bool ChromeLauncherControllerImpl::IsIncognito(
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 ash::WmShelf* shelf = 1442 ash::WmShelf* shelf =
1439 ash::WmShelf::ForWindow(ash::WmShell::Get()->GetPrimaryRootWindow()); 1443 ash::WmShelf::ForWindow(ash::WmShell::Get()->GetPrimaryRootWindow());
1440 if (shelf->alignment() != ash::SHELF_ALIGNMENT_BOTTOM_LOCKED) 1444 if (shelf->alignment() != ash::SHELF_ALIGNMENT_BOTTOM_LOCKED)
1441 SetShelfBehaviorsFromPrefs(); 1445 SetShelfBehaviorsFromPrefs();
1442 } 1446 }
1443 1447
1444 /////////////////////////////////////////////////////////////////////////////// 1448 ///////////////////////////////////////////////////////////////////////////////
1445 // AppSyncUIStateObserver: 1449 // AppSyncUIStateObserver:
1446 1450
1447 void ChromeLauncherControllerImpl::OnAppSyncUIStatusChanged() { 1451 void ChromeLauncherControllerImpl::OnAppSyncUIStatusChanged() {
1448 if (app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING) 1452 // Update the app list button title to reflect the syncing status.
1449 model_->set_status(ash::ShelfModel::STATUS_LOADING); 1453 base::string16 title = l10n_util::GetStringUTF16(
1450 else 1454 app_sync_ui_state_->status() == AppSyncUIState::STATUS_SYNCING
1451 model_->set_status(ash::ShelfModel::STATUS_NORMAL); 1455 ? IDS_ASH_SHELF_APP_LIST_LAUNCHER_SYNCING_TITLE
1456 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE);
1457
1458 const int app_list_index = model_->GetItemIndexForType(ash::TYPE_APP_LIST);
1459 DCHECK_GE(app_list_index, 0);
1460 ash::ShelfItem item = model_->items()[app_list_index];
1461 if (item.title != title) {
1462 item.title = title;
1463 model_->Set(app_list_index, item);
1464 }
1452 } 1465 }
1453 1466
1454 /////////////////////////////////////////////////////////////////////////////// 1467 ///////////////////////////////////////////////////////////////////////////////
1455 // AppIconLoaderDelegate: 1468 // AppIconLoaderDelegate:
1456 1469
1457 void ChromeLauncherControllerImpl::OnAppImageUpdated( 1470 void ChromeLauncherControllerImpl::OnAppImageUpdated(
1458 const std::string& id, 1471 const std::string& id,
1459 const gfx::ImageSkia& image) { 1472 const gfx::ImageSkia& image) {
1460 // TODO: need to get this working for shortcuts. 1473 // TODO: need to get this working for shortcuts.
1461 for (int index = 0; index < model_->item_count(); ++index) { 1474 for (int index = 0; index < model_->item_count(); ++index) {
1462 ash::ShelfItem item = model_->items()[index]; 1475 ash::ShelfItem item = model_->items()[index];
1463 if (GetAppIDForShelfID(item.id) != id) 1476 if (GetAppIDForShelfID(item.id) != id)
1464 continue; 1477 continue;
1465 LauncherItemController* controller = GetLauncherItemController(item.id); 1478 LauncherItemController* controller = GetLauncherItemController(item.id);
1466 if (!controller || controller->image_set_by_controller()) 1479 if (!controller || controller->image_set_by_controller())
1467 continue; 1480 continue;
1468 item.image = image; 1481 item.image = image;
1469 if (arc_deferred_launcher_) 1482 if (arc_deferred_launcher_)
1470 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); 1483 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image);
1471 model_->Set(index, item); 1484 model_->Set(index, item);
1472 // It's possible we're waiting on more than one item, so don't break. 1485 // It's possible we're waiting on more than one item, so don't break.
1473 } 1486 }
1474 } 1487 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698