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

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: cleanup Created 3 years, 7 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/shelf_item.h" 8 #include "ash/public/cpp/shelf_item.h"
9 #include "ash/public/interfaces/constants.mojom.h" 9 #include "ash/public/interfaces/constants.mojom.h"
10 #include "ash/resources/grit/ash_resources.h" 10 #include "ash/resources/grit/ash_resources.h"
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 AppShortcutLauncherItemController::Create(shelf_id); 414 AppShortcutLauncherItemController::Create(shelf_id);
415 if (!item_delegate->GetRunningApplications().empty()) 415 if (!item_delegate->GetRunningApplications().empty())
416 SelectItemWithSource(item_delegate.get(), source); 416 SelectItemWithSource(item_delegate.get(), source);
417 else 417 else
418 LaunchApp(shelf_id, source, event_flags); 418 LaunchApp(shelf_id, source, event_flags);
419 } 419 }
420 420
421 void ChromeLauncherController::SetLauncherItemImage( 421 void ChromeLauncherController::SetLauncherItemImage(
422 const ash::ShelfID& shelf_id, 422 const ash::ShelfID& shelf_id,
423 const gfx::ImageSkia& image) { 423 const gfx::ImageSkia& image) {
424 DCHECK(!image.isNull());
424 const ash::ShelfItem* item = GetItem(shelf_id); 425 const ash::ShelfItem* item = GetItem(shelf_id);
425 if (item) { 426 if (item) {
426 ash::ShelfItem new_item = *item; 427 ash::ShelfItem new_item = *item;
427 new_item.image = image; 428 new_item.image = image;
428 model_->Set(model_->ItemIndexByID(shelf_id), new_item); 429 model_->Set(model_->ItemIndexByID(shelf_id), new_item);
429 } 430 }
430 } 431 }
431 432
433 void ChromeLauncherController::UpdateAppItemImage(const std::string& app_id) {
434 AppIconLoader* icon_loader = GetAppIconLoaderForApp(app_id);
435 if (icon_loader)
436 icon_loader->UpdateImage(app_id);
437 }
438
432 void ChromeLauncherController::UpdateAppState(content::WebContents* contents, 439 void ChromeLauncherController::UpdateAppState(content::WebContents* contents,
433 AppState app_state) { 440 AppState app_state) {
434 ash::ShelfID shelf_id(launcher_controller_helper_->GetAppID(contents)); 441 ash::ShelfID shelf_id(launcher_controller_helper_->GetAppID(contents));
435 442
436 // Check if the gMail app is loaded and it matches the given content. 443 // Check if the gMail app is loaded and it matches the given content.
437 // This special treatment is needed to address crbug.com/234268. 444 // This special treatment is needed to address crbug.com/234268.
438 if (shelf_id.IsNull() && ContentCanBeHandledByGmailApp(contents)) 445 if (shelf_id.IsNull() && ContentCanBeHandledByGmailApp(contents))
439 shelf_id = ash::ShelfID(kGmailAppId); 446 shelf_id = ash::ShelfID(kGmailAppId);
440 447
441 // If the tab changed apps, remove its association with the previous app item. 448 // 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
678 void ChromeLauncherController::OnUserProfileReadyToSwitch(Profile* profile) { 685 void ChromeLauncherController::OnUserProfileReadyToSwitch(Profile* profile) {
679 if (user_switch_observer_.get()) 686 if (user_switch_observer_.get())
680 user_switch_observer_->OnUserProfileReadyToSwitch(profile); 687 user_switch_observer_->OnUserProfileReadyToSwitch(profile);
681 } 688 }
682 689
683 ArcAppDeferredLauncherController* 690 ArcAppDeferredLauncherController*
684 ChromeLauncherController::GetArcDeferredLauncher() { 691 ChromeLauncherController::GetArcDeferredLauncher() {
685 return arc_deferred_launcher_.get(); 692 return arc_deferred_launcher_.get();
686 } 693 }
687 694
688 AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp( 695 AppIconLoader* ChromeLauncherController::GetAppIconLoaderForApp(
msw 2017/05/23 00:02:29 nit: reorder to match decl
khmel 2017/05/23 16:11:43 Done.
689 const std::string& app_id) { 696 const std::string& app_id) {
690 for (const auto& app_icon_loader : app_icon_loaders_) { 697 for (const auto& app_icon_loader : app_icon_loaders_) {
691 if (app_icon_loader->CanLoadImageForApp(app_id)) 698 if (app_icon_loader->CanLoadImageForApp(app_id))
692 return app_icon_loader.get(); 699 return app_icon_loader.get();
693 } 700 }
694 701
695 return nullptr; 702 return nullptr;
696 } 703 }
697 704
698 void ChromeLauncherController::SetShelfAutoHideBehaviorFromPrefs() { 705 void ChromeLauncherController::SetShelfAutoHideBehaviorFromPrefs() {
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE); 1382 : IDS_ASH_SHELF_APP_LIST_LAUNCHER_TITLE);
1376 1383
1377 const int app_list_index = model_->GetItemIndexForType(ash::TYPE_APP_LIST); 1384 const int app_list_index = model_->GetItemIndexForType(ash::TYPE_APP_LIST);
1378 DCHECK_GE(app_list_index, 0); 1385 DCHECK_GE(app_list_index, 0);
1379 ash::ShelfItem item = model_->items()[app_list_index]; 1386 ash::ShelfItem item = model_->items()[app_list_index];
1380 if (item.title != title) { 1387 if (item.title != title) {
1381 item.title = title; 1388 item.title = title;
1382 model_->Set(app_list_index, item); 1389 model_->Set(app_list_index, item);
1383 } 1390 }
1384 } 1391 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698