Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / renderer / extensions / extension_localization_peer.h
blob43d4032dd8d6c302b3c2ff12e4464ba3f62b0fe6
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
3 // found in the LICENSE file.
5 #ifndef CHROME_RENDERER_EXTENSIONS_EXTENSION_LOCALIZATION_PEER_H_
6 #define CHROME_RENDERER_EXTENSIONS_EXTENSION_LOCALIZATION_PEER_H_
8 #include <string>
10 #include "content/public/child/request_peer.h"
11 #include "webkit/common/resource_response_info.h"
13 namespace IPC {
14 class Sender;
17 // The ExtensionLocalizationPeer is a proxy to a
18 // content::RequestPeer instance. It is used to pre-process
19 // CSS files requested by extensions to replace localization templates with the
20 // appropriate localized strings.
22 // Call the factory method CreateExtensionLocalizationPeer() to obtain an
23 // instance of ExtensionLocalizationPeer based on the original Peer.
24 class ExtensionLocalizationPeer : public content::RequestPeer {
25 public:
26 virtual ~ExtensionLocalizationPeer();
28 static ExtensionLocalizationPeer* CreateExtensionLocalizationPeer(
29 content::RequestPeer* peer,
30 IPC::Sender* message_sender,
31 const std::string& mime_type,
32 const GURL& request_url);
34 // content::RequestPeer methods.
35 virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE;
36 virtual bool OnReceivedRedirect(const GURL& new_url,
37 const webkit_glue::ResourceResponseInfo& info,
38 bool* has_new_first_party_for_cookies,
39 GURL* new_first_party_for_cookies) OVERRIDE;
40 virtual void OnReceivedResponse(
41 const webkit_glue::ResourceResponseInfo& info) OVERRIDE;
42 virtual void OnDownloadedData(int len, int encoded_data_length) OVERRIDE {}
43 virtual void OnReceivedData(const char* data,
44 int data_length,
45 int encoded_data_length) OVERRIDE;
46 virtual void OnCompletedRequest(int error_code,
47 bool was_ignored_by_handler,
48 bool stale_copy_in_cache,
49 const std::string& security_info,
50 const base::TimeTicks& completion_time,
51 int64 total_transfer_size) OVERRIDE;
53 private:
54 friend class ExtensionLocalizationPeerTest;
56 // Use CreateExtensionLocalizationPeer to create an instance.
57 ExtensionLocalizationPeer(content::RequestPeer* peer,
58 IPC::Sender* message_sender,
59 const GURL& request_url);
61 // Loads message catalogs, and replaces all __MSG_some_name__ templates within
62 // loaded file.
63 void ReplaceMessages();
65 // Original peer that handles the request once we are done processing data_.
66 content::RequestPeer* original_peer_;
68 // We just pass though the response info. This holds the copy of the original.
69 webkit_glue::ResourceResponseInfo response_info_;
71 // Sends ExtensionHostMsg_GetMessageBundle message to the browser to fetch
72 // message catalog.
73 IPC::Sender* message_sender_;
75 // Buffer for incoming data. We wait until OnCompletedRequest before using it.
76 std::string data_;
78 // Original request URL.
79 GURL request_url_;
81 private:
82 DISALLOW_COPY_AND_ASSIGN(ExtensionLocalizationPeer);
85 #endif // CHROME_RENDERER_EXTENSIONS_EXTENSION_LOCALIZATION_PEER_H_