| OLD | NEW |
| 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 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 #include "ui/aura/window_event_dispatcher.h" | 83 #include "ui/aura/window_event_dispatcher.h" |
| 84 #include "ui/base/l10n/l10n_util.h" | 84 #include "ui/base/l10n/l10n_util.h" |
| 85 #include "ui/base/resource/resource_bundle.h" | 85 #include "ui/base/resource/resource_bundle.h" |
| 86 #include "ui/base/window_open_disposition.h" | 86 #include "ui/base/window_open_disposition.h" |
| 87 #include "ui/display/types/display_constants.h" | 87 #include "ui/display/types/display_constants.h" |
| 88 #include "ui/keyboard/keyboard_util.h" | 88 #include "ui/keyboard/keyboard_util.h" |
| 89 #include "ui/resources/grit/ui_resources.h" | 89 #include "ui/resources/grit/ui_resources.h" |
| 90 #include "ui/wm/core/window_animations.h" | 90 #include "ui/wm/core/window_animations.h" |
| 91 | 91 |
| 92 using extensions::Extension; | 92 using extensions::Extension; |
| 93 using extension_misc::kChromeAppId; |
| 93 using extension_misc::kGmailAppId; | 94 using extension_misc::kGmailAppId; |
| 94 using content::WebContents; | 95 using content::WebContents; |
| 95 | 96 |
| 96 namespace { | 97 namespace { |
| 97 | 98 |
| 98 int64_t GetDisplayIDForShelf(ash::WmShelf* shelf) { | 99 int64_t GetDisplayIDForShelf(ash::WmShelf* shelf) { |
| 99 display::Display display = | 100 display::Display display = |
| 100 shelf->GetWindow()->GetRootWindow()->GetDisplayNearestWindow(); | 101 shelf->GetWindow()->GetRootWindow()->GetDisplayNearestWindow(); |
| 101 DCHECK(display.is_valid()); | 102 DCHECK(display.is_valid()); |
| 102 return display.id(); | 103 return display.id(); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 ChromeLauncherControllerImpl::~ChromeLauncherControllerImpl() { | 268 ChromeLauncherControllerImpl::~ChromeLauncherControllerImpl() { |
| 268 // Reset the BrowserStatusMonitor as it has a weak pointer to this. | 269 // Reset the BrowserStatusMonitor as it has a weak pointer to this. |
| 269 browser_status_monitor_.reset(); | 270 browser_status_monitor_.reset(); |
| 270 | 271 |
| 271 // Reset the app window controllers here since it has a weak pointer to this. | 272 // Reset the app window controllers here since it has a weak pointer to this. |
| 272 app_window_controllers_.clear(); | 273 app_window_controllers_.clear(); |
| 273 | 274 |
| 274 model_->RemoveObserver(this); | 275 model_->RemoveObserver(this); |
| 275 if (ash::Shell::HasInstance()) | 276 if (ash::Shell::HasInstance()) |
| 276 ash::Shell::Get()->window_tree_host_manager()->RemoveObserver(this); | 277 ash::Shell::Get()->window_tree_host_manager()->RemoveObserver(this); |
| 277 for (const auto& pair : id_to_item_controller_map_) { | |
| 278 int index = model_->ItemIndexByID(pair.first); | |
| 279 // A "browser proxy" is not known to the model and this removal does | |
| 280 // therefore not need to be propagated to the model. | |
| 281 if (index != -1 && | |
| 282 model_->items()[index].type != ash::TYPE_BROWSER_SHORTCUT) | |
| 283 model_->RemoveItemAt(index); | |
| 284 } | |
| 285 | 278 |
| 286 // Release all profile dependent resources. | 279 // Release all profile dependent resources. |
| 287 ReleaseProfile(); | 280 ReleaseProfile(); |
| 288 | 281 |
| 289 // Get rid of the multi user window manager instance. | 282 // Get rid of the multi user window manager instance. |
| 290 chrome::MultiUserWindowManager::DeleteInstance(); | 283 chrome::MultiUserWindowManager::DeleteInstance(); |
| 291 } | 284 } |
| 292 | 285 |
| 293 ash::ShelfID ChromeLauncherControllerImpl::CreateAppLauncherItem( | 286 ash::ShelfID ChromeLauncherControllerImpl::CreateAppLauncherItem( |
| 294 std::unique_ptr<ash::ShelfItemDelegate> item_delegate, | 287 std::unique_ptr<ash::ShelfItemDelegate> item_delegate, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 318 void ChromeLauncherControllerImpl::SetItemStatus(ash::ShelfID id, | 311 void ChromeLauncherControllerImpl::SetItemStatus(ash::ShelfID id, |
| 319 ash::ShelfItemStatus status) { | 312 ash::ShelfItemStatus status) { |
| 320 const ash::ShelfItem* item = GetItem(id); | 313 const ash::ShelfItem* item = GetItem(id); |
| 321 if (item && item->status != status) { | 314 if (item && item->status != status) { |
| 322 ash::ShelfItem new_item = *item; | 315 ash::ShelfItem new_item = *item; |
| 323 new_item.status = status; | 316 new_item.status = status; |
| 324 model_->Set(model_->ItemIndexByID(id), new_item); | 317 model_->Set(model_->ItemIndexByID(id), new_item); |
| 325 } | 318 } |
| 326 } | 319 } |
| 327 | 320 |
| 328 void ChromeLauncherControllerImpl::SetShelfItemDelegate( | |
| 329 ash::ShelfID id, | |
| 330 std::unique_ptr<ash::ShelfItemDelegate> item_delegate) { | |
| 331 CHECK(item_delegate); | |
| 332 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id); | |
| 333 CHECK(iter != id_to_item_controller_map_.end()); | |
| 334 item_delegate->set_shelf_id(id); | |
| 335 iter->second = item_delegate.get(); | |
| 336 model_->SetShelfItemDelegate(id, std::move(item_delegate)); | |
| 337 } | |
| 338 | |
| 339 void ChromeLauncherControllerImpl::CloseLauncherItem(ash::ShelfID id) { | 321 void ChromeLauncherControllerImpl::CloseLauncherItem(ash::ShelfID id) { |
| 340 CHECK(id); | 322 CHECK(id); |
| 341 if (IsPinned(id)) { | 323 if (IsPinned(id)) { |
| 342 // Create a new shortcut delegate. | 324 // Create a new shortcut delegate. |
| 343 SetItemStatus(id, ash::STATUS_CLOSED); | 325 SetItemStatus(id, ash::STATUS_CLOSED); |
| 344 SetShelfItemDelegate(id, AppShortcutLauncherItemController::Create( | 326 model_->SetShelfItemDelegate(id, AppShortcutLauncherItemController::Create( |
| 345 GetItem(id)->app_launch_id)); | 327 GetItem(id)->app_launch_id)); |
| 346 } else { | 328 } else { |
| 347 LauncherItemClosed(id); | 329 RemoveShelfItem(id); |
| 348 } | 330 } |
| 349 } | 331 } |
| 350 | 332 |
| 351 void ChromeLauncherControllerImpl::UnpinShelfItemInternal(ash::ShelfID id) { | 333 void ChromeLauncherControllerImpl::UnpinShelfItemInternal(ash::ShelfID id) { |
| 352 const ash::ShelfItem* item = GetItem(id); | 334 const ash::ShelfItem* item = GetItem(id); |
| 353 if (item && item->status != ash::STATUS_CLOSED) | 335 if (item && item->status != ash::STATUS_CLOSED) |
| 354 UnpinRunningAppInternal(model_->ItemIndexByID(id)); | 336 UnpinRunningAppInternal(model_->ItemIndexByID(id)); |
| 355 else | 337 else |
| 356 LauncherItemClosed(id); | 338 RemoveShelfItem(id); |
| 357 } | 339 } |
| 358 | 340 |
| 359 bool ChromeLauncherControllerImpl::IsPinned(ash::ShelfID id) { | 341 bool ChromeLauncherControllerImpl::IsPinned(ash::ShelfID id) { |
| 360 const ash::ShelfItem* item = GetItem(id); | 342 const ash::ShelfItem* item = GetItem(id); |
| 361 return item && ItemTypeIsPinned(*item); | 343 return item && ItemTypeIsPinned(*item); |
| 362 } | 344 } |
| 363 | 345 |
| 364 void ChromeLauncherControllerImpl::SetV1AppStatus(const std::string& app_id, | 346 void ChromeLauncherControllerImpl::SetV1AppStatus(const std::string& app_id, |
| 365 ash::ShelfItemStatus status) { | 347 ash::ShelfItemStatus status) { |
| 366 ash::ShelfID id = GetShelfIDForAppID(app_id); | 348 ash::ShelfID id = GetShelfIDForAppID(app_id); |
| 367 const ash::ShelfItem* item = GetItem(id); | 349 const ash::ShelfItem* item = GetItem(id); |
| 368 if (item) { | 350 if (item) { |
| 369 if (!IsPinned(id) && status == ash::STATUS_CLOSED) | 351 if (!IsPinned(id) && status == ash::STATUS_CLOSED) |
| 370 LauncherItemClosed(id); | 352 RemoveShelfItem(id); |
| 371 else | 353 else |
| 372 SetItemStatus(id, status); | 354 SetItemStatus(id, status); |
| 373 } else if (status != ash::STATUS_CLOSED && !app_id.empty()) { | 355 } else if (status != ash::STATUS_CLOSED && !app_id.empty()) { |
| 374 InsertAppLauncherItem( | 356 InsertAppLauncherItem( |
| 375 AppShortcutLauncherItemController::Create(ash::AppLaunchId(app_id)), | 357 AppShortcutLauncherItemController::Create(ash::AppLaunchId(app_id)), |
| 376 status, model_->item_count(), ash::TYPE_APP); | 358 status, model_->item_count(), ash::TYPE_APP); |
| 377 } | 359 } |
| 378 } | 360 } |
| 379 | 361 |
| 380 void ChromeLauncherControllerImpl::Launch(ash::ShelfID id, int event_flags) { | 362 void ChromeLauncherControllerImpl::Launch(ash::ShelfID id, int event_flags) { |
| 381 ash::ShelfItemDelegate* delegate = GetShelfItemDelegate(id); | 363 ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(id); |
| 382 if (!delegate) | 364 if (!delegate) |
| 383 return; // In case invoked from menu and item closed while menu up. | 365 return; // In case invoked from menu and item closed while menu up. |
| 384 | 366 |
| 385 // Launching some items replaces the associated item delegate instance, | 367 // Launching some items replaces the associated item delegate instance, |
| 386 // which destroys the app and launch id strings; making copies avoid crashes. | 368 // which destroys the app and launch id strings; making copies avoid crashes. |
| 387 LaunchApp(ash::AppLaunchId(delegate->app_id(), delegate->launch_id()), | 369 LaunchApp(ash::AppLaunchId(delegate->app_id(), delegate->launch_id()), |
| 388 ash::LAUNCH_FROM_UNKNOWN, event_flags); | 370 ash::LAUNCH_FROM_UNKNOWN, event_flags); |
| 389 } | 371 } |
| 390 | 372 |
| 391 void ChromeLauncherControllerImpl::Close(ash::ShelfID id) { | 373 void ChromeLauncherControllerImpl::Close(ash::ShelfID id) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 if (id) { | 456 if (id) { |
| 475 SetItemStatus(id, (app_state == APP_STATE_WINDOW_ACTIVE || | 457 SetItemStatus(id, (app_state == APP_STATE_WINDOW_ACTIVE || |
| 476 app_state == APP_STATE_ACTIVE) | 458 app_state == APP_STATE_ACTIVE) |
| 477 ? ash::STATUS_ACTIVE | 459 ? ash::STATUS_ACTIVE |
| 478 : GetAppState(app_id)); | 460 : GetAppState(app_id)); |
| 479 } | 461 } |
| 480 } | 462 } |
| 481 | 463 |
| 482 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForWebContents( | 464 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForWebContents( |
| 483 content::WebContents* contents) { | 465 content::WebContents* contents) { |
| 484 DCHECK(contents); | |
| 485 | |
| 486 std::string app_id = launcher_controller_helper()->GetAppID(contents); | 466 std::string app_id = launcher_controller_helper()->GetAppID(contents); |
| 487 | |
| 488 if (app_id.empty() && ContentCanBeHandledByGmailApp(contents)) | 467 if (app_id.empty() && ContentCanBeHandledByGmailApp(contents)) |
| 489 app_id = kGmailAppId; | 468 app_id = kGmailAppId; |
| 490 | 469 |
| 491 ash::ShelfID id = GetShelfIDForAppID(app_id); | 470 ash::ShelfID id = GetShelfIDForAppID(app_id); |
| 492 | 471 // If there is no dedicated app item, use the browser shortcut item. |
| 493 if (app_id.empty() || !id) { | 472 return id == ash::kInvalidShelfID ? GetShelfIDForAppID(kChromeAppId) : id; |
| 494 int browser_index = model_->GetItemIndexForType(ash::TYPE_BROWSER_SHORTCUT); | |
| 495 return model_->items()[browser_index].id; | |
| 496 } | |
| 497 | |
| 498 return id; | |
| 499 } | 473 } |
| 500 | 474 |
| 501 void ChromeLauncherControllerImpl::SetRefocusURLPatternForTest( | 475 void ChromeLauncherControllerImpl::SetRefocusURLPatternForTest( |
| 502 ash::ShelfID id, | 476 ash::ShelfID id, |
| 503 const GURL& url) { | 477 const GURL& url) { |
| 504 const ash::ShelfItem* item = GetItem(id); | 478 const ash::ShelfItem* item = GetItem(id); |
| 505 if (item && !IsPlatformApp(id) && | 479 if (item && !IsPlatformApp(id) && |
| 506 (item->type == ash::TYPE_PINNED_APP || item->type == ash::TYPE_APP)) { | 480 (item->type == ash::TYPE_PINNED_APP || item->type == ash::TYPE_APP)) { |
| 507 ash::ShelfItemDelegate* item_delegate = GetShelfItemDelegate(id); | 481 ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(id); |
| 508 AppShortcutLauncherItemController* item_controller = | 482 AppShortcutLauncherItemController* item_controller = |
| 509 static_cast<AppShortcutLauncherItemController*>(item_delegate); | 483 static_cast<AppShortcutLauncherItemController*>(delegate); |
| 510 item_controller->set_refocus_url(url); | 484 item_controller->set_refocus_url(url); |
| 511 } else { | 485 } else { |
| 512 NOTREACHED() << "Invalid launcher item or type"; | 486 NOTREACHED() << "Invalid launcher item or type"; |
| 513 } | 487 } |
| 514 } | 488 } |
| 515 | 489 |
| 516 ash::ShelfAction ChromeLauncherControllerImpl::ActivateWindowOrMinimizeIfActive( | 490 ash::ShelfAction ChromeLauncherControllerImpl::ActivateWindowOrMinimizeIfActive( |
| 517 ui::BaseWindow* window, | 491 ui::BaseWindow* window, |
| 518 bool allow_minimize) { | 492 bool allow_minimize) { |
| 519 // In separated desktop mode we might have to teleport a window back to the | 493 // In separated desktop mode we might have to teleport a window back to the |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 | 550 |
| 577 void ChromeLauncherControllerImpl::AdditionalUserAddedToSession( | 551 void ChromeLauncherControllerImpl::AdditionalUserAddedToSession( |
| 578 Profile* profile) { | 552 Profile* profile) { |
| 579 // Switch the running applications to the new user. | 553 // Switch the running applications to the new user. |
| 580 for (auto& controller : app_window_controllers_) | 554 for (auto& controller : app_window_controllers_) |
| 581 controller->AdditionalUserAddedToSession(profile); | 555 controller->AdditionalUserAddedToSession(profile); |
| 582 } | 556 } |
| 583 | 557 |
| 584 ash::MenuItemList ChromeLauncherControllerImpl::GetAppMenuItemsForTesting( | 558 ash::MenuItemList ChromeLauncherControllerImpl::GetAppMenuItemsForTesting( |
| 585 const ash::ShelfItem& item) { | 559 const ash::ShelfItem& item) { |
| 586 ash::ShelfItemDelegate* item_delegate = GetShelfItemDelegate(item.id); | 560 ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(item.id); |
| 587 return item_delegate ? item_delegate->GetAppMenuItems(ui::EF_NONE) | 561 return delegate ? delegate->GetAppMenuItems(ui::EF_NONE) |
| 588 : ash::MenuItemList(); | 562 : ash::MenuItemList(); |
| 589 } | 563 } |
| 590 | 564 |
| 591 std::vector<content::WebContents*> | 565 std::vector<content::WebContents*> |
| 592 ChromeLauncherControllerImpl::GetV1ApplicationsFromAppId( | 566 ChromeLauncherControllerImpl::GetV1ApplicationsFromAppId( |
| 593 const std::string& app_id) { | 567 const std::string& app_id) { |
| 594 const ash::ShelfItem* item = GetItem(GetShelfIDForAppID(app_id)); | 568 const ash::ShelfItem* item = GetItem(GetShelfIDForAppID(app_id)); |
| 595 // If there is no such item pinned to the launcher, no menu gets created. | 569 // If there is no such item pinned to the launcher, no menu gets created. |
| 596 if (!item || item->type != ash::TYPE_PINNED_APP) | 570 if (!item || item->type != ash::TYPE_PINNED_APP) |
| 597 return std::vector<content::WebContents*>(); | 571 return std::vector<content::WebContents*>(); |
| 598 ash::ShelfItemDelegate* item_delegate = GetShelfItemDelegate(item->id); | 572 ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(item->id); |
| 599 AppShortcutLauncherItemController* item_controller = | 573 AppShortcutLauncherItemController* item_controller = |
| 600 static_cast<AppShortcutLauncherItemController*>(item_delegate); | 574 static_cast<AppShortcutLauncherItemController*>(delegate); |
| 601 return item_controller->GetRunningApplications(); | 575 return item_controller->GetRunningApplications(); |
| 602 } | 576 } |
| 603 | 577 |
| 604 void ChromeLauncherControllerImpl::ActivateShellApp(const std::string& app_id, | 578 void ChromeLauncherControllerImpl::ActivateShellApp(const std::string& app_id, |
| 605 int window_index) { | 579 int window_index) { |
| 606 const ash::ShelfItem* item = GetItem(GetShelfIDForAppID(app_id)); | 580 const ash::ShelfItem* item = GetItem(GetShelfIDForAppID(app_id)); |
| 607 if (item && | 581 if (item && |
| 608 (item->type == ash::TYPE_APP || item->type == ash::TYPE_PINNED_APP)) { | 582 (item->type == ash::TYPE_APP || item->type == ash::TYPE_PINNED_APP)) { |
| 609 ash::ShelfItemDelegate* item_delegate = GetShelfItemDelegate(item->id); | 583 ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(item->id); |
| 610 AppWindowLauncherItemController* item_controller = | 584 AppWindowLauncherItemController* item_controller = |
| 611 item_delegate->AsAppWindowLauncherItemController(); | 585 delegate->AsAppWindowLauncherItemController(); |
| 612 item_controller->ActivateIndexedApp(window_index); | 586 item_controller->ActivateIndexedApp(window_index); |
| 613 } | 587 } |
| 614 } | 588 } |
| 615 | 589 |
| 616 bool ChromeLauncherControllerImpl::IsWebContentHandledByApplication( | 590 bool ChromeLauncherControllerImpl::IsWebContentHandledByApplication( |
| 617 content::WebContents* web_contents, | 591 content::WebContents* web_contents, |
| 618 const std::string& app_id) { | 592 const std::string& app_id) { |
| 619 if ((web_contents_to_app_id_.find(web_contents) != | 593 if ((web_contents_to_app_id_.find(web_contents) != |
| 620 web_contents_to_app_id_.end()) && | 594 web_contents_to_app_id_.end()) && |
| 621 (web_contents_to_app_id_[web_contents] == app_id)) | 595 (web_contents_to_app_id_[web_contents] == app_id)) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 const extensions::Extension* extension = | 639 const extensions::Extension* extension = |
| 666 GetExtensionForAppID(app_id, profile()); | 640 GetExtensionForAppID(app_id, profile()); |
| 667 if (extension) | 641 if (extension) |
| 668 return base::UTF8ToUTF16(extension->name()); | 642 return base::UTF8ToUTF16(extension->name()); |
| 669 } | 643 } |
| 670 return l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); | 644 return l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); |
| 671 } | 645 } |
| 672 | 646 |
| 673 BrowserShortcutLauncherItemController* | 647 BrowserShortcutLauncherItemController* |
| 674 ChromeLauncherControllerImpl::GetBrowserShortcutLauncherItemController() { | 648 ChromeLauncherControllerImpl::GetBrowserShortcutLauncherItemController() { |
| 675 for (const auto& pair : id_to_item_controller_map_) { | 649 ash::ShelfID id = GetShelfIDForAppID(kChromeAppId); |
| 676 const ash::ShelfItem* item = GetItem(pair.first); | 650 ash::mojom::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(id); |
| 677 if (item && item->type == ash::TYPE_BROWSER_SHORTCUT) | 651 DCHECK(delegate) << "There should be always be a browser shortcut item."; |
| 678 return static_cast<BrowserShortcutLauncherItemController*>(pair.second); | 652 return static_cast<BrowserShortcutLauncherItemController*>(delegate); |
| 679 } | |
| 680 NOTREACHED() | |
| 681 << "There should be always be a BrowserShortcutLauncherItemController."; | |
| 682 return nullptr; | |
| 683 } | |
| 684 | |
| 685 ash::ShelfItemDelegate* ChromeLauncherControllerImpl::GetShelfItemDelegate( | |
| 686 const ash::ShelfID id) { | |
| 687 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id); | |
| 688 return iter == id_to_item_controller_map_.end() ? nullptr : iter->second; | |
| 689 } | 653 } |
| 690 | 654 |
| 691 bool ChromeLauncherControllerImpl::ShelfBoundsChangesProbablyWithUser( | 655 bool ChromeLauncherControllerImpl::ShelfBoundsChangesProbablyWithUser( |
| 692 ash::WmShelf* shelf, | 656 ash::WmShelf* shelf, |
| 693 const AccountId& account_id) const { | 657 const AccountId& account_id) const { |
| 694 Profile* other_profile = multi_user_util::GetProfileFromAccountId(account_id); | 658 Profile* other_profile = multi_user_util::GetProfileFromAccountId(account_id); |
| 695 if (!other_profile || other_profile == profile()) | 659 if (!other_profile || other_profile == profile()) |
| 696 return false; | 660 return false; |
| 697 | 661 |
| 698 // Note: The Auto hide state from preferences is not the same as the actual | 662 // Note: The Auto hide state from preferences is not the same as the actual |
| (...skipping 20 matching lines...) Expand all Loading... |
| 719 user_switch_observer_->OnUserProfileReadyToSwitch(profile); | 683 user_switch_observer_->OnUserProfileReadyToSwitch(profile); |
| 720 } | 684 } |
| 721 | 685 |
| 722 ArcAppDeferredLauncherController* | 686 ArcAppDeferredLauncherController* |
| 723 ChromeLauncherControllerImpl::GetArcDeferredLauncher() { | 687 ChromeLauncherControllerImpl::GetArcDeferredLauncher() { |
| 724 return arc_deferred_launcher_.get(); | 688 return arc_deferred_launcher_.get(); |
| 725 } | 689 } |
| 726 | 690 |
| 727 const std::string& ChromeLauncherControllerImpl::GetLaunchIDForShelfID( | 691 const std::string& ChromeLauncherControllerImpl::GetLaunchIDForShelfID( |
| 728 ash::ShelfID id) { | 692 ash::ShelfID id) { |
| 729 ash::ShelfItemDelegate* delegate = GetShelfItemDelegate(id); | 693 ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(id); |
| 730 return delegate ? delegate->launch_id() : base::EmptyString(); | 694 return delegate ? delegate->launch_id() : base::EmptyString(); |
| 731 } | 695 } |
| 732 | 696 |
| 733 void ChromeLauncherControllerImpl::AttachProfile(Profile* profile_to_attach) { | 697 void ChromeLauncherControllerImpl::AttachProfile(Profile* profile_to_attach) { |
| 734 // The base class implementation updates the helper and app icon loaders. | 698 // The base class implementation updates the helper and app icon loaders. |
| 735 ChromeLauncherController::AttachProfile(profile_to_attach); | 699 ChromeLauncherController::AttachProfile(profile_to_attach); |
| 736 | 700 |
| 737 pref_change_registrar_.Init(profile()->GetPrefs()); | 701 pref_change_registrar_.Init(profile()->GetPrefs()); |
| 738 pref_change_registrar_.Add( | 702 pref_change_registrar_.Add( |
| 739 prefs::kPolicyPinnedLauncherApps, | 703 prefs::kPolicyPinnedLauncherApps, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 // Get shelf id for |app_id| and an empty |launch_id|. | 755 // Get shelf id for |app_id| and an empty |launch_id|. |
| 792 return GetShelfIDForAppIDAndLaunchID(app_id, std::string()); | 756 return GetShelfIDForAppIDAndLaunchID(app_id, std::string()); |
| 793 } | 757 } |
| 794 | 758 |
| 795 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppIDAndLaunchID( | 759 ash::ShelfID ChromeLauncherControllerImpl::GetShelfIDForAppIDAndLaunchID( |
| 796 const std::string& app_id, | 760 const std::string& app_id, |
| 797 const std::string& launch_id) { | 761 const std::string& launch_id) { |
| 798 // TODO(khmel): Fix this Arc application id mapping. See http://b/31703859 | 762 // TODO(khmel): Fix this Arc application id mapping. See http://b/31703859 |
| 799 const std::string shelf_app_id = | 763 const std::string shelf_app_id = |
| 800 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); | 764 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); |
| 765 if (shelf_app_id.empty()) |
| 766 return ash::kInvalidShelfID; |
| 801 | 767 |
| 802 for (const ash::ShelfItem& item : model_->items()) { | 768 for (const ash::ShelfItem& item : model_->items()) { |
| 803 // Ash's ShelfWindowWatcher handles app panel windows separately. | 769 // Ash's ShelfWindowWatcher handles app panel windows separately. |
| 804 if (item.type != ash::TYPE_APP_PANEL && | 770 if (item.type != ash::TYPE_APP_PANEL && |
| 805 item.app_launch_id.app_id() == shelf_app_id && | 771 item.app_launch_id.app_id() == shelf_app_id && |
| 806 item.app_launch_id.launch_id() == launch_id) { | 772 item.app_launch_id.launch_id() == launch_id) { |
| 807 return item.id; | 773 return item.id; |
| 808 } | 774 } |
| 809 } | 775 } |
| 810 return ash::kInvalidShelfID; | 776 return ash::kInvalidShelfID; |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 if (item && item->type == ash::TYPE_APP) { | 930 if (item && item->type == ash::TYPE_APP) { |
| 965 int app_index = model_->ItemIndexByID(item->id); | 931 int app_index = model_->ItemIndexByID(item->id); |
| 966 DCHECK_GE(app_index, 0); | 932 DCHECK_GE(app_index, 0); |
| 967 if (running_index != app_index) | 933 if (running_index != app_index) |
| 968 model_->Move(running_index, app_index); | 934 model_->Move(running_index, app_index); |
| 969 running_index++; | 935 running_index++; |
| 970 } | 936 } |
| 971 } | 937 } |
| 972 } | 938 } |
| 973 | 939 |
| 974 void ChromeLauncherControllerImpl::LauncherItemClosed(ash::ShelfID id) { | 940 void ChromeLauncherControllerImpl::RemoveShelfItem(ash::ShelfID id) { |
| 975 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id); | 941 const std::string& app_id = GetAppIDForShelfID(id); |
| 976 CHECK(iter != id_to_item_controller_map_.end()); | |
| 977 CHECK(iter->second); | |
| 978 const std::string& app_id = iter->second->app_id(); | |
| 979 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); | 942 AppIconLoader* app_icon_loader = GetAppIconLoaderForApp(app_id); |
| 980 if (app_icon_loader) | 943 if (app_icon_loader) |
| 981 app_icon_loader->ClearImage(app_id); | 944 app_icon_loader->ClearImage(app_id); |
| 982 id_to_item_controller_map_.erase(iter); | 945 const int index = model_->ItemIndexByID(id); |
| 983 int index = model_->ItemIndexByID(id); | |
| 984 // A "browser proxy" is not known to the model and this removal does | 946 // A "browser proxy" is not known to the model and this removal does |
| 985 // therefore not need to be propagated to the model. | 947 // therefore not need to be propagated to the model. |
| 986 if (index != -1) | 948 if (index != -1) |
| 987 model_->RemoveItemAt(index); | 949 model_->RemoveItemAt(index); |
| 988 } | 950 } |
| 989 | 951 |
| 990 void ChromeLauncherControllerImpl::PinRunningAppInternal( | 952 void ChromeLauncherControllerImpl::PinRunningAppInternal( |
| 991 int index, | 953 int index, |
| 992 ash::ShelfID shelf_id) { | 954 ash::ShelfID shelf_id) { |
| 993 DCHECK_EQ(GetItem(shelf_id)->type, ash::TYPE_APP); | 955 DCHECK_EQ(GetItem(shelf_id)->type, ash::TYPE_APP); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1093 if (shelf_app_id != app_id) | 1055 if (shelf_app_id != app_id) |
| 1094 continue; | 1056 continue; |
| 1095 | 1057 |
| 1096 // Update apps icon if applicable. | 1058 // Update apps icon if applicable. |
| 1097 OnAppUpdated(profile(), app_id); | 1059 OnAppUpdated(profile(), app_id); |
| 1098 | 1060 |
| 1099 // Find existing pin or app from the right of current |index|. | 1061 // Find existing pin or app from the right of current |index|. |
| 1100 int app_index = index; | 1062 int app_index = index; |
| 1101 for (; app_index < model_->item_count(); ++app_index) { | 1063 for (; app_index < model_->item_count(); ++app_index) { |
| 1102 const ash::ShelfItem& item = model_->items()[app_index]; | 1064 const ash::ShelfItem& item = model_->items()[app_index]; |
| 1103 const IDToItemControllerMap::iterator it = | 1065 if (item.app_launch_id.app_id() == app_id && |
| 1104 id_to_item_controller_map_.find(item.id); | 1066 item.app_launch_id.launch_id() == pref_app_launch_id.launch_id()) { |
| 1105 if (it != id_to_item_controller_map_.end() && | |
| 1106 it->second->app_id() == app_id && | |
| 1107 it->second->launch_id() == pref_app_launch_id.launch_id()) { | |
| 1108 break; | 1067 break; |
| 1109 } | 1068 } |
| 1110 } | 1069 } |
| 1111 if (app_index < model_->item_count()) { | 1070 if (app_index < model_->item_count()) { |
| 1112 // Found existing pin or running app. | 1071 // Found existing pin or running app. |
| 1113 const ash::ShelfItem item = model_->items()[app_index]; | 1072 const ash::ShelfItem item = model_->items()[app_index]; |
| 1114 if (item.type == ash::TYPE_PINNED_APP || | 1073 if (ItemTypeIsPinned(item)) { |
| 1115 item.type == ash::TYPE_BROWSER_SHORTCUT) { | |
| 1116 // Just move to required position or keep it inplace. | 1074 // Just move to required position or keep it inplace. |
| 1117 model_->Move(app_index, index); | 1075 model_->Move(app_index, index); |
| 1118 } else { | 1076 } else { |
| 1119 PinRunningAppInternal(index, item.id); | 1077 PinRunningAppInternal(index, item.id); |
| 1120 } | 1078 } |
| 1121 DCHECK_EQ(model_->ItemIndexByID(item.id), index); | 1079 DCHECK_EQ(model_->ItemIndexByID(item.id), index); |
| 1122 } else { | 1080 } else { |
| 1123 // This is fresh pin. Create new one. | 1081 // This is fresh pin. Create new one. |
| 1124 DCHECK_NE(app_id, extension_misc::kChromeAppId); | 1082 DCHECK_NE(app_id, kChromeAppId); |
| 1125 CreateAppShortcutLauncherItem(pref_app_launch_id, index); | 1083 CreateAppShortcutLauncherItem(pref_app_launch_id, index); |
| 1126 } | 1084 } |
| 1127 ++index; | 1085 ++index; |
| 1128 } | 1086 } |
| 1129 | 1087 |
| 1130 // At second step remove any pin to the right from the current index. | 1088 // At second step remove any pin to the right from the current index. |
| 1131 while (index < model_->item_count()) { | 1089 while (index < model_->item_count()) { |
| 1132 const ash::ShelfItem item = model_->items()[index]; | 1090 const ash::ShelfItem item = model_->items()[index]; |
| 1133 if (item.type == ash::TYPE_PINNED_APP) | 1091 if (item.type == ash::TYPE_PINNED_APP) |
| 1134 UnpinShelfItemInternal(item.id); | 1092 UnpinShelfItemInternal(item.id); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 ash::ShelfID ChromeLauncherControllerImpl::InsertAppLauncherItem( | 1156 ash::ShelfID ChromeLauncherControllerImpl::InsertAppLauncherItem( |
| 1199 std::unique_ptr<ash::ShelfItemDelegate> item_delegate, | 1157 std::unique_ptr<ash::ShelfItemDelegate> item_delegate, |
| 1200 ash::ShelfItemStatus status, | 1158 ash::ShelfItemStatus status, |
| 1201 int index, | 1159 int index, |
| 1202 ash::ShelfItemType shelf_item_type) { | 1160 ash::ShelfItemType shelf_item_type) { |
| 1203 ash::ShelfID id = model_->next_id(); | 1161 ash::ShelfID id = model_->next_id(); |
| 1204 CHECK(!GetItem(id)); | 1162 CHECK(!GetItem(id)); |
| 1205 CHECK(item_delegate); | 1163 CHECK(item_delegate); |
| 1206 // Ash's ShelfWindowWatcher handles app panel windows separately. | 1164 // Ash's ShelfWindowWatcher handles app panel windows separately. |
| 1207 DCHECK_NE(ash::TYPE_APP_PANEL, shelf_item_type); | 1165 DCHECK_NE(ash::TYPE_APP_PANEL, shelf_item_type); |
| 1208 id_to_item_controller_map_[id] = item_delegate.get(); | |
| 1209 item_delegate->set_shelf_id(id); | |
| 1210 | 1166 |
| 1211 ash::ShelfItem item; | 1167 ash::ShelfItem item; |
| 1212 item.type = shelf_item_type; | 1168 item.type = shelf_item_type; |
| 1213 item.app_launch_id = item_delegate->app_launch_id(); | 1169 item.app_launch_id = item_delegate->app_launch_id(); |
| 1214 item.image = extensions::util::GetDefaultAppIcon(); | 1170 item.image = extensions::util::GetDefaultAppIcon(); |
| 1215 | 1171 |
| 1216 const std::string& app_id = item_delegate->app_id(); | 1172 const std::string& app_id = item_delegate->app_id(); |
| 1217 item.title = LauncherControllerHelper::GetAppTitle(profile(), app_id); | 1173 item.title = LauncherControllerHelper::GetAppTitle(profile(), app_id); |
| 1218 | 1174 |
| 1219 ash::ShelfItemStatus new_state = GetAppState(app_id); | 1175 ash::ShelfItemStatus new_state = GetAppState(app_id); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1237 // Do not sync the pin position of the browser shortcut item when it is added; | 1193 // Do not sync the pin position of the browser shortcut item when it is added; |
| 1238 // its initial position before prefs have loaded is unimportant and the sync | 1194 // its initial position before prefs have loaded is unimportant and the sync |
| 1239 // service may not yet be initialized. | 1195 // service may not yet be initialized. |
| 1240 ScopedPinSyncDisabler scoped_pin_sync_disabler = GetScopedPinSyncDisabler(); | 1196 ScopedPinSyncDisabler scoped_pin_sync_disabler = GetScopedPinSyncDisabler(); |
| 1241 | 1197 |
| 1242 ash::ShelfItem browser_shortcut; | 1198 ash::ShelfItem browser_shortcut; |
| 1243 browser_shortcut.type = ash::TYPE_BROWSER_SHORTCUT; | 1199 browser_shortcut.type = ash::TYPE_BROWSER_SHORTCUT; |
| 1244 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 1200 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 1245 browser_shortcut.image = *rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_32); | 1201 browser_shortcut.image = *rb.GetImageSkiaNamed(IDR_PRODUCT_LOGO_32); |
| 1246 browser_shortcut.title = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); | 1202 browser_shortcut.title = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME); |
| 1247 browser_shortcut.app_launch_id = | 1203 browser_shortcut.app_launch_id = ash::AppLaunchId(kChromeAppId); |
| 1248 ash::AppLaunchId(extension_misc::kChromeAppId); | |
| 1249 ash::ShelfID id = model_->next_id(); | 1204 ash::ShelfID id = model_->next_id(); |
| 1250 model_->AddAt(0, browser_shortcut); | 1205 model_->AddAt(0, browser_shortcut); |
| 1251 std::unique_ptr<BrowserShortcutLauncherItemController> item_delegate = | 1206 std::unique_ptr<BrowserShortcutLauncherItemController> item_delegate = |
| 1252 base::MakeUnique<BrowserShortcutLauncherItemController>(model_); | 1207 base::MakeUnique<BrowserShortcutLauncherItemController>(model_); |
| 1253 BrowserShortcutLauncherItemController* item_controller = item_delegate.get(); | 1208 BrowserShortcutLauncherItemController* item_controller = item_delegate.get(); |
| 1254 item_controller->set_shelf_id(id); | |
| 1255 id_to_item_controller_map_[id] = item_controller; | |
| 1256 model_->SetShelfItemDelegate(id, std::move(item_delegate)); | 1209 model_->SetShelfItemDelegate(id, std::move(item_delegate)); |
| 1257 item_controller->UpdateBrowserItemState(); | 1210 item_controller->UpdateBrowserItemState(); |
| 1258 } | 1211 } |
| 1259 | 1212 |
| 1260 bool ChromeLauncherControllerImpl::IsIncognito( | 1213 bool ChromeLauncherControllerImpl::IsIncognito( |
| 1261 const content::WebContents* web_contents) const { | 1214 const content::WebContents* web_contents) const { |
| 1262 const Profile* profile = | 1215 const Profile* profile = |
| 1263 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 1216 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 1264 return profile->IsOffTheRecord() && !profile->IsGuestSession() && | 1217 return profile->IsOffTheRecord() && !profile->IsGuestSession() && |
| 1265 !profile->IsSystemProfile(); | 1218 !profile->IsSystemProfile(); |
| 1266 } | 1219 } |
| 1267 | 1220 |
| 1268 int ChromeLauncherControllerImpl::FindInsertionPoint() { | 1221 int ChromeLauncherControllerImpl::FindInsertionPoint() { |
| 1269 DCHECK_GT(model_->item_count(), 0); | |
| 1270 for (int i = model_->item_count() - 1; i > 0; --i) { | 1222 for (int i = model_->item_count() - 1; i > 0; --i) { |
| 1271 ash::ShelfItemType type = model_->items()[i].type; | 1223 if (ItemTypeIsPinned(model_->items()[i])) |
| 1272 DCHECK_NE(ash::TYPE_APP_LIST, type); | |
| 1273 if (type == ash::TYPE_PINNED_APP || type == ash::TYPE_BROWSER_SHORTCUT) | |
| 1274 return i; | 1224 return i; |
| 1275 } | 1225 } |
| 1276 return 0; | 1226 return 0; |
| 1277 } | 1227 } |
| 1278 | 1228 |
| 1279 void ChromeLauncherControllerImpl::CloseWindowedAppsFromRemovedExtension( | 1229 void ChromeLauncherControllerImpl::CloseWindowedAppsFromRemovedExtension( |
| 1280 const std::string& app_id, | 1230 const std::string& app_id, |
| 1281 const Profile* profile) { | 1231 const Profile* profile) { |
| 1282 // This function cannot rely on the controller's enumeration functionality | 1232 // This function cannot rely on the controller's enumeration functionality |
| 1283 // since the extension has already been unloaded. | 1233 // since the extension has already been unloaded. |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 // Remove the pin position from preferences as needed. | 1287 // Remove the pin position from preferences as needed. |
| 1338 if (ItemTypeIsPinned(old_item) && should_sync_pin_changes()) { | 1288 if (ItemTypeIsPinned(old_item) && should_sync_pin_changes()) { |
| 1339 // TODO(khmel): Fix this Arc application id mapping. See http://b/31703859 | 1289 // TODO(khmel): Fix this Arc application id mapping. See http://b/31703859 |
| 1340 const std::string shelf_app_id = | 1290 const std::string shelf_app_id = |
| 1341 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId( | 1291 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId( |
| 1342 old_item.app_launch_id.app_id()); | 1292 old_item.app_launch_id.app_id()); |
| 1343 ash::AppLaunchId app_launch_id(shelf_app_id, | 1293 ash::AppLaunchId app_launch_id(shelf_app_id, |
| 1344 old_item.app_launch_id.launch_id()); | 1294 old_item.app_launch_id.launch_id()); |
| 1345 ash::launcher::RemovePinPosition(profile(), app_launch_id); | 1295 ash::launcher::RemovePinPosition(profile(), app_launch_id); |
| 1346 } | 1296 } |
| 1347 | |
| 1348 // TODO(skuhne): This fixes crbug.com/429870, but it does not answer why we | |
| 1349 // get into this state in the first place. | |
| 1350 if (id_to_item_controller_map_.count(old_item.id) > 0) | |
| 1351 id_to_item_controller_map_.erase(old_item.id); | |
| 1352 } | 1297 } |
| 1353 | 1298 |
| 1354 void ChromeLauncherControllerImpl::ShelfItemMoved(int start_index, | 1299 void ChromeLauncherControllerImpl::ShelfItemMoved(int start_index, |
| 1355 int target_index) { | 1300 int target_index) { |
| 1356 // Update the pin position preference as needed. | 1301 // Update the pin position preference as needed. |
| 1357 const ash::ShelfItem& item = model_->items()[target_index]; | 1302 const ash::ShelfItem& item = model_->items()[target_index]; |
| 1358 DCHECK_NE(ash::TYPE_APP_LIST, item.type); | 1303 DCHECK_NE(ash::TYPE_APP_LIST, item.type); |
| 1359 if (ItemTypeIsPinned(item) && should_sync_pin_changes()) | 1304 if (ItemTypeIsPinned(item) && should_sync_pin_changes()) |
| 1360 SyncPinPosition(item.id); | 1305 SyncPinPosition(item.id); |
| 1361 } | 1306 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1375 const std::string shelf_app_id = | 1320 const std::string shelf_app_id = |
| 1376 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId( | 1321 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId( |
| 1377 old_item.app_launch_id.app_id()); | 1322 old_item.app_launch_id.app_id()); |
| 1378 | 1323 |
| 1379 ash::AppLaunchId app_launch_id(shelf_app_id, | 1324 ash::AppLaunchId app_launch_id(shelf_app_id, |
| 1380 old_item.app_launch_id.launch_id()); | 1325 old_item.app_launch_id.launch_id()); |
| 1381 ash::launcher::RemovePinPosition(profile(), app_launch_id); | 1326 ash::launcher::RemovePinPosition(profile(), app_launch_id); |
| 1382 } | 1327 } |
| 1383 } | 1328 } |
| 1384 | 1329 |
| 1385 void ChromeLauncherControllerImpl::OnSetShelfItemDelegate( | |
| 1386 ash::ShelfID id, | |
| 1387 ash::ShelfItemDelegate* item_delegate) { | |
| 1388 // TODO(skuhne): This fixes crbug.com/429870, but it does not answer why we | |
| 1389 // get into this state in the first place. | |
| 1390 IDToItemControllerMap::iterator iter = id_to_item_controller_map_.find(id); | |
| 1391 if (iter == id_to_item_controller_map_.end() || item_delegate == iter->second) | |
| 1392 return; | |
| 1393 LOG(ERROR) << "Unexpected change of shelf item delegate, id: " << id; | |
| 1394 id_to_item_controller_map_.erase(iter); | |
| 1395 } | |
| 1396 | |
| 1397 /////////////////////////////////////////////////////////////////////////////// | 1330 /////////////////////////////////////////////////////////////////////////////// |
| 1398 // ash::WindowTreeHostManager::Observer: | 1331 // ash::WindowTreeHostManager::Observer: |
| 1399 | 1332 |
| 1400 void ChromeLauncherControllerImpl::OnDisplayConfigurationChanged() { | 1333 void ChromeLauncherControllerImpl::OnDisplayConfigurationChanged() { |
| 1401 // In BOTTOM_LOCKED state, ignore the call of SetShelfBehaviorsFromPrefs. | 1334 // In BOTTOM_LOCKED state, ignore the call of SetShelfBehaviorsFromPrefs. |
| 1402 // Because it might be called by some operations, like crbug.com/627040 | 1335 // Because it might be called by some operations, like crbug.com/627040 |
| 1403 // rotating screen. | 1336 // rotating screen. |
| 1404 ash::WmShelf* shelf = | 1337 ash::WmShelf* shelf = |
| 1405 ash::WmShelf::ForWindow(ash::WmShell::Get()->GetPrimaryRootWindow()); | 1338 ash::WmShelf::ForWindow(ash::WmShell::Get()->GetPrimaryRootWindow()); |
| 1406 if (shelf->alignment() != ash::SHELF_ALIGNMENT_BOTTOM_LOCKED) | 1339 if (shelf->alignment() != ash::SHELF_ALIGNMENT_BOTTOM_LOCKED) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1423 if (item.title != title) { | 1356 if (item.title != title) { |
| 1424 item.title = title; | 1357 item.title = title; |
| 1425 model_->Set(app_list_index, item); | 1358 model_->Set(app_list_index, item); |
| 1426 } | 1359 } |
| 1427 } | 1360 } |
| 1428 | 1361 |
| 1429 /////////////////////////////////////////////////////////////////////////////// | 1362 /////////////////////////////////////////////////////////////////////////////// |
| 1430 // AppIconLoaderDelegate: | 1363 // AppIconLoaderDelegate: |
| 1431 | 1364 |
| 1432 void ChromeLauncherControllerImpl::OnAppImageUpdated( | 1365 void ChromeLauncherControllerImpl::OnAppImageUpdated( |
| 1433 const std::string& id, | 1366 const std::string& app_id, |
| 1434 const gfx::ImageSkia& image) { | 1367 const gfx::ImageSkia& image) { |
| 1435 // TODO: need to get this working for shortcuts. | 1368 // TODO: need to get this working for shortcuts. |
| 1436 for (int index = 0; index < model_->item_count(); ++index) { | 1369 for (int index = 0; index < model_->item_count(); ++index) { |
| 1437 ash::ShelfItem item = model_->items()[index]; | 1370 ash::ShelfItem item = model_->items()[index]; |
| 1438 if (GetAppIDForShelfID(item.id) != id) | 1371 ash::ShelfItemDelegate* delegate = model_->GetShelfItemDelegate(item.id); |
| 1372 if (item.type == ash::TYPE_APP_PANEL || !delegate || |
| 1373 delegate->image_set_by_controller() || |
| 1374 item.app_launch_id.app_id() != app_id) { |
| 1439 continue; | 1375 continue; |
| 1440 ash::ShelfItemDelegate* delegate = GetShelfItemDelegate(item.id); | 1376 } |
| 1441 if (!delegate || delegate->image_set_by_controller()) | |
| 1442 continue; | |
| 1443 item.image = image; | 1377 item.image = image; |
| 1444 if (arc_deferred_launcher_) | 1378 if (arc_deferred_launcher_) |
| 1445 arc_deferred_launcher_->MaybeApplySpinningEffect(id, &item.image); | 1379 arc_deferred_launcher_->MaybeApplySpinningEffect(app_id, &item.image); |
| 1446 model_->Set(index, item); | 1380 model_->Set(index, item); |
| 1447 // It's possible we're waiting on more than one item, so don't break. | 1381 // It's possible we're waiting on more than one item, so don't break. |
| 1448 } | 1382 } |
| 1449 } | 1383 } |
| OLD | NEW |