2013-03-14 13:03:50 +00:00
|
|
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE-CHROMIUM file.
|
|
|
|
|
|
|
|
#include "common/content_client.h"
|
|
|
|
|
2013-10-07 19:16:49 +00:00
|
|
|
#include "base/strings/stringprintf.h"
|
|
|
|
#include "base/strings/string_util.h"
|
2017-05-18 22:06:57 +00:00
|
|
|
#include "common/application_info.h"
|
2014-06-26 20:34:53 +00:00
|
|
|
#include "content/public/common/user_agent.h"
|
2014-10-31 11:42:06 +00:00
|
|
|
#include "ui/base/l10n/l10n_util.h"
|
2013-03-14 13:03:50 +00:00
|
|
|
#include "ui/base/resource/resource_bundle.h"
|
|
|
|
|
|
|
|
namespace brightray {
|
|
|
|
|
2015-07-23 10:18:03 +00:00
|
|
|
std::string GetProductInternal() {
|
|
|
|
auto name = GetApplicationName();
|
|
|
|
base::RemoveChars(name, base::kWhitespaceASCII, &name);
|
|
|
|
return base::StringPrintf("%s/%s",
|
|
|
|
name.c_str(), GetApplicationVersion().c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string GetBrightrayUserAgent() {
|
|
|
|
return content::BuildUserAgentFromProduct(GetProductInternal());
|
|
|
|
}
|
|
|
|
|
2013-03-14 13:03:50 +00:00
|
|
|
ContentClient::ContentClient() {
|
|
|
|
}
|
|
|
|
|
|
|
|
ContentClient::~ContentClient() {
|
|
|
|
}
|
|
|
|
|
2013-04-08 16:41:30 +00:00
|
|
|
std::string ContentClient::GetProduct() const {
|
2015-07-23 10:18:03 +00:00
|
|
|
return GetProductInternal();
|
2013-04-08 16:41:30 +00:00
|
|
|
}
|
|
|
|
|
2013-03-14 13:03:50 +00:00
|
|
|
std::string ContentClient::GetUserAgent() const {
|
2015-07-23 10:18:03 +00:00
|
|
|
return GetBrightrayUserAgent();
|
2013-03-14 13:03:50 +00:00
|
|
|
}
|
|
|
|
|
2014-10-31 11:42:06 +00:00
|
|
|
base::string16 ContentClient::GetLocalizedString(int message_id) const {
|
|
|
|
return l10n_util::GetStringUTF16(message_id);
|
|
|
|
}
|
|
|
|
|
2013-11-17 23:56:44 +00:00
|
|
|
base::StringPiece ContentClient::GetDataResource(
|
|
|
|
int resource_id, ui::ScaleFactor scale_factor) const {
|
|
|
|
return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
|
|
|
|
resource_id, scale_factor);
|
2013-03-14 13:03:50 +00:00
|
|
|
}
|
|
|
|
|
2013-04-27 02:49:24 +00:00
|
|
|
gfx::Image& ContentClient::GetNativeImageNamed(int resource_id) const {
|
2013-11-17 23:56:44 +00:00
|
|
|
return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
|
|
|
|
resource_id);
|
2013-04-27 02:49:24 +00:00
|
|
|
}
|
|
|
|
|
2016-09-06 08:22:52 +00:00
|
|
|
base::RefCountedMemory* ContentClient::GetDataResourceBytes(
|
|
|
|
int resource_id) const {
|
2015-03-29 08:33:51 +00:00
|
|
|
return ResourceBundle::GetSharedInstance().LoadDataResourceBytes(resource_id);
|
|
|
|
}
|
|
|
|
|
2013-11-17 23:20:17 +00:00
|
|
|
} // namespace brightray
|