OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/app_menu_model.h" | 5 #include "chrome/browser/ui/toolbar/app_menu_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/debug/debugging_flags.h" | 11 #include "base/debug/debugging_flags.h" |
12 #include "base/debug/profiler.h" | 12 #include "base/debug/profiler.h" |
13 #include "base/i18n/number_formatting.h" | 13 #include "base/i18n/number_formatting.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 16 #include "base/metrics/user_metrics.h" |
16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
18 #include "build/build_config.h" | 19 #include "build/build_config.h" |
19 #include "chrome/app/chrome_command_ids.h" | 20 #include "chrome/app/chrome_command_ids.h" |
20 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/defaults.h" | 22 #include "chrome/browser/defaults.h" |
22 #include "chrome/browser/extensions/extension_util.h" | 23 #include "chrome/browser/extensions/extension_util.h" |
23 #include "chrome/browser/media/router/media_router_feature.h" | 24 #include "chrome/browser/media/router/media_router_feature.h" |
24 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 25 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
25 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
(...skipping 26 matching lines...) Expand all Loading... |
52 #include "components/signin/core/browser/signin_manager.h" | 53 #include "components/signin/core/browser/signin_manager.h" |
53 #include "components/signin/core/common/profile_management_switches.h" | 54 #include "components/signin/core/common/profile_management_switches.h" |
54 #include "components/strings/grit/components_strings.h" | 55 #include "components/strings/grit/components_strings.h" |
55 #include "components/zoom/zoom_controller.h" | 56 #include "components/zoom/zoom_controller.h" |
56 #include "components/zoom/zoom_event_manager.h" | 57 #include "components/zoom/zoom_event_manager.h" |
57 #include "content/public/browser/host_zoom_map.h" | 58 #include "content/public/browser/host_zoom_map.h" |
58 #include "content/public/browser/navigation_entry.h" | 59 #include "content/public/browser/navigation_entry.h" |
59 #include "content/public/browser/notification_service.h" | 60 #include "content/public/browser/notification_service.h" |
60 #include "content/public/browser/notification_source.h" | 61 #include "content/public/browser/notification_source.h" |
61 #include "content/public/browser/notification_types.h" | 62 #include "content/public/browser/notification_types.h" |
62 #include "content/public/browser/user_metrics.h" | |
63 #include "content/public/browser/web_contents.h" | 63 #include "content/public/browser/web_contents.h" |
64 #include "ui/base/l10n/l10n_util.h" | 64 #include "ui/base/l10n/l10n_util.h" |
65 #include "ui/base/layout.h" | 65 #include "ui/base/layout.h" |
66 #include "ui/base/models/button_menu_item_model.h" | 66 #include "ui/base/models/button_menu_item_model.h" |
67 #include "ui/base/resource/resource_bundle.h" | 67 #include "ui/base/resource/resource_bundle.h" |
68 #include "ui/gfx/image/image.h" | 68 #include "ui/gfx/image/image.h" |
69 #include "ui/gfx/image/image_skia.h" | 69 #include "ui/gfx/image/image_skia.h" |
70 | 70 |
71 #if defined(OS_CHROMEOS) | 71 #if defined(OS_CHROMEOS) |
72 #include "chromeos/chromeos_switches.h" | 72 #include "chromeos/chromeos_switches.h" |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 LogMenuAction(MENU_ACTION_ZOOM_MINUS); | 503 LogMenuAction(MENU_ACTION_ZOOM_MINUS); |
504 } | 504 } |
505 break; | 505 break; |
506 case IDC_ZOOM_PLUS: | 506 case IDC_ZOOM_PLUS: |
507 if (!uma_action_recorded_) { | 507 if (!uma_action_recorded_) { |
508 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.ZoomPlus", delta); | 508 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.ZoomPlus", delta); |
509 LogMenuAction(MENU_ACTION_ZOOM_PLUS); | 509 LogMenuAction(MENU_ACTION_ZOOM_PLUS); |
510 } | 510 } |
511 break; | 511 break; |
512 case IDC_FULLSCREEN: | 512 case IDC_FULLSCREEN: |
513 content::RecordAction(UserMetricsAction("EnterFullScreenWithWrenchMenu")); | 513 base::RecordAction(UserMetricsAction("EnterFullScreenWithWrenchMenu")); |
514 | 514 |
515 if (!uma_action_recorded_) { | 515 if (!uma_action_recorded_) { |
516 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.EnterFullScreen", | 516 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.EnterFullScreen", |
517 delta); | 517 delta); |
518 } | 518 } |
519 LogMenuAction(MENU_ACTION_FULLSCREEN); | 519 LogMenuAction(MENU_ACTION_FULLSCREEN); |
520 break; | 520 break; |
521 | 521 |
522 case IDC_SHOW_HISTORY: | 522 case IDC_SHOW_HISTORY: |
523 if (!uma_action_recorded_) { | 523 if (!uma_action_recorded_) { |
(...skipping 22 matching lines...) Expand all Loading... |
546 LogMenuAction(MENU_ACTION_OPTIONS); | 546 LogMenuAction(MENU_ACTION_OPTIONS); |
547 break; | 547 break; |
548 case IDC_ABOUT: | 548 case IDC_ABOUT: |
549 if (!uma_action_recorded_) | 549 if (!uma_action_recorded_) |
550 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.About", delta); | 550 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.About", delta); |
551 LogMenuAction(MENU_ACTION_ABOUT); | 551 LogMenuAction(MENU_ACTION_ABOUT); |
552 break; | 552 break; |
553 | 553 |
554 // Help menu. | 554 // Help menu. |
555 case IDC_HELP_PAGE_VIA_MENU: | 555 case IDC_HELP_PAGE_VIA_MENU: |
556 content::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu")); | 556 base::RecordAction(UserMetricsAction("ShowHelpTabViaWrenchMenu")); |
557 | 557 |
558 if (!uma_action_recorded_) | 558 if (!uma_action_recorded_) |
559 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.HelpPage", delta); | 559 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.HelpPage", delta); |
560 LogMenuAction(MENU_ACTION_HELP_PAGE_VIA_MENU); | 560 LogMenuAction(MENU_ACTION_HELP_PAGE_VIA_MENU); |
561 break; | 561 break; |
562 #if defined(GOOGLE_CHROME_BUILD) | 562 #if defined(GOOGLE_CHROME_BUILD) |
563 case IDC_FEEDBACK: | 563 case IDC_FEEDBACK: |
564 if (!uma_action_recorded_) | 564 if (!uma_action_recorded_) |
565 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.Feedback", delta); | 565 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.Feedback", delta); |
566 LogMenuAction(MENU_ACTION_FEEDBACK); | 566 LogMenuAction(MENU_ACTION_FEEDBACK); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 for (GlobalErrorService::GlobalErrorList::const_iterator | 785 for (GlobalErrorService::GlobalErrorList::const_iterator |
786 it = errors.begin(); it != errors.end(); ++it) { | 786 it = errors.begin(); it != errors.end(); ++it) { |
787 GlobalError* error = *it; | 787 GlobalError* error = *it; |
788 DCHECK(error); | 788 DCHECK(error); |
789 if (error->HasMenuItem()) { | 789 if (error->HasMenuItem()) { |
790 AddItem(error->MenuItemCommandID(), error->MenuItemLabel()); | 790 AddItem(error->MenuItemCommandID(), error->MenuItemLabel()); |
791 SetIcon(GetIndexOfCommandId(error->MenuItemCommandID()), | 791 SetIcon(GetIndexOfCommandId(error->MenuItemCommandID()), |
792 error->MenuItemIcon()); | 792 error->MenuItemIcon()); |
793 menu_items_added = true; | 793 menu_items_added = true; |
794 if (IDC_SHOW_SIGNIN_ERROR == error->MenuItemCommandID()) { | 794 if (IDC_SHOW_SIGNIN_ERROR == error->MenuItemCommandID()) { |
795 content::RecordAction( | 795 base::RecordAction( |
796 base::UserMetricsAction("Signin_Impression_FromMenu")); | 796 base::UserMetricsAction("Signin_Impression_FromMenu")); |
797 } | 797 } |
798 } | 798 } |
799 } | 799 } |
800 return menu_items_added; | 800 return menu_items_added; |
801 } | 801 } |
802 | 802 |
803 void AppMenuModel::CreateActionToolbarOverflowMenu() { | 803 void AppMenuModel::CreateActionToolbarOverflowMenu() { |
804 // We only add the extensions overflow container if there are any icons that | 804 // We only add the extensions overflow container if there are any icons that |
805 // aren't shown in the main container. | 805 // aren't shown in the main container. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 browser_->tab_strip_model()->GetActiveWebContents()) | 863 browser_->tab_strip_model()->GetActiveWebContents()) |
864 ->GetZoomPercent(); | 864 ->GetZoomPercent(); |
865 } | 865 } |
866 zoom_label_ = base::FormatPercent(zoom_percent); | 866 zoom_label_ = base::FormatPercent(zoom_percent); |
867 } | 867 } |
868 | 868 |
869 void AppMenuModel::OnZoomLevelChanged( | 869 void AppMenuModel::OnZoomLevelChanged( |
870 const content::HostZoomMap::ZoomLevelChange& change) { | 870 const content::HostZoomMap::ZoomLevelChange& change) { |
871 UpdateZoomControls(); | 871 UpdateZoomControls(); |
872 } | 872 } |
OLD | NEW |