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

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

Issue 8234013: Add a content::GetUserAgent() to wrap webkit_glue::GetUserAgent() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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) 2011 The Chromium Authors. All rights reserved. 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 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/common/content_client.h" 5 #include "content/common/content_client.h"
6 6
7 #include "base/logging.h"
7 #include "base/string_piece.h" 8 #include "base/string_piece.h"
8 #include "webkit/glue/webkit_glue.h" 9 #include "webkit/glue/webkit_glue.h"
9 10
10 namespace content { 11 namespace content {
11 12
12 static ContentClient* g_client; 13 static ContentClient* g_client;
13 14
14 void SetContentClient(ContentClient* client) { 15 void SetContentClient(ContentClient* client) {
15 g_client = client; 16 g_client = client;
16 17
17 // TODO(dpranke): Doing real work (calling webkit_glue::SetUserAgent) 18 // TODO(dpranke): Doing real work (calling webkit_glue::SetUserAgent)
18 // inside what looks like a function that initializes a global is a 19 // inside what looks like a function that initializes a global is a
19 // bit odd, but we need to make sure this is done before 20 // bit odd, but we need to make sure this is done before
20 // webkit_glue::GetUserAgent() is called (so that the UA doesn't change). 21 // webkit_glue::GetUserAgent() is called (so that the UA doesn't change).
21 // 22 //
22 // It would be cleaner if we could rename this to something like a 23 // It would be cleaner if we could rename this to something like a
23 // content::Initialize(). Maybe we can merge this into ContentMain() somehow? 24 // content::Initialize(). Maybe we can merge this into ContentMain() somehow?
24 if (client) { 25 if (client) {
25 bool custom = false; 26 bool custom = false;
26 std::string ua = client->GetUserAgent(&custom); 27 std::string ua = client->GetUserAgent(&custom);
27 webkit_glue::SetUserAgent(ua, custom); 28 webkit_glue::SetUserAgent(ua, custom);
28 } 29 }
29 } 30 }
30 31
31 ContentClient* GetContentClient() { 32 ContentClient* GetContentClient() {
32 return g_client; 33 return g_client;
33 } 34 }
34 35
36 const std::string& GetUserAgent(const GURL& url) {
37 DCHECK(g_client);
38 return webkit_glue::GetUserAgent(url);
39 }
40
35 ContentClient::ContentClient() 41 ContentClient::ContentClient()
36 : browser_(NULL), plugin_(NULL), renderer_(NULL), utility_(NULL) { 42 : browser_(NULL), plugin_(NULL), renderer_(NULL), utility_(NULL) {
37 } 43 }
38 44
39 ContentClient::~ContentClient() { 45 ContentClient::~ContentClient() {
40 } 46 }
41 47
42 } // namespace content 48 } // namespace content
OLDNEW
« content/common/content_client.h ('K') | « content/common/content_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698