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. 4 5 #include "content/public/common/content_client.h" 6 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" 11 12 namespace content { 13 14 static ContentClient* g_client; 15 16 class InternalTestInitializer { 17 public: SetBrowser(ContentBrowserClient * b)18 static ContentBrowserClient* SetBrowser(ContentBrowserClient* b) { 19 ContentBrowserClient* rv = g_client->browser_; 20 g_client->browser_ = b; 21 return rv; 22 } 23 SetRenderer(ContentRendererClient * r)24 static ContentRendererClient* SetRenderer(ContentRendererClient* r) { 25 ContentRendererClient* rv = g_client->renderer_; 26 g_client->renderer_ = r; 27 return rv; 28 } 29 SetUtility(ContentUtilityClient * u)30 static ContentUtilityClient* SetUtility(ContentUtilityClient* u) { 31 ContentUtilityClient* rv = g_client->utility_; 32 g_client->utility_ = u; 33 return rv; 34 } 35 }; 36 SetContentClient(ContentClient * client)37void SetContentClient(ContentClient* client) { 38 g_client = client; 39 40 // TODO(jam): find out which static on Windows is causing this to have to be 41 // called on startup. 42 if (client) 43 client->GetUserAgent(); 44 } 45 GetContentClient()46ContentClient* GetContentClient() { 47 return g_client; 48 } 49 SetBrowserClientForTesting(ContentBrowserClient * b)50ContentBrowserClient* SetBrowserClientForTesting(ContentBrowserClient* b) { 51 return InternalTestInitializer::SetBrowser(b); 52 } 53 SetRendererClientForTesting(ContentRendererClient * r)54ContentRendererClient* SetRendererClientForTesting(ContentRendererClient* r) { 55 return InternalTestInitializer::SetRenderer(r); 56 } 57 SetUtilityClientForTesting(ContentUtilityClient * u)58ContentUtilityClient* SetUtilityClientForTesting(ContentUtilityClient* u) { 59 return InternalTestInitializer::SetUtility(u); 60 } 61 ContentClient()62ContentClient::ContentClient() 63 : browser_(NULL), plugin_(NULL), renderer_(NULL), utility_(NULL) { 64 } 65 ~ContentClient()66ContentClient::~ContentClient() { 67 } 68 CanSendWhileSwappedOut(const IPC::Message * message)69bool ContentClient::CanSendWhileSwappedOut(const IPC::Message* message) { 70 return false; 71 } 72 GetProduct() const73std::string ContentClient::GetProduct() const { 74 return std::string(); 75 } 76 GetUserAgent() const77std::string ContentClient::GetUserAgent() const { 78 return std::string(); 79 } 80 GetLocalizedString(int message_id) const81base::string16 ContentClient::GetLocalizedString(int message_id) const { 82 return base::string16(); 83 } 84 GetDataResource(int resource_id,ui::ScaleFactor scale_factor) const85base::StringPiece ContentClient::GetDataResource( 86 int resource_id, 87 ui::ScaleFactor scale_factor) const { 88 return base::StringPiece(); 89 } 90 GetDataResourceBytes(int resource_id) const91base::RefCountedStaticMemory* ContentClient::GetDataResourceBytes( 92 int resource_id) const { 93 return NULL; 94 } 95 GetNativeImageNamed(int resource_id) const96gfx::Image& ContentClient::GetNativeImageNamed(int resource_id) const { 97 CR_DEFINE_STATIC_LOCAL(gfx::Image, kEmptyImage, ()); 98 return kEmptyImage; 99 } 100 GetProcessTypeNameInEnglish(int type)101std::string ContentClient::GetProcessTypeNameInEnglish(int type) { 102 NOTIMPLEMENTED(); 103 return std::string(); 104 } 105 106 #if defined(OS_MACOSX) && !defined(OS_IOS) GetSandboxProfileForSandboxType(int sandbox_type,int * sandbox_profile_resource_id) const107bool ContentClient::GetSandboxProfileForSandboxType( 108 int sandbox_type, 109 int* sandbox_profile_resource_id) const { 110 return false; 111 } 112 #endif 113 114 } // namespace content 115