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

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

Issue 10388214: Make cloud print dialog creation function not use browser list, instead obtain profile and parent w… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/printing/printing_message_filter.cc ('k') | chrome/common/print_messages.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_handler.h" 5 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 29 matching lines...) Expand all
40 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" 40 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
41 #include "chrome/browser/ui/webui/print_preview/sticky_settings.h" 41 #include "chrome/browser/ui/webui/print_preview/sticky_settings.h"
42 #include "chrome/common/chrome_paths.h" 42 #include "chrome/common/chrome_paths.h"
43 #include "chrome/common/pref_names.h" 43 #include "chrome/common/pref_names.h"
44 #include "chrome/common/print_messages.h" 44 #include "chrome/common/print_messages.h"
45 #include "content/public/browser/browser_thread.h" 45 #include "content/public/browser/browser_thread.h"
46 #include "content/public/browser/navigation_controller.h" 46 #include "content/public/browser/navigation_controller.h"
47 #include "content/public/browser/navigation_entry.h" 47 #include "content/public/browser/navigation_entry.h"
48 #include "content/public/browser/render_view_host.h" 48 #include "content/public/browser/render_view_host.h"
49 #include "content/public/browser/web_contents.h" 49 #include "content/public/browser/web_contents.h"
50 #include "content/public/browser/web_contents_view.h"
50 #include "content/public/browser/web_contents_delegate.h" 51 #include "content/public/browser/web_contents_delegate.h"
51 #include "content/public/browser/web_ui.h" 52 #include "content/public/browser/web_ui.h"
52 #include "printing/backend/print_backend.h" 53 #include "printing/backend/print_backend.h"
53 #include "printing/metafile.h" 54 #include "printing/metafile.h"
54 #include "printing/metafile_impl.h" 55 #include "printing/metafile_impl.h"
55 #include "printing/page_range.h" 56 #include "printing/page_range.h"
56 #include "printing/page_size_margins.h" 57 #include "printing/page_size_margins.h"
57 #include "printing/print_settings.h" 58 #include "printing/print_settings.h"
58 #include "unicode/ulocdata.h" 59 #include "unicode/ulocdata.h"
59 60
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 const base::WeakPtr<PrintPreviewHandler>& handler) { 541 const base::WeakPtr<PrintPreviewHandler>& handler) {
541 if (handler.get()) { 542 if (handler.get()) {
542 PrintPreviewUI* print_preview_ui = 543 PrintPreviewUI* print_preview_ui =
543 static_cast<PrintPreviewUI*>(handler->web_ui()->GetController()); 544 static_cast<PrintPreviewUI*>(handler->web_ui()->GetController());
544 if (print_preview_ui) 545 if (print_preview_ui)
545 print_preview_ui->OnReloadPrintersList(); 546 print_preview_ui->OnReloadPrintersList();
546 } 547 }
547 } 548 }
548 549
549 void PrintPreviewHandler::HandleSignin(const ListValue* /*args*/) { 550 void PrintPreviewHandler::HandleSignin(const ListValue* /*args*/) {
551 gfx::NativeWindow modal_parent =
552 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow();
550 print_dialog_cloud::CreateCloudPrintSigninDialog( 553 print_dialog_cloud::CreateCloudPrintSigninDialog(
554 web_ui()->GetWebContents()->GetBrowserContext(),
555 modal_parent,
551 base::Bind(&PrintPreviewHandler::OnSigninComplete, AsWeakPtr())); 556 base::Bind(&PrintPreviewHandler::OnSigninComplete, AsWeakPtr()));
552 } 557 }
553 558
554 void PrintPreviewHandler::HandlePrintWithCloudPrint() { 559 void PrintPreviewHandler::HandlePrintWithCloudPrint() {
555 // Record the number of times the user asks to print via cloud print 560 // Record the number of times the user asks to print via cloud print
556 // instead of the print preview dialog. 561 // instead of the print preview dialog.
557 ReportStats(); 562 ReportStats();
558 563
559 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( 564 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(
560 web_ui()->GetController()); 565 web_ui()->GetController());
561 scoped_refptr<base::RefCountedBytes> data; 566 scoped_refptr<base::RefCountedBytes> data;
562 print_preview_ui->GetPrintPreviewDataForIndex( 567 print_preview_ui->GetPrintPreviewDataForIndex(
563 printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &data); 568 printing::COMPLETE_PREVIEW_DOCUMENT_INDEX, &data);
564 if (!data.get()) { 569 if (!data.get()) {
565 NOTREACHED(); 570 NOTREACHED();
566 return; 571 return;
567 } 572 }
568 DCHECK_GT(data->size(), 0U); 573 DCHECK_GT(data->size(), 0U);
569 print_dialog_cloud::CreatePrintDialogForBytes(data, 574
575 gfx::NativeWindow modal_parent =
576 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow();
577 print_dialog_cloud::CreatePrintDialogForBytes(
578 web_ui()->GetWebContents()->GetBrowserContext(),
579 modal_parent,
580 data,
570 string16(print_preview_ui->initiator_tab_title()), 581 string16(print_preview_ui->initiator_tab_title()),
571 string16(), 582 string16(),
572 std::string("application/pdf"), 583 std::string("application/pdf"));
573 true);
574 584
575 // Once the cloud print dialog comes up we're no longer in a background 585 // Once the cloud print dialog comes up we're no longer in a background
576 // printing situation. Close the print preview. 586 // printing situation. Close the print preview.
577 // TODO(abodenha@chromium.org) The flow should be changed as described in 587 // TODO(abodenha@chromium.org) The flow should be changed as described in
578 // http://code.google.com/p/chromium/issues/detail?id=44093 588 // http://code.google.com/p/chromium/issues/detail?id=44093
579 ActivateInitiatorTabAndClosePreviewTab(); 589 ActivateInitiatorTabAndClosePreviewTab();
580 } 590 }
581 591
582 void PrintPreviewHandler::HandleManageCloudPrint(const ListValue* /*args*/) { 592 void PrintPreviewHandler::HandleManageCloudPrint(const ListValue* /*args*/) {
583 ++manage_cloud_printers_dialog_request_count_; 593 ++manage_cloud_printers_dialog_request_count_;
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 return; 915 return;
906 916
907 // We no longer require the initiator tab details. Remove those details 917 // We no longer require the initiator tab details. Remove those details
908 // associated with the preview tab to allow the initiator tab to create 918 // associated with the preview tab to allow the initiator tab to create
909 // another preview tab. 919 // another preview tab.
910 printing::PrintPreviewTabController* tab_controller = 920 printing::PrintPreviewTabController* tab_controller =
911 printing::PrintPreviewTabController::GetInstance(); 921 printing::PrintPreviewTabController::GetInstance();
912 if (tab_controller) 922 if (tab_controller)
913 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper()); 923 tab_controller->EraseInitiatorTabInfo(preview_tab_wrapper());
914 } 924 }
OLDNEW
« no previous file with comments | « chrome/browser/printing/printing_message_filter.cc ('k') | chrome/common/print_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698