Skip to content

Commit

Permalink
Replace all usage of base::string16 with std::u16string
Browse files Browse the repository at this point in the history
The "base/strings/string16.h" file does no longer exist and we need
to remove all remaining usages of that type with the one from the
C++ standard library instead, like Chromium upstream already did.

Also replaces no longer needed ASCIIToUTF16 and UTF8ToUTF16 calls used
with constant strings with `u` string literals.

Chromium change:

https://chromium.googlesource.com/chromium/src.git/+/7e1e44476bb361e95dc252d8428324a3feb89ecd

commit 7e1e44476bb361e95dc252d8428324a3feb89ecd
Author: Jan Wilken Dörrie <[email protected]>
Date:   Sun Mar 14 19:37:05 2021 +0000

    [LSC] Remove base/strings/string16.h

    This change removes base/strings/string16.h and remaining references to
    it from the code base.

    Bug: 1184339
  • Loading branch information
mariospr committed May 5, 2021
1 parent 74e64d1 commit 79af4bc
Show file tree
Hide file tree
Showing 136 changed files with 419 additions and 486 deletions.
4 changes: 2 additions & 2 deletions browser/brave_browser_main_parts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ void BraveBrowserMainParts::PostBrowserStart() {
ProfileAttributesEntry* entry =
storage.GetProfileAttributesWithPath(tor_legacy_path);
if (!entry) {
storage.AddProfile(tor_legacy_path, base::string16(), std::string(),
base::string16(),
storage.AddProfile(tor_legacy_path, std::u16string(), std::string(),
std::u16string(),
/* is_consented_primary_account*/ false, 0,
std::string(), EmptyAccountId());
}
Expand Down
6 changes: 3 additions & 3 deletions browser/brave_rewards/tip_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TipDialogDelegate : public ui::WebDialogDelegate {
~TipDialogDelegate() override;

ui::ModalType GetDialogModalType() const override;
base::string16 GetDialogTitle() const override;
std::u16string GetDialogTitle() const override;
GURL GetDialogContentURL() const override;
void GetWebUIMessageHandlers(
std::vector<WebUIMessageHandler*>* handlers) const override;
Expand Down Expand Up @@ -78,9 +78,9 @@ ui::ModalType TipDialogDelegate::GetDialogModalType() const {
return ui::MODAL_TYPE_WINDOW;
}

base::string16 TipDialogDelegate::GetDialogTitle() const {
std::u16string TipDialogDelegate::GetDialogTitle() const {
// Only used on Windows?
return base::string16();
return std::u16string();
}

GURL TipDialogDelegate::GetDialogContentURL() const {
Expand Down
10 changes: 5 additions & 5 deletions browser/brave_shields/domain_block_page_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ IN_PROC_BROWSER_TEST_F(DomainBlockTest, ShowInterstitialAndProceed) {
// originally requested page.
ClickAndWaitForNavigation("primary-button");
ASSERT_FALSE(IsShowingInterstitial());
base::string16 expected_title = base::ASCIIToUTF16("OK");
std::u16string expected_title(u"OK");
content::TitleWatcher watcher(web_contents(), expected_title);
EXPECT_EQ(expected_title, watcher.WaitAndGetTitle());
}
Expand Down Expand Up @@ -182,7 +182,7 @@ IN_PROC_BROWSER_TEST_F(DomainBlockTest, ProceedAndReload) {
// originally requested page.
ClickAndWaitForNavigation("primary-button");
ASSERT_FALSE(IsShowingInterstitial());
base::string16 expected_title = base::ASCIIToUTF16("OK");
std::u16string expected_title(u"OK");
content::TitleWatcher watcher(web_contents(), expected_title);
EXPECT_EQ(expected_title, watcher.WaitAndGetTitle());

Expand Down Expand Up @@ -215,7 +215,7 @@ IN_PROC_BROWSER_TEST_F(DomainBlockTest, ProceedDoesNotAffectNewTabs) {
// originally requested page.
ClickAndWaitForNavigation("primary-button");
ASSERT_FALSE(IsShowingInterstitial());
base::string16 expected_title = base::ASCIIToUTF16("OK");
std::u16string expected_title(u"OK");
content::TitleWatcher watcher(web_contents(), expected_title);
EXPECT_EQ(expected_title, watcher.WaitAndGetTitle());

Expand Down Expand Up @@ -255,7 +255,7 @@ IN_PROC_BROWSER_TEST_F(DomainBlockTest, DontWarnAgainAndProceed) {
ClickAndWaitForNavigation("primary-button");
WaitForAdBlockServiceThreads();
ASSERT_FALSE(IsShowingInterstitial());
base::string16 expected_title = base::ASCIIToUTF16("OK");
std::u16string expected_title(u"OK");
content::TitleWatcher watcher(web_contents(), expected_title);
EXPECT_EQ(expected_title, watcher.WaitAndGetTitle());

Expand Down Expand Up @@ -400,7 +400,7 @@ IN_PROC_BROWSER_TEST_F(DomainBlockDisabledTest, NoInterstitial) {
ASSERT_FALSE(IsShowingInterstitial());

// Ensure we ended up on the expected page.
base::string16 expected_title = base::ASCIIToUTF16("OK");
std::u16string expected_title(u"OK");
content::TitleWatcher watcher(web_contents(), expected_title);
EXPECT_EQ(expected_title, watcher.WaitAndGetTitle());
}
13 changes: 6 additions & 7 deletions browser/download/brave_download_item_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <string>

#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/download/download_ui_model.h"
Expand All @@ -28,14 +27,14 @@ BraveDownloadItemModel::BraveDownloadItemModel(DownloadUIModel* model)
BraveDownloadItemModel::~BraveDownloadItemModel() {}

// Adds origin url to the tooltip text and "Not secure", if needed.
base::string16 BraveDownloadItemModel::GetTooltipText() {
base::string16 tooltip = model_->GetTooltipText();
std::u16string BraveDownloadItemModel::GetTooltipText() {
std::u16string tooltip = model_->GetTooltipText();

bool is_secure;
base::string16 origin_url = GetOriginURLText(&is_secure);
std::u16string origin_url = GetOriginURLText(&is_secure);

if (!origin_url.empty()) {
tooltip += base::ASCIIToUTF16("\n");
tooltip += u"\n";
if (!is_secure) {
tooltip += l10n_util::GetStringUTF16(IDS_NOT_SECURE_VERBOSE_STATE) +
char16_t(' ');
Expand All @@ -47,11 +46,11 @@ base::string16 BraveDownloadItemModel::GetTooltipText() {
}

// Returns origin url text and sets |is_secure|.
base::string16 BraveDownloadItemModel::GetOriginURLText(bool* is_secure) {
std::u16string BraveDownloadItemModel::GetOriginURLText(bool* is_secure) {
*is_secure = false;
const GURL gurl = model_->download()->GetURL();
if (gurl.is_empty()) {
return base::string16();
return std::u16string();
}

std::string origin;
Expand Down
7 changes: 4 additions & 3 deletions browser/download/brave_download_item_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
#ifndef BRAVE_BROWSER_DOWNLOAD_BRAVE_DOWNLOAD_ITEM_MODEL_H_
#define BRAVE_BROWSER_DOWNLOAD_BRAVE_DOWNLOAD_ITEM_MODEL_H_

#include <string>

#include "base/macros.h"
#include "base/strings/string16.h"

// The purpose of this class is to extend DonwloadItemModel's class
// functionality by adding a method for the origin URL text and
Expand All @@ -28,11 +29,11 @@ class BraveDownloadItemModel {
// a regular download, the tooltip is the filename and the origin URL with an
// indicator if the URL is secure. For an interrupted download, falls back on
// the base class behavior.
base::string16 GetTooltipText();
std::u16string GetTooltipText();

// Returns a string suitable for use as the origin URL. |is_secure| is set to
// true if the url is considered secure.
base::string16 GetOriginURLText(bool* is_secure);
std::u16string GetOriginURLText(bool* is_secure);

// Encapsulated model.
DownloadUIModel* model_;
Expand Down
1 change: 0 additions & 1 deletion browser/download/brave_download_item_model_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/stl_util.h"
#include "base/strings/string16.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
Expand Down
2 changes: 1 addition & 1 deletion browser/extensions/api/brave_wallet_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ BraveWalletService* GetBraveWalletService(
return BraveWalletServiceFactory::GetInstance()->GetForContext(context);
}

base::Value MakeSelectValue(const base::string16& name,
base::Value MakeSelectValue(const std::u16string& name,
BraveWalletWeb3ProviderTypes value) {
base::Value item(base::Value::Type::DICTIONARY);
item.SetKey("value", base::Value(static_cast<int>(value)));
Expand Down
2 changes: 1 addition & 1 deletion browser/extensions/api/ipfs_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bool IsIpfsEnabled(content::BrowserContext* context) {
return ipfs::IsIpfsEnabled(context);
}

base::Value MakeSelectValue(const base::string16& name,
base::Value MakeSelectValue(const std::u16string& name,
IPFSResolveMethodTypes value) {
base::Value item(base::Value::Type::DICTIONARY);
item.SetKey("value", base::Value(static_cast<int>(value)));
Expand Down
4 changes: 2 additions & 2 deletions browser/extensions/brave_extension_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ std::string BraveExtensionProvider::GetDebugPolicyProviderName() const {
}

bool BraveExtensionProvider::UserMayLoad(const Extension* extension,
base::string16* error) const {
std::u16string* error) const {
if (IsBlacklisted(extension)) {
if (error) {
*error = l10n_util::GetStringFUTF16(IDS_EXTENSION_CANT_INSTALL_ON_BRAVE,
Expand All @@ -71,7 +71,7 @@ bool BraveExtensionProvider::UserMayLoad(const Extension* extension,
}

bool BraveExtensionProvider::MustRemainInstalled(const Extension* extension,
base::string16* error) const {
std::u16string* error) const {
return extension->id() == brave_extension_id ||
extension->id() == brave_rewards_extension_id;
}
Expand Down
4 changes: 2 additions & 2 deletions browser/extensions/brave_extension_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ class BraveExtensionProvider : public ManagementPolicy::Provider {
~BraveExtensionProvider() override;
std::string GetDebugPolicyProviderName() const override;
bool UserMayLoad(const Extension* extension,
base::string16* error) const override;
std::u16string* error) const override;
bool MustRemainInstalled(const Extension* extension,
base::string16* error) const override;
std::u16string* error) const override;

private:
DISALLOW_COPY_AND_ASSIGN(BraveExtensionProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class BraveNavigatorUserAgentFarblingBrowserTest : public InProcessBrowserTest {
// Tests results of farbling user agent
IN_PROC_BROWSER_TEST_F(BraveNavigatorUserAgentFarblingBrowserTest,
FarbleNavigatorUserAgent) {
base::string16 expected_title = base::ASCIIToUTF16("pass");
std::u16string expected_title(u"pass");
std::string domain_b = "b.com";
std::string domain_z = "z.com";
GURL url_b = embedded_test_server()->GetURL(domain_b, "/simple.html");
Expand Down
8 changes: 4 additions & 4 deletions browser/importer/brave_external_process_importer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ void BraveExternalProcessImporterClient::OnImportItemFinished(
}

void BraveExternalProcessImporterClient::OnCreditCardImportReady(
const base::string16& name_on_card,
const base::string16& expiration_month,
const base::string16& expiration_year,
const base::string16& decrypted_card_number,
const std::u16string& name_on_card,
const std::u16string& expiration_month,
const std::u16string& expiration_year,
const std::u16string& decrypted_card_number,
const std::string& origin) {
if (cancelled_)
return;
Expand Down
12 changes: 5 additions & 7 deletions browser/importer/brave_external_process_importer_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <string>

#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "brave/common/importer/profile_import.mojom.h"
#include "chrome/browser/importer/external_process_importer_client.h"
#include "mojo/public/cpp/bindings/receiver.h"
Expand Down Expand Up @@ -37,12 +36,11 @@ class BraveExternalProcessImporterClient
void OnImportItemFinished(importer::ImportItem import_item) override;

// brave::mojom::ProfileImportObserver overrides:
void OnCreditCardImportReady(
const base::string16& name_on_card,
const base::string16& expiration_month,
const base::string16& expiration_year,
const base::string16& decrypted_card_number,
const std::string& origin) override;
void OnCreditCardImportReady(const std::u16string& name_on_card,
const std::u16string& expiration_month,
const std::u16string& expiration_year,
const std::u16string& decrypted_card_number,
const std::string& origin) override;

protected:
~BraveExternalProcessImporterClient() override;
Expand Down
8 changes: 4 additions & 4 deletions browser/importer/brave_in_process_importer_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
BraveInProcessImporterBridge::~BraveInProcessImporterBridge() = default;

void BraveInProcessImporterBridge::SetCreditCard(
const base::string16& name_on_card,
const base::string16& expiration_month,
const base::string16& expiration_year,
const base::string16& decrypted_card_number,
const std::u16string& name_on_card,
const std::u16string& expiration_month,
const std::u16string& expiration_year,
const std::u16string& decrypted_card_number,
const std::string& origin) {
writer_->AddCreditCard(name_on_card,
expiration_month,
Expand Down
8 changes: 4 additions & 4 deletions browser/importer/brave_in_process_importer_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class BraveInProcessImporterBridge : public InProcessImporterBridge,
const BraveInProcessImporterBridge&) = delete;

// BraveImporterBridge overrides:
void SetCreditCard(const base::string16& name_on_card,
const base::string16& expiration_month,
const base::string16& expiration_year,
const base::string16& decrypted_card_number,
void SetCreditCard(const std::u16string& name_on_card,
const std::u16string& expiration_month,
const std::u16string& expiration_year,
const std::u16string& decrypted_card_number,
const std::string& origin) override;

private:
Expand Down
6 changes: 3 additions & 3 deletions browser/infobars/brave_confirm_p3a_infobar_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,23 @@ void BraveConfirmP3AInfoBarDelegate::InfoBarDismissed() {
}
}

base::string16 BraveConfirmP3AInfoBarDelegate::GetMessageText() const {
std::u16string BraveConfirmP3AInfoBarDelegate::GetMessageText() const {
return l10n_util::GetStringUTF16(IDS_BRAVE_CONFIRM_P3A_INFO_BAR);
}

int BraveConfirmP3AInfoBarDelegate::GetButtons() const {
return BUTTON_OK | BUTTON_CANCEL;
}

base::string16 BraveConfirmP3AInfoBarDelegate::GetButtonLabel(
std::u16string BraveConfirmP3AInfoBarDelegate::GetButtonLabel(
InfoBarButton button) const {
if (button == BUTTON_CANCEL) {
return l10n_util::GetStringUTF16(IDS_BRAVE_CONFIRM_P3A_INFO_BAR_DISABLE);
}
return l10n_util::GetStringUTF16(IDS_BRAVE_CONFIRM_P3A_INFO_BAR_ACKNOWLEDGE);
}

base::string16 BraveConfirmP3AInfoBarDelegate::GetLinkText() const {
std::u16string BraveConfirmP3AInfoBarDelegate::GetLinkText() const {
return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
}

Expand Down
7 changes: 3 additions & 4 deletions browser/infobars/brave_confirm_p3a_infobar_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/strings/string16.h"
#include "components/infobars/core/confirm_infobar_delegate.h"
#include "url/gurl.h"

Expand All @@ -28,10 +27,10 @@ class BraveConfirmP3AInfoBarDelegate : public ConfirmInfoBarDelegate {
const gfx::VectorIcon& GetVectorIcon() const override;
bool ShouldExpire(const NavigationDetails& details) const override;
void InfoBarDismissed() override;
base::string16 GetMessageText() const override;
std::u16string GetMessageText() const override;
int GetButtons() const override;
base::string16 GetButtonLabel(InfoBarButton button) const override;
base::string16 GetLinkText() const override;
std::u16string GetButtonLabel(InfoBarButton button) const override;
std::u16string GetLinkText() const override;
GURL GetLinkURL() const override;
bool Accept() override;
bool Cancel() override;
Expand Down
6 changes: 3 additions & 3 deletions browser/infobars/crypto_wallets_infobar_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const gfx::VectorIcon& CryptoWalletsInfoBarDelegate::GetVectorIcon() const {
void CryptoWalletsInfoBarDelegate::InfoBarDismissed() {
}

base::string16 CryptoWalletsInfoBarDelegate::GetMessageText() const {
std::u16string CryptoWalletsInfoBarDelegate::GetMessageText() const {
if (subtype_ == InfobarSubType::LOAD_CRYPTO_WALLETS) {
return l10n_util::GetStringUTF16(IDS_BRAVE_CRYPTO_WALLETS_LAZY_LOAD_TEXT);
}
Expand All @@ -65,7 +65,7 @@ int CryptoWalletsInfoBarDelegate::GetButtons() const {
return BUTTON_OK | BUTTON_CANCEL;
}

base::string16 CryptoWalletsInfoBarDelegate::GetButtonLabel(
std::u16string CryptoWalletsInfoBarDelegate::GetButtonLabel(
InfoBarButton button) const {
if (subtype_ == InfobarSubType::LOAD_CRYPTO_WALLETS) {
if (button == BUTTON_CANCEL) {
Expand All @@ -83,7 +83,7 @@ base::string16 CryptoWalletsInfoBarDelegate::GetButtonLabel(
IDS_BRAVE_CRYPTO_WALLETS_SETUP_CRYPTO_WALLETS);
}

base::string16 CryptoWalletsInfoBarDelegate::GetLinkText() const {
std::u16string CryptoWalletsInfoBarDelegate::GetLinkText() const {
return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
}

Expand Down
7 changes: 3 additions & 4 deletions browser/infobars/crypto_wallets_infobar_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "components/infobars/core/confirm_infobar_delegate.h"
#include "url/gurl.h"

Expand Down Expand Up @@ -37,10 +36,10 @@ class CryptoWalletsInfoBarDelegate : public ConfirmInfoBarDelegate {
infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override;
const gfx::VectorIcon& GetVectorIcon() const override;
void InfoBarDismissed() override;
base::string16 GetMessageText() const override;
std::u16string GetMessageText() const override;
int GetButtons() const override;
base::string16 GetButtonLabel(InfoBarButton button) const override;
base::string16 GetLinkText() const override;
std::u16string GetButtonLabel(InfoBarButton button) const override;
std::u16string GetLinkText() const override;
GURL GetLinkURL() const override;
bool Accept() override;
bool Cancel() override;
Expand Down
4 changes: 2 additions & 2 deletions browser/infobars/sync_v2_migrate_infobar_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ void SyncV2MigrateInfoBarDelegate::InfoBarDismissed() {
brave_sync_prefs.SetDismissSyncMigrateNotice(true);
}

base::string16 SyncV2MigrateInfoBarDelegate::GetMessageText() const {
std::u16string SyncV2MigrateInfoBarDelegate::GetMessageText() const {
return l10n_util::GetStringUTF16(IDS_BRAVE_SYNC_V2_MIGRATE_INFOBAR_MESSAGE);
}

int SyncV2MigrateInfoBarDelegate::GetButtons() const {
return BUTTON_OK;
}

base::string16 SyncV2MigrateInfoBarDelegate::GetButtonLabel(
std::u16string SyncV2MigrateInfoBarDelegate::GetButtonLabel(
InfoBarButton button) const {
return l10n_util::GetStringUTF16(IDS_BRAVE_SYNC_V2_MIGRATE_INFOBAR_COMMAND);
}
Expand Down
Loading

0 comments on commit 79af4bc

Please sign in to comment.