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

Side by Side Diff: chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm

Issue 2771233002: Remove the wrapper functions content::RecordAction et al (Closed)
Patch Set: Rebased Created 3 years, 9 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 (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 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 5 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
6 6
7 #import <QuartzCore/QuartzCore.h> 7 #import <QuartzCore/QuartzCore.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <limits> 10 #include <limits>
11 #include <string> 11 #include <string>
12 12
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/mac/mac_util.h" 14 #include "base/mac/mac_util.h"
15 #include "base/mac/scoped_nsautorelease_pool.h" 15 #include "base/mac/scoped_nsautorelease_pool.h"
16 #include "base/mac/sdk_forward_declarations.h" 16 #include "base/mac/sdk_forward_declarations.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/metrics/histogram_macros.h" 18 #include "base/metrics/histogram_macros.h"
19 #include "base/metrics/user_metrics.h"
19 #include "base/strings/sys_string_conversions.h" 20 #include "base/strings/sys_string_conversions.h"
20 #include "chrome/app/chrome_command_ids.h" 21 #include "chrome/app/chrome_command_ids.h"
21 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" 22 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
22 #include "chrome/browser/extensions/tab_helper.h" 23 #include "chrome/browser/extensions/tab_helper.h"
23 #include "chrome/browser/favicon/favicon_utils.h" 24 #include "chrome/browser/favicon/favicon_utils.h"
24 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/profiles/profile_manager.h" 26 #include "chrome/browser/profiles/profile_manager.h"
26 #include "chrome/browser/themes/theme_service.h" 27 #include "chrome/browser/themes/theme_service.h"
27 #include "chrome/browser/ui/browser.h" 28 #include "chrome/browser/ui/browser.h"
28 #include "chrome/browser/ui/browser_navigator.h" 29 #include "chrome/browser/ui/browser_navigator.h"
(...skipping 23 matching lines...) Expand all
52 #include "chrome/grit/generated_resources.h" 53 #include "chrome/grit/generated_resources.h"
53 #include "chrome/grit/theme_resources.h" 54 #include "chrome/grit/theme_resources.h"
54 #include "components/grit/components_scaled_resources.h" 55 #include "components/grit/components_scaled_resources.h"
55 #include "components/metrics/proto/omnibox_event.pb.h" 56 #include "components/metrics/proto/omnibox_event.pb.h"
56 #include "components/omnibox/browser/autocomplete_classifier.h" 57 #include "components/omnibox/browser/autocomplete_classifier.h"
57 #include "components/omnibox/browser/autocomplete_match.h" 58 #include "components/omnibox/browser/autocomplete_match.h"
58 #include "components/prefs/pref_service.h" 59 #include "components/prefs/pref_service.h"
59 #include "components/url_formatter/url_fixer.h" 60 #include "components/url_formatter/url_fixer.h"
60 #include "components/web_modal/web_contents_modal_dialog_manager.h" 61 #include "components/web_modal/web_contents_modal_dialog_manager.h"
61 #include "content/public/browser/navigation_controller.h" 62 #include "content/public/browser/navigation_controller.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 "skia/ext/skia_utils_mac.h" 64 #include "skia/ext/skia_utils_mac.h"
65 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h " 65 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h "
66 #include "ui/base/cocoa/animation_utils.h" 66 #include "ui/base/cocoa/animation_utils.h"
67 #include "ui/base/cocoa/cocoa_base_utils.h" 67 #include "ui/base/cocoa/cocoa_base_utils.h"
68 #import "ui/base/cocoa/tracking_area.h" 68 #import "ui/base/cocoa/tracking_area.h"
69 #include "ui/base/l10n/l10n_util.h" 69 #include "ui/base/l10n/l10n_util.h"
70 #include "ui/base/material_design/material_design_controller.h" 70 #include "ui/base/material_design/material_design_controller.h"
71 #include "ui/base/models/list_selection_model.h" 71 #include "ui/base/models/list_selection_model.h"
72 #include "ui/base/resource/resource_bundle.h" 72 #include "ui/base/resource/resource_bundle.h"
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 TabController* controller = [[[TabController alloc] init] autorelease]; 631 TabController* controller = [[[TabController alloc] init] autorelease];
632 [controller setTarget:self]; 632 [controller setTarget:self];
633 [controller setAction:@selector(selectTab:)]; 633 [controller setAction:@selector(selectTab:)];
634 [[controller view] setHidden:YES]; 634 [[controller view] setHidden:YES];
635 635
636 return controller; 636 return controller;
637 } 637 }
638 638
639 // (Private) Handles a click on the new tab button. 639 // (Private) Handles a click on the new tab button.
640 - (void)clickNewTabButton:(id)sender { 640 - (void)clickNewTabButton:(id)sender {
641 content::RecordAction(UserMetricsAction("NewTab_Button")); 641 base::RecordAction(UserMetricsAction("NewTab_Button"));
642 UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", TabStripModel::NEW_TAB_BUTTON, 642 UMA_HISTOGRAM_ENUMERATION("Tab.NewTab", TabStripModel::NEW_TAB_BUTTON,
643 TabStripModel::NEW_TAB_ENUM_COUNT); 643 TabStripModel::NEW_TAB_ENUM_COUNT);
644 tabStripModel_->delegate()->AddTabAt(GURL(), -1, true); 644 tabStripModel_->delegate()->AddTabAt(GURL(), -1, true);
645 } 645 }
646 646
647 // (Private) Returns the number of open tabs in the tab strip. This is the 647 // (Private) Returns the number of open tabs in the tab strip. This is the
648 // number of TabControllers we know about (as there's a 1-to-1 mapping from 648 // number of TabControllers we know about (as there's a 1-to-1 mapping from
649 // these controllers to a tab) less the number of closing tabs. 649 // these controllers to a tab) less the number of closing tabs.
650 - (NSInteger)numberOfOpenTabs { 650 - (NSInteger)numberOfOpenTabs {
651 return static_cast<NSInteger>(tabStripModel_->count()); 651 return static_cast<NSInteger>(tabStripModel_->count());
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 // Cancel any pending tab transition. 807 // Cancel any pending tab transition.
808 hoverTabSelector_->CancelTabTransition(); 808 hoverTabSelector_->CancelTabTransition();
809 809
810 if ([hoveredTab_ isEqual:sender]) 810 if ([hoveredTab_ isEqual:sender])
811 [self setHoveredTab:nil]; 811 [self setHoveredTab:nil];
812 812
813 NSInteger index = [self modelIndexForTabView:sender]; 813 NSInteger index = [self modelIndexForTabView:sender];
814 if (!tabStripModel_->ContainsIndex(index)) 814 if (!tabStripModel_->ContainsIndex(index))
815 return; 815 return;
816 816
817 content::RecordAction(UserMetricsAction("CloseTab_Mouse")); 817 base::RecordAction(UserMetricsAction("CloseTab_Mouse"));
818 const NSInteger numberOfOpenTabs = [self numberOfOpenTabs]; 818 const NSInteger numberOfOpenTabs = [self numberOfOpenTabs];
819 if (numberOfOpenTabs > 1) { 819 if (numberOfOpenTabs > 1) {
820 bool isClosingLastTab = index == numberOfOpenTabs - 1; 820 bool isClosingLastTab = index == numberOfOpenTabs - 1;
821 if (!isClosingLastTab) { 821 if (!isClosingLastTab) {
822 // Limit the width available for laying out tabs so that tabs are not 822 // Limit the width available for laying out tabs so that tabs are not
823 // resized until a later time (when the mouse leaves the tab strip). 823 // resized until a later time (when the mouse leaves the tab strip).
824 // However, if the tab being closed is a pinned tab, break out of 824 // However, if the tab being closed is a pinned tab, break out of
825 // rapid-closure mode since the mouse is almost guaranteed not to be over 825 // rapid-closure mode since the mouse is almost guaranteed not to be over
826 // the closebox of the adjacent tab (due to the difference in widths). 826 // the closebox of the adjacent tab (due to the difference in widths).
827 // TODO(pinkerton): re-visit when handling tab overflow. 827 // TODO(pinkerton): re-visit when handling tab overflow.
(...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after
2114 WindowOpenDisposition disposition; 2114 WindowOpenDisposition disposition;
2115 [self droppingURLsAt:point 2115 [self droppingURLsAt:point
2116 givesIndex:&index 2116 givesIndex:&index
2117 disposition:&disposition 2117 disposition:&disposition
2118 activateTab:activateTab]; 2118 activateTab:activateTab];
2119 2119
2120 // Either insert a new tab or open in a current tab. 2120 // Either insert a new tab or open in a current tab.
2121 switch (disposition) { 2121 switch (disposition) {
2122 case WindowOpenDisposition::NEW_FOREGROUND_TAB: 2122 case WindowOpenDisposition::NEW_FOREGROUND_TAB:
2123 case WindowOpenDisposition::NEW_BACKGROUND_TAB: { 2123 case WindowOpenDisposition::NEW_BACKGROUND_TAB: {
2124 content::RecordAction(UserMetricsAction("Tab_DropURLBetweenTabs")); 2124 base::RecordAction(UserMetricsAction("Tab_DropURLBetweenTabs"));
2125 chrome::NavigateParams params(browser_, *url, 2125 chrome::NavigateParams params(browser_, *url,
2126 ui::PAGE_TRANSITION_TYPED); 2126 ui::PAGE_TRANSITION_TYPED);
2127 params.disposition = disposition; 2127 params.disposition = disposition;
2128 params.tabstrip_index = index; 2128 params.tabstrip_index = index;
2129 params.tabstrip_add_types = 2129 params.tabstrip_add_types =
2130 TabStripModel::ADD_ACTIVE | TabStripModel::ADD_FORCE_INDEX; 2130 TabStripModel::ADD_ACTIVE | TabStripModel::ADD_FORCE_INDEX;
2131 chrome::Navigate(&params); 2131 chrome::Navigate(&params);
2132 break; 2132 break;
2133 } 2133 }
2134 case WindowOpenDisposition::CURRENT_TAB: { 2134 case WindowOpenDisposition::CURRENT_TAB: {
2135 content::RecordAction(UserMetricsAction("Tab_DropURLOnTab")); 2135 base::RecordAction(UserMetricsAction("Tab_DropURLOnTab"));
2136 OpenURLParams params(*url, Referrer(), WindowOpenDisposition::CURRENT_TAB, 2136 OpenURLParams params(*url, Referrer(), WindowOpenDisposition::CURRENT_TAB,
2137 ui::PAGE_TRANSITION_TYPED, false); 2137 ui::PAGE_TRANSITION_TYPED, false);
2138 tabStripModel_->GetWebContentsAt(index)->OpenURL(params); 2138 tabStripModel_->GetWebContentsAt(index)->OpenURL(params);
2139 tabStripModel_->ActivateTabAt(index, true); 2139 tabStripModel_->ActivateTabAt(index, true);
2140 break; 2140 break;
2141 } 2141 }
2142 default: 2142 default:
2143 NOTIMPLEMENTED(); 2143 NOTIMPLEMENTED();
2144 } 2144 }
2145 } 2145 }
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
2417 for (int i = 0; i < tabStripModel_->count(); i++) { 2417 for (int i = 0; i < tabStripModel_->count(); i++) {
2418 [self updateIconsForContents:tabStripModel_->GetWebContentsAt(i) atIndex:i]; 2418 [self updateIconsForContents:tabStripModel_->GetWebContentsAt(i) atIndex:i];
2419 } 2419 }
2420 } 2420 }
2421 2421
2422 - (void)setVisualEffectsDisabledForFullscreen:(BOOL)fullscreen { 2422 - (void)setVisualEffectsDisabledForFullscreen:(BOOL)fullscreen {
2423 [tabStripView_ setVisualEffectsDisabledForFullscreen:fullscreen]; 2423 [tabStripView_ setVisualEffectsDisabledForFullscreen:fullscreen];
2424 } 2424 }
2425 2425
2426 @end 2426 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tabs/tab_controller.mm ('k') | chrome/browser/ui/content_settings/content_setting_bubble_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698