| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "app/table_model_observer.h" | 9 #include "app/table_model_observer.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| 11 #include "chrome/browser/browser.h" | 11 #include "chrome/browser/browser.h" |
| 12 #include "chrome/browser/browser_list.h" | 12 #include "chrome/browser/browser_list.h" |
| 13 #include "chrome/browser/pref_service.h" | 13 #include "chrome/browser/pref_service.h" |
| 14 #include "chrome/browser/profile.h" | 14 #include "chrome/browser/profile.h" |
| 15 #include "chrome/browser/tab_contents/tab_contents.h" | 15 #include "chrome/browser/tab_contents/tab_contents.h" |
| 16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "chrome/common/url_constants.h" | |
| 18 #include "gfx/codec/png_codec.h" | 17 #include "gfx/codec/png_codec.h" |
| 19 #include "grit/app_resources.h" | 18 #include "grit/app_resources.h" |
| 20 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 21 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
| 22 | 21 |
| 23 // static | 22 // static |
| 24 SkBitmap CustomHomePagesTableModel::default_favicon_; | 23 SkBitmap CustomHomePagesTableModel::default_favicon_; |
| 25 | 24 |
| 26 CustomHomePagesTableModel::CustomHomePagesTableModel(Profile* profile) | 25 CustomHomePagesTableModel::CustomHomePagesTableModel(Profile* profile) |
| 27 : profile_(profile), | 26 : profile_(profile), |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // And add all tabs for all open browsers with our profile. | 77 // And add all tabs for all open browsers with our profile. |
| 79 int add_index = 0; | 78 int add_index = 0; |
| 80 for (BrowserList::const_iterator browser_i = BrowserList::begin(); | 79 for (BrowserList::const_iterator browser_i = BrowserList::begin(); |
| 81 browser_i != BrowserList::end(); ++browser_i) { | 80 browser_i != BrowserList::end(); ++browser_i) { |
| 82 Browser* browser = *browser_i; | 81 Browser* browser = *browser_i; |
| 83 if (browser->profile() != profile_) | 82 if (browser->profile() != profile_) |
| 84 continue; // Skip incognito browsers. | 83 continue; // Skip incognito browsers. |
| 85 | 84 |
| 86 for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) { | 85 for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) { |
| 87 const GURL url = browser->GetTabContentsAt(tab_index)->GetURL(); | 86 const GURL url = browser->GetTabContentsAt(tab_index)->GetURL(); |
| 88 if (!url.is_empty() && | 87 if (!url.is_empty()) |
| 89 !(url.SchemeIs(chrome::kChromeUIScheme) && | |
| 90 url.host() == chrome::kChromeUIOptionsHost)) | |
| 91 Add(add_index++, url); | 88 Add(add_index++, url); |
| 92 } | 89 } |
| 93 } | 90 } |
| 94 } | 91 } |
| 95 | 92 |
| 96 std::vector<GURL> CustomHomePagesTableModel::GetURLs() { | 93 std::vector<GURL> CustomHomePagesTableModel::GetURLs() { |
| 97 std::vector<GURL> urls(entries_.size()); | 94 std::vector<GURL> urls(entries_.size()); |
| 98 for (size_t i = 0; i < entries_.size(); ++i) | 95 for (size_t i = 0; i < entries_.size(); ++i) |
| 99 urls[i] = entries_[i].url; | 96 urls[i] = entries_[i].url; |
| 100 return urls; | 97 return urls; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 return NULL; | 212 return NULL; |
| 216 } | 213 } |
| 217 | 214 |
| 218 std::wstring CustomHomePagesTableModel::FormattedURL(int row) const { | 215 std::wstring CustomHomePagesTableModel::FormattedURL(int row) const { |
| 219 std::wstring languages = | 216 std::wstring languages = |
| 220 UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); | 217 UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); |
| 221 std::wstring url(net::FormatUrl(entries_[row].url, languages)); | 218 std::wstring url(net::FormatUrl(entries_[row].url, languages)); |
| 222 base::i18n::GetDisplayStringInLTRDirectionality(&url); | 219 base::i18n::GetDisplayStringInLTRDirectionality(&url); |
| 223 return url; | 220 return url; |
| 224 } | 221 } |
| OLD | NEW |