Skip to content

Commit

Permalink
refactor: eliminate brightray::ContentClient (#15303)
Browse files Browse the repository at this point in the history
  • Loading branch information
miniak authored and alexeykuzmin committed Oct 22, 2018
1 parent 9262731 commit e8e7edf
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 122 deletions.
19 changes: 19 additions & 0 deletions atom/app/atom_content_client.cc
Expand Up @@ -21,6 +21,7 @@
#include "electron/buildflags/buildflags.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "url/url_constants.h"
// In SHARED_INTERMEDIATE_DIR.
#include "widevine_cdm_version.h" // NOLINT(build/include)
Expand Down Expand Up @@ -193,6 +194,24 @@ base::string16 AtomContentClient::GetLocalizedString(int message_id) const {
return l10n_util::GetStringUTF16(message_id);
}

base::StringPiece AtomContentClient::GetDataResource(
int resource_id,
ui::ScaleFactor scale_factor) const {
return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
resource_id, scale_factor);
}

gfx::Image& AtomContentClient::GetNativeImageNamed(int resource_id) const {
return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
resource_id);
}

base::RefCountedMemory* AtomContentClient::GetDataResourceBytes(
int resource_id) const {
return ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
resource_id);
}

void AtomContentClient::AddAdditionalSchemes(Schemes* schemes) {
schemes->standard_schemes.push_back("chrome-extension");

Expand Down
8 changes: 6 additions & 2 deletions atom/app/atom_content_client.h
Expand Up @@ -9,11 +9,11 @@
#include <string>
#include <vector>

#include "brightray/common/content_client.h"
#include "content/public/common/content_client.h"

namespace atom {

class AtomContentClient : public brightray::ContentClient {
class AtomContentClient : public content::ContentClient {
public:
AtomContentClient();
~AtomContentClient() override;
Expand All @@ -23,6 +23,10 @@ class AtomContentClient : public brightray::ContentClient {
std::string GetProduct() const override;
std::string GetUserAgent() const override;
base::string16 GetLocalizedString(int message_id) const override;
base::StringPiece GetDataResource(int resource_id,
ui::ScaleFactor) const override;
gfx::Image& GetNativeImageNamed(int resource_id) const override;
base::RefCountedMemory* GetDataResourceBytes(int resource_id) const override;
void AddAdditionalSchemes(Schemes* schemes) override;
void AddPepperPlugins(
std::vector<content::PepperPluginInfo>* plugins) override;
Expand Down
8 changes: 3 additions & 5 deletions atom/app/atom_main_delegate.cc
Expand Up @@ -129,6 +129,9 @@ bool AtomMainDelegate::BasicStartupComplete(int* exit_code) {
base::win::DisableHandleVerifier();
#endif

content_client_ = std::make_unique<AtomContentClient>();
SetContentClient(content_client_.get());

return brightray::MainDelegate::BasicStartupComplete(exit_code);
}

Expand Down Expand Up @@ -212,9 +215,4 @@ bool AtomMainDelegate::DelaySandboxInitialization(
}
#endif

std::unique_ptr<brightray::ContentClient>
AtomMainDelegate::CreateContentClient() {
return std::make_unique<AtomContentClient>();
}

} // namespace atom
4 changes: 2 additions & 2 deletions atom/app/atom_main_delegate.h
Expand Up @@ -8,8 +8,8 @@
#include <memory>
#include <string>

#include "brightray/common/content_client.h"
#include "brightray/common/main_delegate.h"
#include "content/public/common/content_client.h"

namespace atom {

Expand All @@ -35,7 +35,6 @@ class AtomMainDelegate : public brightray::MainDelegate {
#endif

// brightray::MainDelegate:
std::unique_ptr<brightray::ContentClient> CreateContentClient() override;
#if defined(OS_MACOSX)
void OverrideChildProcessPath() override;
void OverrideFrameworkBundlePath() override;
Expand All @@ -47,6 +46,7 @@ class AtomMainDelegate : public brightray::MainDelegate {
#endif

std::unique_ptr<content::ContentBrowserClient> browser_client_;
std::unique_ptr<content::ContentClient> content_client_;
std::unique_ptr<content::ContentRendererClient> renderer_client_;
std::unique_ptr<content::ContentUtilityClient> utility_client_;

Expand Down
1 change: 0 additions & 1 deletion atom/browser/ui/devtools_manager_delegate.cc
Expand Up @@ -13,7 +13,6 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "brightray/common/content_client.h"
#include "content/public/browser/devtools_agent_host.h"
#include "content/public/browser/devtools_frontend_host.h"
#include "content/public/browser/devtools_socket_factory.h"
Expand Down
2 changes: 0 additions & 2 deletions brightray/BUILD.gn
Expand Up @@ -30,8 +30,6 @@ static_library("brightray") {
"common/application_info.h",
"common/application_info_mac.mm",
"common/application_info_win.cc",
"common/content_client.cc",
"common/content_client.h",
"common/mac/main_application_bundle.h",
"common/mac/main_application_bundle.mm",
"common/main_delegate.cc",
Expand Down
61 changes: 0 additions & 61 deletions brightray/common/content_client.cc

This file was deleted.

36 changes: 0 additions & 36 deletions brightray/common/content_client.h

This file was deleted.

7 changes: 0 additions & 7 deletions brightray/common/main_delegate.cc
Expand Up @@ -10,7 +10,6 @@
#include "base/mac/bundle_locations.h"
#include "base/path_service.h"
#include "brightray/browser/browser_client.h"
#include "brightray/common/content_client.h"
#include "content/public/common/content_switches.h"
#include "electron/buildflags/buildflags.h"
#include "services/service_manager/embedder/switches.h"
Expand Down Expand Up @@ -77,13 +76,7 @@ MainDelegate::MainDelegate() {}

MainDelegate::~MainDelegate() {}

std::unique_ptr<ContentClient> MainDelegate::CreateContentClient() {
return std::unique_ptr<ContentClient>(new ContentClient);
}

bool MainDelegate::BasicStartupComplete(int* exit_code) {
content_client_ = CreateContentClient();
SetContentClient(content_client_.get());
#if defined(OS_MACOSX)
OverrideChildProcessPath();
OverrideFrameworkBundlePath();
Expand Down
6 changes: 0 additions & 6 deletions brightray/common/main_delegate.h
Expand Up @@ -22,7 +22,6 @@ class ResourceBundle;
namespace brightray {

class BrowserClient;
class ContentClient;

void LoadResourceBundle(const std::string& locale);
void LoadCommonResources();
Expand All @@ -33,10 +32,6 @@ class MainDelegate : public content::ContentMainDelegate {
~MainDelegate() override;

protected:
// Subclasses can override this to provide their own ContentClient
// implementation.
virtual std::unique_ptr<ContentClient> CreateContentClient();

// Subclasses can override this to provide their own BrowserClient
// implementation.
virtual std::unique_ptr<BrowserClient> CreateBrowserClient();
Expand All @@ -54,7 +49,6 @@ class MainDelegate : public content::ContentMainDelegate {
private:
content::ContentBrowserClient* CreateContentBrowserClient() override;

std::unique_ptr<ContentClient> content_client_;
std::unique_ptr<BrowserClient> browser_client_;

DISALLOW_COPY_AND_ASSIGN(MainDelegate);
Expand Down

0 comments on commit e8e7edf

Please sign in to comment.