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

Side by Side Diff: chrome/browser/custom_home_pages_table_model.cc

Issue 52823006: Small crash fix for set pages dialog drag'n'drop issue. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options/options_browsertest.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 /** 90 /**
91 * Move a number of existing entries to a new position, reordering the table. 91 * Move a number of existing entries to a new position, reordering the table.
92 * 92 *
93 * We determine the range of elements affected by the move, save the moved 93 * We determine the range of elements affected by the move, save the moved
94 * elements, compact the remaining ones, and re-insert moved elements. 94 * elements, compact the remaining ones, and re-insert moved elements.
95 * Expects |index_list| to be ordered ascending. 95 * Expects |index_list| to be ordered ascending.
96 */ 96 */
97 void CustomHomePagesTableModel::MoveURLs(int insert_before, 97 void CustomHomePagesTableModel::MoveURLs(int insert_before,
98 const std::vector<int>& index_list) { 98 const std::vector<int>& index_list) {
99 DCHECK(!index_list.empty()); 99 if (index_list.empty()) return;
100 DCHECK(insert_before >= 0 && insert_before <= RowCount()); 100 DCHECK(insert_before >= 0 && insert_before <= RowCount());
101 101
102 // The range of elements that needs to be reshuffled is [ |first|, |last| ). 102 // The range of elements that needs to be reshuffled is [ |first|, |last| ).
103 int first = std::min(insert_before, index_list.front()); 103 int first = std::min(insert_before, index_list.front());
104 int last = std::max(insert_before, index_list.back() + 1); 104 int last = std::max(insert_before, index_list.back() + 1);
105 105
106 // Save the dragged elements. Also, adjust insertion point if it is before a 106 // Save the dragged elements. Also, adjust insertion point if it is before a
107 // dragged element. 107 // dragged element.
108 std::vector<Entry> moved_entries; 108 std::vector<Entry> moved_entries;
109 for (size_t i = 0; i < index_list.size(); ++i) { 109 for (size_t i = 0; i < index_list.size(); ++i) {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 return NULL; 264 return NULL;
265 } 265 }
266 266
267 string16 CustomHomePagesTableModel::FormattedURL(int row) const { 267 string16 CustomHomePagesTableModel::FormattedURL(int row) const {
268 std::string languages = 268 std::string languages =
269 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); 269 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages);
270 string16 url = net::FormatUrl(entries_[row].url, languages); 270 string16 url = net::FormatUrl(entries_[row].url, languages);
271 url = base::i18n::GetDisplayStringInLTRDirectionality(url); 271 url = base::i18n::GetDisplayStringInLTRDirectionality(url);
272 return url; 272 return url;
273 } 273 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/webui/options/options_browsertest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698