fix: add theme data source for devtools. (#44114)

* fix: add theme data source for devtools.

* chore: add ut.

* chore: remove recording histograms

* fix: add theme data source for devtools.

* chore: separate files

* chore: separate files

* chore: remove pragma once

* chore: fix lint issue.
This commit is contained in:
BILL SHEN 2024-11-13 20:23:37 +08:00 committed by GitHub
parent d380cda14a
commit a120d87570
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 474 additions and 110 deletions

View file

@ -0,0 +1,40 @@
// Copyright (c) 2024 The Chromium Authors. All rights reserved.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_BROWSER_UI_DEVTOOLS_UI_BUNDLE_DATA_SOURCE_H_
#define ELECTRON_SHELL_BROWSER_UI_DEVTOOLS_UI_BUNDLE_DATA_SOURCE_H_
#include "content/public/browser/url_data_source.h"
namespace electron {
// A BundledDataSource implementation that handles devtools://devtools/
// requests.
class BundledDataSource : public content::URLDataSource {
public:
BundledDataSource() = default;
~BundledDataSource() override = default;
// disable copy
BundledDataSource(const BundledDataSource&) = delete;
BundledDataSource& operator=(const BundledDataSource&) = delete;
std::string GetSource() override;
void StartDataRequest(const GURL& url,
const content::WebContents::Getter& wc_getter,
GotDataCallback callback) override;
private:
std::string GetMimeType(const GURL& url) override;
bool ShouldAddContentSecurityPolicy() override;
bool ShouldDenyXFrameOptions() override;
bool ShouldServeMimeTypeAsContentTypeHeader() override;
void StartBundledDataRequest(const std::string& path,
GotDataCallback callback);
};
} // namespace electron
#endif // ELECTRON_SHELL_BROWSER_UI_DEVTOOLS_UI_BUNDLE_DATA_SOURCE_H_