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

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

Issue 8919017: Split UserMetrics into API vs. implementation. Move API to content/public. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Version for commit (merged again). Created 9 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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>
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 48 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
49 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 49 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
50 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 50 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
51 #include "chrome/browser/ui/tabs/tab_menu_model.h" 51 #include "chrome/browser/ui/tabs/tab_menu_model.h"
52 #include "chrome/common/chrome_switches.h" 52 #include "chrome/common/chrome_switches.h"
53 #include "chrome/common/pref_names.h" 53 #include "chrome/common/pref_names.h"
54 #include "content/browser/tab_contents/navigation_controller.h" 54 #include "content/browser/tab_contents/navigation_controller.h"
55 #include "content/browser/tab_contents/navigation_entry.h" 55 #include "content/browser/tab_contents/navigation_entry.h"
56 #include "content/browser/tab_contents/tab_contents.h" 56 #include "content/browser/tab_contents/tab_contents.h"
57 #include "content/browser/tab_contents/tab_contents_view.h" 57 #include "content/browser/tab_contents/tab_contents_view.h"
58 #include "content/browser/user_metrics.h" 58 #include "content/public/browser/user_metrics.h"
59 #include "grit/generated_resources.h" 59 #include "grit/generated_resources.h"
60 #include "grit/theme_resources.h" 60 #include "grit/theme_resources.h"
61 #include "grit/theme_resources_standard.h" 61 #include "grit/theme_resources_standard.h"
62 #include "grit/ui_resources.h" 62 #include "grit/ui_resources.h"
63 #include "skia/ext/skia_utils_mac.h" 63 #include "skia/ext/skia_utils_mac.h"
64 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" 64 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h"
65 #include "ui/base/l10n/l10n_util.h" 65 #include "ui/base/l10n/l10n_util.h"
66 #include "ui/base/resource/resource_bundle.h" 66 #include "ui/base/resource/resource_bundle.h"
67 #include "ui/gfx/image/image.h" 67 #include "ui/gfx/image/image.h"
68 #include "ui/gfx/mac/nsimage_cache.h" 68 #include "ui/gfx/mac/nsimage_cache.h"
69 69
70 using content::UserMetricsAction;
71
70 NSString* const kTabStripNumberOfTabsChanged = @"kTabStripNumberOfTabsChanged"; 72 NSString* const kTabStripNumberOfTabsChanged = @"kTabStripNumberOfTabsChanged";
71 73
72 namespace { 74 namespace {
73 75
74 // A value to indicate tab layout should use the full available width of the 76 // A value to indicate tab layout should use the full available width of the
75 // view. 77 // view.
76 const CGFloat kUseFullAvailableWidth = -1.0; 78 const CGFloat kUseFullAvailableWidth = -1.0;
77 79
78 // The amount by which tabs overlap. 80 // The amount by which tabs overlap.
79 const CGFloat kTabOverlap = 19.0; 81 const CGFloat kTabOverlap = 19.0;
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 hoverTabSelector_->CancelTabTransition(); 690 hoverTabSelector_->CancelTabTransition();
689 691
690 if ([hoveredTab_ isEqual:sender]) { 692 if ([hoveredTab_ isEqual:sender]) {
691 hoveredTab_ = nil; 693 hoveredTab_ = nil;
692 } 694 }
693 695
694 NSInteger index = [self modelIndexForTabView:sender]; 696 NSInteger index = [self modelIndexForTabView:sender];
695 if (!tabStripModel_->ContainsIndex(index)) 697 if (!tabStripModel_->ContainsIndex(index))
696 return; 698 return;
697 699
698 UserMetrics::RecordAction(UserMetricsAction("CloseTab_Mouse")); 700 content::RecordAction(UserMetricsAction("CloseTab_Mouse"));
699 const NSInteger numberOfOpenTabs = [self numberOfOpenTabs]; 701 const NSInteger numberOfOpenTabs = [self numberOfOpenTabs];
700 if (numberOfOpenTabs > 1) { 702 if (numberOfOpenTabs > 1) {
701 bool isClosingLastTab = index == numberOfOpenTabs - 1; 703 bool isClosingLastTab = index == numberOfOpenTabs - 1;
702 if (!isClosingLastTab) { 704 if (!isClosingLastTab) {
703 // Limit the width available for laying out tabs so that tabs are not 705 // Limit the width available for laying out tabs so that tabs are not
704 // resized until a later time (when the mouse leaves the tab strip). 706 // resized until a later time (when the mouse leaves the tab strip).
705 // However, if the tab being closed is a pinned tab, break out of 707 // However, if the tab being closed is a pinned tab, break out of
706 // rapid-closure mode since the mouse is almost guaranteed not to be over 708 // rapid-closure mode since the mouse is almost guaranteed not to be over
707 // the closebox of the adjacent tab (due to the difference in widths). 709 // the closebox of the adjacent tab (due to the difference in widths).
708 // TODO(pinkerton): re-visit when handling tab overflow. 710 // TODO(pinkerton): re-visit when handling tab overflow.
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 // Get the index and disposition. 1827 // Get the index and disposition.
1826 NSInteger index; 1828 NSInteger index;
1827 WindowOpenDisposition disposition; 1829 WindowOpenDisposition disposition;
1828 [self droppingURLsAt:point 1830 [self droppingURLsAt:point
1829 givesIndex:&index 1831 givesIndex:&index
1830 disposition:&disposition]; 1832 disposition:&disposition];
1831 1833
1832 // Either insert a new tab or open in a current tab. 1834 // Either insert a new tab or open in a current tab.
1833 switch (disposition) { 1835 switch (disposition) {
1834 case NEW_FOREGROUND_TAB: { 1836 case NEW_FOREGROUND_TAB: {
1835 UserMetrics::RecordAction(UserMetricsAction("Tab_DropURLBetweenTabs")); 1837 content::RecordAction(UserMetricsAction("Tab_DropURLBetweenTabs"));
1836 browser::NavigateParams params( 1838 browser::NavigateParams params(
1837 browser_, *url, content::PAGE_TRANSITION_TYPED); 1839 browser_, *url, content::PAGE_TRANSITION_TYPED);
1838 params.disposition = disposition; 1840 params.disposition = disposition;
1839 params.tabstrip_index = index; 1841 params.tabstrip_index = index;
1840 params.tabstrip_add_types = 1842 params.tabstrip_add_types =
1841 TabStripModel::ADD_ACTIVE | TabStripModel::ADD_FORCE_INDEX; 1843 TabStripModel::ADD_ACTIVE | TabStripModel::ADD_FORCE_INDEX;
1842 browser::Navigate(&params); 1844 browser::Navigate(&params);
1843 break; 1845 break;
1844 } 1846 }
1845 case CURRENT_TAB: 1847 case CURRENT_TAB:
1846 UserMetrics::RecordAction(UserMetricsAction("Tab_DropURLOnTab")); 1848 content::RecordAction(UserMetricsAction("Tab_DropURLOnTab"));
1847 tabStripModel_->GetTabContentsAt(index) 1849 tabStripModel_->GetTabContentsAt(index)
1848 ->tab_contents()->OpenURL(*url, GURL(), CURRENT_TAB, 1850 ->tab_contents()->OpenURL(*url, GURL(), CURRENT_TAB,
1849 content::PAGE_TRANSITION_TYPED); 1851 content::PAGE_TRANSITION_TYPED);
1850 tabStripModel_->ActivateTabAt(index, true); 1852 tabStripModel_->ActivateTabAt(index, true);
1851 break; 1853 break;
1852 default: 1854 default:
1853 NOTIMPLEMENTED(); 1855 NOTIMPLEMENTED();
1854 } 1856 }
1855 } 1857 }
1856 1858
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
2049 NSInteger index = [self indexFromModelIndex:modelIndex]; 2051 NSInteger index = [self indexFromModelIndex:modelIndex];
2050 BrowserWindowController* controller = 2052 BrowserWindowController* controller =
2051 (BrowserWindowController*)[[switchView_ window] windowController]; 2053 (BrowserWindowController*)[[switchView_ window] windowController];
2052 DCHECK(index >= 0); 2054 DCHECK(index >= 0);
2053 if (index >= 0) { 2055 if (index >= 0) {
2054 [controller setTab:[self viewAtIndex:index] isDraggable:YES]; 2056 [controller setTab:[self viewAtIndex:index] isDraggable:YES];
2055 } 2057 }
2056 } 2058 }
2057 2059
2058 @end 2060 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698