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

Side by Side Diff: android_webview/common/aw_content_client.cc

Issue 186883002: Move user_agent code from webkit/ to content/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 "android_webview/common/aw_content_client.h" 5 #include "android_webview/common/aw_content_client.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "content/public/common/content_switches.h" 9 #include "content/public/common/content_switches.h"
10 #include "content/public/common/user_agent_util.h"
10 #include "ipc/ipc_message.h" 11 #include "ipc/ipc_message.h"
11 #include "ui/base/l10n/l10n_util.h" 12 #include "ui/base/l10n/l10n_util.h"
12 #include "ui/base/resource/resource_bundle.h" 13 #include "ui/base/resource/resource_bundle.h"
13 #include "webkit/common/user_agent/user_agent_util.h"
14 14
15 namespace android_webview { 15 namespace android_webview {
16 16
17 std::string AwContentClient::GetProduct() const { 17 std::string AwContentClient::GetProduct() const {
18 // "Chrome/XX.0.0.0" identifies that this WebView is derived from the 18 // "Chrome/XX.0.0.0" identifies that this WebView is derived from the
19 // corresponding Chromium version XX. 19 // corresponding Chromium version XX.
20 // TODO(torne): Use chrome/VERSION file. See http://crbug.com/297522 20 // TODO(torne): Use chrome/VERSION file. See http://crbug.com/297522
21 return "Chrome/33.0.0.0"; 21 return "Chrome/33.0.0.0";
22 } 22 }
23 23
24 std::string AwContentClient::GetUserAgent() const { 24 std::string AwContentClient::GetUserAgent() const {
25 // "Version/4.0" had been hardcoded in the legacy WebView. 25 // "Version/4.0" had been hardcoded in the legacy WebView.
26 std::string product = "Version/4.0 " + GetProduct(); 26 std::string product = "Version/4.0 " + GetProduct();
27 if (CommandLine::ForCurrentProcess()->HasSwitch( 27 if (CommandLine::ForCurrentProcess()->HasSwitch(
28 switches::kUseMobileUserAgent)) { 28 switches::kUseMobileUserAgent)) {
29 product += " Mobile"; 29 product += " Mobile";
30 } 30 }
31 return webkit_glue::BuildUserAgentFromProduct(product); 31 return content::BuildUserAgentFromProduct(product);
32 } 32 }
33 33
34 base::string16 AwContentClient::GetLocalizedString(int message_id) const { 34 base::string16 AwContentClient::GetLocalizedString(int message_id) const {
35 // TODO(boliu): Used only by WebKit, so only bundle those resources for 35 // TODO(boliu): Used only by WebKit, so only bundle those resources for
36 // Android WebView. 36 // Android WebView.
37 return l10n_util::GetStringUTF16(message_id); 37 return l10n_util::GetStringUTF16(message_id);
38 } 38 }
39 39
40 base::StringPiece AwContentClient::GetDataResource( 40 base::StringPiece AwContentClient::GetDataResource(
41 int resource_id, 41 int resource_id,
42 ui::ScaleFactor scale_factor) const { 42 ui::ScaleFactor scale_factor) const {
43 // TODO(boliu): Used only by WebKit, so only bundle those resources for 43 // TODO(boliu): Used only by WebKit, so only bundle those resources for
44 // Android WebView. 44 // Android WebView.
45 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( 45 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
46 resource_id, scale_factor); 46 resource_id, scale_factor);
47 } 47 }
48 48
49 bool AwContentClient::CanSendWhileSwappedOut(const IPC::Message* message) { 49 bool AwContentClient::CanSendWhileSwappedOut(const IPC::Message* message) {
50 // For legacy API support we perform a few browser -> renderer synchronous IPC 50 // For legacy API support we perform a few browser -> renderer synchronous IPC
51 // messages that block the browser. However, the synchronous IPC replies might 51 // messages that block the browser. However, the synchronous IPC replies might
52 // be dropped by the renderer during a swap out, deadlocking the browser. 52 // be dropped by the renderer during a swap out, deadlocking the browser.
53 // Because of this we should never drop any synchronous IPC replies. 53 // Because of this we should never drop any synchronous IPC replies.
54 return message->type() == IPC_REPLY_ID; 54 return message->type() == IPC_REPLY_ID;
55 } 55 }
56 56
57 } // namespace android_webview 57 } // namespace android_webview
OLDNEW
« no previous file with comments | « no previous file | android_webview/native/aw_dev_tools_server.cc » ('j') | content/public/common/content_client.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698