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

Side by Side Diff: chrome/browser/tabs/tab_strip_model.h

Issue 8983010: Convert WebContents to return a content::NavigationController instead of the implementation. Upda... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 8 years, 11 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 #ifndef CHROME_BROWSER_TABS_TAB_STRIP_MODEL_H_ 5 #ifndef CHROME_BROWSER_TABS_TAB_STRIP_MODEL_H_
6 #define CHROME_BROWSER_TABS_TAB_STRIP_MODEL_H_ 6 #define CHROME_BROWSER_TABS_TAB_STRIP_MODEL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "chrome/browser/tabs/tab_strip_model_observer.h" 12 #include "chrome/browser/tabs/tab_strip_model_observer.h"
13 #include "chrome/browser/tabs/tab_strip_selection_model.h" 13 #include "chrome/browser/tabs/tab_strip_selection_model.h"
14 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
16 #include "content/public/common/page_transition_types.h" 16 #include "content/public/common/page_transition_types.h"
17 17
18 class NavigationController;
19 class Profile; 18 class Profile;
20 class TabContents; 19 class TabContents;
21 class TabContentsWrapper; 20 class TabContentsWrapper;
22 class TabStripModelDelegate; 21 class TabStripModelDelegate;
23 class TabStripModelOrderController; 22 class TabStripModelOrderController;
24 23
25 namespace content { 24 namespace content {
26 class NavigationController; 25 class NavigationController;
27 class WebContents; 26 class WebContents;
28 } 27 }
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 292
294 // Close all tabs at once. Code can use closing_all() above to defer 293 // Close all tabs at once. Code can use closing_all() above to defer
295 // operations that might otherwise by invoked by the flurry of detach/select 294 // operations that might otherwise by invoked by the flurry of detach/select
296 // notifications this method causes. 295 // notifications this method causes.
297 void CloseAllTabs(); 296 void CloseAllTabs();
298 297
299 // Returns true if there are any TabContents that are currently loading. 298 // Returns true if there are any TabContents that are currently loading.
300 bool TabsAreLoading() const; 299 bool TabsAreLoading() const;
301 300
302 // Returns the controller controller that opened the TabContents at |index|. 301 // Returns the controller controller that opened the TabContents at |index|.
303 NavigationController* GetOpenerOfTabContentsAt(int index); 302 content::NavigationController* GetOpenerOfTabContentsAt(int index);
304 303
305 // Returns the index of the next TabContents in the sequence of TabContentses 304 // Returns the index of the next TabContents in the sequence of TabContentses
306 // spawned by the specified NavigationController after |start_index|. 305 // spawned by the specified NavigationController after |start_index|.
307 // If |use_group| is true, the group property of the tab is used instead of 306 // If |use_group| is true, the group property of the tab is used instead of
308 // the opener to find the next tab. Under some circumstances the group 307 // the opener to find the next tab. Under some circumstances the group
309 // relationship may exist but the opener may not. 308 // relationship may exist but the opener may not.
310 int GetIndexOfNextTabContentsOpenedBy(const NavigationController* opener, 309 int GetIndexOfNextTabContentsOpenedBy(
311 int start_index, 310 const content::NavigationController* opener,
312 bool use_group) const; 311 int start_index,
312 bool use_group) const;
313 313
314 // Returns the index of the first TabContents in the model opened by the 314 // Returns the index of the first TabContents in the model opened by the
315 // specified opener. 315 // specified opener.
316 int GetIndexOfFirstTabContentsOpenedBy(const NavigationController* opener, 316 int GetIndexOfFirstTabContentsOpenedBy(
317 int start_index) const; 317 const content::NavigationController* opener,
318 int start_index) const;
318 319
319 // Returns the index of the last TabContents in the model opened by the 320 // Returns the index of the last TabContents in the model opened by the
320 // specified opener, starting at |start_index|. 321 // specified opener, starting at |start_index|.
321 int GetIndexOfLastTabContentsOpenedBy(const NavigationController* opener, 322 int GetIndexOfLastTabContentsOpenedBy(
322 int start_index) const; 323 const content::NavigationController* opener,
324 int start_index) const;
323 325
324 // Called by the Browser when a navigation is about to occur in the specified 326 // Called by the Browser when a navigation is about to occur in the specified
325 // TabContents. Depending on the tab, and the transition type of the 327 // TabContents. Depending on the tab, and the transition type of the
326 // navigation, the TabStripModel may adjust its selection and grouping 328 // navigation, the TabStripModel may adjust its selection and grouping
327 // behavior. 329 // behavior.
328 void TabNavigating(TabContentsWrapper* contents, 330 void TabNavigating(TabContentsWrapper* contents,
329 content::PageTransition transition); 331 content::PageTransition transition);
330 332
331 // Forget all Opener relationships that are stored (but _not_ group 333 // Forget all Opener relationships that are stored (but _not_ group
332 // relationships!) This is to reduce unpredictable tab switching behavior 334 // relationships!) This is to reduce unpredictable tab switching behavior
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 563
562 // Implementation of MoveSelectedTabsTo. Moves |length| of the selected tabs 564 // Implementation of MoveSelectedTabsTo. Moves |length| of the selected tabs
563 // starting at |start| to |index|. See MoveSelectedTabsTo for more details. 565 // starting at |start| to |index|. See MoveSelectedTabsTo for more details.
564 void MoveSelectedTabsToImpl(int index, size_t start, size_t length); 566 void MoveSelectedTabsToImpl(int index, size_t start, size_t length);
565 567
566 // Returns true if the tab represented by the specified data has an opener 568 // Returns true if the tab represented by the specified data has an opener
567 // that matches the specified one. If |use_group| is true, then this will 569 // that matches the specified one. If |use_group| is true, then this will
568 // fall back to check the group relationship as well. 570 // fall back to check the group relationship as well.
569 struct TabContentsData; 571 struct TabContentsData;
570 static bool OpenerMatches(const TabContentsData* data, 572 static bool OpenerMatches(const TabContentsData* data,
571 const NavigationController* opener, 573 const content::NavigationController* opener,
572 bool use_group); 574 bool use_group);
573 575
574 // Sets the group/opener of any tabs that reference |tab| to NULL. 576 // Sets the group/opener of any tabs that reference |tab| to NULL.
575 void ForgetOpenersAndGroupsReferencing(const NavigationController* tab); 577 void ForgetOpenersAndGroupsReferencing(
578 const content::NavigationController* tab);
576 579
577 // Our delegate. 580 // Our delegate.
578 TabStripModelDelegate* delegate_; 581 TabStripModelDelegate* delegate_;
579 582
580 // A hunk of data representing a TabContents and (optionally) the 583 // A hunk of data representing a TabContents and (optionally) the
581 // NavigationController that spawned it. This memory only sticks around while 584 // NavigationController that spawned it. This memory only sticks around while
582 // the TabContents is in the current TabStripModel, unless otherwise 585 // the TabContents is in the current TabStripModel, unless otherwise
583 // specified in code. 586 // specified in code.
584 struct TabContentsData { 587 struct TabContentsData {
585 explicit TabContentsData(TabContentsWrapper* a_contents) 588 explicit TabContentsData(TabContentsWrapper* a_contents)
586 : contents(a_contents), 589 : contents(a_contents),
587 reset_group_on_select(false), 590 reset_group_on_select(false),
588 pinned(false), 591 pinned(false),
589 blocked(false), 592 blocked(false),
590 discarded(false) { 593 discarded(false) {
591 SetGroup(NULL); 594 SetGroup(NULL);
592 } 595 }
593 596
594 // Create a relationship between this TabContents and other TabContentses. 597 // Create a relationship between this TabContents and other TabContentses.
595 // Used to identify which TabContents to select next after one is closed. 598 // Used to identify which TabContents to select next after one is closed.
596 void SetGroup(NavigationController* a_group) { 599 void SetGroup(content::NavigationController* a_group) {
597 group = a_group; 600 group = a_group;
598 opener = a_group; 601 opener = a_group;
599 } 602 }
600 603
601 // Forget the opener relationship so that when this TabContents is closed 604 // Forget the opener relationship so that when this TabContents is closed
602 // unpredictable re-selection does not occur. 605 // unpredictable re-selection does not occur.
603 void ForgetOpener() { 606 void ForgetOpener() {
604 opener = NULL; 607 opener = NULL;
605 } 608 }
606 609
607 TabContentsWrapper* contents; 610 TabContentsWrapper* contents;
608 // We use NavigationControllers here since they more closely model the 611 // We use NavigationControllers here since they more closely model the
609 // "identity" of a Tab, TabContents can change depending on the URL loaded 612 // "identity" of a Tab, TabContents can change depending on the URL loaded
610 // in the Tab. 613 // in the Tab.
611 // The group is used to model a set of tabs spawned from a single parent 614 // The group is used to model a set of tabs spawned from a single parent
612 // tab. This value is preserved for a given tab as long as the tab remains 615 // tab. This value is preserved for a given tab as long as the tab remains
613 // navigated to the link it was initially opened at or some navigation from 616 // navigated to the link it was initially opened at or some navigation from
614 // that page (i.e. if the user types or visits a bookmark or some other 617 // that page (i.e. if the user types or visits a bookmark or some other
615 // navigation within that tab, the group relationship is lost). This 618 // navigation within that tab, the group relationship is lost). This
616 // property can safely be used to implement features that depend on a 619 // property can safely be used to implement features that depend on a
617 // logical group of related tabs. 620 // logical group of related tabs.
618 NavigationController* group; 621 content::NavigationController* group;
619 // The owner models the same relationship as group, except it is more 622 // The owner models the same relationship as group, except it is more
620 // easily discarded, e.g. when the user switches to a tab not part of the 623 // easily discarded, e.g. when the user switches to a tab not part of the
621 // same group. This property is used to determine what tab to select next 624 // same group. This property is used to determine what tab to select next
622 // when one is closed. 625 // when one is closed.
623 NavigationController* opener; 626 content::NavigationController* opener;
624 // True if our group should be reset the moment selection moves away from 627 // True if our group should be reset the moment selection moves away from
625 // this Tab. This is the case for tabs opened in the foreground at the end 628 // this Tab. This is the case for tabs opened in the foreground at the end
626 // of the TabStrip while viewing another Tab. If these tabs are closed 629 // of the TabStrip while viewing another Tab. If these tabs are closed
627 // before selection moves elsewhere, their opener is selected. But if 630 // before selection moves elsewhere, their opener is selected. But if
628 // selection shifts to _any_ tab (including their opener), the group 631 // selection shifts to _any_ tab (including their opener), the group
629 // relationship is reset to avoid confusing close sequencing. 632 // relationship is reset to avoid confusing close sequencing.
630 bool reset_group_on_select; 633 bool reset_group_on_select;
631 634
632 // Is the tab pinned? 635 // Is the tab pinned?
633 bool pinned; 636 bool pinned;
(...skipping 25 matching lines...) Expand all
659 662
660 // A scoped container for notification registries. 663 // A scoped container for notification registries.
661 content::NotificationRegistrar registrar_; 664 content::NotificationRegistrar registrar_;
662 665
663 TabStripSelectionModel selection_model_; 666 TabStripSelectionModel selection_model_;
664 667
665 DISALLOW_IMPLICIT_CONSTRUCTORS(TabStripModel); 668 DISALLOW_IMPLICIT_CONSTRUCTORS(TabStripModel);
666 }; 669 };
667 670
668 #endif // CHROME_BROWSER_TABS_TAB_STRIP_MODEL_H_ 671 #endif // CHROME_BROWSER_TABS_TAB_STRIP_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698