Commit 3f6485c4 authored by rbpotter's avatar rbpotter Committed by Commit Bot

Printing: Refactor print_dialog_cloud.*

- Move CreateCloudPrintSigninTab() to the
  c/b/ui/webui/print_preview/ directory in a new file, since it's
  only used by the print_preview_handler.
- Delete  print_dialog_cloud_posix.cc since it only contains a
  NOTIMPLEMENTED() function, and instead make the caller and
  print_dialog_cloud.* Windows only.

Bug: 982641
Change-Id: Id292511b4c2b418a809f25957f99f76f9cdcb6fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2143112Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#758117}
parent 9e5925fc
...@@ -4551,9 +4551,6 @@ jumbo_static_library("browser") { ...@@ -4551,9 +4551,6 @@ jumbo_static_library("browser") {
"printing/background_printing_manager.h", "printing/background_printing_manager.h",
"printing/pdf_nup_converter_client.cc", "printing/pdf_nup_converter_client.cc",
"printing/pdf_nup_converter_client.h", "printing/pdf_nup_converter_client.h",
"printing/print_dialog_cloud.cc",
"printing/print_dialog_cloud.h",
"printing/print_dialog_cloud_win.cc",
"printing/print_error_dialog.cc", "printing/print_error_dialog.cc",
"printing/print_error_dialog.h", "printing/print_error_dialog.h",
"printing/print_preview_context_menu_observer.cc", "printing/print_preview_context_menu_observer.cc",
...@@ -4576,8 +4573,11 @@ jumbo_static_library("browser") { ...@@ -4576,8 +4573,11 @@ jumbo_static_library("browser") {
deps += [ "//components/printing/common:mojo_interfaces" ] deps += [ "//components/printing/common:mojo_interfaces" ]
if (is_posix || is_fuchsia) { if (is_win) {
sources += [ "printing/print_dialog_cloud_posix.cc" ] sources += [
"printing/print_dialog_cloud_win.cc",
"printing/print_dialog_cloud_win.h",
]
} }
if (!is_chromeos) { if (!is_chromeos) {
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/printing/print_dialog_cloud.h"
#include "base/logging.h"
namespace print_dialog_cloud {
bool CreatePrintDialogFromCommandLine(Profile* profile,
const base::CommandLine& command_line) {
NOTIMPLEMENTED();
return false;
}
} // namespace print_dialog_cloud
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/printing/print_dialog_cloud.h" #include "chrome/browser/printing/print_dialog_cloud_win.h"
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
...@@ -74,8 +74,8 @@ class PrintDataSetter : public content::WebContentsObserver { ...@@ -74,8 +74,8 @@ class PrintDataSetter : public content::WebContentsObserver {
GURL url = web_contents()->GetURL(); GURL url = web_contents()->GetURL();
if (cloud_devices::IsCloudPrintURL(url)) { if (cloud_devices::IsCloudPrintURL(url)) {
base::string16 origin = base::UTF8ToUTF16(url.GetOrigin().spec()); base::string16 origin = base::UTF8ToUTF16(url.GetOrigin().spec());
content::MessagePortProvider::PostMessageToFrame( content::MessagePortProvider::PostMessageToFrame(web_contents(), origin,
web_contents(), origin, origin, message_data_); origin, message_data_);
} }
} }
......
...@@ -2,14 +2,9 @@ ...@@ -2,14 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_PRINTING_PRINT_DIALOG_CLOUD_H_ #ifndef CHROME_BROWSER_PRINTING_PRINT_DIALOG_CLOUD_WIN_H_
#define CHROME_BROWSER_PRINTING_PRINT_DIALOG_CLOUD_H_ #define CHROME_BROWSER_PRINTING_PRINT_DIALOG_CLOUD_WIN_H_
#include <string>
#include "base/callback_forward.h"
class Browser;
class Profile; class Profile;
namespace base { namespace base {
...@@ -18,16 +13,10 @@ class CommandLine; ...@@ -18,16 +13,10 @@ class CommandLine;
namespace print_dialog_cloud { namespace print_dialog_cloud {
// Creates a tab with Google 'sign in' or 'add account' page, based on
// passed |add_account| value.
void CreateCloudPrintSigninTab(Browser* browser,
bool add_account,
base::OnceClosure callback);
// Parse switches from command_line and display the print dialog as appropriate. // Parse switches from command_line and display the print dialog as appropriate.
bool CreatePrintDialogFromCommandLine(Profile* profile, bool CreatePrintDialogFromCommandLine(Profile* profile,
const base::CommandLine& command_line); const base::CommandLine& command_line);
} // namespace print_dialog_cloud } // namespace print_dialog_cloud
#endif // CHROME_BROWSER_PRINTING_PRINT_DIALOG_CLOUD_H_ #endif // CHROME_BROWSER_PRINTING_PRINT_DIALOG_CLOUD_WIN_H_
...@@ -4180,6 +4180,8 @@ jumbo_static_library("ui") { ...@@ -4180,6 +4180,8 @@ jumbo_static_library("ui") {
} }
if (enable_print_preview) { if (enable_print_preview) {
sources += [ sources += [
"webui/print_preview/cloud_print_signin.cc",
"webui/print_preview/cloud_print_signin.h",
"webui/print_preview/cloud_printer_handler.cc", "webui/print_preview/cloud_printer_handler.cc",
"webui/print_preview/cloud_printer_handler.h", "webui/print_preview/cloud_printer_handler.h",
"webui/print_preview/extension_printer_handler.cc", "webui/print_preview/extension_printer_handler.cc",
......
...@@ -96,11 +96,10 @@ ...@@ -96,11 +96,10 @@
#include "chrome/browser/notifications/win/notification_launch_id.h" #include "chrome/browser/notifications/win/notification_launch_id.h"
#include "chrome/browser/ui/webui/settings/reset_settings_handler.h" #include "chrome/browser/ui/webui/settings/reset_settings_handler.h"
#include "chrome/credential_provider/common/gcp_strings.h" #include "chrome/credential_provider/common/gcp_strings.h"
#endif
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/printing/print_dialog_cloud.h" #include "chrome/browser/printing/print_dialog_cloud_win.h"
#endif #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW)
#endif // defined(OS_WIN)
using content::BrowserThread; using content::BrowserThread;
using content::ChildProcessSecurityPolicy; using content::ChildProcessSecurityPolicy;
...@@ -609,7 +608,7 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( ...@@ -609,7 +608,7 @@ bool StartupBrowserCreator::ProcessCmdLineImpl(
!IncognitoModePrefs::ShouldLaunchIncognito( !IncognitoModePrefs::ShouldLaunchIncognito(
command_line, last_used_profile->GetPrefs())); command_line, last_used_profile->GetPrefs()));
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) #if defined(OS_WIN) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
// If we are just displaying a print dialog we shouldn't open browser // If we are just displaying a print dialog we shouldn't open browser
// windows. // windows.
if (command_line.HasSwitch(switches::kCloudPrintFile) && if (command_line.HasSwitch(switches::kCloudPrintFile) &&
...@@ -618,7 +617,7 @@ bool StartupBrowserCreator::ProcessCmdLineImpl( ...@@ -618,7 +617,7 @@ bool StartupBrowserCreator::ProcessCmdLineImpl(
command_line)) { command_line)) {
silent_launch = true; silent_launch = true;
} }
#endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) #endif // defined(OS_WIN) && BUILDFLAG(ENABLE_PRINT_PREVIEW)
if (command_line.HasSwitch(switches::kValidateCrx)) { if (command_line.HasSwitch(switches::kValidateCrx)) {
if (!process_startup) { if (!process_startup) {
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/printing/print_dialog_cloud.h" #include "chrome/browser/ui/webui/print_preview/cloud_print_signin.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/macros.h" #include "base/macros.h"
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
namespace print_dialog_cloud { namespace printing {
namespace { namespace {
...@@ -73,4 +73,4 @@ void CreateCloudPrintSigninTab(Browser* browser, ...@@ -73,4 +73,4 @@ void CreateCloudPrintSigninTab(Browser* browser,
new SignInObserver(web_contents, std::move(callback)); new SignInObserver(web_contents, std::move(callback));
} }
} // namespace print_dialog_cloud } // namespace printing
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_CLOUD_PRINT_SIGNIN_H_
#define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_CLOUD_PRINT_SIGNIN_H_
#include "base/callback_forward.h"
class Browser;
namespace printing {
// Creates a tab with Google 'sign in' or 'add account' page, based on
// passed |add_account| value.
void CreateCloudPrintSigninTab(Browser* browser,
bool add_account,
base::OnceClosure callback);
} // namespace printing
#endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_CLOUD_PRINT_SIGNIN_H_
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "chrome/browser/bad_message.h" #include "chrome/browser/bad_message.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/printing/background_printing_manager.h" #include "chrome/browser/printing/background_printing_manager.h"
#include "chrome/browser/printing/print_dialog_cloud.h"
#include "chrome/browser/printing/print_error_dialog.h" #include "chrome/browser/printing/print_error_dialog.h"
#include "chrome/browser/printing/print_job_manager.h" #include "chrome/browser/printing/print_job_manager.h"
#include "chrome/browser/printing/print_preview_dialog_controller.h" #include "chrome/browser/printing/print_preview_dialog_controller.h"
...@@ -45,6 +44,7 @@ ...@@ -45,6 +44,7 @@
#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/chrome_pages.h" #include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/browser/ui/webui/print_preview/cloud_print_signin.h"
#include "chrome/browser/ui/webui/print_preview/pdf_printer_handler.h" #include "chrome/browser/ui/webui/print_preview/pdf_printer_handler.h"
#include "chrome/browser/ui/webui/print_preview/policy_settings.h" #include "chrome/browser/ui/webui/print_preview/policy_settings.h"
#include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
...@@ -965,7 +965,7 @@ void PrintPreviewHandler::HandleSignin(const base::ListValue* args) { ...@@ -965,7 +965,7 @@ void PrintPreviewHandler::HandleSignin(const base::ListValue* args) {
#endif #endif
chrome::ScopedTabbedBrowserDisplayer displayer(profile); chrome::ScopedTabbedBrowserDisplayer displayer(profile);
print_dialog_cloud::CreateCloudPrintSigninTab( CreateCloudPrintSigninTab(
displayer.browser(), add_account, displayer.browser(), add_account,
base::BindOnce(&PrintPreviewHandler::OnSignInTabClosed, base::BindOnce(&PrintPreviewHandler::OnSignInTabClosed,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment