-
Notifications
You must be signed in to change notification settings - Fork 899
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move GetUpdateHostUrl out of brave_component
- Loading branch information
Showing
9 changed files
with
109 additions
and
69 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
59 changes: 59 additions & 0 deletions
59
chromium_src/chrome/common/extensions/chrome_extensions_client.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,59 @@ | ||
// Copyright (c) 2021 The Brave Authors. All rights reserved. | ||
// 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 "chrome/common/extensions/chrome_extensions_client.h" | ||
|
||
#include "base/command_line.h" | ||
#include "base/strings/string_split.h" | ||
#include "components/component_updater/component_updater_switches.h" | ||
|
||
#define ChromeExtensionsClient ChromeExtensionsClient_ChromiumImpl | ||
#include "../../../../../chrome/common/extensions/chrome_extensions_client.cc" | ||
#undef ChromeExtensionsClient | ||
|
||
namespace extensions { | ||
|
||
namespace { | ||
|
||
std::string ParseUpdateUrlHost(std::string options) { | ||
std::vector<std::string> flags = base::SplitString( | ||
options, ",", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | ||
|
||
for (const auto& flag : flags) { | ||
if (flag.empty()) { | ||
continue; | ||
} | ||
|
||
std::vector<std::string> values = base::SplitString( | ||
flag, "=", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | ||
|
||
if (values.size() != 2) { | ||
continue; | ||
} | ||
|
||
std::string name = base::ToLowerASCII(values[0]); | ||
std::string value = values[1]; | ||
|
||
if (name == "url-source") { | ||
return value; | ||
} | ||
} | ||
|
||
return ""; | ||
} | ||
|
||
} // namespace | ||
|
||
void ChromeExtensionsClient::InitializeWebStoreUpdateURL() { | ||
auto* command_line = base::CommandLine::ForCurrentProcess(); | ||
webstore_update_url_ = GURL(ParseUpdateUrlHost( | ||
command_line->GetSwitchValueASCII(switches::kComponentUpdater))); | ||
} | ||
|
||
const GURL& ChromeExtensionsClient::GetWebstoreUpdateURL() const { | ||
return webstore_update_url_; | ||
} | ||
|
||
} // namespace extensions |
30 changes: 30 additions & 0 deletions
30
chromium_src/chrome/common/extensions/chrome_extensions_client.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,30 @@ | ||
// Copyright (c) 2021 The Brave Authors. All rights reserved. | ||
// 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_CHROMIUM_SRC_CHROME_COMMON_EXTENSIONS_CHROME_EXTENSIONS_CLIENT_H_ | ||
#define BRAVE_CHROMIUM_SRC_CHROME_COMMON_EXTENSIONS_CHROME_EXTENSIONS_CLIENT_H_ | ||
|
||
#define ChromeExtensionsClient ChromeExtensionsClient_ChromiumImpl | ||
#include "../../../../../chrome/common/extensions/chrome_extensions_client.h" | ||
#undef ChromeExtensionsClient | ||
|
||
namespace extensions { | ||
|
||
class ChromeExtensionsClient : public ChromeExtensionsClient_ChromiumImpl { | ||
public: | ||
using ChromeExtensionsClient_ChromiumImpl:: | ||
ChromeExtensionsClient_ChromiumImpl; | ||
|
||
void InitializeWebStoreUpdateURL(); | ||
const GURL& GetWebstoreUpdateURL() const override; | ||
|
||
private: | ||
GURL webstore_update_url_; | ||
DISALLOW_COPY_AND_ASSIGN(ChromeExtensionsClient); | ||
}; | ||
|
||
} // namespace extensions | ||
|
||
#endif // BRAVE_CHROMIUM_SRC_CHROME_COMMON_EXTENSIONS_CHROME_EXTENSIONS_CLIENT_H_ |
This file was deleted.
Oops, something went wrong.
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
30 changes: 0 additions & 30 deletions
30
components/brave_component_updater/browser/brave_component_unittest.cc
This file was deleted.
Oops, something went wrong.
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