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

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

Issue 12548008: Really fix crash when dragging and dropping in chrome://settings/startup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Trim quotes Created 7 years, 9 months 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/resources/options/browser_options_startup_page_list.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 // Was causing crashes when just a DCHECK(), see http://crbug.com/136576. 99 DCHECK(!index_list.empty());
100 if (index_list.empty() || insert_before < 0 || insert_before > RowCount()) { 100 DCHECK(insert_before >= 0 && insert_before <= RowCount());
101 NOTREACHED();
102 return;
103 }
104 101
105 // 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| ).
106 int first = std::min(insert_before, index_list.front()); 103 int first = std::min(insert_before, index_list.front());
107 int last = std::max(insert_before, index_list.back() + 1); 104 int last = std::max(insert_before, index_list.back() + 1);
108 105
109 // 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
110 // dragged element. 107 // dragged element.
111 std::vector<Entry> moved_entries; 108 std::vector<Entry> moved_entries;
112 for (size_t i = 0; i < index_list.size(); ++i) { 109 for (size_t i = 0; i < index_list.size(); ++i) {
113 moved_entries.push_back(entries_[index_list[i]]); 110 moved_entries.push_back(entries_[index_list[i]]);
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 return NULL; 264 return NULL;
268 } 265 }
269 266
270 string16 CustomHomePagesTableModel::FormattedURL(int row) const { 267 string16 CustomHomePagesTableModel::FormattedURL(int row) const {
271 std::string languages = 268 std::string languages =
272 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); 269 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages);
273 string16 url = net::FormatUrl(entries_[row].url, languages); 270 string16 url = net::FormatUrl(entries_[row].url, languages);
274 url = base::i18n::GetDisplayStringInLTRDirectionality(url); 271 url = base::i18n::GetDisplayStringInLTRDirectionality(url);
275 return url; 272 return url;
276 } 273 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/options/browser_options_startup_page_list.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698