OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/extension_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
6 #include "chrome/browser/extensions/extension_service.h" | 6 #include "chrome/browser/extensions/extension_service.h" |
7 #include "chrome/browser/extensions/extension_web_ui.h" | 7 #include "chrome/browser/extensions/extension_web_ui.h" |
8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
9 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 9 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_tabstrip.h" | 12 #include "chrome/browser/ui/browser_tabstrip.h" |
13 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
15 #include "content/public/browser/navigation_entry.h" | 15 #include "content/public/browser/navigation_entry.h" |
16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
17 | 17 |
18 using content::WebContents; | 18 using content::WebContents; |
19 | 19 |
20 class ExtensionOverrideTest : public ExtensionApiTest { | 20 class ExtensionOverrideTest : public ExtensionApiTest { |
21 protected: | 21 protected: |
22 bool CheckHistoryOverridesContainsNoDupes() { | 22 bool CheckHistoryOverridesContainsNoDupes() { |
23 // There should be no duplicate entries in the preferences. | 23 // There should be no duplicate entries in the preferences. |
24 const DictionaryValue* overrides = | 24 const DictionaryValue* overrides = |
25 browser()->profile()->GetPrefs()->GetDictionary( | 25 browser()->profile()->GetPrefs()->GetDictionary( |
26 ExtensionWebUI::kExtensionURLOverrides); | 26 ExtensionWebUI::kExtensionURLOverrides); |
27 | 27 |
28 ListValue* values = NULL; | 28 const ListValue* values = NULL; |
29 if (!overrides->GetList("history", &values)) | 29 if (!overrides->GetList("history", &values)) |
30 return false; | 30 return false; |
31 | 31 |
32 std::set<std::string> seen_overrides; | 32 std::set<std::string> seen_overrides; |
33 for (size_t i = 0; i < values->GetSize(); ++i) { | 33 for (size_t i = 0; i < values->GetSize(); ++i) { |
34 std::string value; | 34 std::string value; |
35 if (!values->GetString(i, &value)) | 35 if (!values->GetString(i, &value)) |
36 return false; | 36 return false; |
37 | 37 |
38 if (seen_overrides.find(value) != seen_overrides.end()) | 38 if (seen_overrides.find(value) != seen_overrides.end()) |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 ExtensionWebUI::kExtensionURLOverrides); | 132 ExtensionWebUI::kExtensionURLOverrides); |
133 update.Get()->Set("history", list); | 133 update.Get()->Set("history", list); |
134 } | 134 } |
135 | 135 |
136 ASSERT_FALSE(CheckHistoryOverridesContainsNoDupes()); | 136 ASSERT_FALSE(CheckHistoryOverridesContainsNoDupes()); |
137 | 137 |
138 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("override/history"))); | 138 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("override/history"))); |
139 | 139 |
140 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); | 140 ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); |
141 } | 141 } |
OLD | NEW |