| OLD | NEW |
| 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/views/hung_renderer_view.h" | 5 #include "chrome/browser/ui/views/hung_renderer_view.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/memory/ptr_util.h" |
| 8 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 10 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 11 #include "chrome/browser/platform_util.h" | 12 #include "chrome/browser/platform_util.h" |
| 12 #include "chrome/browser/ui/browser_finder.h" | 13 #include "chrome/browser/ui/browser_finder.h" |
| 13 #include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h" | 14 #include "chrome/browser/ui/chrome_web_modal_dialog_manager_delegate.h" |
| 14 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 15 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 15 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" | 16 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" |
| 16 #include "chrome/common/chrome_constants.h" | 17 #include "chrome/common/chrome_constants.h" |
| 17 #include "chrome/common/crash_keys.h" | 18 #include "chrome/common/crash_keys.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 content::RenderViewHost* HungPagesTableModel::GetRenderViewHost() { | 74 content::RenderViewHost* HungPagesTableModel::GetRenderViewHost() { |
| 74 return tab_observers_.empty() ? NULL : | 75 return tab_observers_.empty() ? NULL : |
| 75 tab_observers_[0]->web_contents()->GetRenderViewHost(); | 76 tab_observers_[0]->web_contents()->GetRenderViewHost(); |
| 76 } | 77 } |
| 77 | 78 |
| 78 void HungPagesTableModel::InitForWebContents(WebContents* hung_contents) { | 79 void HungPagesTableModel::InitForWebContents(WebContents* hung_contents) { |
| 79 tab_observers_.clear(); | 80 tab_observers_.clear(); |
| 80 if (hung_contents) { | 81 if (hung_contents) { |
| 81 // Force hung_contents to be first. | 82 // Force hung_contents to be first. |
| 82 if (hung_contents) { | 83 if (hung_contents) { |
| 83 tab_observers_.push_back(new WebContentsObserverImpl(this, | 84 tab_observers_.push_back( |
| 84 hung_contents)); | 85 base::MakeUnique<WebContentsObserverImpl>(this, hung_contents)); |
| 85 } | 86 } |
| 86 for (TabContentsIterator it; !it.done(); it.Next()) { | 87 for (TabContentsIterator it; !it.done(); it.Next()) { |
| 87 if (*it != hung_contents && | 88 if (*it != hung_contents && |
| 88 it->GetRenderProcessHost() == hung_contents->GetRenderProcessHost()) | 89 it->GetRenderProcessHost() == hung_contents->GetRenderProcessHost()) |
| 89 tab_observers_.push_back(new WebContentsObserverImpl(this, *it)); | 90 tab_observers_.push_back( |
| 91 base::MakeUnique<WebContentsObserverImpl>(this, *it)); |
| 90 } | 92 } |
| 91 } | 93 } |
| 92 // The world is different. | 94 // The world is different. |
| 93 if (observer_) | 95 if (observer_) |
| 94 observer_->OnModelChanged(); | 96 observer_->OnModelChanged(); |
| 95 } | 97 } |
| 96 | 98 |
| 97 /////////////////////////////////////////////////////////////////////////////// | 99 /////////////////////////////////////////////////////////////////////////////// |
| 98 // HungPagesTableModel, ui::TableModel implementation: | 100 // HungPagesTableModel, ui::TableModel implementation: |
| 99 | 101 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 127 | 129 |
| 128 void HungPagesTableModel::GetGroupRange(int model_index, | 130 void HungPagesTableModel::GetGroupRange(int model_index, |
| 129 views::GroupRange* range) { | 131 views::GroupRange* range) { |
| 130 DCHECK(range); | 132 DCHECK(range); |
| 131 range->start = 0; | 133 range->start = 0; |
| 132 range->length = RowCount(); | 134 range->length = RowCount(); |
| 133 } | 135 } |
| 134 | 136 |
| 135 void HungPagesTableModel::TabDestroyed(WebContentsObserverImpl* tab) { | 137 void HungPagesTableModel::TabDestroyed(WebContentsObserverImpl* tab) { |
| 136 // Clean up tab_observers_ and notify our observer. | 138 // Clean up tab_observers_ and notify our observer. |
| 137 TabObservers::iterator i = std::find( | 139 size_t index = 0; |
| 138 tab_observers_.begin(), tab_observers_.end(), tab); | 140 for (; index < tab_observers_.size(); ++index) { |
| 139 DCHECK(i != tab_observers_.end()); | 141 if (tab_observers_[index].get() == tab) |
| 140 int index = static_cast<int>(i - tab_observers_.begin()); | 142 break; |
| 141 tab_observers_.erase(i); | 143 } |
| 144 DCHECK(index < tab_observers_.size()); |
| 145 tab_observers_.erase(tab_observers_.begin() + index); |
| 142 if (observer_) | 146 if (observer_) |
| 143 observer_->OnItemsRemoved(index, 1); | 147 observer_->OnItemsRemoved(static_cast<int>(index), 1); |
| 144 | 148 |
| 145 // Notify the delegate. | 149 // Notify the delegate. |
| 146 delegate_->TabDestroyed(); | 150 delegate_->TabDestroyed(); |
| 147 // WARNING: we've likely been deleted. | 151 // WARNING: we've likely been deleted. |
| 148 } | 152 } |
| 149 | 153 |
| 150 HungPagesTableModel::WebContentsObserverImpl::WebContentsObserverImpl( | 154 HungPagesTableModel::WebContentsObserverImpl::WebContentsObserverImpl( |
| 151 HungPagesTableModel* model, WebContents* tab) | 155 HungPagesTableModel* model, WebContents* tab) |
| 152 : content::WebContentsObserver(tab), | 156 : content::WebContentsObserver(tab), |
| 153 model_(model) { | 157 model_(model) { |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 | 474 |
| 471 // static | 475 // static |
| 472 void HungRendererDialogView::InitClass() { | 476 void HungRendererDialogView::InitClass() { |
| 473 static bool initialized = false; | 477 static bool initialized = false; |
| 474 if (!initialized) { | 478 if (!initialized) { |
| 475 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 479 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 476 frozen_icon_ = rb.GetImageSkiaNamed(IDR_FROZEN_TAB_ICON); | 480 frozen_icon_ = rb.GetImageSkiaNamed(IDR_FROZEN_TAB_ICON); |
| 477 initialized = true; | 481 initialized = true; |
| 478 } | 482 } |
| 479 } | 483 } |
| OLD | NEW |