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

Side by Side Diff: chrome/browser/ui/cocoa/view_id_util.mm

Issue 1393233002: Mac Energy Test Harness/Framework Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Snapshot of scripts for http://crbug.com/391646 Created 5 years, 2 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
« no previous file with comments | « base/test/energy_monitor_mac.cc ('k') | chrome/browser/ui/energy_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/view_id_util.h" 5 #import "chrome/browser/ui/cocoa/view_id_util.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 DCHECK(view); 53 DCHECK(view);
54 g_view_id_map.Get().erase(view); 54 g_view_id_map.Get().erase(view);
55 } 55 }
56 56
57 NSView* GetView(NSWindow* window, ViewID viewID) { 57 NSView* GetView(NSWindow* window, ViewID viewID) {
58 DCHECK(viewID != VIEW_ID_NONE); 58 DCHECK(viewID != VIEW_ID_NONE);
59 DCHECK(window); 59 DCHECK(window);
60 60
61 // As tabs can be created, destroyed or rearranged dynamically, we handle them 61 // As tabs can be created, destroyed or rearranged dynamically, we handle them
62 // here specially. 62 // here specially.
63 #if 0
63 if (viewID >= VIEW_ID_TAB_0 && viewID <= VIEW_ID_TAB_LAST) { 64 if (viewID >= VIEW_ID_TAB_0 && viewID <= VIEW_ID_TAB_LAST) {
64 BrowserWindowController* windowController = [window windowController]; 65 BrowserWindowController* windowController = [window windowController];
65 DCHECK([windowController isKindOfClass:[BrowserWindowController class]]); 66 DCHECK([windowController isKindOfClass:[BrowserWindowController class]]);
66 TabStripController* tabStripController = 67 TabStripController* tabStripController =
67 [windowController tabStripController]; 68 [windowController tabStripController];
68 DCHECK(tabStripController); 69 DCHECK(tabStripController);
69 NSUInteger count = [tabStripController viewsCount]; 70 NSUInteger count = [tabStripController viewsCount];
70 DCHECK(count); 71 DCHECK(count);
71 NSUInteger index = 72 NSUInteger index =
72 (viewID == VIEW_ID_TAB_LAST ? count - 1 : viewID - VIEW_ID_TAB_0); 73 (viewID == VIEW_ID_TAB_LAST ? count - 1 : viewID - VIEW_ID_TAB_0);
73 return index < count ? [tabStripController viewAtIndex:index] : nil; 74 return index < count ? [tabStripController viewAtIndex:index] : nil;
74 } 75 }
76 #endif
75 77
76 return FindViewWithID([[window contentView] superview], viewID); 78 return FindViewWithID([[window contentView] superview], viewID);
77 } 79 }
78 80
79 } // namespace view_id_util 81 } // namespace view_id_util
80 82
81 @implementation NSView (ViewID) 83 @implementation NSView (ViewID)
82 84
83 - (ViewID)viewID { 85 - (ViewID)viewID {
84 ViewIDMap* map = g_view_id_map.Pointer(); 86 ViewIDMap* map = g_view_id_map.Pointer();
85 ViewIDMap::const_iterator iter = map->find(self); 87 ViewIDMap::const_iterator iter = map->find(self);
86 return iter != map->end() ? iter->second : VIEW_ID_NONE; 88 return iter != map->end() ? iter->second : VIEW_ID_NONE;
87 } 89 }
88 90
89 - (NSView*)ancestorWithViewID:(ViewID)viewID { 91 - (NSView*)ancestorWithViewID:(ViewID)viewID {
90 NSView* ancestor = self; 92 NSView* ancestor = self;
91 while (ancestor && [ancestor viewID] != viewID) 93 while (ancestor && [ancestor viewID] != viewID)
92 ancestor = [ancestor superview]; 94 ancestor = [ancestor superview];
93 return ancestor; 95 return ancestor;
94 } 96 }
95 97
96 @end 98 @end
OLDNEW
« no previous file with comments | « base/test/energy_monitor_mac.cc ('k') | chrome/browser/ui/energy_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698