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

Side by Side Diff: chrome/common/net/net_resource_provider.cc

Issue 210027: Move FTP LIST parsing code to the renderer process. (Closed)
Patch Set: fixes Created 11 years, 3 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
(Empty)
1 // Copyright (c) 2009 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.
4
5 #include "chrome/common/net/net_resource_provider.h"
6
7 #include <string>
8
9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h"
11 #include "base/string_piece.h"
12 #include "base/values.h"
13 #include "chrome/common/jstemplate_builder.h"
14 #include "grit/generated_resources.h"
15 #include "grit/net_resources.h"
16
17 namespace {
18
19 // The net module doesn't have access to this HTML or the strings that need to
20 // be localized. The Chrome locale will never change while we're running, so
21 // it's safe to have a static string that we always return a pointer into.
22 // This allows us to have the ResourceProvider return a pointer into the actual
23 // resource (via a StringPiece), instead of always copying resources.
24 struct LazyDirectoryListerCacher {
25 LazyDirectoryListerCacher() {
26 DictionaryValue value;
27 value.SetString(L"header",
28 l10n_util::GetString(IDS_DIRECTORY_LISTING_HEADER));
29 value.SetString(L"parentDirText",
30 l10n_util::GetString(IDS_DIRECTORY_LISTING_PARENT));
31 value.SetString(L"headerName",
32 l10n_util::GetString(IDS_DIRECTORY_LISTING_NAME));
33 value.SetString(L"headerSize",
34 l10n_util::GetString(IDS_DIRECTORY_LISTING_SIZE));
35 value.SetString(L"headerDateModified",
36 l10n_util::GetString(IDS_DIRECTORY_LISTING_DATE_MODIFIED));
37 html_data = jstemplate_builder::GetI18nTemplateHtml(
38 ResourceBundle::GetSharedInstance().GetRawDataResource(
39 IDR_DIR_HEADER_HTML),
40 &value);
41 }
42
43 std::string html_data;
44 };
45
46 } // namespace
47
48 namespace chrome_common_net {
49
50 base::StringPiece NetResourceProvider(int key) {
51 static LazyDirectoryListerCacher lazy_dir_lister;
52
53 if (IDR_DIR_HEADER_HTML == key)
54 return base::StringPiece(lazy_dir_lister.html_data);
55
56 return ResourceBundle::GetSharedInstance().GetRawDataResource(key);
57 }
58
59 } // namespace chrome_common_net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698