Chromium Code Reviews| 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 auto i = |
| 138 tab_observers_.begin(), tab_observers_.end(), tab); | 140 std::find_if(tab_observers_.begin(), tab_observers_.end(), |
| 141 [tab](const std::unique_ptr<WebContentsObserverImpl>& ptr) { | |
| 142 return ptr.get() == tab; | |
| 143 }); | |
|
Nico
2017/01/03 18:12:35
again, just use a loop instead of find_if and then
Avi (use Gerrit)
2017/01/03 22:54:53
Done.
| |
| 139 DCHECK(i != tab_observers_.end()); | 144 DCHECK(i != tab_observers_.end()); |
| 140 int index = static_cast<int>(i - tab_observers_.begin()); | 145 int index = static_cast<int>(i - tab_observers_.begin()); |
| 141 tab_observers_.erase(i); | 146 tab_observers_.erase(i); |
| 142 if (observer_) | 147 if (observer_) |
| 143 observer_->OnItemsRemoved(index, 1); | 148 observer_->OnItemsRemoved(index, 1); |
| 144 | 149 |
| 145 // Notify the delegate. | 150 // Notify the delegate. |
| 146 delegate_->TabDestroyed(); | 151 delegate_->TabDestroyed(); |
| 147 // WARNING: we've likely been deleted. | 152 // WARNING: we've likely been deleted. |
| 148 } | 153 } |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 | 475 |
| 471 // static | 476 // static |
| 472 void HungRendererDialogView::InitClass() { | 477 void HungRendererDialogView::InitClass() { |
| 473 static bool initialized = false; | 478 static bool initialized = false; |
| 474 if (!initialized) { | 479 if (!initialized) { |
| 475 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 480 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 476 frozen_icon_ = rb.GetImageSkiaNamed(IDR_FROZEN_TAB_ICON); | 481 frozen_icon_ = rb.GetImageSkiaNamed(IDR_FROZEN_TAB_ICON); |
| 477 initialized = true; | 482 initialized = true; |
| 478 } | 483 } |
| 479 } | 484 } |
| OLD | NEW |