Include the application's version number in the user agent string

This commit is contained in:
Adam Roben 2013-04-08 12:41:30 -04:00
parent 3cef0dd98c
commit d2c04779e4
9 changed files with 51 additions and 30 deletions

View file

@ -47,8 +47,8 @@
'browser/notification_presenter_mac.mm',
'browser/url_request_context_getter.cc',
'browser/url_request_context_getter.h',
'common/application_name.h',
'common/application_name_mac.mm',
'common/application_info.h',
'common/application_info_mac.mm',
'common/content_client.cc',
'common/content_client.h',
'common/mac/foundation_util.h',

View file

@ -4,7 +4,7 @@
#include "browser_context.h"
#include "common/application_name.h"
#include "common/application_info.h"
#include "base/files/file_path.h"
#include "base/path_service.h"

View 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

View 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);
}
}

View file

@ -1,12 +0,0 @@
#ifndef BRIGHTRAY_COMMON_APPLICATION_NAME_H_
#define BRIGHTRAY_COMMON_APPLICATION_NAME_H_
#include <string>
namespace brightray {
std::string GetApplicationName();
}
#endif

View file

@ -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];
}
}

View file

@ -4,8 +4,9 @@
#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 "webkit/user_agent/user_agent_util.h"
@ -17,8 +18,12 @@ 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 {
return webkit_glue::BuildUserAgentFromProduct(GetApplicationName());
return webkit_glue::BuildUserAgentFromProduct(GetProduct());
}
base::StringPiece ContentClient::GetDataResource(int resource_id, ui::ScaleFactor scale_factor) const {

View file

@ -16,6 +16,7 @@ public:
~ContentClient();
private:
virtual std::string GetProduct() const OVERRIDE;
virtual std::string GetUserAgent() const OVERRIDE;
virtual base::StringPiece GetDataResource(int resource_id, ui::ScaleFactor) const OVERRIDE;

View file

@ -5,7 +5,7 @@
#import "main_delegate.h"
#include "common/application_name.h"
#include "common/application_info.h"
#include "common/mac/foundation_util.h"
#include "common/mac/main_application_bundle.h"