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

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

Issue 6814029: Revert 80519 - Move favicon from TabContents to TabContentsWrapper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 8 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
OLDNEW
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_tab_helper.h"
14 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" 15 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h"
17 #include "chrome/browser/ui/gtk/custom_button.h" 16 #include "chrome/browser/ui/gtk/custom_button.h"
18 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 17 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
19 #include "chrome/browser/ui/gtk/gtk_util.h" 18 #include "chrome/browser/ui/gtk/gtk_util.h"
20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
21 #include "content/browser/tab_contents/tab_contents.h" 20 #include "content/browser/tab_contents/tab_contents.h"
22 #include "content/common/notification_service.h" 21 #include "content/common/notification_service.h"
23 #include "grit/app_resources.h" 22 #include "grit/app_resources.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 for (BitmapCache::iterator it = cached_bitmaps_.begin(); 279 for (BitmapCache::iterator it = cached_bitmaps_.begin();
281 it != cached_bitmaps_.end(); ++it) { 280 it != cached_bitmaps_.end(); ++it) {
282 delete it->second.bitmap; 281 delete it->second.bitmap;
283 } 282 }
284 } 283 }
285 284
286 void TabRendererGtk::UpdateData(TabContents* contents, 285 void TabRendererGtk::UpdateData(TabContents* contents,
287 bool app, 286 bool app,
288 bool loading_only) { 287 bool loading_only) {
289 DCHECK(contents); 288 DCHECK(contents);
290 TabContentsWrapper* wrapper =
291 TabContentsWrapper::GetCurrentWrapperForContents(contents);
292 theme_service_ = GtkThemeService::GetFrom(contents->profile()); 289 theme_service_ = GtkThemeService::GetFrom(contents->profile());
293 290
294 if (!loading_only) { 291 if (!loading_only) {
295 data_.title = contents->GetTitle(); 292 data_.title = contents->GetTitle();
296 data_.incognito = contents->profile()->IsOffTheRecord(); 293 data_.incognito = contents->profile()->IsOffTheRecord();
297 data_.crashed = contents->is_crashed(); 294 data_.crashed = contents->is_crashed();
298 295
299 SkBitmap* app_icon = 296 SkBitmap* app_icon =
300 TabContentsWrapper::GetCurrentWrapperForContents(contents)-> 297 TabContentsWrapper::GetCurrentWrapperForContents(contents)->
301 extension_tab_helper()->GetExtensionAppIcon(); 298 extension_tab_helper()->GetExtensionAppIcon();
302 if (app_icon) 299 if (app_icon)
303 data_.favicon = *app_icon; 300 data_.favicon = *app_icon;
304 else 301 else
305 data_.favicon = wrapper->favicon_tab_helper()->GetFavicon(); 302 data_.favicon = contents->GetFavicon();
306 303
307 data_.app = app; 304 data_.app = app;
308 // This is kind of a hacky way to determine whether our icon is the default 305 // This is kind of a hacky way to determine whether our icon is the default
309 // favicon. But the plumbing that would be necessary to do it right would 306 // favicon. But the plumbing that would be necessary to do it right would
310 // be a good bit of work and would sully code for other platforms which 307 // be a good bit of work and would sully code for other platforms which
311 // don't care to custom-theme the favicon. Hopefully the default favicon 308 // don't care to custom-theme the favicon. Hopefully the default favicon
312 // will eventually be chromium-themable and this code will go away. 309 // will eventually be chromium-themable and this code will go away.
313 data_.is_default_favicon = 310 data_.is_default_favicon =
314 (data_.favicon.pixelRef() == 311 (data_.favicon.pixelRef() ==
315 ResourceBundle::GetSharedInstance().GetBitmapNamed( 312 ResourceBundle::GetSharedInstance().GetBitmapNamed(
316 IDR_DEFAULT_FAVICON)->pixelRef()); 313 IDR_DEFAULT_FAVICON)->pixelRef());
317 } 314 }
318 315
319 // Loading state also involves whether we show the favicon, since that's where 316 // Loading state also involves whether we show the favicon, since that's where
320 // we display the throbber. 317 // we display the throbber.
321 data_.loading = contents->is_loading(); 318 data_.loading = contents->is_loading();
322 data_.show_icon = wrapper->favicon_tab_helper()->ShouldDisplayFavicon(); 319 data_.show_icon = contents->ShouldDisplayFavicon();
323 } 320 }
324 321
325 void TabRendererGtk::UpdateFromModel() { 322 void TabRendererGtk::UpdateFromModel() {
326 // Force a layout, since the tab may have grown a favicon. 323 // Force a layout, since the tab may have grown a favicon.
327 Layout(); 324 Layout();
328 SchedulePaint(); 325 SchedulePaint();
329 326
330 if (data_.crashed) { 327 if (data_.crashed) {
331 if (!should_display_crashed_favicon_ && !IsPerformingCrashAnimation()) 328 if (!should_display_crashed_favicon_ && !IsPerformingCrashAnimation())
332 StartCrashAnimation(); 329 StartCrashAnimation();
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 1083
1087 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 1084 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
1088 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); 1085 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont);
1089 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize); 1086 title_font_ = new gfx::Font(base_font.GetFontName(), kFontPixelSize);
1090 title_font_height_ = title_font_->GetHeight(); 1087 title_font_height_ = title_font_->GetHeight();
1091 1088
1092 crashed_favicon = rb.GetBitmapNamed(IDR_SAD_FAVICON); 1089 crashed_favicon = rb.GetBitmapNamed(IDR_SAD_FAVICON);
1093 1090
1094 initialized_ = true; 1091 initialized_ = true;
1095 } 1092 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/location_bar_view_gtk.cc ('k') | chrome/browser/ui/tab_contents/tab_contents_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698