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

Side by Side Diff: extensions/browser/api_unittest.cc

Issue 1909773002: Convert //extensions/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 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
« no previous file with comments | « extensions/browser/api_unittest.h ('k') | extensions/browser/app_window/app_window.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api_unittest.h" 5 #include "extensions/browser/api_unittest.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "components/user_prefs/user_prefs.h" 8 #include "components/user_prefs/user_prefs.h"
9 #include "content/public/browser/browser_context.h" 9 #include "content/public/browser/browser_context.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 GURL url = BackgroundInfo::GetBackgroundURL(extension()); 64 GURL url = BackgroundInfo::GetBackgroundURL(extension());
65 if (url.is_empty()) 65 if (url.is_empty())
66 url = GURL(url::kAboutBlankURL); 66 url = GURL(url::kAboutBlankURL);
67 contents_.reset( 67 contents_.reset(
68 content::WebContents::Create(content::WebContents::CreateParams( 68 content::WebContents::Create(content::WebContents::CreateParams(
69 browser_context(), 69 browser_context(),
70 content::SiteInstance::CreateForURL(browser_context(), url)))); 70 content::SiteInstance::CreateForURL(browser_context(), url))));
71 } 71 }
72 } 72 }
73 73
74 scoped_ptr<base::Value> ApiUnitTest::RunFunctionAndReturnValue( 74 std::unique_ptr<base::Value> ApiUnitTest::RunFunctionAndReturnValue(
75 UIThreadExtensionFunction* function, 75 UIThreadExtensionFunction* function,
76 const std::string& args) { 76 const std::string& args) {
77 function->set_extension(extension()); 77 function->set_extension(extension());
78 if (contents_) 78 if (contents_)
79 function->SetRenderFrameHost(contents_->GetMainFrame()); 79 function->SetRenderFrameHost(contents_->GetMainFrame());
80 return scoped_ptr<base::Value>(utils::RunFunctionAndReturnSingleResult( 80 return std::unique_ptr<base::Value>(utils::RunFunctionAndReturnSingleResult(
81 function, args, browser_context())); 81 function, args, browser_context()));
82 } 82 }
83 83
84 scoped_ptr<base::DictionaryValue> ApiUnitTest::RunFunctionAndReturnDictionary( 84 std::unique_ptr<base::DictionaryValue>
85 UIThreadExtensionFunction* function, 85 ApiUnitTest::RunFunctionAndReturnDictionary(UIThreadExtensionFunction* function,
86 const std::string& args) { 86 const std::string& args) {
87 base::Value* value = RunFunctionAndReturnValue(function, args).release(); 87 base::Value* value = RunFunctionAndReturnValue(function, args).release();
88 base::DictionaryValue* dict = NULL; 88 base::DictionaryValue* dict = NULL;
89 89
90 if (value && !value->GetAsDictionary(&dict)) 90 if (value && !value->GetAsDictionary(&dict))
91 delete value; 91 delete value;
92 92
93 // We expect to either have successfuly retrieved a dictionary from the value, 93 // We expect to either have successfuly retrieved a dictionary from the value,
94 // or the value to have been NULL. 94 // or the value to have been NULL.
95 EXPECT_TRUE(dict || !value); 95 EXPECT_TRUE(dict || !value);
96 return scoped_ptr<base::DictionaryValue>(dict); 96 return std::unique_ptr<base::DictionaryValue>(dict);
97 } 97 }
98 98
99 scoped_ptr<base::ListValue> ApiUnitTest::RunFunctionAndReturnList( 99 std::unique_ptr<base::ListValue> ApiUnitTest::RunFunctionAndReturnList(
100 UIThreadExtensionFunction* function, 100 UIThreadExtensionFunction* function,
101 const std::string& args) { 101 const std::string& args) {
102 base::Value* value = RunFunctionAndReturnValue(function, args).release(); 102 base::Value* value = RunFunctionAndReturnValue(function, args).release();
103 base::ListValue* list = NULL; 103 base::ListValue* list = NULL;
104 104
105 if (value && !value->GetAsList(&list)) 105 if (value && !value->GetAsList(&list))
106 delete value; 106 delete value;
107 107
108 // We expect to either have successfuly retrieved a list from the value, 108 // We expect to either have successfuly retrieved a list from the value,
109 // or the value to have been NULL. 109 // or the value to have been NULL.
110 EXPECT_TRUE(list || !value); 110 EXPECT_TRUE(list || !value);
111 return scoped_ptr<base::ListValue>(list); 111 return std::unique_ptr<base::ListValue>(list);
112 } 112 }
113 113
114 std::string ApiUnitTest::RunFunctionAndReturnError( 114 std::string ApiUnitTest::RunFunctionAndReturnError(
115 UIThreadExtensionFunction* function, 115 UIThreadExtensionFunction* function,
116 const std::string& args) { 116 const std::string& args) {
117 function->set_extension(extension()); 117 function->set_extension(extension());
118 if (contents_) 118 if (contents_)
119 function->SetRenderFrameHost(contents_->GetMainFrame()); 119 function->SetRenderFrameHost(contents_->GetMainFrame());
120 return utils::RunFunctionAndReturnError(function, args, browser_context()); 120 return utils::RunFunctionAndReturnError(function, args, browser_context());
121 } 121 }
122 122
123 void ApiUnitTest::RunFunction(UIThreadExtensionFunction* function, 123 void ApiUnitTest::RunFunction(UIThreadExtensionFunction* function,
124 const std::string& args) { 124 const std::string& args) {
125 RunFunctionAndReturnValue(function, args); 125 RunFunctionAndReturnValue(function, args);
126 } 126 }
127 127
128 } // namespace extensions 128 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api_unittest.h ('k') | extensions/browser/app_window/app_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698