Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Side by Side Diff: chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc

Issue 11011002: Switch FaviconTabHelper to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/gtk/location_bar_view_gtk.cc ('k') | chrome/browser/ui/panels/panel_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #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/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/defaults.h" 12 #include "chrome/browser/defaults.h"
13 #include "chrome/browser/extensions/tab_helper.h" 13 #include "chrome/browser/extensions/tab_helper.h"
14 #include "chrome/browser/favicon/favicon_tab_helper.h" 14 #include "chrome/browser/favicon/favicon_tab_helper.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" 17 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h"
18 #include "chrome/browser/ui/gtk/custom_button.h" 18 #include "chrome/browser/ui/gtk/custom_button.h"
19 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 19 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
20 #include "chrome/browser/ui/gtk/gtk_util.h" 20 #include "chrome/browser/ui/gtk/gtk_util.h"
21 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" 21 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
22 #include "chrome/browser/ui/tab_contents/tab_contents.h"
23 #include "chrome/common/chrome_notification_types.h" 22 #include "chrome/common/chrome_notification_types.h"
24 #include "content/public/browser/notification_source.h" 23 #include "content/public/browser/notification_source.h"
25 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
26 #include "grit/generated_resources.h" 25 #include "grit/generated_resources.h"
27 #include "grit/theme_resources.h" 26 #include "grit/theme_resources.h"
28 #include "grit/ui_resources.h" 27 #include "grit/ui_resources.h"
29 #include "skia/ext/image_operations.h" 28 #include "skia/ext/image_operations.h"
30 #include "ui/base/animation/slide_animation.h" 29 #include "ui/base/animation/slide_animation.h"
31 #include "ui/base/animation/throb_animation.h" 30 #include "ui/base/animation/throb_animation.h"
32 #include "ui/base/gtk/gtk_compat.h" 31 #include "ui/base/gtk/gtk_compat.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 selected_title_color_ = 317 selected_title_color_ =
319 theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT); 318 theme_service_->GetColor(ThemeService::COLOR_TAB_TEXT);
320 unselected_title_color_ = 319 unselected_title_color_ =
321 theme_service_->GetColor(ThemeService::COLOR_BACKGROUND_TAB_TEXT); 320 theme_service_->GetColor(ThemeService::COLOR_BACKGROUND_TAB_TEXT);
322 } 321 }
323 322
324 void TabRendererGtk::UpdateData(WebContents* contents, 323 void TabRendererGtk::UpdateData(WebContents* contents,
325 bool app, 324 bool app,
326 bool loading_only) { 325 bool loading_only) {
327 DCHECK(contents); 326 DCHECK(contents);
328 TabContents* tab_contents = TabContents::FromWebContents(contents); 327 FaviconTabHelper* favicon_tab_helper =
328 FaviconTabHelper::FromWebContents(contents);
329 329
330 if (!loading_only) { 330 if (!loading_only) {
331 data_.title = contents->GetTitle(); 331 data_.title = contents->GetTitle();
332 data_.incognito = contents->GetBrowserContext()->IsOffTheRecord(); 332 data_.incognito = contents->GetBrowserContext()->IsOffTheRecord();
333 data_.crashed = contents->IsCrashed(); 333 data_.crashed = contents->IsCrashed();
334 334
335 SkBitmap* app_icon = 335 SkBitmap* app_icon =
336 extensions::TabHelper::FromWebContents(contents)->GetExtensionAppIcon(); 336 extensions::TabHelper::FromWebContents(contents)->GetExtensionAppIcon();
337 if (app_icon) { 337 if (app_icon) {
338 data_.favicon = *app_icon; 338 data_.favicon = *app_icon;
339 } else { 339 } else {
340 data_.favicon = 340 data_.favicon = favicon_tab_helper->GetFavicon().AsBitmap();
341 tab_contents->favicon_tab_helper()->GetFavicon().AsBitmap();
342 } 341 }
343 342
344 data_.app = app; 343 data_.app = app;
345 344
346 // Make a cairo cached version of the favicon. 345 // Make a cairo cached version of the favicon.
347 if (!data_.favicon.isNull()) { 346 if (!data_.favicon.isNull()) {
348 // Instead of resizing the icon during each frame, create our resized 347 // Instead of resizing the icon during each frame, create our resized
349 // icon resource now, send it to the xserver and use that each frame 348 // icon resource now, send it to the xserver and use that each frame
350 // instead. 349 // instead.
351 350
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 // will eventually be chromium-themable and this code will go away. 394 // will eventually be chromium-themable and this code will go away.
396 data_.is_default_favicon = 395 data_.is_default_favicon =
397 (data_.favicon.pixelRef() == 396 (data_.favicon.pixelRef() ==
398 ui::ResourceBundle::GetSharedInstance().GetBitmapNamed( 397 ui::ResourceBundle::GetSharedInstance().GetBitmapNamed(
399 IDR_DEFAULT_FAVICON)->pixelRef()); 398 IDR_DEFAULT_FAVICON)->pixelRef());
400 } 399 }
401 400
402 // Loading state also involves whether we show the favicon, since that's where 401 // Loading state also involves whether we show the favicon, since that's where
403 // we display the throbber. 402 // we display the throbber.
404 data_.loading = contents->IsLoading(); 403 data_.loading = contents->IsLoading();
405 data_.show_icon = tab_contents->favicon_tab_helper()->ShouldDisplayFavicon(); 404 data_.show_icon = favicon_tab_helper->ShouldDisplayFavicon();
406 } 405 }
407 406
408 void TabRendererGtk::UpdateFromModel() { 407 void TabRendererGtk::UpdateFromModel() {
409 // Force a layout, since the tab may have grown a favicon. 408 // Force a layout, since the tab may have grown a favicon.
410 Layout(); 409 Layout();
411 SchedulePaint(); 410 SchedulePaint();
412 411
413 if (data_.crashed) { 412 if (data_.crashed) {
414 if (!should_display_crashed_favicon_ && !IsPerformingCrashAnimation()) 413 if (!should_display_crashed_favicon_ && !IsPerformingCrashAnimation())
415 StartCrashAnimation(); 414 StartCrashAnimation();
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 GdkPixbuf* tab_close = rb.GetNativeImageNamed(IDR_TAB_CLOSE).ToGdkPixbuf(); 1120 GdkPixbuf* tab_close = rb.GetNativeImageNamed(IDR_TAB_CLOSE).ToGdkPixbuf();
1122 close_button_width_ = gdk_pixbuf_get_width(tab_close); 1121 close_button_width_ = gdk_pixbuf_get_width(tab_close);
1123 close_button_height_ = gdk_pixbuf_get_height(tab_close); 1122 close_button_height_ = gdk_pixbuf_get_height(tab_close);
1124 1123
1125 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont); 1124 const gfx::Font& base_font = rb.GetFont(ui::ResourceBundle::BaseFont);
1126 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); 1125 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize);
1127 title_font_height_ = title_font_->GetHeight(); 1126 title_font_height_ = title_font_->GetHeight();
1128 1127
1129 initialized_ = true; 1128 initialized_ = true;
1130 } 1129 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/location_bar_view_gtk.cc ('k') | chrome/browser/ui/panels/panel_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698