Skip to content

Commit

Permalink
Merge pull request #15 from brave/web-ui
Browse files Browse the repository at this point in the history
Add Brave WebUI about:payments and brave-extension loading
  • Loading branch information
bbondy authored Jan 6, 2018
2 parents b4ec0ef + 3429d5e commit 46ea972
Show file tree
Hide file tree
Showing 38 changed files with 828 additions and 6 deletions.
53 changes: 53 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import("//tools/grit/repack.gni")

group("child_dependencies") {
public_deps = [
"//brave/renderer",
Expand All @@ -10,6 +12,7 @@ group("browser_dependencies") {
public_deps = [
"//brave/browser",
"common",
":brave_framework_resources",
]
}

Expand All @@ -18,3 +21,53 @@ group("brave") {
"//chrome",
]
}

repack("packed_extra_resources") {
visibility = [ "./*" ]
sources = [
"$root_gen_dir/components/brave_components_resources.pak",
"$root_gen_dir/brave/brave_extension.pak",
]

deps = [
"//brave/components/resources:brave_components_resources_grit",
"//brave/browser/resources:brave_extension_grit"
]

deps += [
"//brave/common/extensions/api"
]

if (is_mac) {
output = "$root_gen_dir/repack/brave_resources.pak"
} else {
output = "$root_out_dir/brave_resources.pak"
}
}

group("packed_resources") {
public_deps = [
":packed_extra_resources",
]
}

brave_framework_public_deps = [
":packed_resources",
]

if (is_mac) {
bundle_data("brave_framework_resources") {
sources = [
"$root_gen_dir/repack/brave_resources.pak",
]
public_deps = brave_framework_public_deps

outputs = [
"{{bundle_resources_dir}}/{{source_file_part}}",
]
}
} else {
group("brave_framework_resources") {
public_deps = brave_framework_public_deps
}
}
8 changes: 7 additions & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ deps = {
"vendor/tracking-protection": "https://github.com/brave/tracking-protection.git@0931529eba33109c6b3946a83295577fea540045",
"vendor/hashset-cpp": "https://github.com/bbondy/hashset-cpp.git@f427324d667d7188a9e0975cca7f3a8c06226b4d",
"vendor/bloom-filter-cpp": "https://github.com/bbondy/bloom-filter-cpp.git@6faa14ececa33badad149c40f94ff9867159681c",
"vendor/brave-extension": "https://github.com/brave/brave-extension.git@964216a438140ec4cd8bca606c51bee2f4869730",
"vendor/brave-extension": "https://github.com/brave/brave-extension.git@9ebbb89d540dcc8f2923349bc42f88042ad94e43",
"vendor/requests": "https://github.com/kennethreitz/requests@e4d59bedfd3c7f4f254f4f5d036587bcd8152458",
"vendor/boto": "https://github.com/boto/boto@f7574aa6cc2c819430c1f05e9a1a1a666ef8169b",
"vendor/python-patch": "https://github.com/svn2github/python-patch@a336a458016ced89aba90dfc3f4c8222ae3b1403",
Expand All @@ -17,5 +17,11 @@ hooks = [
'name': 'apply_patches',
'pattern': '.',
'action': ['python', 'src/brave/script/apply-patches.py'],
},
{
# Run npm install for brave-extension
'name': 'init',
'pattern': '.',
'action': ['python', 'src/brave/script/init-brave-extension.py'],
}
]
7 changes: 7 additions & 0 deletions app/brave_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "base/time/time.h"
#include "build/build_config.h"
#include "brave/browser/brave_content_browser_client.h"
#include "brave/common/resource_bundle_helper.h"
#include "brave/renderer/brave_content_renderer_client.h"
#include "brave/utility/brave_content_utility_client.h"

Expand Down Expand Up @@ -61,3 +62,9 @@ bool BraveMainDelegate::ShouldEnableProfilerRecording() {
return false;
}

void BraveMainDelegate::PreSandboxStartup() {
ChromeMainDelegate::PreSandboxStartup();
if (brave::SubprocessNeedsResourceBundle()) {
brave::InitializeResourceBundle();
}
}
1 change: 1 addition & 0 deletions app/brave_main_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class BraveMainDelegate : public ChromeMainDelegate {
content::ContentBrowserClient* CreateContentBrowserClient() override;
content::ContentRendererClient* CreateContentRendererClient() override;
content::ContentUtilityClient* CreateContentUtilityClient() override;
void PreSandboxStartup() override;

DISALLOW_COPY_AND_ASSIGN(BraveMainDelegate);
};
Expand Down
6 changes: 6 additions & 0 deletions browser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import("//build/config/features.gni")

source_set("browser_process") {
sources = [
"brave_browser_main_extra_parts.cc",
"brave_browser_main_extra_parts.h",
"brave_browser_process_impl.cc",
"brave_browser_process_impl.h",
"brave_tab_helpers.cc",
Expand All @@ -20,11 +22,15 @@ source_set("browser") {
]

public_deps = [
"//brave/components/resources:brave_components_resources_grit",
"//brave/browser/resources:brave_extension_grit",
"//chrome/browser",
]

deps = [
"//brave/components/brave_shields/browser:brave_shields",
"extensions",
"net",
"ui",
]
}
17 changes: 17 additions & 0 deletions browser/brave_browser_main_extra_parts.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "brave/browser/brave_browser_main_extra_parts.h"

#include "brave/common/resource_bundle_helper.h"

BraveBrowserMainExtraParts::BraveBrowserMainExtraParts() {
}

BraveBrowserMainExtraParts::~BraveBrowserMainExtraParts() {
}

void BraveBrowserMainExtraParts::PreCreateThreads() {
brave::InitializeResourceBundle();
}
25 changes: 25 additions & 0 deletions browser/brave_browser_main_extra_parts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef BRAVE_BROWSER_BRAVE_BROWSER_MAIN_EXTRA_PARTS_H_
#define BRAVE_BROWSER_BRAVE_BROWSER_MAIN_EXTRA_PARTS_H_

#include "base/compiler_specific.h"
#include "base/macros.h"
#include "chrome/browser/chrome_browser_main.h"
#include "chrome/browser/chrome_browser_main_extra_parts.h"

class BraveBrowserMainExtraParts : public ChromeBrowserMainExtraParts {
public:
explicit BraveBrowserMainExtraParts();
~BraveBrowserMainExtraParts() override;

// ChromeBrowserMainExtraParts overrides.
void PreCreateThreads() override;

private:
DISALLOW_COPY_AND_ASSIGN(BraveBrowserMainExtraParts);
};

#endif // BRAVE_BROWSER_BRAVE_BROWSER_MAIN_EXTRA_PARTS_H_
13 changes: 11 additions & 2 deletions browser/brave_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@

#include "brave/browser/brave_content_browser_client.h"

BraveContentBrowserClient::BraveContentBrowserClient()
: ChromeContentBrowserClient() {}
#include "brave/browser/brave_browser_main_extra_parts.h"

BraveContentBrowserClient::BraveContentBrowserClient() {}

BraveContentBrowserClient::~BraveContentBrowserClient() {}

content::BrowserMainParts* BraveContentBrowserClient::CreateBrowserMainParts(
const content::MainFunctionParams& parameters) {
ChromeBrowserMainParts* main_parts = (ChromeBrowserMainParts*)
ChromeContentBrowserClient::CreateBrowserMainParts(parameters);
main_parts->AddParts(new BraveBrowserMainExtraParts());
return main_parts;
}
4 changes: 4 additions & 0 deletions browser/brave_content_browser_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class BraveContentBrowserClient : public ChromeContentBrowserClient {
BraveContentBrowserClient();
~BraveContentBrowserClient() override;

// Overridden from ChromeContentBrowserClient:
content::BrowserMainParts* CreateBrowserMainParts(
const content::MainFunctionParams& parameters) override;

private:
DISALLOW_COPY_AND_ASSIGN(BraveContentBrowserClient);
};
Expand Down
13 changes: 13 additions & 0 deletions browser/extensions/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import("//build/config/features.gni")

source_set("extensions") {
sources = [
"brave_component_extension_resource_manager.cc",
"brave_component_extension_resource_manager.h",
"brave_component_loader.cc",
"brave_component_loader.h",
]
deps = [
"//chrome/browser"
]
}
21 changes: 21 additions & 0 deletions browser/extensions/brave_component_extension_resource_manager.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "brave/browser/extensions/brave_component_extension_resource_manager.h"

#include "brave/grit/brave_extension_resources_map.h"

namespace extensions {

BraveComponentExtensionResourceManager::
BraveComponentExtensionResourceManager() {
AddComponentResourceEntries(
kBraveExtension,
kBraveExtensionSize);
}

BraveComponentExtensionResourceManager::
~BraveComponentExtensionResourceManager() {}

} // namespace extensions
23 changes: 23 additions & 0 deletions browser/extensions/brave_component_extension_resource_manager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef BRAVE_BROWSER_EXTENSIONS_BRAVE_COMPONENT_EXTENSION_RESOURCE_MANAGER_H_
#define BRAVE_BROWSER_EXTENSIONS_BRAVE_COMPONENT_EXTENSION_RESOURCE_MANAGER_H_

#include "chrome/browser/extensions/chrome_component_extension_resource_manager.h"

namespace extensions {

class BraveComponentExtensionResourceManager
: public ChromeComponentExtensionResourceManager {
public:
BraveComponentExtensionResourceManager();
~BraveComponentExtensionResourceManager() override;

DISALLOW_COPY_AND_ASSIGN(BraveComponentExtensionResourceManager);
};

} // namespace extensions

#endif // BRAVE_BROWSER_EXTENSIONS_BRAVE_COMPONENT_EXTENSION_RESOURCE_MANAGER_H_
31 changes: 31 additions & 0 deletions browser/extensions/brave_component_loader.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "brave/browser/extensions/brave_component_loader.h"

#include "components/grit/brave_components_resources.h"

namespace extensions {

BraveComponentLoader::BraveComponentLoader(
ExtensionServiceInterface* extension_service,
PrefService* profile_prefs,
PrefService* local_state,
Profile* profile)
: ComponentLoader(extension_service, profile_prefs, local_state, profile) {
}

BraveComponentLoader::~BraveComponentLoader() {
}

void BraveComponentLoader::AddDefaultComponentExtensions(
bool skip_session_components) {
ComponentLoader::AddDefaultComponentExtensions(skip_session_components);
base::FilePath brave_extension_path(FILE_PATH_LITERAL("${root_gen_dir}"));
brave_extension_path =
brave_extension_path.Append(FILE_PATH_LITERAL("brave_extension"));
Add(IDR_BRAVE_EXTENSON, brave_extension_path);
}

} // namespace extensions
32 changes: 32 additions & 0 deletions browser/extensions/brave_component_loader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef BRAVE_BROWSER_EXTENSIONS_BRAVE_COMPONENT_LOADER_H_
#define BRAVE_BROWSER_EXTENSIONS_BRAVE_COMPONENT_LOADER_H_

#include "chrome/browser/extensions/component_loader.h"

namespace extensions {

// For registering, loading, and unloading component extensions.
class BraveComponentLoader : public ComponentLoader {
public:
BraveComponentLoader(ExtensionServiceInterface* extension_service,
PrefService* prefs,
PrefService* local_state,
Profile* browser_context);
~BraveComponentLoader() override;

// Adds the default component extensions. If |skip_session_components|
// the loader will skip loading component extensions that weren't supposed to
// be loaded unless we are in signed user session (ChromeOS). For all other
// platforms this |skip_session_components| is expected to be unset.
void AddDefaultComponentExtensions(bool skip_session_components) override;

DISALLOW_COPY_AND_ASSIGN(BraveComponentLoader);
};

} // namespace extensions

#endif // BRAVE_BROWSER_EXTENSIONS_BRAVE_COMPONENT_LOADER_H_
28 changes: 28 additions & 0 deletions browser/resources/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import("//chrome/common/features.gni")
import("//tools/grit/grit_rule.gni")

grit("brave_extension_grit") {
source = "brave_extension.grd"

grit_flags = [
"-E",
"root_gen_dir=" + rebase_path(root_gen_dir, "."),
]

# output_name = "brave_components_resources_new"
outputs = [
"grit/brave_extension.h",
"grit/brave_extension_resources_map.cc",
"grit/brave_extension_resources_map.h",
"brave_extension.pak",
]

deps = [
"//brave/vendor/brave-extension",
]

output_dir = "$root_gen_dir/brave"
# Empty string means use value from the grit element
resource_ids = ""
}

25 changes: 25 additions & 0 deletions browser/resources/brave_extension.grd
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<grit base_dir="." latest_public_release="0" current_release="1" output_all_resource_defines="true">
<outputs>
<output filename="grit/brave_extension.h" type="rc_header">
<emit emit_type='prepend'></emit>
</output>
<output filename="brave_extension.pak" type="data_package" />
<output filename="grit/brave_extension_resources_map.cc" type="resource_file_map_source" />
<output filename="grit/brave_extension_resources_map.h" type="resource_map_header" />
</outputs>
<release seq="1">
<includes>
<include name="IDR_BRAVE_EXTENSON_INJECT_HTML" file="${root_gen_dir}/brave_extension/inject.html" type="BINDATA" />
<include name="IDR_BRAVE_EXTENSON_SHIELDS_BUNDLE_JS" file="${root_gen_dir}/brave_extension/js/braveShieldsPanel.bundle.js" type="BINDATA" />
<include name="IDR_BRAVE_EXTENSON_BACKGROUND_BUNDLE_JS" file="${root_gen_dir}/brave_extension/js/background.bundle.js" type="BINDATA" />
<include name="IDR_BRAVE_EXTENSON_ICON_16_PNG" file="${root_gen_dir}/brave_extension/img/icon-16.png" type="BINDATA" />
<include name="IDR_BRAVE_EXTENSON_ICON_48_PNG" file="${root_gen_dir}/brave_extension/img/icon-48.png" type="BINDATA" />
<include name="IDR_BRAVE_EXTENSON_ICON_128_PNG" file="${root_gen_dir}/brave_extension/img/icon-128.png" type="BINDATA" />
<include name="IDR_BRAVE_EXTENSON_BACKGROUND_HTML" file="${root_gen_dir}/brave_extension/background.html" type="BINDATA" />
<include name="IDR_BRAVE_EXTENSON_EN_US_MESSAGES_JSON" file="${root_gen_dir}/brave_extension/_locales/en_US/messages.json" type="BINDATA" />
<include name="IDR_BRAVE_EXTENSON_BRAVE_SHIELDS_HTML" file="${root_gen_dir}/brave_extension/braveShieldsPanel.html" type="BINDATA" />
<include name="IDR_BRAVE_EXTENSON_BRAVELIZER_JS" file="${root_gen_dir}/brave_extension/bravelizer.css" type="BINDATA" />
</includes>
</release>
</grit>
Loading

0 comments on commit 46ea972

Please sign in to comment.