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/origin_util.h"
10 #include "content/public/common/user_agent.h"
11 #include "ui/gfx/image/image.h"
15 static ContentClient
* g_client
;
17 class InternalTestInitializer
{
19 static ContentBrowserClient
* SetBrowser(ContentBrowserClient
* b
) {
20 ContentBrowserClient
* rv
= g_client
->browser_
;
21 g_client
->browser_
= b
;
25 static ContentRendererClient
* SetRenderer(ContentRendererClient
* r
) {
26 ContentRendererClient
* rv
= g_client
->renderer_
;
27 g_client
->renderer_
= r
;
31 static ContentUtilityClient
* SetUtility(ContentUtilityClient
* u
) {
32 ContentUtilityClient
* rv
= g_client
->utility_
;
33 g_client
->utility_
= u
;
38 void SetContentClient(ContentClient
* client
) {
41 // TODO(jam): find out which static on Windows is causing this to have to be
44 client
->GetUserAgent();
47 ContentClient
* GetContentClient() {
51 ContentBrowserClient
* SetBrowserClientForTesting(ContentBrowserClient
* b
) {
52 return InternalTestInitializer::SetBrowser(b
);
55 ContentRendererClient
* SetRendererClientForTesting(ContentRendererClient
* r
) {
56 return InternalTestInitializer::SetRenderer(r
);
59 ContentUtilityClient
* SetUtilityClientForTesting(ContentUtilityClient
* u
) {
60 return InternalTestInitializer::SetUtility(u
);
63 ContentClient::ContentClient()
64 : browser_(NULL
), plugin_(NULL
), renderer_(NULL
), utility_(NULL
) {
67 ContentClient::~ContentClient() {
70 bool ContentClient::CanSendWhileSwappedOut(const IPC::Message
* message
) {
74 std::string
ContentClient::GetProduct() const {
78 std::string
ContentClient::GetUserAgent() const {
82 base::string16
ContentClient::GetLocalizedString(int message_id
) const {
83 return base::string16();
86 base::StringPiece
ContentClient::GetDataResource(
88 ui::ScaleFactor scale_factor
) const {
89 return base::StringPiece();
92 base::RefCountedStaticMemory
* ContentClient::GetDataResourceBytes(
93 int resource_id
) const {
97 gfx::Image
& ContentClient::GetNativeImageNamed(int resource_id
) const {
98 CR_DEFINE_STATIC_LOCAL(gfx::Image
, kEmptyImage
, ());
102 std::string
ContentClient::GetProcessTypeNameInEnglish(int type
) {
104 return std::string();
107 #if defined(OS_MACOSX) && !defined(OS_IOS)
108 bool ContentClient::GetSandboxProfileForSandboxType(
110 int* sandbox_profile_resource_id
) const {
115 } // namespace content