Include the application's version number in the user agent string
This commit is contained in:
parent
3cef0dd98c
commit
d2c04779e4
9 changed files with 51 additions and 30 deletions
|
@ -47,8 +47,8 @@
|
||||||
'browser/notification_presenter_mac.mm',
|
'browser/notification_presenter_mac.mm',
|
||||||
'browser/url_request_context_getter.cc',
|
'browser/url_request_context_getter.cc',
|
||||||
'browser/url_request_context_getter.h',
|
'browser/url_request_context_getter.h',
|
||||||
'common/application_name.h',
|
'common/application_info.h',
|
||||||
'common/application_name_mac.mm',
|
'common/application_info_mac.mm',
|
||||||
'common/content_client.cc',
|
'common/content_client.cc',
|
||||||
'common/content_client.h',
|
'common/content_client.h',
|
||||||
'common/mac/foundation_util.h',
|
'common/mac/foundation_util.h',
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include "browser_context.h"
|
#include "browser_context.h"
|
||||||
|
|
||||||
#include "common/application_name.h"
|
#include "common/application_info.h"
|
||||||
|
|
||||||
#include "base/files/file_path.h"
|
#include "base/files/file_path.h"
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
|
|
13
brightray/common/application_info.h
Normal file
13
brightray/common/application_info.h
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef BRIGHTRAY_COMMON_APPLICATION_INFO_H_
|
||||||
|
#define BRIGHTRAY_COMMON_APPLICATION_INFO_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace brightray {
|
||||||
|
|
||||||
|
std::string GetApplicationName();
|
||||||
|
std::string GetApplicationVersion();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
26
brightray/common/application_info_mac.mm
Normal file
26
brightray/common/application_info_mac.mm
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#import "common/application_info.h"
|
||||||
|
|
||||||
|
#import "common/mac/foundation_util.h"
|
||||||
|
#import "common/mac/main_application_bundle.h"
|
||||||
|
|
||||||
|
#import "base/sys_string_conversions.h"
|
||||||
|
|
||||||
|
namespace brightray {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
std::string ApplicationInfoDictionaryValue(CFStringRef key) {
|
||||||
|
return base::SysNSStringToUTF8([MainApplicationBundle().infoDictionary objectForKey:base::mac::CFToNSCast(key)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetApplicationName() {
|
||||||
|
return ApplicationInfoDictionaryValue(kCFBundleNameKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GetApplicationVersion() {
|
||||||
|
return ApplicationInfoDictionaryValue(kCFBundleVersionKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,12 +0,0 @@
|
||||||
#ifndef BRIGHTRAY_COMMON_APPLICATION_NAME_H_
|
|
||||||
#define BRIGHTRAY_COMMON_APPLICATION_NAME_H_
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace brightray {
|
|
||||||
|
|
||||||
std::string GetApplicationName();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,12 +0,0 @@
|
||||||
#import "common/application_name.h"
|
|
||||||
|
|
||||||
#import "common/mac/foundation_util.h"
|
|
||||||
#import "common/mac/main_application_bundle.h"
|
|
||||||
|
|
||||||
namespace brightray {
|
|
||||||
|
|
||||||
std::string GetApplicationName() {
|
|
||||||
return [[MainApplicationBundle().infoDictionary objectForKey:base::mac::CFToNSCast(kCFBundleNameKey)] UTF8String];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -4,8 +4,9 @@
|
||||||
|
|
||||||
#include "common/content_client.h"
|
#include "common/content_client.h"
|
||||||
|
|
||||||
#include "common/application_name.h"
|
#include "common/application_info.h"
|
||||||
|
|
||||||
|
#include "base/stringprintf.h"
|
||||||
#include "ui/base/resource/resource_bundle.h"
|
#include "ui/base/resource/resource_bundle.h"
|
||||||
#include "webkit/user_agent/user_agent_util.h"
|
#include "webkit/user_agent/user_agent_util.h"
|
||||||
|
|
||||||
|
@ -17,8 +18,12 @@ ContentClient::ContentClient() {
|
||||||
ContentClient::~ContentClient() {
|
ContentClient::~ContentClient() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ContentClient::GetProduct() const {
|
||||||
|
return base::StringPrintf("%s/%s", GetApplicationName().c_str(), GetApplicationVersion().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
std::string ContentClient::GetUserAgent() const {
|
std::string ContentClient::GetUserAgent() const {
|
||||||
return webkit_glue::BuildUserAgentFromProduct(GetApplicationName());
|
return webkit_glue::BuildUserAgentFromProduct(GetProduct());
|
||||||
}
|
}
|
||||||
|
|
||||||
base::StringPiece ContentClient::GetDataResource(int resource_id, ui::ScaleFactor scale_factor) const {
|
base::StringPiece ContentClient::GetDataResource(int resource_id, ui::ScaleFactor scale_factor) const {
|
||||||
|
|
|
@ -16,6 +16,7 @@ public:
|
||||||
~ContentClient();
|
~ContentClient();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
virtual std::string GetProduct() const OVERRIDE;
|
||||||
virtual std::string GetUserAgent() const OVERRIDE;
|
virtual std::string GetUserAgent() const OVERRIDE;
|
||||||
virtual base::StringPiece GetDataResource(int resource_id, ui::ScaleFactor) const OVERRIDE;
|
virtual base::StringPiece GetDataResource(int resource_id, ui::ScaleFactor) const OVERRIDE;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#import "main_delegate.h"
|
#import "main_delegate.h"
|
||||||
|
|
||||||
#include "common/application_name.h"
|
#include "common/application_info.h"
|
||||||
#include "common/mac/foundation_util.h"
|
#include "common/mac/foundation_util.h"
|
||||||
#include "common/mac/main_application_bundle.h"
|
#include "common/mac/main_application_bundle.h"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue