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