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 // For empty |app_id| tab, its state is udpated by UpdateBrowserItemState(). | |
Mr4D (OOO till 08-26)
2013/10/01 03:20:33
What about:
UpdateBrowserItemState will update th
simonhong_
2013/10/01 05:10:43
Done.
| |
839 if (app_id.empty()) | |
840 return; | |
841 | |
837 AppIDToWebContentsListMap::iterator i_app_id = | 842 AppIDToWebContentsListMap::iterator i_app_id = |
838 app_id_to_web_contents_list_.find(app_id); | 843 app_id_to_web_contents_list_.find(app_id); |
839 if (i_app_id != app_id_to_web_contents_list_.end()) { | 844 if (i_app_id != app_id_to_web_contents_list_.end()) { |
840 WebContentsList* tab_list = &i_app_id->second; | 845 WebContentsList* tab_list = &i_app_id->second; |
841 tab_list->remove(tab); | 846 tab_list->remove(tab); |
842 if (tab_list->empty()) { | 847 if (tab_list->empty()) { |
843 app_id_to_web_contents_list_.erase(i_app_id); | 848 app_id_to_web_contents_list_.erase(i_app_id); |
844 i_app_id = app_id_to_web_contents_list_.end(); | 849 i_app_id = app_id_to_web_contents_list_.end(); |
845 ash::LauncherID id = GetLauncherIDForAppID(app_id); | 850 ash::LauncherID id = GetLauncherIDForAppID(app_id); |
846 if (id) | 851 if (id) |
(...skipping 17 matching lines...) Expand all Loading... | |
864 std::string last_app_id = web_contents_to_app_id_[contents]; | 869 std::string last_app_id = web_contents_to_app_id_[contents]; |
865 if (last_app_id != app_id) | 870 if (last_app_id != app_id) |
866 RemoveTabFromRunningApp(contents, last_app_id); | 871 RemoveTabFromRunningApp(contents, last_app_id); |
867 } | 872 } |
868 | 873 |
869 web_contents_to_app_id_[contents] = app_id; | 874 web_contents_to_app_id_[contents] = app_id; |
870 | 875 |
871 if (app_state == APP_STATE_REMOVED) { | 876 if (app_state == APP_STATE_REMOVED) { |
872 // The tab has gone away. | 877 // The tab has gone away. |
873 RemoveTabFromRunningApp(contents, app_id); | 878 RemoveTabFromRunningApp(contents, app_id); |
874 } else { | 879 } else if (!app_id.empty()) { |
875 WebContentsList& tab_list(app_id_to_web_contents_list_[app_id]); | 880 WebContentsList& tab_list(app_id_to_web_contents_list_[app_id]); |
876 | 881 |
877 if (app_state == APP_STATE_INACTIVE) { | 882 if (app_state == APP_STATE_INACTIVE) { |
878 WebContentsList::const_iterator i_tab = | 883 WebContentsList::const_iterator i_tab = |
879 std::find(tab_list.begin(), tab_list.end(), contents); | 884 std::find(tab_list.begin(), tab_list.end(), contents); |
880 if (i_tab == tab_list.end()) | 885 if (i_tab == tab_list.end()) |
881 tab_list.push_back(contents); | 886 tab_list.push_back(contents); |
887 // TODO(simon.hong81): Does this below case exist? | |
882 if (i_tab != tab_list.begin()) { | 888 if (i_tab != tab_list.begin()) { |
883 // Going inactive, but wasn't the front tab, indicating that a new | 889 // Going inactive, but wasn't the front tab, indicating that a new |
884 // tab has already become active. | 890 // tab has already become active. |
885 return; | 891 return; |
886 } | 892 } |
887 } else { | 893 } else { |
888 tab_list.remove(contents); | 894 tab_list.remove(contents); |
889 tab_list.push_front(contents); | 895 tab_list.push_front(contents); |
890 } | 896 } |
891 ash::LauncherID id = GetLauncherIDForAppID(app_id); | 897 ash::LauncherID id = GetLauncherIDForAppID(app_id); |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1889 } | 1895 } |
1890 | 1896 |
1891 void ChromeLauncherController::ReleaseProfile() { | 1897 void ChromeLauncherController::ReleaseProfile() { |
1892 if (app_sync_ui_state_) | 1898 if (app_sync_ui_state_) |
1893 app_sync_ui_state_->RemoveObserver(this); | 1899 app_sync_ui_state_->RemoveObserver(this); |
1894 | 1900 |
1895 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); | 1901 PrefServiceSyncable::FromProfile(profile_)->RemoveObserver(this); |
1896 | 1902 |
1897 pref_change_registrar_.RemoveAll(); | 1903 pref_change_registrar_.RemoveAll(); |
1898 } | 1904 } |
OLD | NEW |