Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.cc

Issue 2771233002: Remove the wrapper functions content::RecordAction et al (Closed)
Patch Set: Rebased Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_macros.h" 10 #include "base/metrics/histogram_macros.h"
11 #include "base/metrics/user_metrics.h"
11 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "build/build_config.h" 14 #include "build/build_config.h"
14 #include "chrome/app/chrome_command_ids.h" 15 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/favicon/favicon_service_factory.h" 16 #include "chrome/browser/favicon/favicon_service_factory.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/search/search.h" 18 #include "chrome/browser/search/search.h"
18 #include "chrome/browser/sessions/session_restore.h" 19 #include "chrome/browser/sessions/session_restore.h"
19 #include "chrome/browser/sessions/tab_restore_service_factory.h" 20 #include "chrome/browser/sessions/tab_restore_service_factory.h"
20 #include "chrome/browser/sync/profile_sync_service_factory.h" 21 #include "chrome/browser/sync/profile_sync_service_factory.h"
21 #include "chrome/browser/ui/browser.h" 22 #include "chrome/browser/ui/browser.h"
22 #include "chrome/browser/ui/browser_commands.h" 23 #include "chrome/browser/ui/browser_commands.h"
23 #include "chrome/browser/ui/browser_live_tab_context.h" 24 #include "chrome/browser/ui/browser_live_tab_context.h"
24 #include "chrome/browser/ui/tabs/tab_strip_model.h" 25 #include "chrome/browser/ui/tabs/tab_strip_model.h"
25 #include "chrome/browser/ui/toolbar/app_menu_model.h" 26 #include "chrome/browser/ui/toolbar/app_menu_model.h"
26 #include "chrome/grit/browser_resources.h" 27 #include "chrome/grit/browser_resources.h"
27 #include "chrome/grit/generated_resources.h" 28 #include "chrome/grit/generated_resources.h"
28 #include "chrome/grit/theme_resources.h" 29 #include "chrome/grit/theme_resources.h"
29 #include "components/browser_sync/profile_sync_service.h" 30 #include "components/browser_sync/profile_sync_service.h"
30 #include "components/favicon_base/favicon_types.h" 31 #include "components/favicon_base/favicon_types.h"
31 #include "components/prefs/scoped_user_pref_update.h" 32 #include "components/prefs/scoped_user_pref_update.h"
32 #include "components/sessions/core/tab_restore_service.h" 33 #include "components/sessions/core/tab_restore_service.h"
33 #include "components/strings/grit/components_strings.h" 34 #include "components/strings/grit/components_strings.h"
34 #include "components/sync_sessions/open_tabs_ui_delegate.h" 35 #include "components/sync_sessions/open_tabs_ui_delegate.h"
35 #include "components/sync_sessions/synced_session.h" 36 #include "components/sync_sessions/synced_session.h"
36 #include "content/public/browser/user_metrics.h"
37 #include "ui/base/accelerators/accelerator.h" 37 #include "ui/base/accelerators/accelerator.h"
38 #include "ui/base/l10n/l10n_util.h" 38 #include "ui/base/l10n/l10n_util.h"
39 #include "ui/base/resource/resource_bundle.h" 39 #include "ui/base/resource/resource_bundle.h"
40 #include "ui/resources/grit/ui_resources.h" 40 #include "ui/resources/grit/ui_resources.h"
41 41
42 #if !defined(OS_MACOSX) 42 #if !defined(OS_MACOSX)
43 #include "chrome/app/vector_icons/vector_icons.h" 43 #include "chrome/app/vector_icons/vector_icons.h"
44 #include "ui/gfx/color_palette.h" 44 #include "ui/gfx/color_palette.h"
45 #include "ui/gfx/paint_vector_icon.h" 45 #include "ui/gfx/paint_vector_icon.h"
46 #endif 46 #endif
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 BrowserLiveTabContext::FindContextForWebContents( 304 BrowserLiveTabContext::FindContextForWebContents(
305 browser_->tab_strip_model()->GetActiveWebContents()); 305 browser_->tab_strip_model()->GetActiveWebContents());
306 if (IsTabModelCommandId(command_id)) { 306 if (IsTabModelCommandId(command_id)) {
307 TabNavigationItems* tab_items = NULL; 307 TabNavigationItems* tab_items = NULL;
308 int tab_items_idx = CommandIdToTabVectorIndex(command_id, &tab_items); 308 int tab_items_idx = CommandIdToTabVectorIndex(command_id, &tab_items);
309 const TabNavigationItem& item = (*tab_items)[tab_items_idx]; 309 const TabNavigationItem& item = (*tab_items)[tab_items_idx];
310 DCHECK(item.tab_id > -1 && item.url.is_valid()); 310 DCHECK(item.tab_id > -1 && item.url.is_valid());
311 311
312 if (item.session_tag.empty()) { // Restore tab of local session. 312 if (item.session_tag.empty()) { // Restore tab of local session.
313 if (service && context) { 313 if (service && context) {
314 content::RecordAction( 314 base::RecordAction(
315 base::UserMetricsAction("WrenchMenu_OpenRecentTabFromLocal")); 315 base::UserMetricsAction("WrenchMenu_OpenRecentTabFromLocal"));
316 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.RecentTabsSubMenu", 316 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.RecentTabsSubMenu",
317 LOCAL_SESSION_TAB, LIMIT_RECENT_TAB_ACTION); 317 LOCAL_SESSION_TAB, LIMIT_RECENT_TAB_ACTION);
318 service->RestoreEntryById(context, item.tab_id, disposition); 318 service->RestoreEntryById(context, item.tab_id, disposition);
319 } 319 }
320 } else { // Restore tab of session from other devices. 320 } else { // Restore tab of session from other devices.
321 sync_sessions::OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate(); 321 sync_sessions::OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate();
322 if (!open_tabs) 322 if (!open_tabs)
323 return; 323 return;
324 const sessions::SessionTab* tab; 324 const sessions::SessionTab* tab;
325 if (!open_tabs->GetForeignTab(item.session_tag, item.tab_id, &tab)) 325 if (!open_tabs->GetForeignTab(item.session_tag, item.tab_id, &tab))
326 return; 326 return;
327 if (tab->navigations.empty()) 327 if (tab->navigations.empty())
328 return; 328 return;
329 content::RecordAction( 329 base::RecordAction(
330 base::UserMetricsAction("WrenchMenu_OpenRecentTabFromDevice")); 330 base::UserMetricsAction("WrenchMenu_OpenRecentTabFromDevice"));
331 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.RecentTabsSubMenu", 331 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.RecentTabsSubMenu",
332 OTHER_DEVICE_TAB, LIMIT_RECENT_TAB_ACTION); 332 OTHER_DEVICE_TAB, LIMIT_RECENT_TAB_ACTION);
333 SessionRestore::RestoreForeignSessionTab( 333 SessionRestore::RestoreForeignSessionTab(
334 browser_->tab_strip_model()->GetActiveWebContents(), 334 browser_->tab_strip_model()->GetActiveWebContents(),
335 *tab, disposition); 335 *tab, disposition);
336 } 336 }
337 } else { 337 } else {
338 DCHECK(IsWindowModelCommandId(command_id)); 338 DCHECK(IsWindowModelCommandId(command_id));
339 if (service && context) { 339 if (service && context) {
340 int window_items_idx = CommandIdToWindowVectorIndex(command_id); 340 int window_items_idx = CommandIdToWindowVectorIndex(command_id);
341 DCHECK(window_items_idx >= 0 && 341 DCHECK(window_items_idx >= 0 &&
342 window_items_idx < static_cast<int>(local_window_items_.size())); 342 window_items_idx < static_cast<int>(local_window_items_.size()));
343 content::RecordAction( 343 base::RecordAction(
344 base::UserMetricsAction("WrenchMenu_OpenRecentWindow")); 344 base::UserMetricsAction("WrenchMenu_OpenRecentWindow"));
345 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.RecentTabsSubMenu", RESTORE_WINDOW, 345 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.RecentTabsSubMenu", RESTORE_WINDOW,
346 LIMIT_RECENT_TAB_ACTION); 346 LIMIT_RECENT_TAB_ACTION);
347 service->RestoreEntryById(context, local_window_items_[window_items_idx], 347 service->RestoreEntryById(context, local_window_items_[window_items_idx],
348 disposition); 348 disposition);
349 } 349 }
350 } 350 }
351 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.OpenRecentTab", 351 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.OpenRecentTab",
352 menu_opened_timer_.Elapsed()); 352 menu_opened_timer_.Elapsed());
353 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.MenuAction", MENU_ACTION_RECENT_TAB, 353 UMA_HISTOGRAM_ENUMERATION("WrenchMenu.MenuAction", MENU_ACTION_RECENT_TAB,
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 729
730 ui::MenuModelDelegate* menu_model_delegate = GetMenuModelDelegate(); 730 ui::MenuModelDelegate* menu_model_delegate = GetMenuModelDelegate();
731 if (menu_model_delegate) 731 if (menu_model_delegate)
732 menu_model_delegate->OnMenuStructureChanged(); 732 menu_model_delegate->OnMenuStructureChanged();
733 } 733 }
734 734
735 void RecentTabsSubMenuModel::TabRestoreServiceDestroyed( 735 void RecentTabsSubMenuModel::TabRestoreServiceDestroyed(
736 sessions::TabRestoreService* service) { 736 sessions::TabRestoreService* service) {
737 TabRestoreServiceChanged(service); 737 TabRestoreServiceChanged(service);
738 } 738 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/back_forward_menu_model.cc ('k') | chrome/browser/ui/uma_browsing_activity_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698