-
Notifications
You must be signed in to change notification settings - Fork 904
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "Allow all extensions, warn for unvetted, 1 component …
…updater only now"" This reverts commit 61f822d.
- Loading branch information
Showing
27 changed files
with
369 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* 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_extension_install_prompt.h" | ||
|
||
#include "base/strings/utf_string_conversions.h" | ||
#include "brave/browser/extensions/brave_extension_provider.h" | ||
#include "brave/grit/brave_generated_resources.h" | ||
#include "extensions/common/extension_id.h" | ||
#include "ui/base/l10n/l10n_util.h" | ||
|
||
BravePrompt::BravePrompt(ExtensionInstallPrompt::PromptType type) : | ||
ExtensionInstallPrompt::Prompt(type) { | ||
} | ||
|
||
BravePrompt::~BravePrompt() { | ||
} | ||
|
||
base::string16 BravePrompt::GetDialogTitle() const { | ||
if (!extensions::BraveExtensionProvider::IsVetted(extension())) { | ||
if (type_ == ExtensionInstallPrompt::INSTALL_PROMPT || | ||
type_ == ExtensionInstallPrompt::INLINE_INSTALL_PROMPT) { | ||
return l10n_util::GetStringFUTF16(IDS_UNVETTED_EXTENSION_INSTALL_PROMPT_TITLE, | ||
base::UTF8ToUTF16(extension_->name())); | ||
} | ||
} | ||
return ExtensionInstallPrompt::Prompt::GetDialogTitle(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* 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_EXTENSION_INSTALL_PROMPT_H_ | ||
#define BRAVE_BROWSER_EXTENSIONS_BRAVE_EXTENSION_INSTALL_PROMPT_H_ | ||
|
||
#include "chrome/browser/extensions/extension_install_prompt.h" | ||
|
||
class BravePrompt : public ExtensionInstallPrompt::Prompt { | ||
public: | ||
explicit BravePrompt(ExtensionInstallPrompt::PromptType type); | ||
~BravePrompt() override; | ||
|
||
base::string16 GetDialogTitle() const override; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(BravePrompt); | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_EXTENSIONS_BRAVE_EXTENSION_INSTALL_PROMPT_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
browser/net/brave_common_static_redirect_network_delegate_helper.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* 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/net/brave_common_static_redirect_network_delegate_helper.h" | ||
|
||
#include "brave/common/network_constants.h" | ||
#include "components/component_updater/component_updater_url_constants.h" | ||
#include "extensions/common/extension_urls.h" | ||
#include "extensions/common/url_pattern.h" | ||
#include "net/url_request/url_request.h" | ||
|
||
|
||
namespace brave { | ||
|
||
// Update server checks happen from the profile context for admin policy installed extensions. | ||
// Update server checks happen from the system context for normal update operations. | ||
bool IsUpdaterURL(const GURL& gurl) { | ||
static std::vector<URLPattern> updater_patterns({ | ||
URLPattern(URLPattern::SCHEME_HTTPS, std::string(component_updater::kUpdaterDefaultUrl) + "*"), | ||
URLPattern(URLPattern::SCHEME_HTTP, std::string(component_updater::kUpdaterFallbackUrl) + "*"), | ||
URLPattern(URLPattern::SCHEME_HTTPS, std::string(extension_urls::kChromeWebstoreUpdateURL) + "*") | ||
}); | ||
bool braveRedirect = gurl.query().find("braveRedirect=true") != std::string::npos; | ||
return std::any_of(updater_patterns.begin(), updater_patterns.end(), | ||
[&gurl, braveRedirect](URLPattern pattern) { | ||
return !braveRedirect && pattern.MatchesURL(gurl); | ||
}); | ||
} | ||
|
||
int OnBeforeURLRequest_CommonStaticRedirectWork( | ||
net::URLRequest* request, | ||
GURL* new_url, | ||
const ResponseCallback& next_callback, | ||
std::shared_ptr<BraveRequestInfo> ctx) { | ||
GURL::Replacements replacements; | ||
if (IsUpdaterURL(request->url())) { | ||
replacements.SetQueryStr(request->url().query_piece()); | ||
*new_url = GURL(kBraveUpdatesExtensionsEndpoint).ReplaceComponents(replacements); | ||
return net::OK; | ||
} | ||
return net::OK; | ||
} | ||
|
||
} // namespace brave |
27 changes: 27 additions & 0 deletions
27
browser/net/brave_common_static_redirect_network_delegate_helper.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* 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_NET_BRAVE_COMMON_STATIC_REDIRECT_NETWORK_DELEGATE_H_ | ||
#define BRAVE_BROWSER_NET_BRAVE_COMMON_STATIC_REDIRECT_NETWORK_DELEGATE_H_ | ||
|
||
#include "chrome/browser/net/chrome_network_delegate.h" | ||
#include "brave/browser/net/url_context.h" | ||
|
||
struct BraveRequestInfo; | ||
|
||
namespace net { | ||
class URLRequest; | ||
} | ||
|
||
namespace brave { | ||
|
||
int OnBeforeURLRequest_CommonStaticRedirectWork( | ||
net::URLRequest* request, | ||
GURL* new_url, | ||
const ResponseCallback& next_callback, | ||
std::shared_ptr<BraveRequestInfo> ctx); | ||
|
||
} // namespace brave | ||
|
||
#endif // BRAVE_BROWSER_NET_BRAVE_COMMON_STATIC_REDIRECT_NETWORK_DELEGATE_H_ |
Oops, something went wrong.