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

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

Issue 9623027: Move --user-agent overriding logic from chrome into content. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: fix indent Created 8 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
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/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 "webkit/glue/webkit_glue.h" 9 #include "webkit/glue/webkit_glue.h"
10 #include "webkit/plugins/ppapi/host_globals.h" 10 #include "webkit/plugins/ppapi/host_globals.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 static ContentClient* g_client; 14 static ContentClient* g_client;
15 15
16 void SetContentClient(ContentClient* client) { 16 void SetContentClient(ContentClient* client) {
17 g_client = client; 17 g_client = client;
18
19 // TODO(dpranke): Doing real work (calling webkit_glue::SetUserAgent)
20 // inside what looks like a function that initializes a global is a
21 // bit odd, but we need to make sure this is done before
22 // webkit_glue::GetUserAgent() is called (so that the UA doesn't change).
23 //
24 // It would be cleaner if we could rename this to something like a
25 // content::Initialize(). Maybe we can merge this into ContentMain() somehow?
26 if (client) {
27 bool custom = false;
28 std::string ua = client->GetUserAgent(&custom);
29 webkit_glue::SetUserAgent(ua, custom);
30 }
31 } 18 }
32 19
33 ContentClient* GetContentClient() { 20 ContentClient* GetContentClient() {
34 return g_client; 21 return g_client;
35 } 22 }
36 23
37 const std::string& GetUserAgent(const GURL& url) { 24 const std::string& GetUserAgent(const GURL& url) {
38 DCHECK(g_client); 25 DCHECK(g_client);
39 return webkit_glue::GetUserAgent(url); 26 return webkit_glue::GetUserAgent(url);
40 } 27 }
41 28
42 webkit::ppapi::HostGlobals* GetHostGlobals() { 29 webkit::ppapi::HostGlobals* GetHostGlobals() {
43 return webkit::ppapi::HostGlobals::Get(); 30 return webkit::ppapi::HostGlobals::Get();
44 } 31 }
45 32
46 ContentClient::ContentClient() 33 ContentClient::ContentClient()
47 : browser_(NULL), plugin_(NULL), renderer_(NULL), utility_(NULL) { 34 : browser_(NULL), plugin_(NULL), renderer_(NULL), utility_(NULL) {
48 } 35 }
49 36
50 ContentClient::~ContentClient() { 37 ContentClient::~ContentClient() {
51 } 38 }
52 39
53 } // namespace content 40 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698