OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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_UI_VIEWS_SIDEBAR_BROWSER_SIDEBAR_TAB_STRIP_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_SIDEBAR_BROWSER_SIDEBAR_TAB_STRIP_CONTROLLER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include <string> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/scoped_ptr.h" |
| 13 #include "base/timer.h" |
| 14 #include "chrome/browser/ui/views/sidebar/sidebar_tab_strip_controller.h" |
| 15 |
| 16 class SidebarBaseTabStrip; |
| 17 class SidebarContainer; |
| 18 class SidebarModel; |
| 19 class TabContentsWrapper; |
| 20 |
| 21 struct SidebarTabRendererData; |
| 22 |
| 23 // An implementation of SidebarTabStripController that sources data from the |
| 24 // SidebarModel (SidebarManager and SidebarContainers are behind it) |
| 25 // and mediates BrowserView, SidebarModel and SidebarTabStrip interactions. |
| 26 class BrowserSidebarTabStripController : public SidebarTabStripController { |
| 27 public: |
| 28 BrowserSidebarTabStripController(SidebarModel* model, Delegate* delegate); |
| 29 virtual ~BrowserSidebarTabStripController(); |
| 30 |
| 31 // SidebarTabStripController overrides: |
| 32 virtual bool IsSidebarExpanded(); |
| 33 virtual bool IsTabSelected(int model_index); |
| 34 virtual void SelectTab(int model_index); |
| 35 virtual void UpdateTabs(TabContentsWrapper* tab); |
| 36 virtual void UpdateState(const SidebarContainer* sidebar); |
| 37 virtual void UpdateLoadingState(const SidebarContainer* sidebar); |
| 38 virtual void TabStripBoundsChanged(bool is_animating); |
| 39 |
| 40 void set_tab_strip(SidebarBaseTabStrip* tab_strip) { |
| 41 tab_strip_ = tab_strip; |
| 42 } |
| 43 |
| 44 private: |
| 45 friend class BrowserSidebarTabStripControllerTest; |
| 46 |
| 47 SidebarModel* model() const { return model_; } |
| 48 |
| 49 // Updates the loading animations of all mini tabs. |
| 50 void UpdateLoadingAnimations(); |
| 51 // Callback for the loading animation(s) timer associated with this view. |
| 52 void LoadingAnimationCallback(); |
| 53 |
| 54 // Invokes tab_strip_->SetTabData. |
| 55 void SetTabDataAt(SidebarContainer* sidebar, int model_index); |
| 56 |
| 57 // Sets the SidebarTabRendererData from the SidebarContainer. |
| 58 void SetSidebarTabRendererDataFromModel(const SidebarContainer* sidebar, |
| 59 SidebarTabRendererData* data); |
| 60 |
| 61 // Non-owning pointer to the model. |
| 62 SidebarModel* const model_; |
| 63 |
| 64 // Non-owning pointer to the delegate to receive tab strip view size and shape |
| 65 // updates. |
| 66 Delegate* const delegate_; |
| 67 |
| 68 // Non-owning pointer to the tab strip which owns this controller. |
| 69 SidebarBaseTabStrip* tab_strip_; |
| 70 |
| 71 // Page sidebar mini tabs are currently displayed for. |
| 72 TabContentsWrapper* tab_; |
| 73 |
| 74 // Mapping of the model ids (content ids, in sidebar terms) to the order |
| 75 // of the tabs on the tab strip. |
| 76 typedef std::vector<std::string> ModelIndex; |
| 77 ModelIndex model_index_; |
| 78 |
| 79 // The timer used to update frames for the "Loading" animation. |
| 80 base::RepeatingTimer<BrowserSidebarTabStripController> |
| 81 loading_animation_timer_; |
| 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(BrowserSidebarTabStripController); |
| 84 }; |
| 85 |
| 86 #endif // CHROME_BROWSER_UI_VIEWS_SIDEBAR_BROWSER_SIDEBAR_TAB_STRIP_CONTROLLER_
H_ |
| 87 |
OLD | NEW |