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

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

Issue 2900783003: Handle app custom icon via aura::Window property. (Closed)
Patch Set: fix mac compile Created 3 years, 6 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.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
6 6
7 #include "ash/multi_profile_uma.h" 7 #include "ash/multi_profile_uma.h"
8 #include "ash/public/cpp/remote_shelf_item_delegate.h" 8 #include "ash/public/cpp/remote_shelf_item_delegate.h"
9 #include "ash/public/cpp/shelf_item.h" 9 #include "ash/public/cpp/shelf_item.h"
10 #include "ash/public/interfaces/constants.mojom.h" 10 #include "ash/public/interfaces/constants.mojom.h"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 AppShortcutLauncherItemController::Create(shelf_id); 415 AppShortcutLauncherItemController::Create(shelf_id);
416 if (!item_delegate->GetRunningApplications().empty()) 416 if (!item_delegate->GetRunningApplications().empty())
417 SelectItemWithSource(item_delegate.get(), source); 417 SelectItemWithSource(item_delegate.get(), source);
418 else 418 else
419 LaunchApp(shelf_id, source, event_flags, display::kInvalidDisplayId); 419 LaunchApp(shelf_id, source, event_flags, display::kInvalidDisplayId);
420 } 420 }
421 421
422 void ChromeLauncherController::SetLauncherItemImage( 422 void ChromeLauncherController::SetLauncherItemImage(
423 const ash::ShelfID& shelf_id, 423 const ash::ShelfID& shelf_id,
424 const gfx::ImageSkia& image) { 424 const gfx::ImageSkia& image) {
425 DCHECK(!image.isNull());
425 const ash::ShelfItem* item = GetItem(shelf_id); 426 const ash::ShelfItem* item = GetItem(shelf_id);
426 if (item) { 427 if (item) {
427 ash::ShelfItem new_item = *item; 428 ash::ShelfItem new_item = *item;
428 new_item.image = image; 429 new_item.image = image;
429 model_->Set(model_->ItemIndexByID(shelf_id), new_item); 430 model_->Set(model_->ItemIndexByID(shelf_id), new_item);
430 } 431 }
431 } 432 }
432 433
434 void ChromeLauncherController::UpdateLauncherItemImage(
435 const std::string& app_id) {
436 AppIconLoader* icon_loader = GetAppIconLoaderForApp(app_id);
437 if (icon_loader)
438 icon_loader->UpdateImage(app_id);
439 }
440
433 void ChromeLauncherController::UpdateAppState(content::WebContents* contents, 441 void ChromeLauncherController::UpdateAppState(content::WebContents* contents,
434 AppState app_state) { 442 AppState app_state) {
435 ash::ShelfID shelf_id(launcher_controller_helper_->GetAppID(contents)); 443 ash::ShelfID shelf_id(launcher_controller_helper_->GetAppID(contents));
436 444
437 // Check if the gMail app is loaded and it matches the given content. 445 // Check if the gMail app is loaded and it matches the given content.
438 // This special treatment is needed to address crbug.com/234268. 446 // This special treatment is needed to address crbug.com/234268.
439 if (shelf_id.IsNull() && ContentCanBeHandledByGmailApp(contents)) 447 if (shelf_id.IsNull() && ContentCanBeHandledByGmailApp(contents))
440 shelf_id = ash::ShelfID(kGmailAppId); 448 shelf_id = ash::ShelfID(kGmailAppId);
441 449
442 // If the tab changed apps, remove its association with the previous app item. 450 // If the tab changed apps, remove its association with the previous app item.
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 void ChromeLauncherController::OnUserProfileReadyToSwitch(Profile* profile) { 687 void ChromeLauncherController::OnUserProfileReadyToSwitch(Profile* profile) {
680 if (user_switch_observer_.get()) 688 if (user_switch_observer_.get())
681 user_switch_observer_->OnUserProfileReadyToSwitch(profile); 689 user_switch_observer_->OnUserProfileReadyToSwitch(profile);
682 } 690 }
683 691
684 ArcAppDeferredLauncherController* 692 ArcAppDeferredLauncherController*
685 ChromeLauncherController::GetArcDeferredLauncher() { 693 ChromeLauncherController::GetArcDeferredLauncher() {
686 return arc_deferred_launcher_.get(); 694 return arc_deferred_launcher_.get();
687 } 695 }
688 696
689 AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp(
690 const std::string& app_id) {
691 for (const auto& app_icon_loader : app_icon_loaders_) {
692 if (app_icon_loader->CanLoadImageForApp(app_id))
693 return app_icon_loader.get();
694 }
695
696 return nullptr;
697 }
698
699 void ChromeLauncherController::SetShelfAutoHideBehaviorFromPrefs() { 697 void ChromeLauncherController::SetShelfAutoHideBehaviorFromPrefs() {
700 if (!ConnectToShelfController() || updating_shelf_pref_from_observer_) 698 if (!ConnectToShelfController() || updating_shelf_pref_from_observer_)
701 return; 699 return;
702 700
703 // The pref helper functions return default values for invalid display ids. 701 // The pref helper functions return default values for invalid display ids.
704 PrefService* prefs = profile_->GetPrefs(); 702 PrefService* prefs = profile_->GetPrefs();
705 for (const auto& display : display::Screen::GetScreen()->GetAllDisplays()) { 703 for (const auto& display : display::Screen::GetScreen()->GetAllDisplays()) {
706 shelf_controller_->SetAutoHideBehavior( 704 shelf_controller_->SetAutoHideBehavior(
707 GetShelfAutoHideBehaviorPref(prefs, display.id()), display.id()); 705 GetShelfAutoHideBehaviorPref(prefs, display.id()), display.id());
708 } 706 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 } 752 }
755 753
756 bool ChromeLauncherController::IsAppPinned(const std::string& app_id) { 754 bool ChromeLauncherController::IsAppPinned(const std::string& app_id) {
757 return model_->IsAppPinned(app_id); 755 return model_->IsAppPinned(app_id);
758 } 756 }
759 757
760 void ChromeLauncherController::UnpinAppWithID(const std::string& app_id) { 758 void ChromeLauncherController::UnpinAppWithID(const std::string& app_id) {
761 model_->UnpinAppWithID(app_id); 759 model_->UnpinAppWithID(app_id);
762 } 760 }
763 761
762 AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp(
763 const std::string& app_id) {
764 for (const auto& app_icon_loader : app_icon_loaders_) {
765 if (app_icon_loader->CanLoadImageForApp(app_id))
766 return app_icon_loader.get();
767 }
768
769 return nullptr;
770 }
771
764 /////////////////////////////////////////////////////////////////////////////// 772 ///////////////////////////////////////////////////////////////////////////////
765 // LauncherAppUpdater::Delegate: 773 // LauncherAppUpdater::Delegate:
766 774
767 void ChromeLauncherController::OnAppInstalled( 775 void ChromeLauncherController::OnAppInstalled(
768 content::BrowserContext* browser_context, 776 content::BrowserContext* browser_context,
769 const std::string& app_id) { 777 const std::string& app_id) {
770 if (IsAppPinned(app_id)) { 778 if (IsAppPinned(app_id)) {
771 // Clear and re-fetch to ensure icon is up-to-date. 779 // Clear and re-fetch to ensure icon is up-to-date.
772 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); 780 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id);
773 if (app_icon_loader) { 781 if (app_icon_loader) {
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE); 1494 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE);
1487 1495
1488 const int app_list_index = model_->GetItemIndexForType(ash::TYPE_APP_LIST); 1496 const int app_list_index = model_->GetItemIndexForType(ash::TYPE_APP_LIST);
1489 DCHECK_GE(app_list_index, 0); 1497 DCHECK_GE(app_list_index, 0);
1490 ash::ShelfItem item = model_->items()[app_list_index]; 1498 ash::ShelfItem item = model_->items()[app_list_index];
1491 if (item.title != title) { 1499 if (item.title != title) {
1492 item.title = title; 1500 item.title = title;
1493 model_->Set(app_list_index, item); 1501 model_->Set(app_list_index, item);
1494 } 1502 }
1495 } 1503 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698