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

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

Issue 1550053002: Convert Pass()→std::move() in //chrome/browser/ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
9 #include <string> 8 #include <string>
9 #include <utility>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/feature_list.h" 12 #include "base/feature_list.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/dom_distiller/tab_utils.h" 15 #include "chrome/browser/dom_distiller/tab_utils.h"
16 #include "chrome/browser/printing/print_preview_dialog_controller.h" 16 #include "chrome/browser/printing/print_preview_dialog_controller.h"
17 #include "chrome/browser/printing/print_preview_message_handler.h" 17 #include "chrome/browser/printing/print_preview_message_handler.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/web_contents_sizer.h" 19 #include "chrome/browser/ui/web_contents_sizer.h"
(...skipping 19 matching lines...) Expand all
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(WebContents* web_contents,
46 scoped_ptr<base::DictionaryValue> settings, 46 scoped_ptr<base::DictionaryValue> settings,
47 const base::Closure on_failed_callback) 47 const base::Closure on_failed_callback)
48 : content::WebContentsObserver(web_contents), 48 : content::WebContentsObserver(web_contents),
49 settings_(settings.Pass()), 49 settings_(std::move(settings)),
50 on_failed_callback_(on_failed_callback) { 50 on_failed_callback_(on_failed_callback) {
51 web_contents->SetDelegate(this); 51 web_contents->SetDelegate(this);
52 52
53 // Close ourselves when the application is shutting down. 53 // Close ourselves when the application is shutting down.
54 notification_registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, 54 notification_registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING,
55 content::NotificationService::AllSources()); 55 content::NotificationService::AllSources());
56 56
57 // Register to inform new RenderViews that we're rendering. 57 // Register to inform new RenderViews that we're rendering.
58 notification_registrar_.Add( 58 notification_registrar_.Add(
59 this, content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, 59 this, content::NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 return base::FeatureList::IsEnabled(kFeature); 217 return base::FeatureList::IsEnabled(kFeature);
218 } 218 }
219 219
220 PrintPreviewDistiller::PrintPreviewDistiller( 220 PrintPreviewDistiller::PrintPreviewDistiller(
221 WebContents* source_web_contents, 221 WebContents* source_web_contents,
222 const base::Closure on_failed_callback, 222 const base::Closure on_failed_callback,
223 scoped_ptr<base::DictionaryValue> settings) { 223 scoped_ptr<base::DictionaryValue> settings) {
224 content::SessionStorageNamespace* session_storage_namespace = 224 content::SessionStorageNamespace* session_storage_namespace =
225 source_web_contents->GetController().GetDefaultSessionStorageNamespace(); 225 source_web_contents->GetController().GetDefaultSessionStorageNamespace();
226 CreateDestinationWebContents(session_storage_namespace, source_web_contents, 226 CreateDestinationWebContents(session_storage_namespace, source_web_contents,
227 settings.Pass(), on_failed_callback); 227 std::move(settings), on_failed_callback);
228 228
229 DCHECK(web_contents_); 229 DCHECK(web_contents_);
230 ::DistillAndView(source_web_contents, web_contents_.get()); 230 ::DistillAndView(source_web_contents, web_contents_.get());
231 } 231 }
232 232
233 void PrintPreviewDistiller::CreateDestinationWebContents( 233 void PrintPreviewDistiller::CreateDestinationWebContents(
234 SessionStorageNamespace* session_storage_namespace, 234 SessionStorageNamespace* session_storage_namespace,
235 WebContents* source_web_contents, 235 WebContents* source_web_contents,
236 scoped_ptr<base::DictionaryValue> settings, 236 scoped_ptr<base::DictionaryValue> settings,
237 const base::Closure on_failed_callback) { 237 const base::Closure on_failed_callback) {
238 DCHECK(!web_contents_); 238 DCHECK(!web_contents_);
239 239
240 web_contents_.reset( 240 web_contents_.reset(
241 CreateWebContents(session_storage_namespace, source_web_contents)); 241 CreateWebContents(session_storage_namespace, source_web_contents));
242 242
243 printing::PrintPreviewMessageHandler::CreateForWebContents( 243 printing::PrintPreviewMessageHandler::CreateForWebContents(
244 web_contents_.get()); 244 web_contents_.get());
245 245
246 web_contents_delegate_.reset(new WebContentsDelegateImpl( 246 web_contents_delegate_.reset(new WebContentsDelegateImpl(
247 web_contents_.get(), settings.Pass(), on_failed_callback)); 247 web_contents_.get(), std::move(settings), on_failed_callback));
248 248
249 // Set the size of the distilled WebContents. 249 // Set the size of the distilled WebContents.
250 ResizeWebContents(web_contents_.get(), gfx::Size(1, 1)); 250 ResizeWebContents(web_contents_.get(), gfx::Size(1, 1));
251 251
252 printing::PrintPreviewDialogController* dialog_controller = 252 printing::PrintPreviewDialogController* dialog_controller =
253 printing::PrintPreviewDialogController::GetInstance(); 253 printing::PrintPreviewDialogController::GetInstance();
254 if (!dialog_controller) 254 if (!dialog_controller)
255 return; 255 return;
256 256
257 dialog_controller->AddProxyDialogForWebContents(web_contents_.get(), 257 dialog_controller->AddProxyDialogForWebContents(web_contents_.get(),
(...skipping 16 matching lines...) Expand all
274 WebContents* source_web_contents) { 274 WebContents* source_web_contents) {
275 // TODO(ajwong): Remove the temporary map once prerendering is aware of 275 // TODO(ajwong): Remove the temporary map once prerendering is aware of
276 // multiple session storage namespaces per tab. 276 // multiple session storage namespaces per tab.
277 content::SessionStorageNamespaceMap session_storage_namespace_map; 277 content::SessionStorageNamespaceMap session_storage_namespace_map;
278 Profile* profile = 278 Profile* profile =
279 Profile::FromBrowserContext(source_web_contents->GetBrowserContext()); 279 Profile::FromBrowserContext(source_web_contents->GetBrowserContext());
280 session_storage_namespace_map[std::string()] = session_storage_namespace; 280 session_storage_namespace_map[std::string()] = session_storage_namespace;
281 return WebContents::CreateWithSessionStorage( 281 return WebContents::CreateWithSessionStorage(
282 WebContents::CreateParams(profile), session_storage_namespace_map); 282 WebContents::CreateParams(profile), session_storage_namespace_map);
283 } 283 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698