Home | History | Annotate | Download | only in tabs
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_TABS_DEFAULT_TAB_HANDLER_H_
      6 #define CHROME_BROWSER_TABS_DEFAULT_TAB_HANDLER_H_
      7 #pragma once
      8 
      9 #include "base/memory/scoped_ptr.h"
     10 #include "chrome/browser/tabs/tab_handler.h"
     11 #include "chrome/browser/tabs/tab_strip_model_delegate.h"
     12 #include "chrome/browser/tabs/tab_strip_model_observer.h"
     13 
     14 // A TabHandler implementation that interacts with the default TabStripModel.
     15 // The intent is that the TabStripModel API is contained at this level, and
     16 // never propagates beyond to the Browser.
     17 class DefaultTabHandler : public TabHandler,
     18                           public TabStripModelDelegate,
     19                           public TabStripModelObserver {
     20  public:
     21   explicit DefaultTabHandler(TabHandlerDelegate* delegate);
     22   virtual ~DefaultTabHandler();
     23 
     24   // Overridden from TabHandler:
     25   virtual TabStripModel* GetTabStripModel() const;
     26 
     27   // Overridden from TabStripModelDelegate:
     28   virtual TabContentsWrapper* AddBlankTab(bool foreground);
     29   virtual TabContentsWrapper* AddBlankTabAt(int index, bool foreground);
     30   virtual Browser* CreateNewStripWithContents(
     31       TabContentsWrapper* detached_contents,
     32       const gfx::Rect& window_bounds,
     33       const DockInfo& dock_info,
     34       bool maximize);
     35   virtual int GetDragActions() const;
     36   virtual TabContentsWrapper* CreateTabContentsForURL(
     37       const GURL& url,
     38       const GURL& referrer,
     39       Profile* profile,
     40       PageTransition::Type transition,
     41       bool defer_load,
     42       SiteInstance* instance) const;
     43   virtual bool CanDuplicateContentsAt(int index);
     44   virtual void DuplicateContentsAt(int index);
     45   virtual void CloseFrameAfterDragSession();
     46   virtual void CreateHistoricalTab(TabContentsWrapper* contents);
     47   virtual bool RunUnloadListenerBeforeClosing(TabContentsWrapper* contents);
     48   virtual bool CanCloseContentsAt(int index);
     49   virtual bool CanBookmarkAllTabs() const;
     50   virtual void BookmarkAllTabs();
     51   virtual bool CanCloseTab() const;
     52   virtual void ToggleUseVerticalTabs();
     53   virtual bool CanRestoreTab();
     54   virtual void RestoreTab();
     55   virtual bool LargeIconsPermitted() const;
     56   virtual bool UseVerticalTabs() const;
     57 
     58   // Overridden from TabStripModelObserver:
     59   virtual void TabInsertedAt(TabContentsWrapper* contents,
     60                              int index,
     61                              bool foreground);
     62   virtual void TabClosingAt(TabStripModel* tab_strip_model,
     63                             TabContentsWrapper* contents,
     64                             int index);
     65   virtual void TabDetachedAt(TabContentsWrapper* contents, int index);
     66   virtual void TabDeselected(TabContentsWrapper* contents);
     67   virtual void TabSelectedAt(TabContentsWrapper* old_contents,
     68                              TabContentsWrapper* new_contents,
     69                              int index,
     70                              bool user_gesture);
     71   virtual void TabMoved(TabContentsWrapper* contents,
     72                         int from_index,
     73                         int to_index);
     74   virtual void TabReplacedAt(TabStripModel* tab_strip_model,
     75                              TabContentsWrapper* old_contents,
     76                              TabContentsWrapper* new_contents,
     77                              int index);
     78   virtual void TabPinnedStateChanged(TabContentsWrapper* contents, int index);
     79   virtual void TabStripEmpty();
     80 
     81  private:
     82   TabHandlerDelegate* delegate_;
     83 
     84   scoped_ptr<TabStripModel> model_;
     85 
     86   DISALLOW_COPY_AND_ASSIGN(DefaultTabHandler);
     87 };
     88 
     89 #endif  // CHROME_BROWSER_TABS_DEFAULT_TAB_HANDLER_H_
     90 
     91