OLD | NEW |
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/browser/chromeos/file_manager/url_util.h" | 5 #include "chrome/browser/chromeos/file_manager/url_util.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
8 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 11 #include "base/json/json_writer.h" |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "net/base/escape.h" | 14 #include "net/base/escape.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 | 16 |
16 namespace file_manager { | 17 namespace file_manager { |
17 namespace util { | 18 namespace util { |
18 namespace { | 19 namespace { |
19 | 20 |
20 // Pretty print the JSON escaped in the query string. | 21 // Pretty print the JSON escaped in the query string. |
21 std::string PrettyPrintEscapedJson(const std::string& query) { | 22 std::string PrettyPrintEscapedJson(const std::string& query) { |
22 const std::string json = net::UnescapeURLComponent( | 23 const std::string json = net::UnescapeURLComponent( |
23 query, net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS | | 24 query, net::UnescapeRule::SPACES | net::UnescapeRule::PATH_SEPARATORS | |
24 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS); | 25 net::UnescapeRule::URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS); |
25 scoped_ptr<base::Value> value = base::JSONReader::Read(json); | 26 std::unique_ptr<base::Value> value = base::JSONReader::Read(json); |
26 std::string pretty_json; | 27 std::string pretty_json; |
27 base::JSONWriter::WriteWithOptions( | 28 base::JSONWriter::WriteWithOptions( |
28 *value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &pretty_json); | 29 *value, base::JSONWriter::OPTIONS_PRETTY_PRINT, &pretty_json); |
29 return pretty_json; | 30 return pretty_json; |
30 } | 31 } |
31 | 32 |
32 TEST(FileManagerUrlUtilTest, GetFileManagerMainPageUrl) { | 33 TEST(FileManagerUrlUtilTest, GetFileManagerMainPageUrl) { |
33 EXPECT_EQ("chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj/main.html", | 34 EXPECT_EQ("chrome-extension://hhaomjibdihmijegdhdafkllkbggdgoj/main.html", |
34 GetFileManagerMainPageUrl().spec()); | 35 GetFileManagerMainPageUrl().spec()); |
35 } | 36 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 " \"extensions\": [ \"txt\" ],\n" | 122 " \"extensions\": [ \"txt\" ],\n" |
122 " \"selected\": false\n" | 123 " \"selected\": false\n" |
123 " } ]\n" | 124 " } ]\n" |
124 "}\n", | 125 "}\n", |
125 PrettyPrintEscapedJson(url.query())); | 126 PrettyPrintEscapedJson(url.query())); |
126 } | 127 } |
127 | 128 |
128 } // namespace | 129 } // namespace |
129 } // namespace util | 130 } // namespace util |
130 } // namespace file_manager | 131 } // namespace file_manager |
OLD | NEW |