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

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

Issue 1548153002: Switch to standard integer types in chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
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 #include "chrome/renderer/extensions/extension_localization_peer.h" 5 #include "chrome/renderer/extensions/extension_localization_peer.h"
6 6
7 #include "base/macros.h"
7 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
9 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
10 #include "extensions/common/constants.h" 11 #include "extensions/common/constants.h"
11 #include "extensions/common/extension_messages.h" 12 #include "extensions/common/extension_messages.h"
12 #include "extensions/common/message_bundle.h" 13 #include "extensions/common/message_bundle.h"
13 #include "ipc/ipc_sender.h" 14 #include "ipc/ipc_sender.h"
14 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
15 #include "net/http/http_response_headers.h" 16 #include "net/http/http_response_headers.h"
16 17
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 const GURL& request_url) { 55 const GURL& request_url) {
55 // Return NULL if content is not text/css or it doesn't belong to extension 56 // Return NULL if content is not text/css or it doesn't belong to extension
56 // scheme. 57 // scheme.
57 return (request_url.SchemeIs(extensions::kExtensionScheme) && 58 return (request_url.SchemeIs(extensions::kExtensionScheme) &&
58 base::StartsWith(mime_type, "text/css", 59 base::StartsWith(mime_type, "text/css",
59 base::CompareCase::INSENSITIVE_ASCII)) 60 base::CompareCase::INSENSITIVE_ASCII))
60 ? new ExtensionLocalizationPeer(peer, message_sender, request_url) 61 ? new ExtensionLocalizationPeer(peer, message_sender, request_url)
61 : NULL; 62 : NULL;
62 } 63 }
63 64
64 void ExtensionLocalizationPeer::OnUploadProgress( 65 void ExtensionLocalizationPeer::OnUploadProgress(uint64_t position,
65 uint64 position, uint64 size) { 66 uint64_t size) {
66 NOTREACHED(); 67 NOTREACHED();
67 } 68 }
68 69
69 bool ExtensionLocalizationPeer::OnReceivedRedirect( 70 bool ExtensionLocalizationPeer::OnReceivedRedirect(
70 const net::RedirectInfo& redirect_info, 71 const net::RedirectInfo& redirect_info,
71 const content::ResourceResponseInfo& info) { 72 const content::ResourceResponseInfo& info) {
72 NOTREACHED(); 73 NOTREACHED();
73 return false; 74 return false;
74 } 75 }
75 76
76 void ExtensionLocalizationPeer::OnReceivedResponse( 77 void ExtensionLocalizationPeer::OnReceivedResponse(
77 const content::ResourceResponseInfo& info) { 78 const content::ResourceResponseInfo& info) {
78 response_info_ = info; 79 response_info_ = info;
79 } 80 }
80 81
81 void ExtensionLocalizationPeer::OnReceivedData(scoped_ptr<ReceivedData> data) { 82 void ExtensionLocalizationPeer::OnReceivedData(scoped_ptr<ReceivedData> data) {
82 data_.append(data->payload(), data->length()); 83 data_.append(data->payload(), data->length());
83 } 84 }
84 85
85 void ExtensionLocalizationPeer::OnCompletedRequest( 86 void ExtensionLocalizationPeer::OnCompletedRequest(
86 int error_code, 87 int error_code,
87 bool was_ignored_by_handler, 88 bool was_ignored_by_handler,
88 bool stale_copy_in_cache, 89 bool stale_copy_in_cache,
89 const std::string& security_info, 90 const std::string& security_info,
90 const base::TimeTicks& completion_time, 91 const base::TimeTicks& completion_time,
91 int64 total_transfer_size) { 92 int64_t total_transfer_size) {
92 // Make sure we delete ourselves at the end of this call. 93 // Make sure we delete ourselves at the end of this call.
93 scoped_ptr<ExtensionLocalizationPeer> this_deleter(this); 94 scoped_ptr<ExtensionLocalizationPeer> this_deleter(this);
94 // Give sub-classes a chance at altering the data. 95 // Give sub-classes a chance at altering the data.
95 if (error_code != net::OK) { 96 if (error_code != net::OK) {
96 // We failed to load the resource. 97 // We failed to load the resource.
97 original_peer_->OnReceivedCompletedResponse( 98 original_peer_->OnReceivedCompletedResponse(
98 response_info_, nullptr, net::ERR_ABORTED, false, stale_copy_in_cache, 99 response_info_, nullptr, net::ERR_ABORTED, false, stale_copy_in_cache,
99 security_info, completion_time, total_transfer_size); 100 security_info, completion_time, total_transfer_size);
100 return; 101 return;
101 } 102 }
102 103
103 ReplaceMessages(); 104 ReplaceMessages();
104 105
105 scoped_ptr<StringData> data_to_pass(data_.empty() ? nullptr 106 scoped_ptr<StringData> data_to_pass(data_.empty() ? nullptr
106 : new StringData(data_)); 107 : new StringData(data_));
107 original_peer_->OnReceivedCompletedResponse( 108 original_peer_->OnReceivedCompletedResponse(
108 response_info_, data_to_pass.Pass(), error_code, was_ignored_by_handler, 109 response_info_, data_to_pass.Pass(), error_code, was_ignored_by_handler,
109 stale_copy_in_cache, security_info, completion_time, total_transfer_size); 110 stale_copy_in_cache, security_info, completion_time, total_transfer_size);
110 } 111 }
111 112
112 void ExtensionLocalizationPeer::OnReceivedCompletedResponse( 113 void ExtensionLocalizationPeer::OnReceivedCompletedResponse(
113 const content::ResourceResponseInfo& info, 114 const content::ResourceResponseInfo& info,
114 scoped_ptr<ReceivedData> data, 115 scoped_ptr<ReceivedData> data,
115 int error_code, 116 int error_code,
116 bool was_ignored_by_handler, 117 bool was_ignored_by_handler,
117 bool stale_copy_in_cache, 118 bool stale_copy_in_cache,
118 const std::string& security_info, 119 const std::string& security_info,
119 const base::TimeTicks& completion_time, 120 const base::TimeTicks& completion_time,
120 int64 total_transfer_size) { 121 int64_t total_transfer_size) {
121 // Make sure we delete ourselves at the end of this call. 122 // Make sure we delete ourselves at the end of this call.
122 scoped_ptr<ExtensionLocalizationPeer> this_deleter(this); 123 scoped_ptr<ExtensionLocalizationPeer> this_deleter(this);
123 original_peer_->OnReceivedCompletedResponse( 124 original_peer_->OnReceivedCompletedResponse(
124 info, data.Pass(), error_code, was_ignored_by_handler, 125 info, data.Pass(), error_code, was_ignored_by_handler,
125 stale_copy_in_cache, security_info, completion_time, total_transfer_size); 126 stale_copy_in_cache, security_info, completion_time, total_transfer_size);
126 } 127 }
127 128
128 void ExtensionLocalizationPeer::ReplaceMessages() { 129 void ExtensionLocalizationPeer::ReplaceMessages() {
129 if (!message_sender_ || data_.empty()) 130 if (!message_sender_ || data_.empty())
130 return; 131 return;
(...skipping 17 matching lines...) Expand all
148 149
149 l10n_messages = extensions::GetL10nMessagesMap(extension_id); 150 l10n_messages = extensions::GetL10nMessagesMap(extension_id);
150 } 151 }
151 152
152 std::string error; 153 std::string error;
153 if (extensions::MessageBundle::ReplaceMessagesWithExternalDictionary( 154 if (extensions::MessageBundle::ReplaceMessagesWithExternalDictionary(
154 *l10n_messages, &data_, &error)) { 155 *l10n_messages, &data_, &error)) {
155 data_.resize(data_.size()); 156 data_.resize(data_.size());
156 } 157 }
157 } 158 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698