forked from adamlaska/electron
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication_info.cc
More file actions
50 lines (42 loc) · 1.57 KB
/
application_info.cc
File metadata and controls
50 lines (42 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) 2013 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/common/application_info.h"
#include "base/no_destructor.h"
#include "base/strings/stringprintf.h"
#include "chrome/common/chrome_version.h"
#include "content/public/common/user_agent.h"
#include "electron/electron_version.h"
#include "shell/browser/browser.h"
namespace electron {
std::string& OverriddenApplicationName() {
static base::NoDestructor<std::string> overridden_application_name;
return *overridden_application_name;
}
std::string& OverriddenApplicationVersion() {
static base::NoDestructor<std::string> overridden_application_version;
return *overridden_application_version;
}
std::string GetPossiblyOverriddenApplicationName() {
std::string ret = OverriddenApplicationName();
if (!ret.empty())
return ret;
return GetApplicationName();
}
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 == ELECTRON_PRODUCT_NAME) {
user_agent = "Chrome/" CHROME_VERSION_STRING " " ELECTRON_PRODUCT_NAME
"/" ELECTRON_VERSION_STRING;
} else {
user_agent = base::StringPrintf(
"%s/%s Chrome/%s " ELECTRON_PRODUCT_NAME "/" ELECTRON_VERSION_STRING,
name.c_str(), browser->GetVersion().c_str(), CHROME_VERSION_STRING);
}
return content::BuildUserAgentFromProduct(user_agent);
}
} // namespace electron