Skip to content

Commit

Permalink
Allow file access for PDF.js
Browse files Browse the repository at this point in the history
  • Loading branch information
bbondy committed Oct 10, 2018
1 parent 0f7eb50 commit 792b5c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 9 additions & 2 deletions browser/extensions/brave_component_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "brave/components/brave_rewards/extension/grit/brave_rewards_resources.h"
#include "brave/components/brave_webtorrent/grit/brave_webtorrent_resources.h"
#include "components/grit/brave_components_resources.h"
#include "extensions/browser/extension_prefs.h"

namespace extensions {

Expand All @@ -22,7 +23,8 @@ BraveComponentLoader::BraveComponentLoader(
PrefService* profile_prefs,
PrefService* local_state,
Profile* profile)
: ComponentLoader(extension_service, profile_prefs, local_state, profile) {
: ComponentLoader(extension_service, profile_prefs, local_state, profile),
profile_(profile) {
}

BraveComponentLoader::~BraveComponentLoader() {
Expand All @@ -37,9 +39,14 @@ void BraveComponentLoader::OnComponentRegistered(std::string extension_id) {
}

void BraveComponentLoader::OnComponentReady(std::string extension_id,
bool allow_file_access,
const base::FilePath& install_dir,
const std::string& manifest) {
Add(manifest, install_dir);
if (allow_file_access) {
ExtensionPrefs::Get((content::BrowserContext *)profile_)->
SetAllowFileAccess(extension_id, true);
}
}

void BraveComponentLoader::AddExtension(const std::string& extension_id,
Expand All @@ -50,7 +57,7 @@ void BraveComponentLoader::AddExtension(const std::string& extension_id,
base::Bind(&BraveComponentLoader::OnComponentRegistered,
base::Unretained(this), extension_id),
base::Bind(&BraveComponentLoader::OnComponentReady,
base::Unretained(this), extension_id));
base::Unretained(this), extension_id, true));
}

void BraveComponentLoader::AddDefaultComponentExtensions(
Expand Down
4 changes: 3 additions & 1 deletion browser/extensions/brave_component_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ class BraveComponentLoader : public ComponentLoader {
void AddDefaultComponentExtensions(bool skip_session_components) override;
void OnComponentRegistered(std::string extension_id);
void OnComponentReady(std::string extension_id,
bool allow_file_access,
const base::FilePath& install_dir,
const std::string& manifest);
void AddExtension(const std::string& id,
const std::string& name, const std::string& public_key);


private:
Profile* profile_;
DISALLOW_COPY_AND_ASSIGN(BraveComponentLoader);
};

Expand Down

0 comments on commit 792b5c8

Please sign in to comment.