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

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

Issue 191093002: Simplify the user agent code some more since after r255534 it's not affected by the site's URL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: patchset 15 which works Created 6 years, 9 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
« no previous file with comments | « content/public/common/content_client.h ('k') | content/public/common/content_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/strings/string_piece.h" 8 #include "base/strings/string_piece.h"
9 #include "ui/gfx/image/image.h" 9 #include "ui/gfx/image/image.h"
10 #include "webkit/common/user_agent/user_agent.h"
11 10
12 namespace content { 11 namespace content {
13 12
14 static ContentClient* g_client; 13 static ContentClient* g_client;
15 14
16 class InternalTestInitializer { 15 class InternalTestInitializer {
17 public: 16 public:
18 static ContentBrowserClient* SetBrowser(ContentBrowserClient* b) { 17 static ContentBrowserClient* SetBrowser(ContentBrowserClient* b) {
19 ContentBrowserClient* rv = g_client->browser_; 18 ContentBrowserClient* rv = g_client->browser_;
20 g_client->browser_ = b; 19 g_client->browser_ = b;
21 return rv; 20 return rv;
22 } 21 }
23 22
24 static ContentRendererClient* SetRenderer(ContentRendererClient* r) { 23 static ContentRendererClient* SetRenderer(ContentRendererClient* r) {
25 ContentRendererClient* rv = g_client->renderer_; 24 ContentRendererClient* rv = g_client->renderer_;
26 g_client->renderer_ = r; 25 g_client->renderer_ = r;
27 return rv; 26 return rv;
28 } 27 }
29 28
30 static ContentUtilityClient* SetUtility(ContentUtilityClient* u) { 29 static ContentUtilityClient* SetUtility(ContentUtilityClient* u) {
31 ContentUtilityClient* rv = g_client->utility_; 30 ContentUtilityClient* rv = g_client->utility_;
32 g_client->utility_ = u; 31 g_client->utility_ = u;
33 return rv; 32 return rv;
34 } 33 }
35 }; 34 };
36 35
37 void SetContentClient(ContentClient* client) { 36 void SetContentClient(ContentClient* client) {
38 g_client = client; 37 g_client = client;
39 38
40 // Set the default user agent as provided by the client. We need to make 39 // TODO(jam): find out which static on Windows is causing this to have to be
41 // sure this is done before webkit_glue::GetUserAgent() is called (so that 40 // called on startup.
42 // the UA doesn't change).
43 if (client) 41 if (client)
44 webkit_glue::SetUserAgent(client->GetUserAgent()); 42 client->GetUserAgent();
45 } 43 }
46 44
47 ContentClient* GetContentClient() { 45 ContentClient* GetContentClient() {
48 return g_client; 46 return g_client;
49 } 47 }
50 48
51 ContentBrowserClient* SetBrowserClientForTesting(ContentBrowserClient* b) { 49 ContentBrowserClient* SetBrowserClientForTesting(ContentBrowserClient* b) {
52 return InternalTestInitializer::SetBrowser(b); 50 return InternalTestInitializer::SetBrowser(b);
53 } 51 }
54 52
55 ContentRendererClient* SetRendererClientForTesting(ContentRendererClient* r) { 53 ContentRendererClient* SetRendererClientForTesting(ContentRendererClient* r) {
56 return InternalTestInitializer::SetRenderer(r); 54 return InternalTestInitializer::SetRenderer(r);
57 } 55 }
58 56
59 ContentUtilityClient* SetUtilityClientForTesting(ContentUtilityClient* u) { 57 ContentUtilityClient* SetUtilityClientForTesting(ContentUtilityClient* u) {
60 return InternalTestInitializer::SetUtility(u); 58 return InternalTestInitializer::SetUtility(u);
61 } 59 }
62 60
63 const std::string& GetUserAgent(const GURL& url) {
64 DCHECK(g_client);
65 return webkit_glue::GetUserAgent(url);
66 }
67
68 ContentClient::ContentClient() 61 ContentClient::ContentClient()
69 : browser_(NULL), plugin_(NULL), renderer_(NULL), utility_(NULL) { 62 : browser_(NULL), plugin_(NULL), renderer_(NULL), utility_(NULL) {
70 } 63 }
71 64
72 ContentClient::~ContentClient() { 65 ContentClient::~ContentClient() {
73 } 66 }
74 67
75 bool ContentClient::CanSendWhileSwappedOut(const IPC::Message* message) { 68 bool ContentClient::CanSendWhileSwappedOut(const IPC::Message* message) {
76 return false; 69 return false;
77 } 70 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 int* sandbox_profile_resource_id) const { 112 int* sandbox_profile_resource_id) const {
120 return false; 113 return false;
121 } 114 }
122 115
123 std::string ContentClient::GetCarbonInterposePath() const { 116 std::string ContentClient::GetCarbonInterposePath() const {
124 return std::string(); 117 return std::string();
125 } 118 }
126 #endif 119 #endif
127 120
128 } // namespace content 121 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/content_client.h ('k') | content/public/common/content_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698