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.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/launcher/launcher.h" | 10 #include "ash/launcher/launcher.h" |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 app_id, | 338 app_id, |
339 status, | 339 status, |
340 index, | 340 index, |
341 controller->GetLauncherItemType()); | 341 controller->GetLauncherItemType()); |
342 } | 342 } |
343 | 343 |
344 void ChromeLauncherController::SetItemStatus( | 344 void ChromeLauncherController::SetItemStatus( |
345 ash::LauncherID id, | 345 ash::LauncherID id, |
346 ash::LauncherItemStatus status) { | 346 ash::LauncherItemStatus status) { |
347 int index = model_->ItemIndexByID(id); | 347 int index = model_->ItemIndexByID(id); |
| 348 ash::LauncherItemStatus old_status = model_->items()[index].status; |
348 // Since ordinary browser windows are not registered, we might get a negative | 349 // Since ordinary browser windows are not registered, we might get a negative |
349 // index here. | 350 // index here. |
350 if (index >= 0) { | 351 if (index >= 0 && old_status != status) { |
351 ash::LauncherItem item = model_->items()[index]; | 352 ash::LauncherItem item = model_->items()[index]; |
352 item.status = status; | 353 item.status = status; |
353 model_->Set(index, item); | 354 model_->Set(index, item); |
354 } | 355 } |
355 } | 356 } |
356 | 357 |
357 void ChromeLauncherController::SetItemController( | 358 void ChromeLauncherController::SetItemController( |
358 ash::LauncherID id, | 359 ash::LauncherID id, |
359 LauncherItemController* controller) { | 360 LauncherItemController* controller) { |
360 CHECK(controller); | 361 CHECK(controller); |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER : | 780 ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER : |
780 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; | 781 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; |
781 SetShelfAutoHideBehaviorPrefs(behavior, root_window); | 782 SetShelfAutoHideBehaviorPrefs(behavior, root_window); |
782 return; | 783 return; |
783 } | 784 } |
784 | 785 |
785 void ChromeLauncherController::RemoveTabFromRunningApp( | 786 void ChromeLauncherController::RemoveTabFromRunningApp( |
786 WebContents* tab, | 787 WebContents* tab, |
787 const std::string& app_id) { | 788 const std::string& app_id) { |
788 web_contents_to_app_id_.erase(tab); | 789 web_contents_to_app_id_.erase(tab); |
| 790 // For empty |app_id| tab, its state is udpated by UpdateBrowserItemState(). |
| 791 if (app_id.empty()) |
| 792 return; |
| 793 |
789 AppIDToWebContentsListMap::iterator i_app_id = | 794 AppIDToWebContentsListMap::iterator i_app_id = |
790 app_id_to_web_contents_list_.find(app_id); | 795 app_id_to_web_contents_list_.find(app_id); |
791 if (i_app_id != app_id_to_web_contents_list_.end()) { | 796 if (i_app_id != app_id_to_web_contents_list_.end()) { |
792 WebContentsList* tab_list = &i_app_id->second; | 797 WebContentsList* tab_list = &i_app_id->second; |
793 tab_list->remove(tab); | 798 tab_list->remove(tab); |
794 if (tab_list->empty()) { | 799 if (tab_list->empty()) { |
795 app_id_to_web_contents_list_.erase(i_app_id); | 800 app_id_to_web_contents_list_.erase(i_app_id); |
796 i_app_id = app_id_to_web_contents_list_.end(); | 801 i_app_id = app_id_to_web_contents_list_.end(); |
797 ash::LauncherID id = GetLauncherIDForAppID(app_id); | 802 ash::LauncherID id = GetLauncherIDForAppID(app_id); |
798 if (id) | 803 if (id) |
(...skipping 17 matching lines...) Expand all Loading... |
816 std::string last_app_id = web_contents_to_app_id_[contents]; | 821 std::string last_app_id = web_contents_to_app_id_[contents]; |
817 if (last_app_id != app_id) | 822 if (last_app_id != app_id) |
818 RemoveTabFromRunningApp(contents, last_app_id); | 823 RemoveTabFromRunningApp(contents, last_app_id); |
819 } | 824 } |
820 | 825 |
821 web_contents_to_app_id_[contents] = app_id; | 826 web_contents_to_app_id_[contents] = app_id; |
822 | 827 |
823 if (app_state == APP_STATE_REMOVED) { | 828 if (app_state == APP_STATE_REMOVED) { |
824 // The tab has gone away. | 829 // The tab has gone away. |
825 RemoveTabFromRunningApp(contents, app_id); | 830 RemoveTabFromRunningApp(contents, app_id); |
826 } else { | 831 } else if (!app_id.empty()) { |
827 WebContentsList& tab_list(app_id_to_web_contents_list_[app_id]); | 832 WebContentsList& tab_list(app_id_to_web_contents_list_[app_id]); |
828 | 833 |
829 if (app_state == APP_STATE_INACTIVE) { | 834 if (app_state == APP_STATE_INACTIVE) { |
830 WebContentsList::const_iterator i_tab = | 835 WebContentsList::const_iterator i_tab = |
831 std::find(tab_list.begin(), tab_list.end(), contents); | 836 std::find(tab_list.begin(), tab_list.end(), contents); |
832 if (i_tab == tab_list.end()) | 837 if (i_tab == tab_list.end()) |
833 tab_list.push_back(contents); | 838 tab_list.push_back(contents); |
| 839 // TODO(simon.hong81): Does this below case exist? |
834 if (i_tab != tab_list.begin()) { | 840 if (i_tab != tab_list.begin()) { |
835 // Going inactive, but wasn't the front tab, indicating that a new | 841 // Going inactive, but wasn't the front tab, indicating that a new |
836 // tab has already become active. | 842 // tab has already become active. |
837 return; | 843 return; |
838 } | 844 } |
839 } else { | 845 } else { |
840 tab_list.remove(contents); | 846 tab_list.remove(contents); |
841 tab_list.push_front(contents); | 847 tab_list.push_front(contents); |
842 } | 848 } |
843 ash::LauncherID id = GetLauncherIDForAppID(app_id); | 849 ash::LauncherID id = GetLauncherIDForAppID(app_id); |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 // TODO(simon.hong81): Register LauncherItemDelegate when LauncherItemDelegate | 1592 // TODO(simon.hong81): Register LauncherItemDelegate when LauncherItemDelegate |
1587 // is created. | 1593 // is created. |
1588 ash::LauncherItemDelegateManager* manager = | 1594 ash::LauncherItemDelegateManager* manager = |
1589 ash::Shell::GetInstance()->launcher_item_delegate_manager(); | 1595 ash::Shell::GetInstance()->launcher_item_delegate_manager(); |
1590 manager->RegisterLauncherItemDelegate(ash::TYPE_APP_PANEL, this); | 1596 manager->RegisterLauncherItemDelegate(ash::TYPE_APP_PANEL, this); |
1591 manager->RegisterLauncherItemDelegate(ash::TYPE_APP_SHORTCUT, this); | 1597 manager->RegisterLauncherItemDelegate(ash::TYPE_APP_SHORTCUT, this); |
1592 manager->RegisterLauncherItemDelegate(ash::TYPE_BROWSER_SHORTCUT, this); | 1598 manager->RegisterLauncherItemDelegate(ash::TYPE_BROWSER_SHORTCUT, this); |
1593 manager->RegisterLauncherItemDelegate(ash::TYPE_PLATFORM_APP, this); | 1599 manager->RegisterLauncherItemDelegate(ash::TYPE_PLATFORM_APP, this); |
1594 manager->RegisterLauncherItemDelegate(ash::TYPE_WINDOWED_APP, this); | 1600 manager->RegisterLauncherItemDelegate(ash::TYPE_WINDOWED_APP, this); |
1595 } | 1601 } |
OLD | NEW |