1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/public/common/content_client.h"
7 #include "base/logging.h"
8 #include "base/strings/string_piece.h"
9 #include "content/public/common/user_agent.h"
10 #include "ui/gfx/image/image.h"
14 static ContentClient
* g_client
;
16 class InternalTestInitializer
{
18 static ContentBrowserClient
* SetBrowser(ContentBrowserClient
* b
) {
19 ContentBrowserClient
* rv
= g_client
->browser_
;
20 g_client
->browser_
= b
;
24 static ContentRendererClient
* SetRenderer(ContentRendererClient
* r
) {
25 ContentRendererClient
* rv
= g_client
->renderer_
;
26 g_client
->renderer_
= r
;
30 static ContentUtilityClient
* SetUtility(ContentUtilityClient
* u
) {
31 ContentUtilityClient
* rv
= g_client
->utility_
;
32 g_client
->utility_
= u
;
37 void SetContentClient(ContentClient
* client
) {
40 // TODO(jam): find out which static on Windows is causing this to have to be
43 client
->GetUserAgent();
46 ContentClient
* GetContentClient() {
50 ContentBrowserClient
* SetBrowserClientForTesting(ContentBrowserClient
* b
) {
51 return InternalTestInitializer::SetBrowser(b
);
54 ContentRendererClient
* SetRendererClientForTesting(ContentRendererClient
* r
) {
55 return InternalTestInitializer::SetRenderer(r
);
58 ContentUtilityClient
* SetUtilityClientForTesting(ContentUtilityClient
* u
) {
59 return InternalTestInitializer::SetUtility(u
);
62 ContentClient::ContentClient()
63 : browser_(NULL
), plugin_(NULL
), renderer_(NULL
), utility_(NULL
) {
66 ContentClient::~ContentClient() {
69 bool ContentClient::CanSendWhileSwappedOut(const IPC::Message
* message
) {
73 std::string
ContentClient::GetProduct() const {
77 std::string
ContentClient::GetUserAgent() const {
81 base::string16
ContentClient::GetLocalizedString(int message_id
) const {
82 return base::string16();
85 base::StringPiece
ContentClient::GetDataResource(
87 ui::ScaleFactor scale_factor
) const {
88 return base::StringPiece();
91 base::RefCountedStaticMemory
* ContentClient::GetDataResourceBytes(
92 int resource_id
) const {
96 gfx::Image
& ContentClient::GetNativeImageNamed(int resource_id
) const {
97 CR_DEFINE_STATIC_LOCAL(gfx::Image
, kEmptyImage
, ());
101 std::string
ContentClient::GetProcessTypeNameInEnglish(int type
) {
103 return std::string();
106 #if defined(OS_MACOSX) && !defined(OS_IOS)
107 bool ContentClient::GetSandboxProfileForSandboxType(
109 int* sandbox_profile_resource_id
) const {
114 } // namespace content