"Fossies" - the Fresh Open Source Software Archive

Member "brave-core-1.31.87/chromium_src/chrome/browser/ui/webui/about_ui.cc" (19 Oct 2021, 2121 Bytes) of package /linux/www/brave-core-1.31.87.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "about_ui.cc" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.29.81_vs_1.30.86.

    1 /* Copyright (c) 2021 The Brave Authors. All rights reserved.
    2  * This Source Code Form is subject to the terms of the Mozilla Public
    3  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
    4  * You can obtain one at http://mozilla.org/MPL/2.0/. */
    5 
    6 #include "base/strings/string_split.h"
    7 #include "third_party/re2/src/re2/re2.h"
    8 
    9 #include "../../../../../../chrome/browser/ui/webui/about_ui.cc"
   10 
   11 std::string AboutUIHTMLSource::ChromeURLs() const {
   12   std::string chrome_urls = ::ChromeURLs();
   13 
   14   // Replace Chrome -> Brave.
   15   const std::string chrome_header = "Chrome URLs";
   16   const std::string brave_header = "Brave URLs";
   17   const std::string chrome_pages_header = "List of Chrome URLs";
   18   const std::string brave_pages_header = "List of Brave URLs";
   19   const std::string chrome_internal_pages_header =
   20       "List of chrome://internals pages";
   21   const std::string brave_internal_pages_header =
   22       "List of brave://internals pages";
   23   const std::string chrome_url_list = ">chrome://";
   24   const std::string brave_url_list = ">brave://";
   25   RE2::GlobalReplace(&chrome_urls, chrome_header, brave_header);
   26   RE2::GlobalReplace(&chrome_urls, chrome_pages_header, brave_pages_header);
   27   RE2::GlobalReplace(&chrome_urls, chrome_internal_pages_header,
   28                      brave_internal_pages_header);
   29   RE2::GlobalReplace(&chrome_urls, chrome_url_list, brave_url_list);
   30 
   31   // Remove some URLs.
   32   auto html_lines = base::SplitStringPiece(
   33       chrome_urls, "\n", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
   34   const base::flat_set<base::StringPiece> kURLsToRemove{
   35       "brave://memories",
   36   };
   37   // URLs in html should be sorted so it's okay to iterate over sorted
   38   // kURLsToRemove.
   39   auto html_line_it = html_lines.begin();
   40   auto url_to_remove_it = kURLsToRemove.begin();
   41   while (html_line_it != html_lines.end() &&
   42          url_to_remove_it != kURLsToRemove.end()) {
   43     if (base::Contains(*html_line_it, *url_to_remove_it)) {
   44       html_line_it = html_lines.erase(html_line_it);
   45       ++url_to_remove_it;
   46     } else {
   47       ++html_line_it;
   48     }
   49   }
   50 
   51   return base::JoinString(html_lines, "\n");
   52 }