| OLD | NEW |
| 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 #include "chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h" | 5 #include "chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 //////////////////////////////////////////////////////////////////////////////// | 149 //////////////////////////////////////////////////////////////////////////////// |
| 150 // TabRendererGtk::LoadingAnimation, public: | 150 // TabRendererGtk::LoadingAnimation, public: |
| 151 // | 151 // |
| 152 TabRendererGtk::LoadingAnimation::LoadingAnimation( | 152 TabRendererGtk::LoadingAnimation::LoadingAnimation( |
| 153 ThemeService* theme_service) | 153 ThemeService* theme_service) |
| 154 : data_(new Data(theme_service)), | 154 : data_(new Data(theme_service)), |
| 155 theme_service_(theme_service), | 155 theme_service_(theme_service), |
| 156 animation_state_(ANIMATION_NONE), | 156 animation_state_(ANIMATION_NONE), |
| 157 animation_frame_(0) { | 157 animation_frame_(0) { |
| 158 registrar_.Add(this, | 158 registrar_.Add(this, |
| 159 NotificationType::BROWSER_THEME_CHANGED, | 159 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 160 Source<ThemeService>(theme_service_)); | 160 Source<ThemeService>(theme_service_)); |
| 161 } | 161 } |
| 162 | 162 |
| 163 TabRendererGtk::LoadingAnimation::LoadingAnimation( | 163 TabRendererGtk::LoadingAnimation::LoadingAnimation( |
| 164 const LoadingAnimation::Data& data) | 164 const LoadingAnimation::Data& data) |
| 165 : data_(new Data(data)), | 165 : data_(new Data(data)), |
| 166 theme_service_(NULL), | 166 theme_service_(NULL), |
| 167 animation_state_(ANIMATION_NONE), | 167 animation_state_(ANIMATION_NONE), |
| 168 animation_frame_(0) { | 168 animation_frame_(0) { |
| 169 } | 169 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 193 data_->waiting_animation_frame_count : | 193 data_->waiting_animation_frame_count : |
| 194 data_->loading_animation_frame_count); | 194 data_->loading_animation_frame_count); |
| 195 has_changed = true; | 195 has_changed = true; |
| 196 } else { | 196 } else { |
| 197 animation_frame_ = 0; | 197 animation_frame_ = 0; |
| 198 } | 198 } |
| 199 return has_changed; | 199 return has_changed; |
| 200 } | 200 } |
| 201 | 201 |
| 202 void TabRendererGtk::LoadingAnimation::Observe( | 202 void TabRendererGtk::LoadingAnimation::Observe( |
| 203 NotificationType type, | 203 int type, |
| 204 const NotificationSource& source, | 204 const NotificationSource& source, |
| 205 const NotificationDetails& details) { | 205 const NotificationDetails& details) { |
| 206 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); | 206 DCHECK(type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED); |
| 207 data_.reset(new Data(theme_service_)); | 207 data_.reset(new Data(theme_service_)); |
| 208 } | 208 } |
| 209 | 209 |
| 210 //////////////////////////////////////////////////////////////////////////////// | 210 //////////////////////////////////////////////////////////////////////////////// |
| 211 // FaviconCrashAnimation | 211 // FaviconCrashAnimation |
| 212 // | 212 // |
| 213 // A custom animation subclass to manage the favicon crash animation. | 213 // A custom animation subclass to manage the favicon crash animation. |
| 214 class TabRendererGtk::FaviconCrashAnimation : public ui::LinearAnimation, | 214 class TabRendererGtk::FaviconCrashAnimation : public ui::LinearAnimation, |
| 215 public ui::AnimationDelegate { | 215 public ui::AnimationDelegate { |
| 216 public: | 216 public: |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 g_signal_connect(tab_.get(), "expose-event", | 266 g_signal_connect(tab_.get(), "expose-event", |
| 267 G_CALLBACK(OnExposeEventThunk), this); | 267 G_CALLBACK(OnExposeEventThunk), this); |
| 268 g_signal_connect(tab_.get(), "size-allocate", | 268 g_signal_connect(tab_.get(), "size-allocate", |
| 269 G_CALLBACK(OnSizeAllocateThunk), this); | 269 G_CALLBACK(OnSizeAllocateThunk), this); |
| 270 close_button_.reset(MakeCloseButton()); | 270 close_button_.reset(MakeCloseButton()); |
| 271 gtk_widget_show(tab_.get()); | 271 gtk_widget_show(tab_.get()); |
| 272 | 272 |
| 273 hover_animation_.reset(new ui::SlideAnimation(this)); | 273 hover_animation_.reset(new ui::SlideAnimation(this)); |
| 274 hover_animation_->SetSlideDuration(kHoverDurationMs); | 274 hover_animation_->SetSlideDuration(kHoverDurationMs); |
| 275 | 275 |
| 276 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, | 276 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 277 Source<ThemeService>(theme_service_)); | 277 Source<ThemeService>(theme_service_)); |
| 278 } | 278 } |
| 279 | 279 |
| 280 TabRendererGtk::~TabRendererGtk() { | 280 TabRendererGtk::~TabRendererGtk() { |
| 281 tab_.Destroy(); | 281 tab_.Destroy(); |
| 282 for (BitmapCache::iterator it = cached_bitmaps_.begin(); | 282 for (BitmapCache::iterator it = cached_bitmaps_.begin(); |
| 283 it != cached_bitmaps_.end(); ++it) { | 283 it != cached_bitmaps_.end(); ++it) { |
| 284 delete it->second.bitmap; | 284 delete it->second.bitmap; |
| 285 } | 285 } |
| 286 } | 286 } |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 void TabRendererGtk::StopMiniTabTitleAnimation() { | 552 void TabRendererGtk::StopMiniTabTitleAnimation() { |
| 553 if (mini_title_animation_.get()) | 553 if (mini_title_animation_.get()) |
| 554 mini_title_animation_->Stop(); | 554 mini_title_animation_->Stop(); |
| 555 } | 555 } |
| 556 | 556 |
| 557 void TabRendererGtk::SetBounds(const gfx::Rect& bounds) { | 557 void TabRendererGtk::SetBounds(const gfx::Rect& bounds) { |
| 558 requisition_ = bounds; | 558 requisition_ = bounds; |
| 559 gtk_widget_set_size_request(tab_.get(), bounds.width(), bounds.height()); | 559 gtk_widget_set_size_request(tab_.get(), bounds.width(), bounds.height()); |
| 560 } | 560 } |
| 561 | 561 |
| 562 void TabRendererGtk::Observe(NotificationType type, | 562 void TabRendererGtk::Observe(int type, |
| 563 const NotificationSource& source, | 563 const NotificationSource& source, |
| 564 const NotificationDetails& details) { | 564 const NotificationDetails& details) { |
| 565 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED); | 565 DCHECK(type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED); |
| 566 | 566 |
| 567 // Clear our cache when we receive a theme change notification because it | 567 // Clear our cache when we receive a theme change notification because it |
| 568 // contains cached bitmaps based off the previous theme. | 568 // contains cached bitmaps based off the previous theme. |
| 569 for (BitmapCache::iterator it = cached_bitmaps_.begin(); | 569 for (BitmapCache::iterator it = cached_bitmaps_.begin(); |
| 570 it != cached_bitmaps_.end(); ++it) { | 570 it != cached_bitmaps_.end(); ++it) { |
| 571 delete it->second.bitmap; | 571 delete it->second.bitmap; |
| 572 } | 572 } |
| 573 cached_bitmaps_.clear(); | 573 cached_bitmaps_.clear(); |
| 574 } | 574 } |
| 575 | 575 |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 | 1094 |
| 1095 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 1095 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 1096 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); | 1096 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); |
| 1097 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); | 1097 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); |
| 1098 title_font_height_ = title_font_->GetHeight(); | 1098 title_font_height_ = title_font_->GetHeight(); |
| 1099 | 1099 |
| 1100 crashed_favicon = rb.GetBitmapNamed(IDR_SAD_FAVICON); | 1100 crashed_favicon = rb.GetBitmapNamed(IDR_SAD_FAVICON); |
| 1101 | 1101 |
| 1102 initialized_ = true; | 1102 initialized_ = true; |
| 1103 } | 1103 } |
| OLD | NEW |