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

Side by Side Diff: chrome/browser/ui/views/hung_renderer_view.cc

Issue 6735042: Move favicon from TabContents to TabContentsWrapper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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/browser_dialogs.h" 5 #include "chrome/browser/ui/browser_dialogs.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/browser_list.h" 9 #include "chrome/browser/browser_list.h"
10 #include "chrome/browser/favicon_tab_helper.h"
10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
11 #include "chrome/common/chrome_constants.h" 12 #include "chrome/common/chrome_constants.h"
12 #include "chrome/common/logging_chrome.h" 13 #include "chrome/common/logging_chrome.h"
13 #include "content/browser/renderer_host/render_process_host.h" 14 #include "content/browser/renderer_host/render_process_host.h"
14 #include "content/browser/renderer_host/render_view_host.h" 15 #include "content/browser/renderer_host/render_view_host.h"
15 #include "content/browser/tab_contents/tab_contents.h" 16 #include "content/browser/tab_contents/tab_contents.h"
16 #include "content/common/result_codes.h" 17 #include "content/common/result_codes.h"
17 #include "grit/chromium_strings.h" 18 #include "grit/chromium_strings.h"
18 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
19 #include "grit/theme_resources.h" 20 #include "grit/theme_resources.h"
(...skipping 28 matching lines...) Expand all
48 void InitForTabContents(TabContents* hung_contents); 49 void InitForTabContents(TabContents* hung_contents);
49 50
50 // Overridden from views::GroupTableModel: 51 // Overridden from views::GroupTableModel:
51 virtual int RowCount(); 52 virtual int RowCount();
52 virtual string16 GetText(int row, int column_id); 53 virtual string16 GetText(int row, int column_id);
53 virtual SkBitmap GetIcon(int row); 54 virtual SkBitmap GetIcon(int row);
54 virtual void SetObserver(ui::TableModelObserver* observer); 55 virtual void SetObserver(ui::TableModelObserver* observer);
55 virtual void GetGroupRangeForItem(int item, views::GroupRange* range); 56 virtual void GetGroupRangeForItem(int item, views::GroupRange* range);
56 57
57 private: 58 private:
58 typedef std::vector<TabContents*> TabContentsVector; 59 typedef std::vector<TabContentsWrapper*> TabContentsVector;
59 TabContentsVector tab_contentses_; 60 TabContentsVector tab_contentses_;
60 61
61 ui::TableModelObserver* observer_; 62 ui::TableModelObserver* observer_;
62 63
63 DISALLOW_COPY_AND_ASSIGN(HungPagesTableModel); 64 DISALLOW_COPY_AND_ASSIGN(HungPagesTableModel);
64 }; 65 };
65 66
66 /////////////////////////////////////////////////////////////////////////////// 67 ///////////////////////////////////////////////////////////////////////////////
67 // HungPagesTableModel, public: 68 // HungPagesTableModel, public:
68 69
69 HungPagesTableModel::HungPagesTableModel() : observer_(NULL) { 70 HungPagesTableModel::HungPagesTableModel() : observer_(NULL) {
70 } 71 }
71 72
72 HungPagesTableModel::~HungPagesTableModel() { 73 HungPagesTableModel::~HungPagesTableModel() {
73 } 74 }
74 75
75 void HungPagesTableModel::InitForTabContents(TabContents* hung_contents) { 76 void HungPagesTableModel::InitForTabContents(TabContents* hung_contents) {
76 tab_contentses_.clear(); 77 tab_contentses_.clear();
77 for (TabContentsIterator it; !it.done(); ++it) { 78 for (TabContentsIterator it; !it.done(); ++it) {
78 if (it->tab_contents()->GetRenderProcessHost() == 79 if (it->tab_contents()->GetRenderProcessHost() ==
79 hung_contents->GetRenderProcessHost()) 80 hung_contents->GetRenderProcessHost())
80 tab_contentses_.push_back((*it)->tab_contents()); 81 tab_contentses_.push_back(*it);
81 } 82 }
82 // The world is different. 83 // The world is different.
83 if (observer_) 84 if (observer_)
84 observer_->OnModelChanged(); 85 observer_->OnModelChanged();
85 } 86 }
86 87
87 /////////////////////////////////////////////////////////////////////////////// 88 ///////////////////////////////////////////////////////////////////////////////
88 // HungPagesTableModel, views::GroupTableModel implementation: 89 // HungPagesTableModel, views::GroupTableModel implementation:
89 90
90 int HungPagesTableModel::RowCount() { 91 int HungPagesTableModel::RowCount() {
91 return static_cast<int>(tab_contentses_.size()); 92 return static_cast<int>(tab_contentses_.size());
92 } 93 }
93 94
94 string16 HungPagesTableModel::GetText(int row, int column_id) { 95 string16 HungPagesTableModel::GetText(int row, int column_id) {
95 DCHECK(row >= 0 && row < RowCount()); 96 DCHECK(row >= 0 && row < RowCount());
96 string16 title = tab_contentses_[row]->GetTitle(); 97 string16 title = tab_contentses_[row]->tab_contents()->GetTitle();
97 if (title.empty()) 98 if (title.empty())
98 title = TabContentsWrapper::GetDefaultTitle(); 99 title = TabContentsWrapper::GetDefaultTitle();
99 // TODO(xji): Consider adding a special case if the title text is a URL, 100 // TODO(xji): Consider adding a special case if the title text is a URL,
100 // since those should always have LTR directionality. Please refer to 101 // since those should always have LTR directionality. Please refer to
101 // http://crbug.com/6726 for more information. 102 // http://crbug.com/6726 for more information.
102 base::i18n::AdjustStringForLocaleDirection(&title); 103 base::i18n::AdjustStringForLocaleDirection(&title);
103 return title; 104 return title;
104 } 105 }
105 106
106 SkBitmap HungPagesTableModel::GetIcon(int row) { 107 SkBitmap HungPagesTableModel::GetIcon(int row) {
107 DCHECK(row >= 0 && row < RowCount()); 108 DCHECK(row >= 0 && row < RowCount());
108 return tab_contentses_.at(row)->GetFavicon(); 109 return tab_contentses_.at(row)->favicon_tab_helper()->GetFavicon();
109 } 110 }
110 111
111 void HungPagesTableModel::SetObserver(ui::TableModelObserver* observer) { 112 void HungPagesTableModel::SetObserver(ui::TableModelObserver* observer) {
112 observer_ = observer; 113 observer_ = observer;
113 } 114 }
114 115
115 void HungPagesTableModel::GetGroupRangeForItem(int item, 116 void HungPagesTableModel::GetGroupRangeForItem(int item,
116 views::GroupRange* range) { 117 views::GroupRange* range) {
117 DCHECK(range); 118 DCHECK(range);
118 range->start = 0; 119 range->start = 0;
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 g_instance->ShowForTabContents(contents); 458 g_instance->ShowForTabContents(contents);
458 } 459 }
459 } 460 }
460 461
461 void HideHungRendererDialog(TabContents* contents) { 462 void HideHungRendererDialog(TabContents* contents) {
462 if (!logging::DialogsAreSuppressed() && g_instance) 463 if (!logging::DialogsAreSuppressed() && g_instance)
463 g_instance->EndForTabContents(contents); 464 g_instance->EndForTabContents(contents);
464 } 465 }
465 466
466 } // namespace browser 467 } // namespace browser
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/create_application_shortcut_view.cc ('k') | chrome/browser/ui/views/location_bar/location_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698