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

Side by Side Diff: chrome/browser/extensions/api/messaging/native_messaging_host_manifest_unittest.cc

Issue 100823007: Stop doing unnecessary UTF-8 to UTF-16 conversions in JSONWriter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ChromeOS page encodings Created 7 years 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/extensions/api/messaging/native_messaging_host_manifest .h" 5 #include "chrome/browser/extensions/api/messaging/native_messaging_host_manifest .h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/json/string_escape.h" 10 #include "base/json/string_escape.h"
(...skipping 16 matching lines...) Expand all
27 public: 27 public:
28 virtual void SetUp() OVERRIDE { 28 virtual void SetUp() OVERRIDE {
29 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 29 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
30 manifest_path_ = temp_dir_.path().AppendASCII("test.json"); 30 manifest_path_ = temp_dir_.path().AppendASCII("test.json");
31 } 31 }
32 32
33 protected: 33 protected:
34 bool WriteManifest(const std::string& name, 34 bool WriteManifest(const std::string& name,
35 const std::string& path, 35 const std::string& path,
36 const std::string& origin) { 36 const std::string& origin) {
37 std::string escaped_path;
38 base::JsonDoubleQuote(path, false, &escaped_path);
39 return WriteManifest("{" 37 return WriteManifest("{"
40 " \"name\": \"" + name + "\"," 38 " \"name\": \"" + name + "\","
41 " \"description\": \"Native Messaging Test\"," 39 " \"description\": \"Native Messaging Test\","
42 " \"path\": \"" + escaped_path + "\"," 40 " \"path\": " + base::GetQuotedJSONString(path) + ","
43 " \"type\": \"stdio\"," 41 " \"type\": \"stdio\","
44 " \"allowed_origins\": [" 42 " \"allowed_origins\": ["
45 " \"" + origin + "\"" 43 " \"" + origin + "\""
46 " ]" 44 " ]"
47 "}"); 45 "}");
48 } 46 }
49 47
50 bool WriteManifest(const std::string& manifest_content) { 48 bool WriteManifest(const std::string& manifest_content) {
51 return file_util::WriteFile( 49 return file_util::WriteFile(
52 manifest_path_, manifest_content.data(), manifest_content.size()); 50 manifest_path_, manifest_content.data(), manifest_content.size());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 "chrome-extension://*/")); 106 "chrome-extension://*/"));
109 107
110 std::string error_message; 108 std::string error_message;
111 scoped_ptr<NativeMessagingHostManifest> manifest = 109 scoped_ptr<NativeMessagingHostManifest> manifest =
112 NativeMessagingHostManifest::Load(manifest_path_, &error_message); 110 NativeMessagingHostManifest::Load(manifest_path_, &error_message);
113 ASSERT_FALSE(manifest); 111 ASSERT_FALSE(manifest);
114 EXPECT_FALSE(error_message.empty()); 112 EXPECT_FALSE(error_message.empty());
115 } 113 }
116 114
117 } // namespace extensions 115 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/activity_log/activity_log_unittest.cc ('k') | chrome/browser/resources/chromeos/login/login.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698