OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/search_engines/template_url_prepopulate_data.h" | 5 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/browser/search_engines/template_url.h" | 8 #include "chrome/browser/search_engines/template_url.h" |
9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
(...skipping 2662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2673 } | 2673 } |
2674 const GetUserGeoIDFunction GetUserGeoIDPtr = | 2674 const GetUserGeoIDFunction GetUserGeoIDPtr = |
2675 reinterpret_cast<GetUserGeoIDFunction>(GetProcAddress(kernel32_handle, | 2675 reinterpret_cast<GetUserGeoIDFunction>(GetProcAddress(kernel32_handle, |
2676 "GetUserGeoID")); | 2676 "GetUserGeoID")); |
2677 return GetUserGeoIDPtr ? | 2677 return GetUserGeoIDPtr ? |
2678 ((*GetUserGeoIDPtr)(GEOCLASS_NATION)) : GEOID_NOT_AVAILABLE; | 2678 ((*GetUserGeoIDPtr)(GEOCLASS_NATION)) : GEOID_NOT_AVAILABLE; |
2679 } | 2679 } |
2680 | 2680 |
2681 int GetGeoIDFromPrefs(PrefService* prefs) { | 2681 int GetGeoIDFromPrefs(PrefService* prefs) { |
2682 // See if the user overrode the GeoID on the command line. | 2682 // See if the user overrode the GeoID on the command line. |
2683 CommandLine parsed_command_line; | |
2684 const std::wstring geoID( | 2683 const std::wstring geoID( |
2685 parsed_command_line.GetSwitchValue(switches::kGeoID)); | 2684 CommandLine::ForCurrentProcess()->GetSwitchValue(switches::kGeoID)); |
2686 if (!geoID.empty()) | 2685 if (!geoID.empty()) |
2687 return _wtoi(geoID.c_str()); | 2686 return _wtoi(geoID.c_str()); |
2688 | 2687 |
2689 // Cache first run GeoID value in prefs, and use it afterwards. This ensures | 2688 // Cache first run GeoID value in prefs, and use it afterwards. This ensures |
2690 // that just because the user moves around, we won't automatically make major | 2689 // that just because the user moves around, we won't automatically make major |
2691 // changes to their available search providers, which would feel surprising. | 2690 // changes to their available search providers, which would feel surprising. |
2692 if (!prefs) | 2691 if (!prefs) |
2693 return GetCurrentGeoID(); | 2692 return GetCurrentGeoID(); |
2694 if (!prefs->HasPrefPath(prefs::kGeoIDAtInstall)) | 2693 if (!prefs->HasPrefPath(prefs::kGeoIDAtInstall)) |
2695 prefs->SetInteger(prefs::kGeoIDAtInstall, GetCurrentGeoID()); | 2694 prefs->SetInteger(prefs::kGeoIDAtInstall, GetCurrentGeoID()); |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3073 new_turl->set_date_created(Time()); | 3072 new_turl->set_date_created(Time()); |
3074 std::vector<std::string> turl_encodings; | 3073 std::vector<std::string> turl_encodings; |
3075 turl_encodings.push_back(engines[i]->encoding); | 3074 turl_encodings.push_back(engines[i]->encoding); |
3076 new_turl->set_input_encodings(turl_encodings); | 3075 new_turl->set_input_encodings(turl_encodings); |
3077 new_turl->set_prepopulate_id(engines[i]->id); | 3076 new_turl->set_prepopulate_id(engines[i]->id); |
3078 t_urls->push_back(new_turl); | 3077 t_urls->push_back(new_turl); |
3079 } | 3078 } |
3080 } | 3079 } |
3081 | 3080 |
3082 } // namespace TemplateURLPrepopulateData | 3081 } // namespace TemplateURLPrepopulateData |
OLD | NEW |