Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

Commit

Permalink
enable web request for incognito contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
bridiver committed Aug 1, 2016
1 parent bf0cc2b commit 2138301
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions brave/browser/brave_browser_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "atom/browser/extensions/atom_browser_client_extensions_part.h"
#include "atom/browser/extensions/atom_extension_system_factory.h"
#include "atom/browser/extensions/atom_extensions_network_delegate.h"
#include "extensions/browser/api/web_request/web_request_api.h"
#include "extensions/browser/extension_pref_store.h"
#include "extensions/browser/extension_pref_value_map_factory.h"
#include "extensions/browser/extension_prefs.h"
Expand All @@ -39,6 +40,24 @@

using content::BrowserThread;

#if defined(ENABLE_EXTENSIONS)
namespace {

void NotifyOTRProfileCreatedOnIOThread(void* original_profile,
void* otr_profile) {
extensions::ExtensionWebRequestEventRouter::GetInstance()
->OnOTRBrowserContextCreated(original_profile, otr_profile);
}

void NotifyOTRProfileDestroyedOnIOThread(void* original_profile,
void* otr_profile) {
extensions::ExtensionWebRequestEventRouter::GetInstance()
->OnOTRBrowserContextDestroyed(original_profile, otr_profile);
}

} // namespace
#endif

namespace brave {

BraveBrowserContext::BraveBrowserContext(const std::string& partition,
Expand All @@ -58,6 +77,16 @@ BraveBrowserContext::BraveBrowserContext(const std::string& partition,
original_context_->otr_context_ = this;
}
InitPrefs();

#if defined(ENABLE_EXTENSIONS)
if (in_memory) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&NotifyOTRProfileCreatedOnIOThread,
base::Unretained(original_context_),
base::Unretained(this)));
}
#endif
}

BraveBrowserContext::~BraveBrowserContext() {
Expand All @@ -84,6 +113,12 @@ BraveBrowserContext::~BraveBrowserContext() {
if (prefs_loaded) {
user_prefs_->CommitPendingWrite();
}
} else {
#if defined(ENABLE_EXTENSIONS)
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::Bind(&NotifyOTRProfileDestroyedOnIOThread, base::Unretained(original_context_), base::Unretained(this)));
#endif
}

if (otr_context_.get()) {
Expand Down

4 comments on commit 2138301

@bridiver
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pdfjs loads in private tabs with this change, but there is a cors error loading the actual pdf file

@diracdeltas
Copy link
Member

@diracdeltas diracdeltas commented on 2138301 Aug 1, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++. the CORS error is documented here: brave/browser-laptop#2715. This commit (or something else in the Electron update) seems to break the webview.reload workaround though

@diracdeltas
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but i did confirm that going to https://letsencrypt.org/repository/ in a private tab and clicking the first PDF link loads it just fine. thanks!

@bridiver
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

breaks webview.reload in what way? This shouldn't have any effect on that at all

Please sign in to comment.