OLD | NEW |
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 "app/table_model_observer.h" | 5 #include "app/table_model_observer.h" |
6 #include "base/string16.h" | 6 #include "base/string16.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/search_engines/keyword_editor_controller.h" | 9 #include "chrome/browser/search_engines/keyword_editor_controller.h" |
10 #include "chrome/browser/search_engines/template_url.h" | 10 #include "chrome/browser/search_engines/template_url.h" |
(...skipping 50 matching lines...) Loading... |
61 } | 61 } |
62 | 62 |
63 void ClearChangeCount() { | 63 void ClearChangeCount() { |
64 model_changed_count_ = items_changed_count_ = added_count_ = | 64 model_changed_count_ = items_changed_count_ = added_count_ = |
65 removed_count_ = 0; | 65 removed_count_ = 0; |
66 } | 66 } |
67 | 67 |
68 void SimulateDefaultSearchIsManaged(const std::string& url) { | 68 void SimulateDefaultSearchIsManaged(const std::string& url) { |
69 ASSERT_FALSE(url.empty()); | 69 ASSERT_FALSE(url.empty()); |
70 TestingPrefService* service = profile_->GetTestingPrefService(); | 70 TestingPrefService* service = profile_->GetTestingPrefService(); |
71 service->SetManagedPrefWithoutNotification( | 71 service->SetManagedPref( |
72 prefs::kDefaultSearchProviderEnabled, | 72 prefs::kDefaultSearchProviderEnabled, |
73 Value::CreateBooleanValue(true)); | 73 Value::CreateBooleanValue(true)); |
74 service->SetManagedPrefWithoutNotification( | 74 service->SetManagedPref( |
75 prefs::kDefaultSearchProviderSearchURL, | 75 prefs::kDefaultSearchProviderSearchURL, |
76 Value::CreateStringValue(url)); | 76 Value::CreateStringValue(url)); |
77 service->SetManagedPrefWithoutNotification( | 77 service->SetManagedPref( |
78 prefs::kDefaultSearchProviderName, | 78 prefs::kDefaultSearchProviderName, |
79 Value::CreateStringValue("managed")); | 79 Value::CreateStringValue("managed")); |
80 // Clear the IDs that are not specified via policy. | 80 // Clear the IDs that are not specified via policy. |
81 service->SetManagedPrefWithoutNotification( | 81 service->SetManagedPref( |
82 prefs::kDefaultSearchProviderID, new StringValue("")); | 82 prefs::kDefaultSearchProviderID, new StringValue("")); |
83 service->SetManagedPrefWithoutNotification( | 83 service->SetManagedPref( |
84 prefs::kDefaultSearchProviderPrepopulateID, new StringValue("")); | 84 prefs::kDefaultSearchProviderPrepopulateID, new StringValue("")); |
85 model_->Observe( | 85 model_->Observe( |
86 NotificationType::PREF_CHANGED, | 86 NotificationType::PREF_CHANGED, |
87 Source<PrefService>(profile_->GetTestingPrefService()), | 87 Source<PrefService>(profile_->GetTestingPrefService()), |
88 Details<std::string>(NULL)); | 88 Details<std::string>(NULL)); |
89 } | 89 } |
90 | 90 |
91 TemplateURLTableModel* table_model() const { | 91 TemplateURLTableModel* table_model() const { |
92 return controller_->table_model(); | 92 return controller_->table_model(); |
93 } | 93 } |
(...skipping 152 matching lines...) Loading... |
246 turl->set_short_name(L"b"); | 246 turl->set_short_name(L"b"); |
247 model_->Add(turl); | 247 model_->Add(turl); |
248 | 248 |
249 // Table model should have updated. | 249 // Table model should have updated. |
250 VerifyChangeCount(1, 0, 0, 0); | 250 VerifyChangeCount(1, 0, 0, 0); |
251 | 251 |
252 // And should contain the newly added TemplateURL. | 252 // And should contain the newly added TemplateURL. |
253 ASSERT_EQ(1, table_model()->RowCount()); | 253 ASSERT_EQ(1, table_model()->RowCount()); |
254 ASSERT_EQ(0, table_model()->IndexOfTemplateURL(turl)); | 254 ASSERT_EQ(0, table_model()->IndexOfTemplateURL(turl)); |
255 } | 255 } |
OLD | NEW |