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

Side by Side Diff: chrome/browser/ui/webui/print_preview/print_preview_distiller.cc

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/ui/webui/print_preview/print_preview_distiller.h" 5 #include "chrome/browser/ui/webui/print_preview/print_preview_distiller.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 24 matching lines...) Expand all
35 using content::OpenURLParams; 35 using content::OpenURLParams;
36 using content::RenderViewHost; 36 using content::RenderViewHost;
37 using content::SessionStorageNamespace; 37 using content::SessionStorageNamespace;
38 using content::WebContents; 38 using content::WebContents;
39 39
40 class PrintPreviewDistiller::WebContentsDelegateImpl 40 class PrintPreviewDistiller::WebContentsDelegateImpl
41 : public content::WebContentsDelegate, 41 : public content::WebContentsDelegate,
42 public content::NotificationObserver, 42 public content::NotificationObserver,
43 public content::WebContentsObserver { 43 public content::WebContentsObserver {
44 public: 44 public:
45 explicit WebContentsDelegateImpl(WebContents* web_contents, 45 explicit WebContentsDelegateImpl(
46 scoped_ptr<base::DictionaryValue> settings, 46 WebContents* web_contents,
47 const base::Closure on_failed_callback) 47 std::unique_ptr<base::DictionaryValue> settings,
48 const base::Closure on_failed_callback)
48 : content::WebContentsObserver(web_contents), 49 : content::WebContentsObserver(web_contents),
49 settings_(std::move(settings)), 50 settings_(std::move(settings)),
50 on_failed_callback_(on_failed_callback) { 51 on_failed_callback_(on_failed_callback) {
51 web_contents->SetDelegate(this); 52 web_contents->SetDelegate(this);
52 53
53 // Close ourselves when the application is shutting down. 54 // Close ourselves when the application is shutting down.
54 notification_registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, 55 notification_registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING,
55 content::NotificationService::AllSources()); 56 content::NotificationService::AllSources());
56 57
57 // Register to inform new RenderViews that we're rendering. 58 // Register to inform new RenderViews that we're rendering.
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 break; 196 break;
196 } 197 }
197 198
198 default: 199 default:
199 NOTREACHED() << "Unexpected notification sent."; 200 NOTREACHED() << "Unexpected notification sent.";
200 break; 201 break;
201 } 202 }
202 } 203 }
203 204
204 private: 205 private:
205 scoped_ptr<base::DictionaryValue> settings_; 206 std::unique_ptr<base::DictionaryValue> settings_;
206 content::NotificationRegistrar notification_registrar_; 207 content::NotificationRegistrar notification_registrar_;
207 208
208 // The callback called when the preview failed. 209 // The callback called when the preview failed.
209 base::Closure on_failed_callback_; 210 base::Closure on_failed_callback_;
210 }; 211 };
211 212
212 const base::Feature PrintPreviewDistiller::kFeature = { 213 const base::Feature PrintPreviewDistiller::kFeature = {
213 "PrintPreviewDistiller", base::FEATURE_ENABLED_BY_DEFAULT, 214 "PrintPreviewDistiller", base::FEATURE_ENABLED_BY_DEFAULT,
214 }; 215 };
215 216
216 bool PrintPreviewDistiller::IsEnabled() { 217 bool PrintPreviewDistiller::IsEnabled() {
217 return base::FeatureList::IsEnabled(kFeature); 218 return base::FeatureList::IsEnabled(kFeature);
218 } 219 }
219 220
220 PrintPreviewDistiller::PrintPreviewDistiller( 221 PrintPreviewDistiller::PrintPreviewDistiller(
221 WebContents* source_web_contents, 222 WebContents* source_web_contents,
222 const base::Closure on_failed_callback, 223 const base::Closure on_failed_callback,
223 scoped_ptr<base::DictionaryValue> settings) { 224 std::unique_ptr<base::DictionaryValue> settings) {
224 content::SessionStorageNamespace* session_storage_namespace = 225 content::SessionStorageNamespace* session_storage_namespace =
225 source_web_contents->GetController().GetDefaultSessionStorageNamespace(); 226 source_web_contents->GetController().GetDefaultSessionStorageNamespace();
226 CreateDestinationWebContents(session_storage_namespace, source_web_contents, 227 CreateDestinationWebContents(session_storage_namespace, source_web_contents,
227 std::move(settings), on_failed_callback); 228 std::move(settings), on_failed_callback);
228 229
229 DCHECK(web_contents_); 230 DCHECK(web_contents_);
230 ::DistillAndView(source_web_contents, web_contents_.get()); 231 ::DistillAndView(source_web_contents, web_contents_.get());
231 } 232 }
232 233
233 void PrintPreviewDistiller::CreateDestinationWebContents( 234 void PrintPreviewDistiller::CreateDestinationWebContents(
234 SessionStorageNamespace* session_storage_namespace, 235 SessionStorageNamespace* session_storage_namespace,
235 WebContents* source_web_contents, 236 WebContents* source_web_contents,
236 scoped_ptr<base::DictionaryValue> settings, 237 std::unique_ptr<base::DictionaryValue> settings,
237 const base::Closure on_failed_callback) { 238 const base::Closure on_failed_callback) {
238 DCHECK(!web_contents_); 239 DCHECK(!web_contents_);
239 240
240 web_contents_.reset( 241 web_contents_.reset(
241 CreateWebContents(session_storage_namespace, source_web_contents)); 242 CreateWebContents(session_storage_namespace, source_web_contents));
242 243
243 printing::PrintPreviewMessageHandler::CreateForWebContents( 244 printing::PrintPreviewMessageHandler::CreateForWebContents(
244 web_contents_.get()); 245 web_contents_.get());
245 246
246 web_contents_delegate_.reset(new WebContentsDelegateImpl( 247 web_contents_delegate_.reset(new WebContentsDelegateImpl(
(...skipping 27 matching lines...) Expand all
274 WebContents* source_web_contents) { 275 WebContents* source_web_contents) {
275 // TODO(ajwong): Remove the temporary map once prerendering is aware of 276 // TODO(ajwong): Remove the temporary map once prerendering is aware of
276 // multiple session storage namespaces per tab. 277 // multiple session storage namespaces per tab.
277 content::SessionStorageNamespaceMap session_storage_namespace_map; 278 content::SessionStorageNamespaceMap session_storage_namespace_map;
278 Profile* profile = 279 Profile* profile =
279 Profile::FromBrowserContext(source_web_contents->GetBrowserContext()); 280 Profile::FromBrowserContext(source_web_contents->GetBrowserContext());
280 session_storage_namespace_map[std::string()] = session_storage_namespace; 281 session_storage_namespace_map[std::string()] = session_storage_namespace;
281 return WebContents::CreateWithSessionStorage( 282 return WebContents::CreateWithSessionStorage(
282 WebContents::CreateParams(profile), session_storage_namespace_map); 283 WebContents::CreateParams(profile), session_storage_namespace_map);
283 } 284 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698