Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
| 9 #include "content/public/common/user_agent.h" | |
|
jam
2014/03/05 00:09:26
nit: not needed
tfarina
2014/03/05 00:42:52
Done.
| |
| 9 #include "ui/gfx/image/image.h" | 10 #include "ui/gfx/image/image.h" |
| 10 #include "webkit/common/user_agent/user_agent.h" | |
| 11 | 11 |
| 12 namespace content { | 12 namespace content { |
| 13 | 13 |
| 14 static ContentClient* g_client; | 14 static ContentClient* g_client; |
| 15 | 15 |
| 16 class InternalTestInitializer { | 16 class InternalTestInitializer { |
| 17 public: | 17 public: |
| 18 static ContentBrowserClient* SetBrowser(ContentBrowserClient* b) { | 18 static ContentBrowserClient* SetBrowser(ContentBrowserClient* b) { |
| 19 ContentBrowserClient* rv = g_client->browser_; | 19 ContentBrowserClient* rv = g_client->browser_; |
| 20 g_client->browser_ = b; | 20 g_client->browser_ = b; |
| 21 return rv; | 21 return rv; |
| 22 } | 22 } |
| 23 | 23 |
| 24 static ContentRendererClient* SetRenderer(ContentRendererClient* r) { | 24 static ContentRendererClient* SetRenderer(ContentRendererClient* r) { |
| 25 ContentRendererClient* rv = g_client->renderer_; | 25 ContentRendererClient* rv = g_client->renderer_; |
| 26 g_client->renderer_ = r; | 26 g_client->renderer_ = r; |
| 27 return rv; | 27 return rv; |
| 28 } | 28 } |
| 29 | 29 |
| 30 static ContentUtilityClient* SetUtility(ContentUtilityClient* u) { | 30 static ContentUtilityClient* SetUtility(ContentUtilityClient* u) { |
| 31 ContentUtilityClient* rv = g_client->utility_; | 31 ContentUtilityClient* rv = g_client->utility_; |
| 32 g_client->utility_ = u; | 32 g_client->utility_ = u; |
| 33 return rv; | 33 return rv; |
| 34 } | 34 } |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 void SetContentClient(ContentClient* client) { | 37 void SetContentClient(ContentClient* client) { |
| 38 g_client = client; | 38 g_client = client; |
| 39 | |
| 40 // Set the default user agent as provided by the client. We need to make | |
| 41 // sure this is done before webkit_glue::GetUserAgent() is called (so that | |
| 42 // the UA doesn't change). | |
| 43 if (client) { | |
| 44 webkit_glue::SetUserAgent(client->GetUserAgent(), false); | |
|
jam
2014/03/05 00:09:26
i don't see any code which now calls ContentClient
tfarina
2014/03/05 00:22:11
https://code.google.com/p/chromium/codesearch#sear
jam
2014/03/05 08:34:56
sorry I wasn't clear. I mean, user_agent.cc needs
tfarina
2014/03/05 13:31:55
Sorry, I have no idea what you are asking me to do
| |
| 45 } | |
| 46 } | 39 } |
| 47 | 40 |
| 48 ContentClient* GetContentClient() { | 41 ContentClient* GetContentClient() { |
| 49 return g_client; | 42 return g_client; |
| 50 } | 43 } |
| 51 | 44 |
| 52 ContentBrowserClient* SetBrowserClientForTesting(ContentBrowserClient* b) { | 45 ContentBrowserClient* SetBrowserClientForTesting(ContentBrowserClient* b) { |
| 53 return InternalTestInitializer::SetBrowser(b); | 46 return InternalTestInitializer::SetBrowser(b); |
| 54 } | 47 } |
| 55 | 48 |
| 56 ContentRendererClient* SetRendererClientForTesting(ContentRendererClient* r) { | 49 ContentRendererClient* SetRendererClientForTesting(ContentRendererClient* r) { |
| 57 return InternalTestInitializer::SetRenderer(r); | 50 return InternalTestInitializer::SetRenderer(r); |
| 58 } | 51 } |
| 59 | 52 |
| 60 ContentUtilityClient* SetUtilityClientForTesting(ContentUtilityClient* u) { | 53 ContentUtilityClient* SetUtilityClientForTesting(ContentUtilityClient* u) { |
| 61 return InternalTestInitializer::SetUtility(u); | 54 return InternalTestInitializer::SetUtility(u); |
| 62 } | 55 } |
| 63 | 56 |
| 64 const std::string& GetUserAgent(const GURL& url) { | |
| 65 DCHECK(g_client); | |
| 66 return webkit_glue::GetUserAgent(url); | |
| 67 } | |
| 68 | |
| 69 ContentClient::ContentClient() | 57 ContentClient::ContentClient() |
| 70 : browser_(NULL), plugin_(NULL), renderer_(NULL), utility_(NULL) { | 58 : browser_(NULL), plugin_(NULL), renderer_(NULL), utility_(NULL) { |
| 71 } | 59 } |
| 72 | 60 |
| 73 ContentClient::~ContentClient() { | 61 ContentClient::~ContentClient() { |
| 74 } | 62 } |
| 75 | 63 |
| 76 bool ContentClient::CanSendWhileSwappedOut(const IPC::Message* message) { | 64 bool ContentClient::CanSendWhileSwappedOut(const IPC::Message* message) { |
| 77 return false; | 65 return false; |
| 78 } | 66 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 int* sandbox_profile_resource_id) const { | 108 int* sandbox_profile_resource_id) const { |
| 121 return false; | 109 return false; |
| 122 } | 110 } |
| 123 | 111 |
| 124 std::string ContentClient::GetCarbonInterposePath() const { | 112 std::string ContentClient::GetCarbonInterposePath() const { |
| 125 return std::string(); | 113 return std::string(); |
| 126 } | 114 } |
| 127 #endif | 115 #endif |
| 128 | 116 |
| 129 } // namespace content | 117 } // namespace content |
| OLD | NEW |