| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_RENDERER_EXTENSIONS_EXTENSION_LOCALIZATION_PEER_H_ | 5 #ifndef CHROME_RENDERER_EXTENSIONS_EXTENSION_LOCALIZATION_PEER_H_ |
| 6 #define CHROME_RENDERER_EXTENSIONS_EXTENSION_LOCALIZATION_PEER_H_ | 6 #define CHROME_RENDERER_EXTENSIONS_EXTENSION_LOCALIZATION_PEER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <string> | 10 #include <string> |
| 9 | 11 |
| 12 #include "base/macros.h" |
| 10 #include "content/public/child/request_peer.h" | 13 #include "content/public/child/request_peer.h" |
| 11 #include "content/public/common/resource_response_info.h" | 14 #include "content/public/common/resource_response_info.h" |
| 12 | 15 |
| 13 namespace IPC { | 16 namespace IPC { |
| 14 class Sender; | 17 class Sender; |
| 15 } | 18 } |
| 16 | 19 |
| 17 // The ExtensionLocalizationPeer is a proxy to a | 20 // The ExtensionLocalizationPeer is a proxy to a |
| 18 // content::RequestPeer instance. It is used to pre-process | 21 // content::RequestPeer instance. It is used to pre-process |
| 19 // CSS files requested by extensions to replace localization templates with the | 22 // CSS files requested by extensions to replace localization templates with the |
| 20 // appropriate localized strings. | 23 // appropriate localized strings. |
| 21 // | 24 // |
| 22 // Call the factory method CreateExtensionLocalizationPeer() to obtain an | 25 // Call the factory method CreateExtensionLocalizationPeer() to obtain an |
| 23 // instance of ExtensionLocalizationPeer based on the original Peer. | 26 // instance of ExtensionLocalizationPeer based on the original Peer. |
| 24 class ExtensionLocalizationPeer : public content::RequestPeer { | 27 class ExtensionLocalizationPeer : public content::RequestPeer { |
| 25 public: | 28 public: |
| 26 ~ExtensionLocalizationPeer() override; | 29 ~ExtensionLocalizationPeer() override; |
| 27 | 30 |
| 28 static ExtensionLocalizationPeer* CreateExtensionLocalizationPeer( | 31 static ExtensionLocalizationPeer* CreateExtensionLocalizationPeer( |
| 29 content::RequestPeer* peer, | 32 content::RequestPeer* peer, |
| 30 IPC::Sender* message_sender, | 33 IPC::Sender* message_sender, |
| 31 const std::string& mime_type, | 34 const std::string& mime_type, |
| 32 const GURL& request_url); | 35 const GURL& request_url); |
| 33 | 36 |
| 34 // content::RequestPeer methods. | 37 // content::RequestPeer methods. |
| 35 void OnUploadProgress(uint64 position, uint64 size) override; | 38 void OnUploadProgress(uint64_t position, uint64_t size) override; |
| 36 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, | 39 bool OnReceivedRedirect(const net::RedirectInfo& redirect_info, |
| 37 const content::ResourceResponseInfo& info) override; | 40 const content::ResourceResponseInfo& info) override; |
| 38 void OnReceivedResponse(const content::ResourceResponseInfo& info) override; | 41 void OnReceivedResponse(const content::ResourceResponseInfo& info) override; |
| 39 void OnDownloadedData(int len, int encoded_data_length) override {} | 42 void OnDownloadedData(int len, int encoded_data_length) override {} |
| 40 void OnReceivedData(scoped_ptr<ReceivedData> data) override; | 43 void OnReceivedData(scoped_ptr<ReceivedData> data) override; |
| 41 void OnCompletedRequest(int error_code, | 44 void OnCompletedRequest(int error_code, |
| 42 bool was_ignored_by_handler, | 45 bool was_ignored_by_handler, |
| 43 bool stale_copy_in_cache, | 46 bool stale_copy_in_cache, |
| 44 const std::string& security_info, | 47 const std::string& security_info, |
| 45 const base::TimeTicks& completion_time, | 48 const base::TimeTicks& completion_time, |
| 46 int64 total_transfer_size) override; | 49 int64_t total_transfer_size) override; |
| 47 void OnReceivedCompletedResponse(const content::ResourceResponseInfo& info, | 50 void OnReceivedCompletedResponse(const content::ResourceResponseInfo& info, |
| 48 scoped_ptr<ReceivedData> data, | 51 scoped_ptr<ReceivedData> data, |
| 49 int error_code, | 52 int error_code, |
| 50 bool was_ignored_by_handler, | 53 bool was_ignored_by_handler, |
| 51 bool stale_copy_in_cache, | 54 bool stale_copy_in_cache, |
| 52 const std::string& security_info, | 55 const std::string& security_info, |
| 53 const base::TimeTicks& completion_time, | 56 const base::TimeTicks& completion_time, |
| 54 int64 total_transfer_size) override; | 57 int64_t total_transfer_size) override; |
| 55 | 58 |
| 56 private: | 59 private: |
| 57 friend class ExtensionLocalizationPeerTest; | 60 friend class ExtensionLocalizationPeerTest; |
| 58 | 61 |
| 59 // Use CreateExtensionLocalizationPeer to create an instance. | 62 // Use CreateExtensionLocalizationPeer to create an instance. |
| 60 ExtensionLocalizationPeer(content::RequestPeer* peer, | 63 ExtensionLocalizationPeer(content::RequestPeer* peer, |
| 61 IPC::Sender* message_sender, | 64 IPC::Sender* message_sender, |
| 62 const GURL& request_url); | 65 const GURL& request_url); |
| 63 | 66 |
| 64 // Loads message catalogs, and replaces all __MSG_some_name__ templates within | 67 // Loads message catalogs, and replaces all __MSG_some_name__ templates within |
| (...skipping 14 matching lines...) Expand all Loading... |
| 79 std::string data_; | 82 std::string data_; |
| 80 | 83 |
| 81 // Original request URL. | 84 // Original request URL. |
| 82 GURL request_url_; | 85 GURL request_url_; |
| 83 | 86 |
| 84 private: | 87 private: |
| 85 DISALLOW_COPY_AND_ASSIGN(ExtensionLocalizationPeer); | 88 DISALLOW_COPY_AND_ASSIGN(ExtensionLocalizationPeer); |
| 86 }; | 89 }; |
| 87 | 90 |
| 88 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_LOCALIZATION_PEER_H_ | 91 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_LOCALIZATION_PEER_H_ |
| OLD | NEW |