parent
abec938b0a
commit
e1502f6953
9 changed files with 42 additions and 42 deletions
|
@ -4,7 +4,12 @@
|
|||
|
||||
#include "atom/common/application_info.h"
|
||||
|
||||
#include "atom/browser/browser.h"
|
||||
#include "atom/common/atom_version.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "chrome/common/chrome_version.h"
|
||||
#include "content/public/common/user_agent.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
@ -31,4 +36,21 @@ std::string GetOverriddenApplicationVersion() {
|
|||
return *g_overridden_application_version;
|
||||
}
|
||||
|
||||
std::string GetApplicationUserAgent() {
|
||||
// Construct user agent string.
|
||||
Browser* browser = Browser::Get();
|
||||
std::string name, user_agent;
|
||||
if (!base::RemoveChars(browser->GetName(), " ", &name))
|
||||
name = browser->GetName();
|
||||
if (name == ATOM_PRODUCT_NAME) {
|
||||
user_agent = "Chrome/" CHROME_VERSION_STRING " " ATOM_PRODUCT_NAME
|
||||
"/" ATOM_VERSION_STRING;
|
||||
} else {
|
||||
user_agent = base::StringPrintf(
|
||||
"%s/%s Chrome/%s " ATOM_PRODUCT_NAME "/" ATOM_VERSION_STRING,
|
||||
name.c_str(), browser->GetVersion().c_str(), CHROME_VERSION_STRING);
|
||||
}
|
||||
return content::BuildUserAgentFromProduct(user_agent);
|
||||
}
|
||||
|
||||
} // namespace atom
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue