chromium 08 修改浏览器userAgent

chromium 的浏览器ua 在src\content\common\user_agent.cc

std::string BuildUserAgentFromOSAndProduct(const std::string& os_info,
                                           const std::string& product) {
  // Derived from Safari's UA string.
  // This is done to expose our product name in a manner that is maximally
  // compatible with Safari, we hope!!
  std::string user_agent;
  base::StringAppendF(
      &user_agent,
      "Mozilla/5.0 (%s) AppleWebKit/%d.%d (KHTML, like Gecko) %s Safari/%d.%d",
      os_info.c_str(),
      WEBKIT_VERSION_MAJOR,
      WEBKIT_VERSION_MINOR,
      product.c_str(),
      WEBKIT_VERSION_MAJOR,
      WEBKIT_VERSION_MINOR);
  return user_agent;
}

如果要完整修改UserAgent, 可以考虑在这里修改:
src\components\version_info\version_info.cc

std::string GetProductNameAndVersionForUserAgent() {
  //return "Chrome/" + GetVersionNumber();
  return "Chrome/68.0.3440.105 zdx/" + GetVersionNumber();
}

你可能感兴趣的:(chromium,chromium,User,Agent,c++,浏览器)