OLD | NEW |
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 "chrome/common/extensions/extension_localization_peer.h" | 5 #include "chrome/common/extensions/extension_localization_peer.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/common/extensions/extension_message_bundle.h" | 9 #include "chrome/common/extensions/extension_message_bundle.h" |
10 #include "chrome/common/extensions/extension_messages.h" | 10 #include "chrome/common/extensions/extension_messages.h" |
11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
12 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
14 #include "net/http/http_response_headers.h" | 14 #include "net/http/http_response_headers.h" |
15 #include "webkit/glue/webkit_glue.h" | 15 #include "webkit/glue/webkit_glue.h" |
16 | 16 |
17 ExtensionLocalizationPeer::ExtensionLocalizationPeer( | 17 ExtensionLocalizationPeer::ExtensionLocalizationPeer( |
18 webkit_glue::ResourceLoaderBridge::Peer* peer, | 18 webkit_glue::ResourceLoaderBridge::Peer* peer, |
19 IPC::Message::Sender* message_sender, | 19 IPC::Sender* message_sender, |
20 const GURL& request_url) | 20 const GURL& request_url) |
21 : original_peer_(peer), | 21 : original_peer_(peer), |
22 message_sender_(message_sender), | 22 message_sender_(message_sender), |
23 request_url_(request_url) { | 23 request_url_(request_url) { |
24 } | 24 } |
25 | 25 |
26 ExtensionLocalizationPeer::~ExtensionLocalizationPeer() { | 26 ExtensionLocalizationPeer::~ExtensionLocalizationPeer() { |
27 } | 27 } |
28 | 28 |
29 // static | 29 // static |
30 ExtensionLocalizationPeer* | 30 ExtensionLocalizationPeer* |
31 ExtensionLocalizationPeer::CreateExtensionLocalizationPeer( | 31 ExtensionLocalizationPeer::CreateExtensionLocalizationPeer( |
32 webkit_glue::ResourceLoaderBridge::Peer* peer, | 32 webkit_glue::ResourceLoaderBridge::Peer* peer, |
33 IPC::Message::Sender* message_sender, | 33 IPC::Sender* message_sender, |
34 const std::string& mime_type, | 34 const std::string& mime_type, |
35 const GURL& request_url) { | 35 const GURL& request_url) { |
36 // Return NULL if content is not text/css or it doesn't belong to extension | 36 // Return NULL if content is not text/css or it doesn't belong to extension |
37 // scheme. | 37 // scheme. |
38 return (request_url.SchemeIs(chrome::kExtensionScheme) && | 38 return (request_url.SchemeIs(chrome::kExtensionScheme) && |
39 StartsWithASCII(mime_type, "text/css", false)) ? | 39 StartsWithASCII(mime_type, "text/css", false)) ? |
40 new ExtensionLocalizationPeer(peer, message_sender, request_url) : NULL; | 40 new ExtensionLocalizationPeer(peer, message_sender, request_url) : NULL; |
41 } | 41 } |
42 | 42 |
43 void ExtensionLocalizationPeer::OnUploadProgress( | 43 void ExtensionLocalizationPeer::OnUploadProgress( |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 114 |
115 l10n_messages = GetL10nMessagesMap(extension_id); | 115 l10n_messages = GetL10nMessagesMap(extension_id); |
116 } | 116 } |
117 | 117 |
118 std::string error; | 118 std::string error; |
119 if (ExtensionMessageBundle::ReplaceMessagesWithExternalDictionary( | 119 if (ExtensionMessageBundle::ReplaceMessagesWithExternalDictionary( |
120 *l10n_messages, &data_, &error)) { | 120 *l10n_messages, &data_, &error)) { |
121 data_.resize(data_.size()); | 121 data_.resize(data_.size()); |
122 } | 122 } |
123 } | 123 } |
OLD | NEW |