| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/toolbar/recent_tabs_sub_menu_model.h" | 5 #include "chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 int tab_items_idx = CommandIdToTabVectorIndex(command_id, &tab_items); | 302 int tab_items_idx = CommandIdToTabVectorIndex(command_id, &tab_items); |
| 303 const TabNavigationItem& item = (*tab_items)[tab_items_idx]; | 303 const TabNavigationItem& item = (*tab_items)[tab_items_idx]; |
| 304 DCHECK(item.tab_id > -1 && item.url.is_valid()); | 304 DCHECK(item.tab_id > -1 && item.url.is_valid()); |
| 305 | 305 |
| 306 if (item.session_tag.empty()) { // Restore tab of local session. | 306 if (item.session_tag.empty()) { // Restore tab of local session. |
| 307 if (service && context) { | 307 if (service && context) { |
| 308 content::RecordAction( | 308 content::RecordAction( |
| 309 base::UserMetricsAction("WrenchMenu_OpenRecentTabFromLocal")); | 309 base::UserMetricsAction("WrenchMenu_OpenRecentTabFromLocal")); |
| 310 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.RecentTabsSubMenu", | 310 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.RecentTabsSubMenu", |
| 311 LOCAL_SESSION_TAB, LIMIT_RECENT_TAB_ACTION); | 311 LOCAL_SESSION_TAB, LIMIT_RECENT_TAB_ACTION); |
| 312 service->RestoreEntryById(context, item.tab_id, | 312 service->RestoreEntryById(context, item.tab_id, disposition); |
| 313 browser_->host_desktop_type(), disposition); | |
| 314 } | 313 } |
| 315 } else { // Restore tab of session from other devices. | 314 } else { // Restore tab of session from other devices. |
| 316 sync_driver::OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate(); | 315 sync_driver::OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate(); |
| 317 if (!open_tabs) | 316 if (!open_tabs) |
| 318 return; | 317 return; |
| 319 const sessions::SessionTab* tab; | 318 const sessions::SessionTab* tab; |
| 320 if (!open_tabs->GetForeignTab(item.session_tag, item.tab_id, &tab)) | 319 if (!open_tabs->GetForeignTab(item.session_tag, item.tab_id, &tab)) |
| 321 return; | 320 return; |
| 322 if (tab->navigations.empty()) | 321 if (tab->navigations.empty()) |
| 323 return; | 322 return; |
| 324 content::RecordAction( | 323 content::RecordAction( |
| 325 base::UserMetricsAction("WrenchMenu_OpenRecentTabFromDevice")); | 324 base::UserMetricsAction("WrenchMenu_OpenRecentTabFromDevice")); |
| 326 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.RecentTabsSubMenu", | 325 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.RecentTabsSubMenu", |
| 327 OTHER_DEVICE_TAB, LIMIT_RECENT_TAB_ACTION); | 326 OTHER_DEVICE_TAB, LIMIT_RECENT_TAB_ACTION); |
| 328 SessionRestore::RestoreForeignSessionTab( | 327 SessionRestore::RestoreForeignSessionTab( |
| 329 browser_->tab_strip_model()->GetActiveWebContents(), | 328 browser_->tab_strip_model()->GetActiveWebContents(), |
| 330 *tab, disposition); | 329 *tab, disposition); |
| 331 } | 330 } |
| 332 } else { | 331 } else { |
| 333 DCHECK(IsWindowModelCommandId(command_id)); | 332 DCHECK(IsWindowModelCommandId(command_id)); |
| 334 if (service && context) { | 333 if (service && context) { |
| 335 int window_items_idx = CommandIdToWindowVectorIndex(command_id); | 334 int window_items_idx = CommandIdToWindowVectorIndex(command_id); |
| 336 DCHECK(window_items_idx >= 0 && | 335 DCHECK(window_items_idx >= 0 && |
| 337 window_items_idx < static_cast<int>(local_window_items_.size())); | 336 window_items_idx < static_cast<int>(local_window_items_.size())); |
| 338 content::RecordAction( | 337 content::RecordAction( |
| 339 base::UserMetricsAction("WrenchMenu_OpenRecentWindow")); | 338 base::UserMetricsAction("WrenchMenu_OpenRecentWindow")); |
| 340 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.RecentTabsSubMenu", RESTORE_WINDOW, | 339 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.RecentTabsSubMenu", RESTORE_WINDOW, |
| 341 LIMIT_RECENT_TAB_ACTION); | 340 LIMIT_RECENT_TAB_ACTION); |
| 342 service->RestoreEntryById(context, local_window_items_[window_items_idx], | 341 service->RestoreEntryById(context, local_window_items_[window_items_idx], |
| 343 browser_->host_desktop_type(), disposition); | 342 disposition); |
| 344 } | 343 } |
| 345 } | 344 } |
| 346 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.OpenRecentTab", | 345 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.OpenRecentTab", |
| 347 menu_opened_timer_.Elapsed()); | 346 menu_opened_timer_.Elapsed()); |
| 348 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.MenuAction", MENU_ACTION_RECENT_TAB, | 347 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.MenuAction", MENU_ACTION_RECENT_TAB, |
| 349 LIMIT_MENU_ACTION); | 348 LIMIT_MENU_ACTION); |
| 350 } | 349 } |
| 351 | 350 |
| 352 int RecentTabsSubMenuModel::GetFirstRecentTabsCommandId() { | 351 int RecentTabsSubMenuModel::GetFirstRecentTabsCommandId() { |
| 353 return WindowVectorIndexToCommandId(0); | 352 return WindowVectorIndexToCommandId(0); |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 722 | 721 |
| 723 ui::MenuModelDelegate* menu_model_delegate = GetMenuModelDelegate(); | 722 ui::MenuModelDelegate* menu_model_delegate = GetMenuModelDelegate(); |
| 724 if (menu_model_delegate) | 723 if (menu_model_delegate) |
| 725 menu_model_delegate->OnMenuStructureChanged(); | 724 menu_model_delegate->OnMenuStructureChanged(); |
| 726 } | 725 } |
| 727 | 726 |
| 728 void RecentTabsSubMenuModel::TabRestoreServiceDestroyed( | 727 void RecentTabsSubMenuModel::TabRestoreServiceDestroyed( |
| 729 sessions::TabRestoreService* service) { | 728 sessions::TabRestoreService* service) { |
| 730 TabRestoreServiceChanged(service); | 729 TabRestoreServiceChanged(service); |
| 731 } | 730 } |
| OLD | NEW |