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 "base/string16.h" | 5 #include "base/string16.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/search_engines/template_url.h" | 8 #include "chrome/browser/search_engines/template_url.h" |
9 #include "chrome/browser/search_engines/template_url_service.h" | 9 #include "chrome/browser/search_engines/template_url_service.h" |
10 #include "chrome/browser/search_engines/template_url_service_factory.h" | 10 #include "chrome/browser/search_engines/template_url_service_factory.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 void ClearChangeCount() { | 65 void ClearChangeCount() { |
66 model_changed_count_ = items_changed_count_ = added_count_ = | 66 model_changed_count_ = items_changed_count_ = added_count_ = |
67 removed_count_ = 0; | 67 removed_count_ = 0; |
68 } | 68 } |
69 | 69 |
70 void SimulateDefaultSearchIsManaged(const std::string& url) { | 70 void SimulateDefaultSearchIsManaged(const std::string& url) { |
71 ASSERT_FALSE(url.empty()); | 71 ASSERT_FALSE(url.empty()); |
72 TestingPrefService* service = profile_->GetTestingPrefService(); | 72 TestingPrefService* service = profile_->GetTestingPrefService(); |
73 service->SetManagedPref( | 73 service->SetManagedPref( |
74 prefs::kDefaultSearchProviderEnabled, | 74 prefs::kDefaultSearchProviderEnabled, |
75 Value::CreateBooleanValue(true)); | 75 base::TrueValue()); |
76 service->SetManagedPref( | 76 service->SetManagedPref( |
77 prefs::kDefaultSearchProviderSearchURL, | 77 prefs::kDefaultSearchProviderSearchURL, |
78 Value::CreateStringValue(url)); | 78 base::StringValue::New(url)); |
79 service->SetManagedPref( | 79 service->SetManagedPref( |
80 prefs::kDefaultSearchProviderName, | 80 prefs::kDefaultSearchProviderName, |
81 Value::CreateStringValue("managed")); | 81 base::StringValue::New("managed")); |
82 // Clear the IDs that are not specified via policy. | 82 // Clear the IDs that are not specified via policy. |
83 service->SetManagedPref( | 83 service->SetManagedPref( |
84 prefs::kDefaultSearchProviderID, new StringValue("")); | 84 prefs::kDefaultSearchProviderID, base::StringValue::New("")); |
85 service->SetManagedPref( | 85 service->SetManagedPref( |
86 prefs::kDefaultSearchProviderPrepopulateID, new StringValue("")); | 86 prefs::kDefaultSearchProviderPrepopulateID, base::StringValue::New("")); |
87 model_->Observe( | 87 model_->Observe( |
88 chrome::NOTIFICATION_PREF_CHANGED, | 88 chrome::NOTIFICATION_PREF_CHANGED, |
89 Source<PrefService>(profile_->GetTestingPrefService()), | 89 Source<PrefService>(profile_->GetTestingPrefService()), |
90 Details<std::string>(NULL)); | 90 Details<std::string>(NULL)); |
91 } | 91 } |
92 | 92 |
93 TemplateURLTableModel* table_model() const { | 93 TemplateURLTableModel* table_model() const { |
94 return controller_->table_model(); | 94 return controller_->table_model(); |
95 } | 95 } |
96 | 96 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 turl->set_short_name(ASCIIToUTF16("b")); | 252 turl->set_short_name(ASCIIToUTF16("b")); |
253 model_->Add(turl); | 253 model_->Add(turl); |
254 | 254 |
255 // Table model should have updated. | 255 // Table model should have updated. |
256 VerifyChangeCount(1, 0, 0, 0); | 256 VerifyChangeCount(1, 0, 0, 0); |
257 | 257 |
258 // And should contain the newly added TemplateURL. | 258 // And should contain the newly added TemplateURL. |
259 ASSERT_EQ(1, table_model()->RowCount()); | 259 ASSERT_EQ(1, table_model()->RowCount()); |
260 ASSERT_EQ(0, table_model()->IndexOfTemplateURL(turl)); | 260 ASSERT_EQ(0, table_model()->IndexOfTemplateURL(turl)); |
261 } | 261 } |
OLD | NEW |