| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UI_ASH_LAUNCHER_BROWSER_LAUNCHER_ITEM_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_LAUNCHER_ITEM_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_LAUNCHER_ITEM_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_LAUNCHER_ITEM_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ash/launcher/launcher_types.h" | 10 #include "ash/launcher/launcher_types.h" |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/string16.h" | 15 #include "base/string16.h" |
| 16 #include "chrome/browser/ui/ash/launcher/launcher_favicon_loader.h" | 16 #include "chrome/browser/ui/ash/launcher/launcher_favicon_loader.h" |
| 17 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 17 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
| 18 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
| 19 #include "ui/aura/window_observer.h" | 19 #include "ui/aura/window_observer.h" |
| 20 | 20 |
| 21 class Browser; | 21 class Browser; |
| 22 class LauncherFaviconLoader; | |
| 23 | 22 |
| 24 namespace ash { | 23 namespace ash { |
| 25 class LauncherModel; | 24 class LauncherModel; |
| 26 } | 25 } |
| 27 | 26 |
| 28 // BrowserLauncherItemController is responsible for keeping the launcher | 27 // BrowserLauncherItemController is responsible for keeping the launcher |
| 29 // representation of a window up to date as the active tab changes. | 28 // representation of a window up to date as the active tab changes. |
| 30 class BrowserLauncherItemController : public LauncherItemController, | 29 class BrowserLauncherItemController : public LauncherItemController, |
| 31 public TabStripModelObserver, | 30 public TabStripModelObserver, |
| 32 public LauncherFaviconLoader::Delegate, | |
| 33 public aura::WindowObserver { | 31 public aura::WindowObserver { |
| 34 public: | 32 public: |
| 35 // This API is to be used as part of testing only. | 33 // This API is to be used as part of testing only. |
| 36 class TestApi { | 34 class TestApi { |
| 37 public: | 35 public: |
| 38 explicit TestApi(BrowserLauncherItemController* controller) | 36 explicit TestApi(BrowserLauncherItemController* controller) |
| 39 : controller_(controller) {} | 37 : controller_(controller) {} |
| 40 ~TestApi() {} | 38 ~TestApi() {} |
| 41 | 39 |
| 42 // Returns the launcher id for the browser window. | 40 // Returns the launcher id for the browser window. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 57 virtual const std::string& app_id() const OVERRIDE; | 55 virtual const std::string& app_id() const OVERRIDE; |
| 58 | 56 |
| 59 // Sets up this BrowserLauncherItemController. | 57 // Sets up this BrowserLauncherItemController. |
| 60 void Init(); | 58 void Init(); |
| 61 | 59 |
| 62 // Creates and returns a new BrowserLauncherItemController for |browser|. This | 60 // Creates and returns a new BrowserLauncherItemController for |browser|. This |
| 63 // returns NULL if a BrowserLauncherItemController is not needed for the | 61 // returns NULL if a BrowserLauncherItemController is not needed for the |
| 64 // specified browser. | 62 // specified browser. |
| 65 static BrowserLauncherItemController* Create(Browser* browser); | 63 static BrowserLauncherItemController* Create(Browser* browser); |
| 66 | 64 |
| 67 LauncherFaviconLoader* favicon_loader() const { | |
| 68 return favicon_loader_.get(); | |
| 69 } | |
| 70 | |
| 71 // Call to indicate that the window the tabcontents are in has changed its | 65 // Call to indicate that the window the tabcontents are in has changed its |
| 72 // activation state. | 66 // activation state. |
| 73 void BrowserActivationStateChanged(); | 67 void BrowserActivationStateChanged(); |
| 74 | 68 |
| 75 // LauncherItemController overrides: | 69 // LauncherItemController overrides: |
| 76 virtual string16 GetTitle() OVERRIDE; | 70 virtual string16 GetTitle() OVERRIDE; |
| 77 virtual bool HasWindow(aura::Window* window) const OVERRIDE; | 71 virtual bool HasWindow(aura::Window* window) const OVERRIDE; |
| 78 virtual bool IsOpen() const OVERRIDE; | 72 virtual bool IsOpen() const OVERRIDE; |
| 79 virtual bool IsVisible() const OVERRIDE; | 73 virtual bool IsVisible() const OVERRIDE; |
| 80 virtual void Launch(int event_flags) OVERRIDE; | 74 virtual void Launch(int event_flags) OVERRIDE; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 98 int index) OVERRIDE; | 92 int index) OVERRIDE; |
| 99 virtual void TabChangedAt( | 93 virtual void TabChangedAt( |
| 100 content::WebContents* contents, | 94 content::WebContents* contents, |
| 101 int index, | 95 int index, |
| 102 TabStripModelObserver::TabChangeType change_type) OVERRIDE; | 96 TabStripModelObserver::TabChangeType change_type) OVERRIDE; |
| 103 virtual void TabReplacedAt(TabStripModel* tab_strip_model, | 97 virtual void TabReplacedAt(TabStripModel* tab_strip_model, |
| 104 content::WebContents* old_contents, | 98 content::WebContents* old_contents, |
| 105 content::WebContents* new_contents, | 99 content::WebContents* new_contents, |
| 106 int index) OVERRIDE; | 100 int index) OVERRIDE; |
| 107 | 101 |
| 108 // LauncherFaviconLoader::Delegate overrides: | |
| 109 virtual void FaviconUpdated() OVERRIDE; | |
| 110 | |
| 111 // aura::WindowObserver overrides: | 102 // aura::WindowObserver overrides: |
| 112 virtual void OnWindowPropertyChanged(aura::Window* window, | 103 virtual void OnWindowPropertyChanged(aura::Window* window, |
| 113 const void* key, | 104 const void* key, |
| 114 intptr_t old) OVERRIDE; | 105 intptr_t old) OVERRIDE; |
| 115 | 106 |
| 116 private: | 107 private: |
| 117 FRIEND_TEST_ALL_PREFIXES(BrowserLauncherItemControllerTest, PanelItem); | 108 FRIEND_TEST_ALL_PREFIXES(BrowserLauncherItemControllerTest, PanelItem); |
| 118 | 109 |
| 119 // Used to identify what an update corresponds to. | 110 // Used to identify what an update corresponds to. |
| 120 enum UpdateType { | 111 enum UpdateType { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 139 | 130 |
| 140 // If running a windowed V1 app with the new launcher, this (empty) app id | 131 // If running a windowed V1 app with the new launcher, this (empty) app id |
| 141 // will be returned by app_id(). | 132 // will be returned by app_id(). |
| 142 std::string empty_app_id_; | 133 std::string empty_app_id_; |
| 143 | 134 |
| 144 TabStripModel* tab_model_; | 135 TabStripModel* tab_model_; |
| 145 | 136 |
| 146 // Whether this is associated with an incognito profile. | 137 // Whether this is associated with an incognito profile. |
| 147 const bool is_incognito_; | 138 const bool is_incognito_; |
| 148 | 139 |
| 149 // Loads launcher sized favicons for panels. | |
| 150 scoped_ptr<LauncherFaviconLoader> favicon_loader_; | |
| 151 | |
| 152 DISALLOW_COPY_AND_ASSIGN(BrowserLauncherItemController); | 140 DISALLOW_COPY_AND_ASSIGN(BrowserLauncherItemController); |
| 153 }; | 141 }; |
| 154 | 142 |
| 155 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_LAUNCHER_ITEM_CONTROLLER_H_ | 143 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_LAUNCHER_ITEM_CONTROLLER_H_ |
| OLD | NEW |