mirror of
				https://bitbucket.org/chromiumembedded/cef
				synced 2025-06-05 21:39:12 +02:00 
			
		
		
		
	Add "cef/" prefix for CEF #includes in libcef/ directory. Sort #includes by following https://google.github.io/styleguide/cppguide.html#Names_and_Order_of_Includes
		
			
				
	
	
		
			43 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
// Copyright (c) 2021 The Chromium Embedded Framework Authors. All rights
 | 
						|
// reserved. Use of this source code is governed by a BSD-style license that
 | 
						|
// can be found in the LICENSE file.
 | 
						|
 | 
						|
#include "cef/libcef/common/net/url_util.h"
 | 
						|
 | 
						|
#include "base/logging.h"
 | 
						|
#include "components/url_formatter/url_fixer.h"
 | 
						|
 | 
						|
namespace url_util {
 | 
						|
 | 
						|
GURL MakeGURL(const CefString& url, bool fixup) {
 | 
						|
  GURL gurl = GURL(url.ToString());
 | 
						|
  if (!url.empty() && !gurl.is_valid() && !gurl.has_scheme()) {
 | 
						|
    std::string fixed_scheme(url::kHttpScheme);
 | 
						|
    fixed_scheme.append(url::kStandardSchemeSeparator);
 | 
						|
    std::string new_url = url;
 | 
						|
    new_url.insert(0, fixed_scheme);
 | 
						|
    gurl = GURL(new_url);
 | 
						|
  }
 | 
						|
  if (fixup) {
 | 
						|
    FixupGURL(gurl);
 | 
						|
  }
 | 
						|
  return gurl;
 | 
						|
}
 | 
						|
 | 
						|
bool FixupGURL(GURL& gurl) {
 | 
						|
  if (!gurl.is_empty()) {
 | 
						|
    GURL fixup_url =
 | 
						|
        url_formatter::FixupURL(gurl.possibly_invalid_spec(), std::string());
 | 
						|
    if (fixup_url.is_valid()) {
 | 
						|
      gurl = fixup_url;
 | 
						|
    } else {
 | 
						|
      LOG(ERROR) << "Invalid URL: " << gurl.possibly_invalid_spec();
 | 
						|
      gurl = GURL();
 | 
						|
      return false;
 | 
						|
    }
 | 
						|
  }
 | 
						|
  return true;
 | 
						|
}
 | 
						|
 | 
						|
}  // namespace url_util
 |