Chromium Code Reviews| 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_VIEWS_TABS_TAB_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 private: | 140 private: |
| 141 friend class TabTest; | 141 friend class TabTest; |
| 142 FRIEND_TEST_ALL_PREFIXES(TabTest, CloseButtonLayout); | 142 FRIEND_TEST_ALL_PREFIXES(TabTest, CloseButtonLayout); |
| 143 | 143 |
| 144 friend class TabStripTest; | 144 friend class TabStripTest; |
| 145 FRIEND_TEST_ALL_PREFIXES(TabStripTest, TabHitTestMaskWhenStacked); | 145 FRIEND_TEST_ALL_PREFIXES(TabStripTest, TabHitTestMaskWhenStacked); |
| 146 FRIEND_TEST_ALL_PREFIXES(TabStripTest, ClippedTabCloseButton); | 146 FRIEND_TEST_ALL_PREFIXES(TabStripTest, ClippedTabCloseButton); |
| 147 | 147 |
| 148 // The animation object used to swap the favicon with the sad tab icon. | 148 // The animation object used to swap the favicon with the sad tab icon. |
| 149 class FaviconCrashAnimation; | 149 class FaviconCrashAnimation; |
| 150 class MediaIndicatorButton; | |
| 150 class TabCloseButton; | 151 class TabCloseButton; |
| 151 | 152 |
| 152 // Contains a cached image and the values used to generate it. | 153 // Contains a cached image and the values used to generate it. |
| 153 struct ImageCacheEntry { | 154 struct ImageCacheEntry { |
| 154 ImageCacheEntry(); | 155 ImageCacheEntry(); |
| 155 ~ImageCacheEntry(); | 156 ~ImageCacheEntry(); |
| 156 | 157 |
| 157 // ID of the resource used. | 158 // ID of the resource used. |
| 158 int resource_id; | 159 int resource_id; |
| 159 | 160 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 void PaintImmersiveTab(gfx::Canvas* canvas); | 219 void PaintImmersiveTab(gfx::Canvas* canvas); |
| 219 | 220 |
| 220 // Paint various portions of the Tab | 221 // Paint various portions of the Tab |
| 221 void PaintTabBackground(gfx::Canvas* canvas); | 222 void PaintTabBackground(gfx::Canvas* canvas); |
| 222 void PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas); | 223 void PaintInactiveTabBackgroundWithTitleChange(gfx::Canvas* canvas); |
| 223 void PaintInactiveTabBackground(gfx::Canvas* canvas); | 224 void PaintInactiveTabBackground(gfx::Canvas* canvas); |
| 224 void PaintInactiveTabBackgroundUsingResourceId(gfx::Canvas* canvas, | 225 void PaintInactiveTabBackgroundUsingResourceId(gfx::Canvas* canvas, |
| 225 int tab_id); | 226 int tab_id); |
| 226 void PaintActiveTabBackground(gfx::Canvas* canvas); | 227 void PaintActiveTabBackground(gfx::Canvas* canvas); |
| 227 | 228 |
| 228 // Paints the favicon and media indicator icon, mirrored for RTL if needed. | 229 // Paints the favicon, mirrored for RTL if needed. |
| 229 void PaintIcon(gfx::Canvas* canvas); | 230 void PaintIcon(gfx::Canvas* canvas); |
| 230 void PaintMediaIndicator(gfx::Canvas* canvas); | |
| 231 | 231 |
| 232 // Invoked if data_.network_state changes, or the network_state is not none. | 232 // Invoked if data_.network_state changes, or the network_state is not none. |
| 233 void AdvanceLoadingAnimation(TabRendererData::NetworkState old_state, | 233 void AdvanceLoadingAnimation(TabRendererData::NetworkState old_state, |
| 234 TabRendererData::NetworkState state); | 234 TabRendererData::NetworkState state); |
| 235 | 235 |
| 236 // Returns the number of favicon-size elements that can fit in the tab's | 236 // Returns the number of favicon-size elements that can fit in the tab's |
| 237 // current size. | 237 // current size. |
| 238 int IconCapacity() const; | 238 int IconCapacity() const; |
| 239 | 239 |
| 240 // Returns whether the Tab should display a favicon. | 240 // Returns whether the Tab should display a favicon. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 257 | 257 |
| 258 void DisplayCrashedFavicon(); | 258 void DisplayCrashedFavicon(); |
| 259 void ResetCrashedFavicon(); | 259 void ResetCrashedFavicon(); |
| 260 | 260 |
| 261 void StopCrashAnimation(); | 261 void StopCrashAnimation(); |
| 262 void StartCrashAnimation(); | 262 void StartCrashAnimation(); |
| 263 | 263 |
| 264 // Returns true if the crash animation is currently running. | 264 // Returns true if the crash animation is currently running. |
| 265 bool IsPerformingCrashAnimation() const; | 265 bool IsPerformingCrashAnimation() const; |
| 266 | 266 |
| 267 // Starts the media indicator fade-in/out animation. There's no stop method | |
| 268 // because this is not a continuous animation. | |
| 269 void StartMediaIndicatorAnimation(); | |
| 270 | |
| 271 // Schedules repaint task for icon. | 267 // Schedules repaint task for icon. |
| 272 void ScheduleIconPaint(); | 268 void ScheduleIconPaint(); |
| 273 | 269 |
| 274 // Returns the rectangle for the light bar in immersive mode. | 270 // Returns the rectangle for the light bar in immersive mode. |
| 275 gfx::Rect GetImmersiveBarRect() const; | 271 gfx::Rect GetImmersiveBarRect() const; |
| 276 | 272 |
| 277 // Gets the tab id and frame id. | 273 // Gets the tab id and frame id. |
| 278 void GetTabIdAndFrameId(views::Widget* widget, | 274 void GetTabIdAndFrameId(views::Widget* widget, |
| 279 int* tab_id, | 275 int* tab_id, |
| 280 int* frame_id) const; | 276 int* frame_id) const; |
| 281 | 277 |
| 278 // Returns |media_indicator_button_|, creating it on-demand. | |
| 279 MediaIndicatorButton* LazyGetMediaIndicatorButton(); | |
|
sky
2014/09/23 22:58:18
Nuke the 'Lazy'. That is, make it GetMediaIndicato
miu
2014/09/24 22:34:16
Done.
| |
| 280 | |
| 282 // Performs a one-time initialization of static resources such as tab images. | 281 // Performs a one-time initialization of static resources such as tab images. |
| 283 static void InitTabResources(); | 282 static void InitTabResources(); |
| 284 | 283 |
| 285 // Returns the minimum possible size of a single unselected Tab, not | 284 // Returns the minimum possible size of a single unselected Tab, not |
| 286 // including considering touch mode. | 285 // including considering touch mode. |
| 287 static gfx::Size GetBasicMinimumUnselectedSize(); | 286 static gfx::Size GetBasicMinimumUnselectedSize(); |
| 288 | 287 |
| 289 // Loads the images to be used for the tab background. | 288 // Loads the images to be used for the tab background. |
| 290 static void LoadTabImages(); | 289 static void LoadTabImages(); |
| 291 | 290 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 bool should_display_crashed_favicon_; | 327 bool should_display_crashed_favicon_; |
| 329 | 328 |
| 330 // Whole-tab throbbing "pulse" animation. | 329 // Whole-tab throbbing "pulse" animation. |
| 331 scoped_ptr<gfx::ThrobAnimation> pulse_animation_; | 330 scoped_ptr<gfx::ThrobAnimation> pulse_animation_; |
| 332 | 331 |
| 333 scoped_ptr<gfx::MultiAnimation> mini_title_change_animation_; | 332 scoped_ptr<gfx::MultiAnimation> mini_title_change_animation_; |
| 334 | 333 |
| 335 // Crash icon animation (in place of favicon). | 334 // Crash icon animation (in place of favicon). |
| 336 scoped_ptr<gfx::LinearAnimation> crash_icon_animation_; | 335 scoped_ptr<gfx::LinearAnimation> crash_icon_animation_; |
| 337 | 336 |
| 338 // Media indicator fade-in/out animation (i.e., only on show/hide, not a | |
| 339 // continuous animation). | |
| 340 scoped_ptr<gfx::Animation> media_indicator_animation_; | |
| 341 TabMediaState animating_media_state_; | |
| 342 | |
| 343 scoped_refptr<gfx::AnimationContainer> animation_container_; | 337 scoped_refptr<gfx::AnimationContainer> animation_container_; |
| 344 | 338 |
| 345 views::ImageButton* close_button_; | 339 views::ImageButton* close_button_; |
| 340 MediaIndicatorButton* media_indicator_button_; // NULL until first use. | |
| 346 views::Label* title_; | 341 views::Label* title_; |
| 347 | 342 |
| 348 bool tab_activated_with_last_tap_down_; | 343 bool tab_activated_with_last_tap_down_; |
| 349 | 344 |
| 350 views::GlowHoverController hover_controller_; | 345 views::GlowHoverController hover_controller_; |
| 351 | 346 |
| 352 // The bounds of various sections of the display. | 347 // The bounds of various sections of the display. |
| 353 gfx::Rect favicon_bounds_; | 348 gfx::Rect favicon_bounds_; |
| 354 gfx::Rect media_indicator_bounds_; | |
| 355 | 349 |
| 356 // The offset used to paint the inactive background image. | 350 // The offset used to paint the inactive background image. |
| 357 gfx::Point background_offset_; | 351 gfx::Point background_offset_; |
| 358 | 352 |
| 359 struct TabImage { | 353 struct TabImage { |
| 360 gfx::ImageSkia* image_l; | 354 gfx::ImageSkia* image_l; |
| 361 gfx::ImageSkia* image_c; | 355 gfx::ImageSkia* image_c; |
| 362 gfx::ImageSkia* image_r; | 356 gfx::ImageSkia* image_r; |
| 363 int l_width; | 357 int l_width; |
| 364 int r_width; | 358 int r_width; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 383 SkColor close_button_color_; | 377 SkColor close_button_color_; |
| 384 | 378 |
| 385 // As the majority of the tabs are inactive, and painting tabs is slowish, | 379 // As the majority of the tabs are inactive, and painting tabs is slowish, |
| 386 // we cache a handful of the inactive tab backgrounds here. | 380 // we cache a handful of the inactive tab backgrounds here. |
| 387 static ImageCache* image_cache_; | 381 static ImageCache* image_cache_; |
| 388 | 382 |
| 389 DISALLOW_COPY_AND_ASSIGN(Tab); | 383 DISALLOW_COPY_AND_ASSIGN(Tab); |
| 390 }; | 384 }; |
| 391 | 385 |
| 392 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ | 386 #endif // CHROME_BROWSER_UI_VIEWS_TABS_TAB_H_ |
| OLD | NEW |