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
3 // found in the LICENSE file.
5 #include "android_webview/common/aw_content_client.h"
7 #include "base/basictypes.h"
8 #include "ipc/ipc_message.h"
9 #include "ui/base/l10n/l10n_util.h"
10 #include "ui/base/resource/resource_bundle.h"
11 #include "webkit/user_agent/user_agent_util.h"
13 namespace android_webview
{
15 std::string
AwContentClient::GetProduct() const {
16 // "Version/4.0" had been hardcoded in the legacy WebView.
17 return std::string("Version/4.0");
20 std::string
AwContentClient::GetUserAgent() const {
21 return webkit_glue::BuildUserAgentFromProduct(GetProduct());
24 string16
AwContentClient::GetLocalizedString(int message_id
) const {
25 // TODO(boliu): Used only by WebKit, so only bundle those resources for
27 return l10n_util::GetStringUTF16(message_id
);
30 base::StringPiece
AwContentClient::GetDataResource(
32 ui::ScaleFactor scale_factor
) const {
33 // TODO(boliu): Used only by WebKit, so only bundle those resources for
35 return ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
36 resource_id
, scale_factor
);
39 bool AwContentClient::CanSendWhileSwappedOut(const IPC::Message
* message
) {
40 // For legacy API support we perform a few browser -> renderer synchronous IPC
41 // messages that block the browser. However, the synchronous IPC replies might
42 // be dropped by the renderer during a swap out, deadlocking the browser.
43 // Because of this we should never drop any synchronous IPC replies.
44 return message
->type() == IPC_REPLY_ID
;
47 } // namespace android_webview