OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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/common/content_client.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "base/string_piece.h" | |
9 #include "webkit/glue/webkit_glue.h" | |
10 | |
11 namespace content { | |
12 | |
13 static ContentClient* g_client; | |
14 | |
15 void SetContentClient(ContentClient* client) { | |
16 g_client = client; | |
17 | |
18 // TODO(dpranke): Doing real work (calling webkit_glue::SetUserAgent) | |
19 // inside what looks like a function that initializes a global is a | |
20 // bit odd, but we need to make sure this is done before | |
21 // webkit_glue::GetUserAgent() is called (so that the UA doesn't change). | |
22 // | |
23 // It would be cleaner if we could rename this to something like a | |
24 // content::Initialize(). Maybe we can merge this into ContentMain() somehow? | |
25 if (client) { | |
26 bool custom = false; | |
27 std::string ua = client->GetUserAgent(&custom); | |
28 webkit_glue::SetUserAgent(ua, custom); | |
29 } | |
30 } | |
31 | |
32 ContentClient* GetContentClient() { | |
33 return g_client; | |
34 } | |
35 | |
36 const std::string& GetUserAgent(const GURL& url) { | |
37 DCHECK(g_client); | |
38 return webkit_glue::GetUserAgent(url); | |
39 } | |
40 | |
41 ContentClient::ContentClient() | |
42 : browser_(NULL), plugin_(NULL), renderer_(NULL), utility_(NULL) { | |
43 } | |
44 | |
45 ContentClient::~ContentClient() { | |
46 } | |
47 | |
48 } // namespace content | |
OLD | NEW |