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

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

Issue 63022: Layout the tabs explicitly when creating a background tab. Update to correct ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/gtk/tabs/tab_strip_gtk.h » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/cocoa/tab_strip_controller.h" 5 #import "chrome/browser/cocoa/tab_strip_controller.h"
6 6
7 #import "base/sys_string_conversions.h" 7 #import "base/sys_string_conversions.h"
8 #import "chrome/app/chrome_dll_resource.h" 8 #import "chrome/app/chrome_dll_resource.h"
9 #import "chrome/browser/browser.h" 9 #import "chrome/browser/browser.h"
10 #import "chrome/browser/cocoa/bookmark_bar_state_controller.h" 10 #import "chrome/browser/cocoa/bookmark_bar_state_controller.h"
(...skipping 10 matching lines...) Expand all
21 - (void)insertTabWithContents:(TabContents*)contents 21 - (void)insertTabWithContents:(TabContents*)contents
22 atIndex:(NSInteger)index 22 atIndex:(NSInteger)index
23 inForeground:(bool)inForeground; 23 inForeground:(bool)inForeground;
24 - (void)selectTabWithContents:(TabContents*)newContents 24 - (void)selectTabWithContents:(TabContents*)newContents
25 previousContents:(TabContents*)oldContents 25 previousContents:(TabContents*)oldContents
26 atIndex:(NSInteger)index 26 atIndex:(NSInteger)index
27 userGesture:(bool)wasUserGesture; 27 userGesture:(bool)wasUserGesture;
28 - (void)tabDetachedWithContents:(TabContents*)contents 28 - (void)tabDetachedWithContents:(TabContents*)contents
29 atIndex:(NSInteger)index; 29 atIndex:(NSInteger)index;
30 - (void)tabChangedWithContents:(TabContents*)contents 30 - (void)tabChangedWithContents:(TabContents*)contents
31 atIndex:(NSInteger)index; 31 atIndex:(NSInteger)index
32 loadingOnly:(BOOL)loading;
32 @end 33 @end
33 34
34 // A C++ bridge class to handle receiving notifications from the C++ tab 35 // A C++ bridge class to handle receiving notifications from the C++ tab
35 // strip model. Doesn't do much on its own, just sends everything straight 36 // strip model. Doesn't do much on its own, just sends everything straight
36 // to the Cocoa controller. 37 // to the Cocoa controller.
37 class TabStripBridge : public TabStripModelObserver { 38 class TabStripBridge : public TabStripModelObserver {
38 public: 39 public:
39 TabStripBridge(TabStripModel* model, TabStripController* controller); 40 TabStripBridge(TabStripModel* model, TabStripController* controller);
40 ~TabStripBridge(); 41 ~TabStripBridge();
41 42
42 // Overridden from TabStripModelObserver 43 // Overridden from TabStripModelObserver
43 virtual void TabInsertedAt(TabContents* contents, 44 virtual void TabInsertedAt(TabContents* contents,
44 int index, 45 int index,
45 bool foreground); 46 bool foreground);
46 virtual void TabDetachedAt(TabContents* contents, int index); 47 virtual void TabDetachedAt(TabContents* contents, int index);
47 virtual void TabSelectedAt(TabContents* old_contents, 48 virtual void TabSelectedAt(TabContents* old_contents,
48 TabContents* new_contents, 49 TabContents* new_contents,
49 int index, 50 int index,
50 bool user_gesture); 51 bool user_gesture);
51 virtual void TabMoved(TabContents* contents, 52 virtual void TabMoved(TabContents* contents,
52 int from_index, 53 int from_index,
53 int to_index); 54 int to_index);
54 virtual void TabChangedAt(TabContents* contents, int index); 55 virtual void TabChangedAt(TabContents* contents, int index,
56 bool loading_only);
55 virtual void TabStripEmpty(); 57 virtual void TabStripEmpty();
56 58
57 private: 59 private:
58 TabStripController* controller_; // weak, owns me 60 TabStripController* controller_; // weak, owns me
59 TabStripModel* model_; // weak, owned by Browser 61 TabStripModel* model_; // weak, owned by Browser
60 }; 62 };
61 63
62 @implementation TabStripController 64 @implementation TabStripController
63 65
64 - (id)initWithView:(TabStripView*)view 66 - (id)initWithView:(TabStripView*)view
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 bundle:nil 269 bundle:nil
268 contents:contents 270 contents:contents
269 commands:commands_ 271 commands:commands_
270 toolbarModel:toolbarModel_ 272 toolbarModel:toolbarModel_
271 bookmarkModel:bookmarkModel_] 273 bookmarkModel:bookmarkModel_]
272 autorelease]; 274 autorelease];
273 if ([self isBookmarkBarVisible]) 275 if ([self isBookmarkBarVisible])
274 [contentsController toggleBookmarkBar:YES]; 276 [contentsController toggleBookmarkBar:YES];
275 [tabContentsArray_ insertObject:contentsController atIndex:index]; 277 [tabContentsArray_ insertObject:contentsController atIndex:index];
276 278
277 // Make a new tab and add it to the strip. Keep track of its controller. We 279 // Make a new tab and add it to the strip. Keep track of its controller.
278 // don't call |-layoutTabs| here because it will get called when the new
279 // tab is selected by the tab model.
280 TabController* newController = [self newTab]; 280 TabController* newController = [self newTab];
281 [tabArray_ insertObject:newController atIndex:index]; 281 [tabArray_ insertObject:newController atIndex:index];
282 NSView* newView = [newController view]; 282 NSView* newView = [newController view];
283 [tabView_ addSubview:newView]; 283 [tabView_ addSubview:newView];
284 284
285 [self setTabTitle:newController withContents:contents]; 285 [self setTabTitle:newController withContents:contents];
286 286
287 // Select the newly created tab if in the foreground 287 // We don't need to call |-layoutTabs| if the tab will be in the foreground
288 if (inForeground) 288 // because it will get called when the new tab is selected by the tab model.
289 [self swapInTabAtIndex:index]; 289 if (inForeground) {
290 // [self swapInTabAtIndex:index];
TVL 2009/04/06 20:08:12 why commented out?
pink (ping after 24hrs) 2009/04/06 20:13:46 oops, removing that code entirely.
291 } else {
292 [newController setSelected:NO];
293 [self layoutTabs];
294 }
290 } 295 }
291 296
292 // Called when a notification is received from the model to select a particular 297 // Called when a notification is received from the model to select a particular
293 // tab. Swaps in the toolbar and content area associated with |newContents|. 298 // tab. Swaps in the toolbar and content area associated with |newContents|.
294 - (void)selectTabWithContents:(TabContents*)newContents 299 - (void)selectTabWithContents:(TabContents*)newContents
295 previousContents:(TabContents*)oldContents 300 previousContents:(TabContents*)oldContents
296 atIndex:(NSInteger)index 301 atIndex:(NSInteger)index
297 userGesture:(bool)wasUserGesture { 302 userGesture:(bool)wasUserGesture {
298 // De-select all other tabs and select the new tab. 303 // De-select all other tabs and select the new tab.
299 int i = 0; 304 int i = 0;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 342
338 // Once we're totally done with the tab, delete its controller 343 // Once we're totally done with the tab, delete its controller
339 [tabArray_ removeObjectAtIndex:index]; 344 [tabArray_ removeObjectAtIndex:index];
340 345
341 [self layoutTabs]; 346 [self layoutTabs];
342 } 347 }
343 348
344 // Called when a notification is received from the model that the given tab 349 // Called when a notification is received from the model that the given tab
345 // has been updated. 350 // has been updated.
346 - (void)tabChangedWithContents:(TabContents*)contents 351 - (void)tabChangedWithContents:(TabContents*)contents
347 atIndex:(NSInteger)index { 352 atIndex:(NSInteger)index
353 loadingOnly:(BOOL)loading {
348 [self setTabTitle:[tabArray_ objectAtIndex:index] withContents:contents]; 354 [self setTabTitle:[tabArray_ objectAtIndex:index] withContents:contents];
349 355
350 TabContentsController* updatedController = 356 TabContentsController* updatedController =
351 [tabContentsArray_ objectAtIndex:index]; 357 [tabContentsArray_ objectAtIndex:index];
352 [updatedController tabDidChange:contents]; 358 [updatedController tabDidChange:contents];
353 } 359 }
354 360
355 - (LocationBar*)locationBar { 361 - (LocationBar*)locationBar {
356 TabContentsController* selectedController = 362 TabContentsController* selectedController =
357 [tabContentsArray_ objectAtIndex:tabModel_->selected_index()]; 363 [tabContentsArray_ objectAtIndex:tabModel_->selected_index()];
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 atIndex:index 471 atIndex:index
466 userGesture:user_gesture]; 472 userGesture:user_gesture];
467 } 473 }
468 474
469 void TabStripBridge::TabMoved(TabContents* contents, 475 void TabStripBridge::TabMoved(TabContents* contents,
470 int from_index, 476 int from_index,
471 int to_index) { 477 int to_index) {
472 NOTIMPLEMENTED(); 478 NOTIMPLEMENTED();
473 } 479 }
474 480
475 void TabStripBridge::TabChangedAt(TabContents* contents, int index) { 481 void TabStripBridge::TabChangedAt(TabContents* contents, int index,
476 [controller_ tabChangedWithContents:contents atIndex:index]; 482 bool loading_only) {
483 [controller_ tabChangedWithContents:contents
484 atIndex:index
485 loadingOnly:loading_only ? YES : NO];
477 } 486 }
478 487
479 void TabStripBridge::TabStripEmpty() { 488 void TabStripBridge::TabStripEmpty() {
480 NOTIMPLEMENTED(); 489 NOTIMPLEMENTED();
481 } 490 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/gtk/tabs/tab_strip_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698