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/desktop_background/desktop_background_controller.h" | 10 #include "ash/desktop_background/desktop_background_controller.h" |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 app_id, | 383 app_id, |
384 status, | 384 status, |
385 index, | 385 index, |
386 controller->GetLauncherItemType()); | 386 controller->GetLauncherItemType()); |
387 } | 387 } |
388 | 388 |
389 void ChromeLauncherController::SetItemStatus( | 389 void ChromeLauncherController::SetItemStatus( |
390 ash::LauncherID id, | 390 ash::LauncherID id, |
391 ash::LauncherItemStatus status) { | 391 ash::LauncherItemStatus status) { |
392 int index = model_->ItemIndexByID(id); | 392 int index = model_->ItemIndexByID(id); |
| 393 ash::LauncherItemStatus old_status = model_->items()[index].status; |
393 // Since ordinary browser windows are not registered, we might get a negative | 394 // Since ordinary browser windows are not registered, we might get a negative |
394 // index here. | 395 // index here. |
395 if (index >= 0) { | 396 if (index >= 0 && old_status != status) { |
396 ash::LauncherItem item = model_->items()[index]; | 397 ash::LauncherItem item = model_->items()[index]; |
397 item.status = status; | 398 item.status = status; |
398 model_->Set(index, item); | 399 model_->Set(index, item); |
399 } | 400 } |
400 } | 401 } |
401 | 402 |
402 void ChromeLauncherController::SetItemController( | 403 void ChromeLauncherController::SetItemController( |
403 ash::LauncherID id, | 404 ash::LauncherID id, |
404 LauncherItemController* controller) { | 405 LauncherItemController* controller) { |
405 CHECK(controller); | 406 CHECK(controller); |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER : | 828 ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER : |
828 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; | 829 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; |
829 SetShelfAutoHideBehaviorPrefs(behavior, root_window); | 830 SetShelfAutoHideBehaviorPrefs(behavior, root_window); |
830 return; | 831 return; |
831 } | 832 } |
832 | 833 |
833 void ChromeLauncherController::RemoveTabFromRunningApp( | 834 void ChromeLauncherController::RemoveTabFromRunningApp( |
834 WebContents* tab, | 835 WebContents* tab, |
835 const std::string& app_id) { | 836 const std::string& app_id) { |
836 web_contents_to_app_id_.erase(tab); | 837 web_contents_to_app_id_.erase(tab); |
| 838 // BrowserShortcutLauncherItemController::UpdateBrowserItemState() will update |
| 839 // the state when no application is associated with the tab. |
| 840 if (app_id.empty()) |
| 841 return; |
| 842 |
837 AppIDToWebContentsListMap::iterator i_app_id = | 843 AppIDToWebContentsListMap::iterator i_app_id = |
838 app_id_to_web_contents_list_.find(app_id); | 844 app_id_to_web_contents_list_.find(app_id); |
839 if (i_app_id != app_id_to_web_contents_list_.end()) { | 845 if (i_app_id != app_id_to_web_contents_list_.end()) { |
840 WebContentsList* tab_list = &i_app_id->second; | 846 WebContentsList* tab_list = &i_app_id->second; |
841 tab_list->remove(tab); | 847 tab_list->remove(tab); |
842 if (tab_list->empty()) { | 848 if (tab_list->empty()) { |
843 app_id_to_web_contents_list_.erase(i_app_id); | 849 app_id_to_web_contents_list_.erase(i_app_id); |
844 i_app_id = app_id_to_web_contents_list_.end(); | 850 i_app_id = app_id_to_web_contents_list_.end(); |
845 ash::LauncherID id = GetLauncherIDForAppID(app_id); | 851 ash::LauncherID id = GetLauncherIDForAppID(app_id); |
846 if (id) | 852 if (id) |
(...skipping 17 matching lines...) Expand all Loading... |
864 std::string last_app_id = web_contents_to_app_id_[contents]; | 870 std::string last_app_id = web_contents_to_app_id_[contents]; |
865 if (last_app_id != app_id) | 871 if (last_app_id != app_id) |
866 RemoveTabFromRunningApp(contents, last_app_id); | 872 RemoveTabFromRunningApp(contents, last_app_id); |
867 } | 873 } |
868 | 874 |
869 web_contents_to_app_id_[contents] = app_id; | 875 web_contents_to_app_id_[contents] = app_id; |
870 | 876 |
871 if (app_state == APP_STATE_REMOVED) { | 877 if (app_state == APP_STATE_REMOVED) { |
872 // The tab has gone away. | 878 // The tab has gone away. |
873 RemoveTabFromRunningApp(contents, app_id); | 879 RemoveTabFromRunningApp(contents, app_id); |
874 } else { | 880 } else if (!app_id.empty()) { |
875 WebContentsList& tab_list(app_id_to_web_contents_list_[app_id]); | 881 WebContentsList& tab_list(app_id_to_web_contents_list_[app_id]); |
876 | 882 |
877 if (app_state == APP_STATE_INACTIVE) { | 883 if (app_state == APP_STATE_INACTIVE) { |
878 WebContentsList::const_iterator i_tab = | 884 WebContentsList::const_iterator i_tab = |
879 std::find(tab_list.begin(), tab_list.end(), contents); | 885 std::find(tab_list.begin(), tab_list.end(), contents); |
880 if (i_tab == tab_list.end()) | 886 if (i_tab == tab_list.end()) |
881 tab_list.push_back(contents); | 887 tab_list.push_back(contents); |
| 888 // TODO(simon.hong81): Does this below case exist? |
882 if (i_tab != tab_list.begin()) { | 889 if (i_tab != tab_list.begin()) { |
883 // Going inactive, but wasn't the front tab, indicating that a new | 890 // Going inactive, but wasn't the front tab, indicating that a new |
884 // tab has already become active. | 891 // tab has already become active. |
885 return; | 892 return; |
886 } | 893 } |
887 } else { | 894 } else { |
888 tab_list.remove(contents); | 895 tab_list.remove(contents); |
889 tab_list.push_front(contents); | 896 tab_list.push_front(contents); |
890 } | 897 } |
891 ash::LauncherID id = GetLauncherIDForAppID(app_id); | 898 ash::LauncherID id = GetLauncherIDForAppID(app_id); |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1889 } | 1896 } |
1890 | 1897 |
1891 void ChromeLauncherController::ReleaseProfile() { | 1898 void ChromeLauncherController::ReleaseProfile() { |
1892 if (app_sync_ui_state_) | 1899 if (app_sync_ui_state_) |
1893 app_sync_ui_state_->RemoveObserver(this); | 1900 app_sync_ui_state_->RemoveObserver(this); |
1894 | 1901 |
1895 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); | 1902 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); |
1896 | 1903 |
1897 pref_change_registrar_.RemoveAll(); | 1904 pref_change_registrar_.RemoveAll(); |
1898 } | 1905 } |
OLD | NEW |