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/custom_home_pages_table_model.h" | 5 #include "chrome/browser/custom_home_pages_table_model.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/browser/history/history_service_factory.h" | 14 #include "chrome/browser/history/history_service_factory.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/browser_iterator.h" | |
18 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
19 #include "chrome/browser/ui/settings_window_manager.h" | 18 #include "chrome/browser/ui/settings_window_manager.h" |
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
21 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
22 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
23 #include "chrome/grit/generated_resources.h" | 22 #include "chrome/grit/generated_resources.h" |
24 #include "components/history/core/browser/history_service.h" | 23 #include "components/history/core/browser/history_service.h" |
25 #include "components/url_formatter/url_formatter.h" | 24 #include "components/url_formatter/url_formatter.h" |
26 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
27 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 observer_->OnItemsRemoved(index, 1); | 180 observer_->OnItemsRemoved(index, 1); |
182 } | 181 } |
183 | 182 |
184 void CustomHomePagesTableModel::SetToCurrentlyOpenPages() { | 183 void CustomHomePagesTableModel::SetToCurrentlyOpenPages() { |
185 // Remove the current entries. | 184 // Remove the current entries. |
186 while (RowCount()) | 185 while (RowCount()) |
187 RemoveWithoutNotification(0); | 186 RemoveWithoutNotification(0); |
188 | 187 |
189 // Add tabs from appropriate browser windows. | 188 // Add tabs from appropriate browser windows. |
190 int add_index = 0; | 189 int add_index = 0; |
191 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 190 for (auto* browser : *BrowserList::GetInstance()) { |
192 Browser* browser = *it; | |
193 if (!ShouldIncludeBrowser(browser)) | 191 if (!ShouldIncludeBrowser(browser)) |
194 continue; | 192 continue; |
195 | 193 |
196 for (int tab_index = 0; | 194 for (int tab_index = 0; |
197 tab_index < browser->tab_strip_model()->count(); | 195 tab_index < browser->tab_strip_model()->count(); |
198 ++tab_index) { | 196 ++tab_index) { |
199 const GURL url = | 197 const GURL url = |
200 browser->tab_strip_model()->GetWebContentsAt(tab_index)->GetURL(); | 198 browser->tab_strip_model()->GetWebContentsAt(tab_index)->GetURL(); |
201 if (ShouldAddPage(url)) | 199 if (ShouldAddPage(url)) |
202 AddWithoutNotification(add_index++, url); | 200 AddWithoutNotification(add_index++, url); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 } | 317 } |
320 } | 318 } |
321 | 319 |
322 base::string16 CustomHomePagesTableModel::FormattedURL(int row) const { | 320 base::string16 CustomHomePagesTableModel::FormattedURL(int row) const { |
323 std::string languages = | 321 std::string languages = |
324 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); | 322 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); |
325 base::string16 url = url_formatter::FormatUrl(entries_[row].url, languages); | 323 base::string16 url = url_formatter::FormatUrl(entries_[row].url, languages); |
326 url = base::i18n::GetDisplayStringInLTRDirectionality(url); | 324 url = base::i18n::GetDisplayStringInLTRDirectionality(url); |
327 return url; | 325 return url; |
328 } | 326 } |
OLD | NEW |