Move WebTestContentIndexProvider to ShellContentIndexProvider
The ContentIndexProvider is used by web tests as well as
content_browsertests.
[email protected]
Bug: 866140
Change-Id: If07c7869c4484a55be8e958ebb1c43321a65d76a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2269513
Reviewed-by: Avi Drissman <[email protected]>
Commit-Queue: danakj <[email protected]>
Cr-Commit-Position: refs/heads/master@{#783245}
diff --git a/content/shell/browser/DEPS b/content/shell/browser/DEPS
index 4c17205..ba4e5e4 100644
--- a/content/shell/browser/DEPS
+++ b/content/shell/browser/DEPS
@@ -11,7 +11,7 @@
# Separating Content Shell and web test code.
# TODO(danakj): This directory shouldn't need to access web test code as
# the ShellMainDelegate should inject it as appropriate.
- "+content/shell/browser/web_test",
+ "+content/shell/browser/web_test/web_test_control_host.h",
"+content/shell/common/web_test/web_test_switches.h",
]
diff --git a/content/shell/browser/shell_browser_context.cc b/content/shell/browser/shell_browser_context.cc
index 4bf83ad..e991845f 100644
--- a/content/shell/browser/shell_browser_context.cc
+++ b/content/shell/browser/shell_browser_context.cc
@@ -23,9 +23,9 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/common/content_switches.h"
+#include "content/shell/browser/shell_content_index_provider.h"
#include "content/shell/browser/shell_download_manager_delegate.h"
#include "content/shell/browser/shell_permission_manager.h"
-#include "content/shell/browser/web_test/web_test_content_index_provider.h"
#include "content/shell/common/shell_switches.h"
#include "content/test/mock_background_sync_controller.h"
@@ -216,7 +216,7 @@
ContentIndexProvider* ShellBrowserContext::GetContentIndexProvider() {
if (!content_index_provider_)
- content_index_provider_ = std::make_unique<WebTestContentIndexProvider>();
+ content_index_provider_ = std::make_unique<ShellContentIndexProvider>();
return content_index_provider_.get();
}
diff --git a/content/shell/browser/web_test/web_test_content_index_provider.cc b/content/shell/browser/shell_content_index_provider.cc
similarity index 60%
rename from content/shell/browser/web_test/web_test_content_index_provider.cc
rename to content/shell/browser/shell_content_index_provider.cc
index e2d414d..e00e632e 100644
--- a/content/shell/browser/web_test/web_test_content_index_provider.cc
+++ b/content/shell/browser/shell_content_index_provider.cc
@@ -2,27 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/shell/browser/web_test/web_test_content_index_provider.h"
+#include "content/shell/browser/shell_content_index_provider.h"
namespace content {
-WebTestContentIndexProvider::WebTestContentIndexProvider()
+ShellContentIndexProvider::ShellContentIndexProvider()
: icon_sizes_({{96, 96}}) {}
-WebTestContentIndexProvider::~WebTestContentIndexProvider() = default;
+ShellContentIndexProvider::~ShellContentIndexProvider() = default;
-std::vector<gfx::Size> WebTestContentIndexProvider::GetIconSizes(
+std::vector<gfx::Size> ShellContentIndexProvider::GetIconSizes(
blink::mojom::ContentCategory category) {
return icon_sizes_;
}
-void WebTestContentIndexProvider::OnContentAdded(ContentIndexEntry entry) {
+void ShellContentIndexProvider::OnContentAdded(ContentIndexEntry entry) {
entries_[entry.description->id] = {
entry.service_worker_registration_id,
url::Origin::Create(entry.launch_url.GetOrigin())};
}
-void WebTestContentIndexProvider::OnContentDeleted(
+void ShellContentIndexProvider::OnContentDeleted(
int64_t service_worker_registration_id,
const url::Origin& origin,
const std::string& description_id) {
@@ -30,10 +30,10 @@
}
std::pair<int64_t, url::Origin>
-WebTestContentIndexProvider::GetRegistrationDataFromId(const std::string& id) {
+ShellContentIndexProvider::GetRegistrationDataFromId(const std::string& id) {
if (!entries_.count(id))
return {-1, url::Origin()};
return entries_[id];
}
-} // namespace content
\ No newline at end of file
+} // namespace content
diff --git a/content/shell/browser/web_test/web_test_content_index_provider.h b/content/shell/browser/shell_content_index_provider.h
similarity index 74%
rename from content/shell/browser/web_test/web_test_content_index_provider.h
rename to content/shell/browser/shell_content_index_provider.h
index e700d09..27ebf31 100644
--- a/content/shell/browser/web_test/web_test_content_index_provider.h
+++ b/content/shell/browser/shell_content_index_provider.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_CONTENT_INDEX_PROVIDER_H_
-#define CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_CONTENT_INDEX_PROVIDER_H_
+#ifndef CONTENT_SHELL_BROWSER_SHELL_CONTENT_INDEX_PROVIDER_H_
+#define CONTENT_SHELL_BROWSER_SHELL_CONTENT_INDEX_PROVIDER_H_
#include <map>
#include <string>
@@ -17,12 +17,12 @@
namespace content {
-// When using WebTestContentIndexProvider, IDs need to be globally unique,
+// When using ShellContentIndexProvider, IDs need to be globally unique,
// instead of per Service Worker.
-class WebTestContentIndexProvider : public ContentIndexProvider {
+class ShellContentIndexProvider : public ContentIndexProvider {
public:
- WebTestContentIndexProvider();
- ~WebTestContentIndexProvider() override;
+ ShellContentIndexProvider();
+ ~ShellContentIndexProvider() override;
// ContentIndexProvider implementation.
std::vector<gfx::Size> GetIconSizes(
@@ -48,9 +48,9 @@
std::vector<gfx::Size> icon_sizes_;
- DISALLOW_COPY_AND_ASSIGN(WebTestContentIndexProvider);
+ DISALLOW_COPY_AND_ASSIGN(ShellContentIndexProvider);
};
} // namespace content
-#endif // CONTENT_SHELL_BROWSER_WEB_TEST_WEB_TEST_CONTENT_INDEX_PROVIDER_H_
+#endif // CONTENT_SHELL_BROWSER_SHELL_CONTENT_INDEX_PROVIDER_H_
diff --git a/content/shell/browser/web_test/web_test_browser_context.cc b/content/shell/browser/web_test/web_test_browser_context.cc
index a8d3e2c..5e487c4c 100644
--- a/content/shell/browser/web_test/web_test_browser_context.cc
+++ b/content/shell/browser/web_test/web_test_browser_context.cc
@@ -17,7 +17,6 @@
#include "content/public/browser/resource_context.h"
#include "content/shell/browser/web_test/mock_client_hints_controller_delegate.h"
#include "content/shell/browser/web_test/web_test_background_fetch_delegate.h"
-#include "content/shell/browser/web_test/web_test_content_index_provider.h"
#include "content/shell/browser/web_test/web_test_download_manager_delegate.h"
#include "content/shell/browser/web_test/web_test_permission_manager.h"
#include "content/shell/browser/web_test/web_test_push_messaging_service.h"
@@ -92,12 +91,6 @@
GetPermissionControllerDelegate());
}
-ContentIndexProvider* WebTestBrowserContext::GetContentIndexProvider() {
- if (!content_index_provider_)
- content_index_provider_ = std::make_unique<WebTestContentIndexProvider>();
- return content_index_provider_.get();
-}
-
ClientHintsControllerDelegate*
WebTestBrowserContext::GetClientHintsControllerDelegate() {
if (!client_hints_controller_delegate_) {
diff --git a/content/shell/browser/web_test/web_test_browser_context.h b/content/shell/browser/web_test/web_test_browser_context.h
index af55eb6..1a1e7dd6 100644
--- a/content/shell/browser/web_test/web_test_browser_context.h
+++ b/content/shell/browser/web_test/web_test_browser_context.h
@@ -16,7 +16,6 @@
namespace content {
class BackgroundSyncController;
-class ContentIndexProvider;
class DownloadManagerDelegate;
class PermissionControllerDelegate;
class PushMessagingService;
@@ -29,13 +28,12 @@
explicit WebTestBrowserContext(bool off_the_record);
~WebTestBrowserContext() override;
- // BrowserContext implementation.
+ // ShellBrowserContext overrides.
DownloadManagerDelegate* GetDownloadManagerDelegate() override;
PushMessagingService* GetPushMessagingService() override;
PermissionControllerDelegate* GetPermissionControllerDelegate() override;
BackgroundFetchDelegate* GetBackgroundFetchDelegate() override;
BackgroundSyncController* GetBackgroundSyncController() override;
- ContentIndexProvider* GetContentIndexProvider() override;
ClientHintsControllerDelegate* GetClientHintsControllerDelegate() override;
WebTestPermissionManager* GetWebTestPermissionManager();
@@ -46,7 +44,6 @@
std::unique_ptr<WebTestBackgroundFetchDelegate> background_fetch_delegate_;
std::unique_ptr<BackgroundSyncController> background_sync_controller_;
std::unique_ptr<device::ScopedGeolocationOverrider> geolocation_overrider_;
- std::unique_ptr<ContentIndexProvider> content_index_provider_;
std::unique_ptr<ClientHintsControllerDelegate>
client_hints_controller_delegate_;
diff --git a/content/shell/browser/web_test/web_test_client_impl.cc b/content/shell/browser/web_test/web_test_client_impl.cc
index aa30559a..3eb0c530 100644
--- a/content/shell/browser/web_test/web_test_client_impl.cc
+++ b/content/shell/browser/web_test/web_test_client_impl.cc
@@ -20,9 +20,9 @@
#include "content/public/browser/network_service_instance.h"
#include "content/public/browser/storage_partition.h"
#include "content/shell/browser/shell_content_browser_client.h"
+#include "content/shell/browser/shell_content_index_provider.h"
#include "content/shell/browser/web_test/web_test_browser_context.h"
#include "content/shell/browser/web_test/web_test_content_browser_client.h"
-#include "content/shell/browser/web_test/web_test_content_index_provider.h"
#include "content/shell/browser/web_test/web_test_control_host.h"
#include "content/shell/browser/web_test/web_test_permission_manager.h"
#include "content/shell/common/web_test/web_test_constants.h"
@@ -46,10 +46,10 @@
return static_cast<MockPlatformNotificationService*>(service);
}
-WebTestContentIndexProvider* GetWebTestContentIndexProvider() {
+ShellContentIndexProvider* GetShellContentIndexProvider() {
auto* client = WebTestContentBrowserClient::Get();
auto* context = client->GetWebTestBrowserContext();
- return static_cast<WebTestContentIndexProvider*>(
+ return static_cast<ShellContentIndexProvider*>(
context->GetContentIndexProvider());
}
@@ -130,7 +130,7 @@
void WebTestClientImpl::SimulateWebContentIndexDelete(const std::string& id) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- auto* provider = GetWebTestContentIndexProvider();
+ ShellContentIndexProvider* provider = GetShellContentIndexProvider();
std::pair<int64_t, url::Origin> registration_data =
provider->GetRegistrationDataFromId(id);