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

Side by Side Diff: chrome/browser/views/first_run_search_engine_view.cc

Issue 3053050: Add RandomNumberGenerator adapter to base/rand_util.h (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Compile on Windows, too... Created 10 years, 3 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
OLDNEW
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/views/first_run_search_engine_view.h" 5 #include "chrome/browser/views/first_run_search_engine_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <vector>
9 10
10 #include "app/l10n_util.h" 11 #include "app/l10n_util.h"
11 #include "app/resource_bundle.h" 12 #include "app/resource_bundle.h"
12 #include "base/i18n/rtl.h" 13 #include "base/i18n/rtl.h"
14 #include "base/rand_util.h"
13 #include "base/time.h" 15 #include "base/time.h"
14 #include "chrome/browser/options_window.h" 16 #include "chrome/browser/options_window.h"
15 #include "chrome/browser/profile.h" 17 #include "chrome/browser/profile.h"
16 #include "chrome/browser/search_engines/template_url.h" 18 #include "chrome/browser/search_engines/template_url.h"
17 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" 19 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
18 #include "gfx/font.h" 20 #include "gfx/font.h"
19 #include "grit/browser_resources.h" 21 #include "grit/browser_resources.h"
20 #include "grit/chromium_strings.h" 22 #include "grit/chromium_strings.h"
21 #include "grit/google_chrome_strings.h" 23 #include "grit/google_chrome_strings.h"
22 #include "grit/generated_resources.h" 24 #include "grit/generated_resources.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 205 }
204 // Push the default choice to the fourth position. 206 // Push the default choice to the fourth position.
205 if (default_choice) { 207 if (default_choice) {
206 search_engine_choices_.push_back(default_choice); 208 search_engine_choices_.push_back(default_choice);
207 AddChildView(default_choice->GetView()); // The logo or text view. 209 AddChildView(default_choice->GetView()); // The logo or text view.
208 AddChildView(default_choice); // The button associated with the choice. 210 AddChildView(default_choice); // The button associated with the choice.
209 } 211 }
210 212
211 // Randomize order of logos if option has been set. 213 // Randomize order of logos if option has been set.
212 if (randomize_) { 214 if (randomize_) {
213 int seed = static_cast<int>(Time::Now().ToInternalValue());
214 srand(seed);
215 std::random_shuffle(search_engine_choices_.begin(), 215 std::random_shuffle(search_engine_choices_.begin(),
216 search_engine_choices_.end()); 216 search_engine_choices_.end(),
217 base::RandGenerator);
217 // Assign to each choice the position in which it is shown on the screen. 218 // Assign to each choice the position in which it is shown on the screen.
218 std::vector<SearchEngineChoice*>::iterator it; 219 std::vector<SearchEngineChoice*>::iterator it;
219 int slot = 0; 220 int slot = 0;
220 for (it = search_engine_choices_.begin(); 221 for (it = search_engine_choices_.begin();
221 it != search_engine_choices_.end(); 222 it != search_engine_choices_.end();
222 it++) { 223 it++) {
223 (*it)->set_slot(slot++); 224 (*it)->set_slot(slot++);
224 } 225 }
225 } 226 }
226 227
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 logo_padding; 384 logo_padding;
384 search_engine_choices_[3]->SetBounds(next_h_space, next_v_space, 385 search_engine_choices_[3]->SetBounds(next_h_space, next_v_space,
385 button_width, button_height); 386 button_width, button_height);
386 } 387 }
387 } // if (search_engine_choices.size() > 0) 388 } // if (search_engine_choices.size() > 0)
388 } 389 }
389 390
390 std::wstring FirstRunSearchEngineView::GetWindowTitle() const { 391 std::wstring FirstRunSearchEngineView::GetWindowTitle() const {
391 return l10n_util::GetString(IDS_FIRSTRUN_DLG_TITLE); 392 return l10n_util::GetString(IDS_FIRSTRUN_DLG_TITLE);
392 } 393 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698