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

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

Issue 7080064: [Mac] Refactor the logic of tab dragging out of TabView and into a new helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 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 | 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 <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 19 matching lines...) Expand all
30 #include "chrome/browser/tabs/tab_strip_selection_model.h" 30 #include "chrome/browser/tabs/tab_strip_selection_model.h"
31 #include "chrome/browser/ui/browser.h" 31 #include "chrome/browser/ui/browser.h"
32 #include "chrome/browser/ui/browser_navigator.h" 32 #include "chrome/browser/ui/browser_navigator.h"
33 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 33 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
34 #import "chrome/browser/ui/cocoa/constrained_window_mac.h" 34 #import "chrome/browser/ui/cocoa/constrained_window_mac.h"
35 #import "chrome/browser/ui/cocoa/image_button_cell.h" 35 #import "chrome/browser/ui/cocoa/image_button_cell.h"
36 #import "chrome/browser/ui/cocoa/new_tab_button.h" 36 #import "chrome/browser/ui/cocoa/new_tab_button.h"
37 #import "chrome/browser/ui/cocoa/profile_menu_button.h" 37 #import "chrome/browser/ui/cocoa/profile_menu_button.h"
38 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util.h" 38 #import "chrome/browser/ui/cocoa/tab_contents/favicon_util.h"
39 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h" 39 #import "chrome/browser/ui/cocoa/tabs/tab_controller.h"
40 #import "chrome/browser/ui/cocoa/tabs/tab_strip_drag_controller.h"
40 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h" 41 #import "chrome/browser/ui/cocoa/tabs/tab_strip_model_observer_bridge.h"
41 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" 42 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
42 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" 43 #import "chrome/browser/ui/cocoa/tabs/tab_view.h"
43 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h" 44 #import "chrome/browser/ui/cocoa/tabs/throbber_view.h"
44 #import "chrome/browser/ui/cocoa/tracking_area.h" 45 #import "chrome/browser/ui/cocoa/tracking_area.h"
45 #include "chrome/browser/ui/find_bar/find_bar.h" 46 #include "chrome/browser/ui/find_bar/find_bar.h"
46 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 47 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
47 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 48 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
48 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 49 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
49 #include "chrome/browser/ui/tabs/tab_menu_model.h" 50 #include "chrome/browser/ui/tabs/tab_menu_model.h"
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 delegate:(id<TabStripControllerDelegate>)delegate { 353 delegate:(id<TabStripControllerDelegate>)delegate {
353 DCHECK(view && switchView && browser && delegate); 354 DCHECK(view && switchView && browser && delegate);
354 if ((self = [super init])) { 355 if ((self = [super init])) {
355 tabStripView_.reset([view retain]); 356 tabStripView_.reset([view retain]);
356 switchView_ = switchView; 357 switchView_ = switchView;
357 browser_ = browser; 358 browser_ = browser;
358 tabStripModel_ = browser_->tabstrip_model(); 359 tabStripModel_ = browser_->tabstrip_model();
359 hoverTabSelector_.reset(new HoverTabSelector(tabStripModel_)); 360 hoverTabSelector_.reset(new HoverTabSelector(tabStripModel_));
360 delegate_ = delegate; 361 delegate_ = delegate;
361 bridge_.reset(new TabStripModelObserverBridge(tabStripModel_, self)); 362 bridge_.reset(new TabStripModelObserverBridge(tabStripModel_, self));
363 dragController_.reset(
364 [[TabStripDragController alloc] initWithTabStripController:self]);
362 tabContentsArray_.reset([[NSMutableArray alloc] init]); 365 tabContentsArray_.reset([[NSMutableArray alloc] init]);
363 tabArray_.reset([[NSMutableArray alloc] init]); 366 tabArray_.reset([[NSMutableArray alloc] init]);
364 NSWindow* browserWindow = [view window]; 367 NSWindow* browserWindow = [view window];
365 368
366 // Important note: any non-tab subviews not added to |permanentSubviews_| 369 // Important note: any non-tab subviews not added to |permanentSubviews_|
367 // (see |-addSubviewToPermanentList:|) will be wiped out. 370 // (see |-addSubviewToPermanentList:|) will be wiped out.
368 permanentSubviews_.reset([[NSMutableArray alloc] init]); 371 permanentSubviews_.reset([[NSMutableArray alloc] init]);
369 372
370 defaultFavicon_.reset( 373 defaultFavicon_.reset(
371 [app::mac::GetCachedImageWithName(@"nav.pdf") retain]); 374 [app::mac::GetCachedImageWithName(@"nav.pdf") retain]);
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 return tabStripModel_->IsContextMenuCommandEnabled(index, command) ? YES : NO; 807 return tabStripModel_->IsContextMenuCommandEnabled(index, command) ? YES : NO;
805 } 808 }
806 809
807 // Returns a context menu model for a given controller. Caller owns the result. 810 // Returns a context menu model for a given controller. Caller owns the result.
808 - (ui::SimpleMenuModel*)contextMenuModelForController:(TabController*)controller 811 - (ui::SimpleMenuModel*)contextMenuModelForController:(TabController*)controller
809 menuDelegate:(ui::SimpleMenuModel::Delegate*)delegate { 812 menuDelegate:(ui::SimpleMenuModel::Delegate*)delegate {
810 int index = [self modelIndexForTabView:[controller view]]; 813 int index = [self modelIndexForTabView:[controller view]];
811 return new TabMenuModel(delegate, tabStripModel_, index); 814 return new TabMenuModel(delegate, tabStripModel_, index);
812 } 815 }
813 816
817 // Returns a weak reference to the controller that manages dragging of tabs.
818 - (id<TabDraggingEventTarget>)dragController {
819 return dragController_.get();
820 }
821
814 - (void)insertPlaceholderForTab:(TabView*)tab 822 - (void)insertPlaceholderForTab:(TabView*)tab
815 frame:(NSRect)frame 823 frame:(NSRect)frame
816 yStretchiness:(CGFloat)yStretchiness { 824 yStretchiness:(CGFloat)yStretchiness {
817 placeholderTab_ = tab; 825 placeholderTab_ = tab;
818 placeholderFrame_ = frame; 826 placeholderFrame_ = frame;
819 placeholderStretchiness_ = yStretchiness; 827 placeholderStretchiness_ = yStretchiness;
820 [self layoutTabsWithAnimation:initialLayoutComplete_ regenerateSubviews:NO]; 828 [self layoutTabsWithAnimation:initialLayoutComplete_ regenerateSubviews:NO];
821 } 829 }
822 830
823 - (BOOL)isDragSessionActive { 831 - (BOOL)isDragSessionActive {
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after
2128 } 2136 }
2129 2137
2130 std::string profileName = browser_->profile()->GetPrefs()->GetString( 2138 std::string profileName = browser_->profile()->GetPrefs()->GetString(
2131 prefs::kGoogleServicesUsername); 2139 prefs::kGoogleServicesUsername);
2132 [profileMenuButton_ setProfileDisplayName: 2140 [profileMenuButton_ setProfileDisplayName:
2133 [NSString stringWithUTF8String:profileName.c_str()]]; 2141 [NSString stringWithUTF8String:profileName.c_str()]];
2134 [profileMenuButton_ setHidden:NO]; 2142 [profileMenuButton_ setHidden:NO];
2135 } 2143 }
2136 2144
2137 @end 2145 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698