| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/task.h" | 10 #include "base/task.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 Source<SearchProviderInstallDataTest>(this), | 184 Source<SearchProviderInstallDataTest>(this), |
| 185 NotificationService::NoDetails()); | 185 NotificationService::NoDetails()); |
| 186 | 186 |
| 187 util_.TearDown(); | 187 util_.TearDown(); |
| 188 testing::Test::TearDown(); | 188 testing::Test::TearDown(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void SimulateDefaultSearchIsManaged(const std::string& url) { | 191 void SimulateDefaultSearchIsManaged(const std::string& url) { |
| 192 ASSERT_FALSE(url.empty()); | 192 ASSERT_FALSE(url.empty()); |
| 193 TestingPrefService* service = util_.profile()->GetTestingPrefService(); | 193 TestingPrefService* service = util_.profile()->GetTestingPrefService(); |
| 194 service->SetManagedPref( | 194 service->SetManagedPref(prefs::kDefaultSearchProviderEnabled, |
| 195 prefs::kDefaultSearchProviderEnabled, | 195 base::TrueValue()); |
| 196 Value::CreateBooleanValue(true)); | 196 service->SetManagedPref(prefs::kDefaultSearchProviderSearchURL, |
| 197 service->SetManagedPref( | 197 Value::CreateStringValue(url)); |
| 198 prefs::kDefaultSearchProviderSearchURL, | 198 service->SetManagedPref(prefs::kDefaultSearchProviderName, |
| 199 Value::CreateStringValue(url)); | 199 Value::CreateStringValue("managed")); |
| 200 service->SetManagedPref( | |
| 201 prefs::kDefaultSearchProviderName, | |
| 202 Value::CreateStringValue("managed")); | |
| 203 // Clear the IDs that are not specified via policy. | 200 // Clear the IDs that are not specified via policy. |
| 204 service->SetManagedPref( | 201 service->SetManagedPref(prefs::kDefaultSearchProviderID, |
| 205 prefs::kDefaultSearchProviderID, new StringValue("")); | 202 new StringValue("")); |
| 206 service->SetManagedPref( | 203 service->SetManagedPref(prefs::kDefaultSearchProviderPrepopulateID, |
| 207 prefs::kDefaultSearchProviderPrepopulateID, new StringValue("")); | 204 new StringValue("")); |
| 208 util_.model()->Observe( | 205 util_.model()->Observe( |
| 209 chrome::NOTIFICATION_PREF_CHANGED, | 206 chrome::NOTIFICATION_PREF_CHANGED, |
| 210 Source<PrefService>(util_.profile()->GetTestingPrefService()), | 207 Source<PrefService>(util_.profile()->GetTestingPrefService()), |
| 211 Details<std::string>(NULL)); | 208 Details<std::string>(NULL)); |
| 212 } | 209 } |
| 213 | 210 |
| 214 protected: | 211 protected: |
| 215 TemplateURLServiceTestUtil util_; | 212 TemplateURLServiceTestUtil util_; |
| 216 | 213 |
| 217 // Provides the search provider install state on the I/O thread. It must be | 214 // Provides the search provider install state on the I/O thread. It must be |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 // Change the Google base url. | 302 // Change the Google base url. |
| 306 google_host = "foo.com"; | 303 google_host = "foo.com"; |
| 307 util_.SetGoogleBaseURL("http://" + google_host + "/"); | 304 util_.SetGoogleBaseURL("http://" + google_host + "/"); |
| 308 // Wait for the I/O thread to process the update notification. | 305 // Wait for the I/O thread to process the update notification. |
| 309 TemplateURLServiceTestUtil::BlockTillIOThreadProcessesRequests(); | 306 TemplateURLServiceTestUtil::BlockTillIOThreadProcessesRequests(); |
| 310 | 307 |
| 311 // Verify that the change got picked up. | 308 // Verify that the change got picked up. |
| 312 test_get_install_state->set_search_provider_host(google_host); | 309 test_get_install_state->set_search_provider_host(google_host); |
| 313 EXPECT_TRUE(test_get_install_state->RunTests()); | 310 EXPECT_TRUE(test_get_install_state->RunTests()); |
| 314 } | 311 } |
| OLD | NEW |