| 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 "components/omnibox/browser/shortcuts_provider.h" | 5 #include "components/omnibox/browser/shortcuts_provider.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" | 16 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" |
| 17 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 17 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
| 18 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" | 18 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" |
| 19 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
| 20 #include "components/history/core/browser/history_service.h" | 20 #include "components/history/core/browser/history_service.h" |
| 21 #include "components/omnibox/browser/autocomplete_input.h" | 21 #include "components/omnibox/browser/autocomplete_input.h" |
| 22 #include "components/omnibox/browser/autocomplete_match.h" | 22 #include "components/omnibox/browser/autocomplete_match.h" |
| 23 #include "components/omnibox/browser/autocomplete_result.h" | 23 #include "components/omnibox/browser/autocomplete_result.h" |
| 24 #include "components/omnibox/browser/shortcuts_backend.h" | 24 #include "components/omnibox/browser/shortcuts_backend.h" |
| 25 #include "components/omnibox/browser/shortcuts_provider_test_util.h" | 25 #include "components/omnibox/browser/shortcuts_provider_test_util.h" |
| 26 #include "content/public/browser/notification_service.h" | |
| 27 #include "content/public/test/test_browser_thread.h" | 26 #include "content/public/test/test_browser_thread.h" |
| 28 #include "extensions/features/features.h" | 27 #include "extensions/features/features.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 30 | 29 |
| 31 #if BUILDFLAG(ENABLE_EXTENSIONS) | 30 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 32 #include "extensions/browser/notification_types.h" | 31 #include "extensions/browser/extension_registry.h" |
| 33 #include "extensions/common/extension.h" | 32 #include "extensions/common/extension.h" |
| 34 #include "extensions/common/extension_builder.h" | 33 #include "extensions/common/extension_builder.h" |
| 35 #endif | 34 #endif |
| 36 | 35 |
| 37 using ExpectedURLs = std::vector<ExpectedURLAndAllowedToBeDefault>; | 36 using ExpectedURLs = std::vector<ExpectedURLAndAllowedToBeDefault>; |
| 38 | 37 |
| 39 namespace { | 38 namespace { |
| 40 | 39 |
| 41 struct TestShortcutData shortcut_test_db[] = { | 40 struct TestShortcutData shortcut_test_db[] = { |
| 42 {"BD85DBA2-8C29-49F9-84AE-48E1E90880F1", "echo echo", "echo echo", | 41 {"BD85DBA2-8C29-49F9-84AE-48E1E90880F1", "echo echo", "echo echo", |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 105 |
| 107 // Claim the extension has been unloaded. | 106 // Claim the extension has been unloaded. |
| 108 scoped_refptr<const extensions::Extension> extension = | 107 scoped_refptr<const extensions::Extension> extension = |
| 109 extensions::ExtensionBuilder() | 108 extensions::ExtensionBuilder() |
| 110 .SetManifest(extensions::DictionaryBuilder() | 109 .SetManifest(extensions::DictionaryBuilder() |
| 111 .Set("name", "Echo") | 110 .Set("name", "Echo") |
| 112 .Set("version", "1.0") | 111 .Set("version", "1.0") |
| 113 .Build()) | 112 .Build()) |
| 114 .SetID("cedabbhfglmiikkmdgcpjdkocfcmbkee") | 113 .SetID("cedabbhfglmiikkmdgcpjdkocfcmbkee") |
| 115 .Build(); | 114 .Build(); |
| 116 extensions::UnloadedExtensionInfo details( | 115 extensions::ExtensionRegistry::Get(&profile_)->TriggerOnUnloaded( |
| 117 extension.get(), extensions::UnloadedExtensionInfo::REASON_UNINSTALL); | 116 extension.get(), extensions::UnloadedExtensionInfo::REASON_UNINSTALL); |
| 118 content::NotificationService::current()->Notify( | |
| 119 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | |
| 120 content::Source<Profile>(&profile_), | |
| 121 content::Details<extensions::UnloadedExtensionInfo>(&details)); | |
| 122 | 117 |
| 123 // Now the URL should have disappeared. | 118 // Now the URL should have disappeared. |
| 124 RunShortcutsProviderTest(provider_, text, false, ExpectedURLs(), | 119 RunShortcutsProviderTest(provider_, text, false, ExpectedURLs(), |
| 125 std::string(), base::string16()); | 120 std::string(), base::string16()); |
| 126 } | 121 } |
| 127 #endif | 122 #endif |
| OLD | NEW |