| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/test/mock_time_provider.h" | 14 #include "base/test/mock_time_provider.h" |
| 15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "chrome/browser/extensions/extension_service_unittest.h" | 17 #include "chrome/browser/extensions/extension_service_unittest.h" |
| 18 #include "chrome/browser/history/history_notifications.h" | 18 #include "chrome/browser/history/history_notifications.h" |
| 19 #include "chrome/browser/history/history_service.h" | 19 #include "chrome/browser/history/history_service.h" |
| 20 #include "chrome/browser/history/history_service_factory.h" | 20 #include "chrome/browser/history/history_service_factory.h" |
| 21 #include "chrome/browser/search_engines/search_host_to_urls_map.h" | 21 #include "chrome/browser/search_engines/search_host_to_urls_map.h" |
| 22 #include "chrome/browser/search_engines/search_terms_data.h" | 22 #include "chrome/browser/search_engines/search_terms_data.h" |
| 23 #include "chrome/browser/search_engines/template_url.h" | 23 #include "chrome/browser/search_engines/template_url.h" |
| 24 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 24 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
| 25 #include "chrome/browser/search_engines/template_url_service.h" | 25 #include "chrome/browser/search_engines/template_url_service.h" |
| 26 #include "chrome/browser/search_engines/template_url_service_test_util.h" | 26 #include "chrome/browser/search_engines/template_url_service_test_util.h" |
| 27 #include "chrome/browser/webdata/web_data_service_factory.h" | 27 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 28 #include "chrome/common/extensions/extension.h" | 28 #include "chrome/common/extensions/extension.h" |
| 29 #include "chrome/common/extensions/extension_manifest_constants.h" | |
| 30 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
| 31 #include "chrome/test/base/testing_profile.h" | 30 #include "chrome/test/base/testing_profile.h" |
| 32 #include "components/webdata/common/web_database.h" | 31 #include "components/webdata/common/web_database.h" |
| 33 #include "content/public/test/test_browser_thread.h" | 32 #include "content/public/test/test_browser_thread.h" |
| 34 #include "extensions/common/constants.h" | 33 #include "extensions/common/constants.h" |
| 34 #include "extensions/common/manifest_constants.h" |
| 35 #include "testing/gtest/include/gtest/gtest.h" | 35 #include "testing/gtest/include/gtest/gtest.h" |
| 36 | 36 |
| 37 using base::Time; | 37 using base::Time; |
| 38 using base::TimeDelta; | 38 using base::TimeDelta; |
| 39 using content::BrowserThread; | 39 using content::BrowserThread; |
| 40 using ::testing::Return; | 40 using ::testing::Return; |
| 41 using ::testing::StrictMock; | 41 using ::testing::StrictMock; |
| 42 | 42 |
| 43 namespace { | 43 namespace { |
| 44 | 44 |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 std::string(), std::string(), false, "UTF-8", Time(), Time()); | 946 std::string(), std::string(), false, "UTF-8", Time(), Time()); |
| 947 AddKeywordWithDate( | 947 AddKeywordWithDate( |
| 948 model(), "extension2", "ext_keyword2", | 948 model(), "extension2", "ext_keyword2", |
| 949 std::string(extensions::kExtensionScheme) + "://test2", std::string(), | 949 std::string(extensions::kExtensionScheme) + "://test2", std::string(), |
| 950 std::string(), std::string(), false, "UTF-8", Time(), Time()); | 950 std::string(), std::string(), false, "UTF-8", Time(), Time()); |
| 951 TemplateURL* default_provider = model()->GetDefaultSearchProvider(); | 951 TemplateURL* default_provider = model()->GetDefaultSearchProvider(); |
| 952 EXPECT_NE(SEARCH_ENGINE_GOOGLE, | 952 EXPECT_NE(SEARCH_ENGINE_GOOGLE, |
| 953 TemplateURLPrepopulateData::GetEngineType(default_provider->url())); | 953 TemplateURLPrepopulateData::GetEngineType(default_provider->url())); |
| 954 | 954 |
| 955 DictionaryValue manifest; | 955 DictionaryValue manifest; |
| 956 manifest.SetString(extension_manifest_keys::kVersion, "1.0.0.0"); | 956 manifest.SetString(extensions::manifest_keys::kVersion, "1.0.0.0"); |
| 957 manifest.SetString(extension_manifest_keys::kName, "ext1"); | 957 manifest.SetString(extensions::manifest_keys::kName, "ext1"); |
| 958 manifest.SetString("app.launch.web_url", "http://www.google.com"); | 958 manifest.SetString("app.launch.web_url", "http://www.google.com"); |
| 959 manifest.SetString(extension_manifest_keys::kOmniboxKeyword, "ext_keyword"); | 959 manifest.SetString(extensions::manifest_keys::kOmniboxKeyword, "ext_keyword"); |
| 960 std::string error; | 960 std::string error; |
| 961 scoped_refptr<extensions::Extension> extension = | 961 scoped_refptr<extensions::Extension> extension = |
| 962 extensions::Extension::Create( | 962 extensions::Extension::Create( |
| 963 base::FilePath(FILE_PATH_LITERAL("//nonexistent")), | 963 base::FilePath(FILE_PATH_LITERAL("//nonexistent")), |
| 964 extensions::Manifest::COMPONENT, | 964 extensions::Manifest::COMPONENT, |
| 965 manifest, | 965 manifest, |
| 966 extensions::Extension::NO_FLAGS, | 966 extensions::Extension::NO_FLAGS, |
| 967 &error); | 967 &error); |
| 968 EXPECT_TRUE(extension.get() != NULL) << error; | 968 EXPECT_TRUE(extension.get() != NULL) << error; |
| 969 ExtensionService* extension_service = profile()->GetExtensionService(); | 969 ExtensionService* extension_service = profile()->GetExtensionService(); |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1609 EXPECT_EQ(8U, loaded_url->input_encodings().size()); | 1609 EXPECT_EQ(8U, loaded_url->input_encodings().size()); |
| 1610 | 1610 |
| 1611 // Reload the model to verify it was actually saved to the database and the | 1611 // Reload the model to verify it was actually saved to the database and the |
| 1612 // duplicate encodings were removed. | 1612 // duplicate encodings were removed. |
| 1613 test_util_.ResetModel(true); | 1613 test_util_.ResetModel(true); |
| 1614 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); | 1614 ASSERT_EQ(initial_count + 1, model()->GetTemplateURLs().size()); |
| 1615 loaded_url = model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword")); | 1615 loaded_url = model()->GetTemplateURLForKeyword(ASCIIToUTF16("keyword")); |
| 1616 ASSERT_FALSE(loaded_url == NULL); | 1616 ASSERT_FALSE(loaded_url == NULL); |
| 1617 EXPECT_EQ(4U, loaded_url->input_encodings().size()); | 1617 EXPECT_EQ(4U, loaded_url->input_encodings().size()); |
| 1618 } | 1618 } |
| OLD | NEW |