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