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

Side by Side Diff: chrome/renderer/extensions/extension_localization_peer.h

Issue 218973002: Extract Peer interface out of ResourceLoaderBridge. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: REBASED Created 6 years, 8 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 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 "ipc/ipc_sender.h" 10 #include "content/public/child/request_peer.h"
11 #include "webkit/child/resource_loader_bridge.h"
12 #include "webkit/common/resource_response_info.h" 11 #include "webkit/common/resource_response_info.h"
13 12
13 namespace IPC {
14 class Sender;
15 }
16
14 // The ExtensionLocalizationPeer is a proxy to a 17 // The ExtensionLocalizationPeer is a proxy to a
15 // webkit_glue::ResourceLoaderBridge::Peer instance. It is used to pre-process 18 // content::RequestPeer instance. It is used to pre-process
16 // CSS files requested by extensions to replace localization templates with the 19 // CSS files requested by extensions to replace localization templates with the
17 // appropriate localized strings. 20 // appropriate localized strings.
18 // 21 //
19 // Call the factory method CreateExtensionLocalizationPeer() to obtain an 22 // Call the factory method CreateExtensionLocalizationPeer() to obtain an
20 // instance of ExtensionLocalizationPeer based on the original Peer. 23 // instance of ExtensionLocalizationPeer based on the original Peer.
21 class ExtensionLocalizationPeer 24 class ExtensionLocalizationPeer : public content::RequestPeer {
22 : public webkit_glue::ResourceLoaderBridge::Peer {
23 public: 25 public:
24 virtual ~ExtensionLocalizationPeer(); 26 virtual ~ExtensionLocalizationPeer();
25 27
26 static ExtensionLocalizationPeer* CreateExtensionLocalizationPeer( 28 static ExtensionLocalizationPeer* CreateExtensionLocalizationPeer(
27 webkit_glue::ResourceLoaderBridge::Peer* peer, 29 content::RequestPeer* peer,
28 IPC::Sender* message_sender, 30 IPC::Sender* message_sender,
29 const std::string& mime_type, 31 const std::string& mime_type,
30 const GURL& request_url); 32 const GURL& request_url);
31 33
32 // ResourceLoaderBridge::Peer methods. 34 // content::RequestPeer methods.
33 virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE; 35 virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE;
34 virtual bool OnReceivedRedirect( 36 virtual bool OnReceivedRedirect(const GURL& new_url,
35 const GURL& new_url, 37 const webkit_glue::ResourceResponseInfo& info,
36 const webkit_glue::ResourceResponseInfo& info, 38 bool* has_new_first_party_for_cookies,
37 bool* has_new_first_party_for_cookies, 39 GURL* new_first_party_for_cookies) OVERRIDE;
38 GURL* new_first_party_for_cookies) OVERRIDE;
39 virtual void OnReceivedResponse( 40 virtual void OnReceivedResponse(
40 const webkit_glue::ResourceResponseInfo& info) OVERRIDE; 41 const webkit_glue::ResourceResponseInfo& info) OVERRIDE;
41 virtual void OnDownloadedData(int len, int encoded_data_length) OVERRIDE {} 42 virtual void OnDownloadedData(int len, int encoded_data_length) OVERRIDE {}
42 virtual void OnReceivedData(const char* data, 43 virtual void OnReceivedData(const char* data,
43 int data_length, 44 int data_length,
44 int encoded_data_length) OVERRIDE; 45 int encoded_data_length) OVERRIDE;
45 virtual void OnCompletedRequest( 46 virtual void OnCompletedRequest(int error_code,
46 int error_code, 47 bool was_ignored_by_handler,
47 bool was_ignored_by_handler, 48 bool stale_copy_in_cache,
48 bool stale_copy_in_cache, 49 const std::string& security_info,
49 const std::string& security_info, 50 const base::TimeTicks& completion_time,
50 const base::TimeTicks& completion_time, 51 int64 total_transfer_size) OVERRIDE;
51 int64 total_transfer_size) OVERRIDE;
52 52
53 private: 53 private:
54 friend class ExtensionLocalizationPeerTest; 54 friend class ExtensionLocalizationPeerTest;
55 55
56 // Use CreateExtensionLocalizationPeer to create an instance. 56 // Use CreateExtensionLocalizationPeer to create an instance.
57 ExtensionLocalizationPeer( 57 ExtensionLocalizationPeer(content::RequestPeer* peer,
58 webkit_glue::ResourceLoaderBridge::Peer* peer, 58 IPC::Sender* message_sender,
59 IPC::Sender* message_sender, 59 const GURL& request_url);
60 const GURL& request_url);
61 60
62 // Loads message catalogs, and replaces all __MSG_some_name__ templates within 61 // Loads message catalogs, and replaces all __MSG_some_name__ templates within
63 // loaded file. 62 // loaded file.
64 void ReplaceMessages(); 63 void ReplaceMessages();
65 64
66 // Original peer that handles the request once we are done processing data_. 65 // Original peer that handles the request once we are done processing data_.
67 webkit_glue::ResourceLoaderBridge::Peer* original_peer_; 66 content::RequestPeer* original_peer_;
68 67
69 // We just pass though the response info. This holds the copy of the original. 68 // We just pass though the response info. This holds the copy of the original.
70 webkit_glue::ResourceResponseInfo response_info_; 69 webkit_glue::ResourceResponseInfo response_info_;
71 70
72 // Sends ExtensionHostMsg_GetMessageBundle message to the browser to fetch 71 // Sends ExtensionHostMsg_GetMessageBundle message to the browser to fetch
73 // message catalog. 72 // message catalog.
74 IPC::Sender* message_sender_; 73 IPC::Sender* message_sender_;
75 74
76 // Buffer for incoming data. We wait until OnCompletedRequest before using it. 75 // Buffer for incoming data. We wait until OnCompletedRequest before using it.
77 std::string data_; 76 std::string data_;
78 77
79 // Original request URL. 78 // Original request URL.
80 GURL request_url_; 79 GURL request_url_;
81 80
82 private: 81 private:
83 DISALLOW_COPY_AND_ASSIGN(ExtensionLocalizationPeer); 82 DISALLOW_COPY_AND_ASSIGN(ExtensionLocalizationPeer);
84 }; 83 };
85 84
86 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_LOCALIZATION_PEER_H_ 85 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_LOCALIZATION_PEER_H_
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_render_process_observer.cc ('k') | chrome/renderer/extensions/extension_localization_peer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698