OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 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/browser/net/metadata_url_request.h" | 5 #include "chrome/browser/net/metadata_url_request.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/browser/parsers/metadata_parser_manager.h" | 10 #include "chrome/browser/parsers/metadata_parser_manager.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 int *bytes_read) { | 68 int *bytes_read) { |
69 FilePath path; | 69 FilePath path; |
70 | 70 |
71 if (!request()->url().is_valid()) { | 71 if (!request()->url().is_valid()) { |
72 return false; | 72 return false; |
73 } | 73 } |
74 if (!net::FileURLToFilePath(request()->url(), &path)) { | 74 if (!net::FileURLToFilePath(request()->url(), &path)) { |
75 return false; | 75 return false; |
76 } | 76 } |
77 if (!parsed) { | 77 if (!parsed) { |
78 MetadataParserManager* manager = MetadataParserManager::Get(); | 78 MetadataParserManager* manager = MetadataParserManager::GetInstance(); |
79 scoped_ptr<MetadataParser> parser(manager->GetParserForFile(path)); | 79 scoped_ptr<MetadataParser> parser(manager->GetParserForFile(path)); |
80 if (parser != NULL) { | 80 if (parser != NULL) { |
81 result_ = "{\n"; | 81 result_ = "{\n"; |
82 parser->Parse(); | 82 parser->Parse(); |
83 MetadataPropertyIterator *iter = parser->GetPropertyIterator(); | 83 MetadataPropertyIterator *iter = parser->GetPropertyIterator(); |
84 while (!iter->IsEnd()) { | 84 while (!iter->IsEnd()) { |
85 std::string key; | 85 std::string key; |
86 std::string value; | 86 std::string value; |
87 if (iter->GetNext(&key, &value)) { | 87 if (iter->GetNext(&key, &value)) { |
88 result_ += "\""; | 88 result_ += "\""; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 123 } |
124 | 124 |
125 } // namespace | 125 } // namespace |
126 | 126 |
127 void RegisterMetadataURLRequestHandler() { | 127 void RegisterMetadataURLRequestHandler() { |
128 #if defined(OS_CHROMEOS) | 128 #if defined(OS_CHROMEOS) |
129 net::URLRequest::RegisterProtocolFactory(chrome::kMetadataScheme, | 129 net::URLRequest::RegisterProtocolFactory(chrome::kMetadataScheme, |
130 &MetadataRequestHandler::Factory); | 130 &MetadataRequestHandler::Factory); |
131 #endif | 131 #endif |
132 } | 132 } |
OLD | NEW |