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

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

Issue 6735004: Move extension messages to their own file and add a RenderViewObserver to start moving the extens... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/common/extensions/extension_localization_peer.h" 5 #include "chrome/common/extensions/extension_localization_peer.h"
6 6
7 #include "base/scoped_ptr.h" 7 #include "base/scoped_ptr.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/common/extensions/extension_message_bundle.h" 9 #include "chrome/common/extensions/extension_message_bundle.h"
10 #include "chrome/common/render_messages.h" 10 #include "chrome/common/extensions/extension_messages.h"
11 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
12 #include "grit/generated_resources.h" 12 #include "grit/generated_resources.h"
13 #include "net/base/net_errors.h" 13 #include "net/base/net_errors.h"
14 #include "net/http/http_response_headers.h" 14 #include "net/http/http_response_headers.h"
15 #include "webkit/glue/webkit_glue.h" 15 #include "webkit/glue/webkit_glue.h"
16 16
17 ExtensionLocalizationPeer::ExtensionLocalizationPeer( 17 ExtensionLocalizationPeer::ExtensionLocalizationPeer(
18 webkit_glue::ResourceLoaderBridge::Peer* peer, 18 webkit_glue::ResourceLoaderBridge::Peer* peer,
19 IPC::Message::Sender* message_sender, 19 IPC::Message::Sender* message_sender,
20 const GURL& request_url) 20 const GURL& request_url)
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 if (!message_sender_ || data_.empty()) 93 if (!message_sender_ || data_.empty())
94 return; 94 return;
95 95
96 if (!request_url_.is_valid()) 96 if (!request_url_.is_valid())
97 return; 97 return;
98 98
99 std::string extension_id = request_url_.host(); 99 std::string extension_id = request_url_.host();
100 L10nMessagesMap* l10n_messages = GetL10nMessagesMap(extension_id); 100 L10nMessagesMap* l10n_messages = GetL10nMessagesMap(extension_id);
101 if (!l10n_messages) { 101 if (!l10n_messages) {
102 L10nMessagesMap messages; 102 L10nMessagesMap messages;
103 message_sender_->Send(new ViewHostMsg_GetExtensionMessageBundle( 103 message_sender_->Send(new ExtensionHostMsg_GetMessageBundle(
104 extension_id, &messages)); 104 extension_id, &messages));
105 105
106 // Save messages we got, so we don't have to ask again. 106 // Save messages we got, so we don't have to ask again.
107 // Messages map is never empty, it contains at least @@extension_id value. 107 // Messages map is never empty, it contains at least @@extension_id value.
108 ExtensionToL10nMessagesMap& l10n_messages_map = 108 ExtensionToL10nMessagesMap& l10n_messages_map =
109 *GetExtensionToL10nMessagesMap(); 109 *GetExtensionToL10nMessagesMap();
110 l10n_messages_map[extension_id] = messages; 110 l10n_messages_map[extension_id] = messages;
111 111
112 l10n_messages = GetL10nMessagesMap(extension_id); 112 l10n_messages = GetL10nMessagesMap(extension_id);
113 } 113 }
114 114
115 std::string error; 115 std::string error;
116 if (ExtensionMessageBundle::ReplaceMessagesWithExternalDictionary( 116 if (ExtensionMessageBundle::ReplaceMessagesWithExternalDictionary(
117 *l10n_messages, &data_, &error)) { 117 *l10n_messages, &data_, &error)) {
118 data_.resize(data_.size()); 118 data_.resize(data_.size());
119 } 119 }
120 } 120 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_localization_peer.h ('k') | chrome/common/extensions/extension_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698