Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Side by Side Diff: content/public/common/content_client.cc

Issue 13409003: Hide ContentClient getters from embedders so that they they don't reuse content's embedder API. The… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/public/common/content_client.h" 5 #include "content/public/common/content_client.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/string_piece.h" 8 #include "base/string_piece.h"
9 #include "ui/gfx/image/image.h" 9 #include "ui/gfx/image/image.h"
10 #include "webkit/user_agent/user_agent.h" 10 #include "webkit/user_agent/user_agent.h"
11 11
12 #if defined(ENABLE_PLUGINS) 12 #if defined(ENABLE_PLUGINS)
13 #include "webkit/plugins/ppapi/host_globals.h" 13 #include "webkit/plugins/ppapi/host_globals.h"
14 #endif 14 #endif
15 15
16 namespace content { 16 namespace content {
17 17
18 static ContentClient* g_client; 18 static ContentClient* g_client;
19 19
20 class InternalTestInitializer {
21 public:
22 static ContentBrowserClient* SetBrowser(ContentBrowserClient* b) {
23 ContentBrowserClient* rv = g_client->browser_;
24 g_client->browser_ = b;
25 return rv;
26 }
27
28 static ContentRendererClient* SetRenderer(ContentRendererClient* r) {
29 ContentRendererClient* rv = g_client->renderer_;
30 g_client->renderer_ = r;
31 return rv;
32 }
33 };
34
20 void SetContentClient(ContentClient* client) { 35 void SetContentClient(ContentClient* client) {
21 g_client = client; 36 g_client = client;
22 37
23 // Set the default user agent as provided by the client. We need to make 38 // Set the default user agent as provided by the client. We need to make
24 // sure this is done before webkit_glue::GetUserAgent() is called (so that 39 // sure this is done before webkit_glue::GetUserAgent() is called (so that
25 // the UA doesn't change). 40 // the UA doesn't change).
26 if (client) { 41 if (client) {
27 webkit_glue::SetUserAgent(client->GetUserAgent(), false); 42 webkit_glue::SetUserAgent(client->GetUserAgent(), false);
28 } 43 }
29 } 44 }
30 45
31 ContentClient* GetContentClient() { 46 ContentClient* GetContentClient() {
32 return g_client; 47 return g_client;
33 } 48 }
34 49
50 ContentBrowserClient* SetBrowserClientForTesting(ContentBrowserClient* b) {
51 return InternalTestInitializer::SetBrowser(b);
52 }
53
54 ContentRendererClient* SetRendererClientForTesting(ContentRendererClient* r) {
55 return InternalTestInitializer::SetRenderer(r);
56 }
57
35 const std::string& GetUserAgent(const GURL& url) { 58 const std::string& GetUserAgent(const GURL& url) {
36 DCHECK(g_client); 59 DCHECK(g_client);
37 return webkit_glue::GetUserAgent(url); 60 return webkit_glue::GetUserAgent(url);
38 } 61 }
39 62
40 webkit::ppapi::HostGlobals* GetHostGlobals() { 63 webkit::ppapi::HostGlobals* GetHostGlobals() {
41 #if defined(ENABLE_PLUGINS) 64 #if defined(ENABLE_PLUGINS)
42 return webkit::ppapi::HostGlobals::Get(); 65 return webkit::ppapi::HostGlobals::Get();
43 #else 66 #else
44 return NULL; 67 return NULL;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 int* sandbox_profile_resource_id) const { 122 int* sandbox_profile_resource_id) const {
100 return false; 123 return false;
101 } 124 }
102 125
103 std::string ContentClient::GetCarbonInterposePath() const { 126 std::string ContentClient::GetCarbonInterposePath() const {
104 return std::string(); 127 return std::string();
105 } 128 }
106 #endif 129 #endif
107 130
108 } // namespace content 131 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/content_client.h ('k') | content/public/test/render_view_fake_resources_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698