summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/app_controller_mac.mm4
-rw-r--r--chrome/browser/chrome_content_browser_client.cc2
-rw-r--r--chrome/browser/printing/print_dialog_cloud.cc199
-rw-r--r--chrome/browser/printing/print_dialog_cloud.h28
-rw-r--r--chrome/browser/printing/print_dialog_cloud_interative_uitest.cc8
-rw-r--r--chrome/browser/printing/print_dialog_cloud_internal.h25
-rw-r--r--chrome/browser/printing/print_dialog_cloud_unittest.cc3
-rw-r--r--chrome/browser/printing/printing_message_filter.cc18
-rw-r--r--chrome/browser/printing/printing_message_filter.h6
-rw-r--r--chrome/browser/ui/webui/print_preview/print_preview_handler.cc16
-rw-r--r--chrome/common/print_messages.h3
-rw-r--r--chrome/renderer/chrome_mock_render_thread.cc3
-rw-r--r--chrome/renderer/chrome_mock_render_thread.h2
-rw-r--r--chrome/renderer/print_web_view_helper_linux.cc3
14 files changed, 134 insertions, 186 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index d2acb6b..4631613 100644
--- a/chrome/browser/app_controller_mac.mm
+++ b/chrome/browser/app_controller_mac.mm
@@ -1140,9 +1140,9 @@ const AEEventClass kAECloudPrintUninstallClass = 'GCPu';
string16 title16 = base::SysNSStringToUTF16(printTitle);
string16 printTicket16 = base::SysNSStringToUTF16(printTicket);
print_dialog_cloud::CreatePrintDialogForFile(
- ProfileManager::GetDefaultProfile(), NULL,
FilePath([inputPath UTF8String]), title16,
- printTicket16, [mime UTF8String], /*delete_on_close=*/false);
+ printTicket16, [mime UTF8String], /*modal=*/false,
+ /*delete_on_close=*/false);
}
}
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index caf509a..204d69f 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -412,7 +412,7 @@ void ChromeContentBrowserClient::RenderProcessHostCreated(
id, profile, profile->GetRequestContextForRenderProcess(id)));
host->GetChannel()->AddFilter(new PluginInfoMessageFilter(id, profile));
#if !defined(OS_ANDROID)
- host->GetChannel()->AddFilter(new PrintingMessageFilter(id));
+ host->GetChannel()->AddFilter(new PrintingMessageFilter());
#endif
host->GetChannel()->AddFilter(
new SearchProviderInstallStateMessageFilter(id, profile));
diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc
index c728e74..fc4aa38 100644
--- a/chrome/browser/printing/print_dialog_cloud.cc
+++ b/chrome/browser/printing/print_dialog_cloud.cc
@@ -20,7 +20,12 @@
#include "chrome/browser/printing/cloud_print/cloud_print_url.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_window.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/print_messages.h"
@@ -476,13 +481,13 @@ void CloudPrintFlowHandler::StoreDialogClientSize() const {
}
CloudPrintWebDialogDelegate::CloudPrintWebDialogDelegate(
- content::BrowserContext* browser_context,
- gfx::NativeWindow modal_parent,
const FilePath& path_to_file,
+ int width, int height,
const std::string& json_arguments,
const string16& print_job_title,
const string16& print_ticket,
const std::string& file_type,
+ bool modal,
bool delete_on_close,
bool close_after_signin,
const base::Closure& callback)
@@ -493,68 +498,39 @@ CloudPrintWebDialogDelegate::CloudPrintWebDialogDelegate(
file_type,
close_after_signin,
callback)),
- modal_parent_(modal_parent),
+ modal_(modal),
owns_flow_handler_(true),
path_to_file_(path_to_file) {
- Init(browser_context, json_arguments);
+ Init(width, height, json_arguments);
}
// For unit testing.
CloudPrintWebDialogDelegate::CloudPrintWebDialogDelegate(
- const FilePath& path_to_file,
CloudPrintFlowHandler* flow_handler,
+ int width, int height,
const std::string& json_arguments,
+ bool modal,
bool delete_on_close)
: delete_on_close_(delete_on_close),
flow_handler_(flow_handler),
- modal_parent_(NULL),
+ modal_(modal),
owns_flow_handler_(true) {
- Init(NULL, json_arguments);
+ Init(width, height, json_arguments);
}
-// Returns the persisted width/height for the print dialog.
-void GetDialogWidthAndHeightFromPrefs(content::BrowserContext* browser_context,
- int* width,
- int* height) {
- const int kDefaultWidth = 912;
- const int kDefaultHeight = 633;
- if (!browser_context) {
- *width = kDefaultWidth;
- *height = kDefaultHeight;
- return;
- }
-
- Profile* profile = Profile::FromBrowserContext(browser_context);
- if (!profile->GetPrefs()->FindPreference(prefs::kCloudPrintDialogWidth)) {
- profile->GetPrefs()->RegisterIntegerPref(prefs::kCloudPrintDialogWidth,
- kDefaultWidth,
- PrefService::UNSYNCABLE_PREF);
- }
- if (!profile->GetPrefs()->FindPreference(prefs::kCloudPrintDialogHeight)) {
- profile->GetPrefs()->RegisterIntegerPref(prefs::kCloudPrintDialogHeight,
- kDefaultHeight,
- PrefService::UNSYNCABLE_PREF);
- }
-
- *width = profile->GetPrefs()->GetInteger(prefs::kCloudPrintDialogWidth);
- *height = profile->GetPrefs()->GetInteger(prefs::kCloudPrintDialogHeight);
-}
-
-void CloudPrintWebDialogDelegate::Init(content::BrowserContext* browser_context,
+void CloudPrintWebDialogDelegate::Init(int width, int height,
const std::string& json_arguments) {
// This information is needed to show the dialog HTML content.
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
-
params_.url = GURL(chrome::kChromeUICloudPrintResourcesURL);
- GetDialogWidthAndHeightFromPrefs(browser_context,
- &params_.width,
- &params_.height);
+ params_.height = height;
+ params_.width = width;
params_.json_input = json_arguments;
flow_handler_->SetDialogDelegate(this);
// If we're not modal we can show the dialog with no browser.
// We need this to keep Chrome alive while our dialog is up.
- if (!modal_parent_)
+ if (!modal_)
browser::StartKeepAlive();
}
@@ -569,7 +545,7 @@ CloudPrintWebDialogDelegate::~CloudPrintWebDialogDelegate() {
}
ui::ModalType CloudPrintWebDialogDelegate::GetDialogModalType() const {
- return modal_parent_ ? ui::MODAL_TYPE_WINDOW : ui::MODAL_TYPE_NONE;
+ return modal_ ? ui::MODAL_TYPE_WINDOW : ui::MODAL_TYPE_NONE;
}
string16 CloudPrintWebDialogDelegate::GetDialogTitle() const {
@@ -611,7 +587,7 @@ void CloudPrintWebDialogDelegate::OnDialogClosed(
// If we're modal we can show the dialog with no browser.
// End the keep-alive so that Chrome can exit.
- if (!modal_parent_)
+ if (!modal_)
browser::EndKeepAlive();
delete this;
}
@@ -631,12 +607,11 @@ bool CloudPrintWebDialogDelegate::HandleContextMenu(
return true;
}
-void CreatePrintDialogForBytesImpl(content::BrowserContext* browser_context,
- gfx::NativeWindow modal_parent,
- scoped_refptr<base::RefCountedBytes> data,
+void CreatePrintDialogForBytesImpl(scoped_refptr<base::RefCountedBytes> data,
const string16& print_job_title,
const string16& print_ticket,
- const std::string& file_type) {
+ const std::string& file_type,
+ bool modal) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
// TODO(abodenha@chromium.org) Writing the PDF to a file before printing
// is wasteful. Modify the dialog flow to pull PDF data from memory.
@@ -647,61 +622,83 @@ void CreatePrintDialogForBytesImpl(content::BrowserContext* browser_context,
reinterpret_cast<const char*>(data->front()),
data->size());
}
- print_dialog_cloud::CreatePrintDialogForFile(browser_context,
- modal_parent,
- path,
+ print_dialog_cloud::CreatePrintDialogForFile(path,
print_job_title,
print_ticket,
file_type,
+ modal,
true);
}
// Called from the UI thread, starts up the dialog.
-void CreateDialogImpl(content::BrowserContext* browser_context,
- gfx::NativeWindow modal_parent,
- const FilePath& path_to_file,
+void CreateDialogImpl(const FilePath& path_to_file,
const string16& print_job_title,
const string16& print_ticket,
const std::string& file_type,
+ bool modal,
bool delete_on_close,
bool close_after_signin,
const base::Closure& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ Browser* browser = BrowserList::GetLastActive();
+
+ const int kDefaultWidth = 912;
+ const int kDefaultHeight = 633;
+ string16 job_title = print_job_title;
+ Profile* profile = NULL;
+ if (modal) {
+ if (job_title.empty()) {
+ WebContents* web_contents = browser->GetSelectedWebContents();
+ if (web_contents)
+ job_title = web_contents->GetTitle();
+ }
+ profile = browser->profile();
+ } else {
+ std::vector<Profile*> loaded_profiles =
+ g_browser_process->profile_manager()->GetLoadedProfiles();
+ DCHECK_GT(loaded_profiles.size(), 0U);
+ profile = loaded_profiles[0];
+ browser = browser::FindLastActiveWithProfile(profile);
+ }
+ DCHECK(profile);
+ PrefService* pref_service = profile->GetPrefs();
+ DCHECK(pref_service);
+ if (!pref_service->FindPreference(prefs::kCloudPrintDialogWidth)) {
+ pref_service->RegisterIntegerPref(prefs::kCloudPrintDialogWidth,
+ kDefaultWidth,
+ PrefService::UNSYNCABLE_PREF);
+ }
+ if (!pref_service->FindPreference(prefs::kCloudPrintDialogHeight)) {
+ pref_service->RegisterIntegerPref(prefs::kCloudPrintDialogHeight,
+ kDefaultHeight,
+ PrefService::UNSYNCABLE_PREF);
+ }
+
+ int width = pref_service->GetInteger(prefs::kCloudPrintDialogWidth);
+ int height = pref_service->GetInteger(prefs::kCloudPrintDialogHeight);
+
WebDialogDelegate* dialog_delegate =
new internal_cloud_print_helpers::CloudPrintWebDialogDelegate(
- browser_context,
- modal_parent,
- path_to_file,
- std::string(),
- print_job_title,
- print_ticket,
- file_type,
- delete_on_close,
- close_after_signin,
+ path_to_file, width, height, std::string(), job_title, print_ticket,
+ file_type, modal, delete_on_close, close_after_signin,
callback);
- browser::ShowWebDialog(modal_parent,
- Profile::FromBrowserContext(browser_context),
- NULL,
- dialog_delegate);
+ browser::ShowWebDialog(modal ? browser->window()->GetNativeHandle() : NULL,
+ profile, browser, dialog_delegate);
}
-void CreateDialogSigninImpl(content::BrowserContext* browser_context,
- gfx::NativeWindow modal_parent,
- const base::Closure& callback) {
- CreateDialogImpl(browser_context, modal_parent, FilePath(), string16(),
- string16(), std::string(), false, true, callback);
+void CreateDialogSigninImpl(const base::Closure& callback) {
+ CreateDialogImpl(FilePath(), string16(), string16(), std::string(),
+ true, false, true, callback);
}
-void CreateDialogFullImpl(content::BrowserContext* browser_context,
- gfx::NativeWindow modal_parent,
- const FilePath& path_to_file,
- const string16& print_job_title,
- const string16& print_ticket,
- const std::string& file_type,
- bool delete_on_close) {
- CreateDialogImpl(browser_context, modal_parent, path_to_file, print_job_title,
- print_ticket, file_type, delete_on_close, false,
- base::Closure());
+void CreateDialogFullImpl(const FilePath& path_to_file,
+ const string16& print_job_title,
+ const string16& print_ticket,
+ const std::string& file_type,
+ bool modal,
+ bool delete_on_close) {
+ CreateDialogImpl(path_to_file, print_job_title, print_ticket, file_type,
+ modal, delete_on_close, false, base::Closure());
}
@@ -721,41 +718,36 @@ namespace print_dialog_cloud {
// TODO(scottbyer): The signature here will need to change as the
// workflow through the printing code changes to allow for dynamically
// changing page setup parameters while the dialog is active.
-void CreatePrintDialogForFile(content::BrowserContext* browser_context,
- gfx::NativeWindow modal_parent,
- const FilePath& path_to_file,
+void CreatePrintDialogForFile(const FilePath& path_to_file,
const string16& print_job_title,
const string16& print_ticket,
const std::string& file_type,
+ bool modal,
bool delete_on_close) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE) ||
BrowserThread::CurrentlyOn(BrowserThread::UI));
+
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&internal_cloud_print_helpers::CreateDialogFullImpl,
- browser_context, modal_parent, path_to_file, print_job_title,
- print_ticket, file_type, delete_on_close));
+ path_to_file, print_job_title, print_ticket, file_type, modal,
+ delete_on_close));
}
-void CreateCloudPrintSigninDialog(content::BrowserContext* browser_context,
- gfx::NativeWindow modal_parent,
- const base::Closure& callback) {
+void CreateCloudPrintSigninDialog(const base::Closure& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&internal_cloud_print_helpers::CreateDialogSigninImpl,
- browser_context,
- modal_parent,
callback));
}
-void CreatePrintDialogForBytes(content::BrowserContext* browser_context,
- gfx::NativeWindow modal_parent,
- scoped_refptr<base::RefCountedBytes> data,
+void CreatePrintDialogForBytes(scoped_refptr<base::RefCountedBytes> data,
const string16& print_job_title,
const string16& print_ticket,
- const std::string& file_type) {
+ const std::string& file_type,
+ bool modal) {
// TODO(abodenha@chromium.org) Avoid cloning the PDF data. Make use of a
// shared memory object instead.
// http://code.google.com/p/chromium/issues/detail?id=44093
@@ -764,8 +756,7 @@ void CreatePrintDialogForBytes(content::BrowserContext* browser_context,
BrowserThread::PostTask(
BrowserThread::FILE, FROM_HERE,
base::Bind(&internal_cloud_print_helpers::CreatePrintDialogForBytesImpl,
- browser_context, modal_parent, cloned_data, print_job_title,
- print_ticket, file_type));
+ cloned_data, print_job_title, print_ticket, file_type, modal));
}
bool CreatePrintDialogFromCommandLine(const CommandLine& command_line) {
@@ -796,14 +787,12 @@ bool CreatePrintDialogFromCommandLine(const CommandLine& command_line) {
bool delete_on_close = CommandLine::ForCurrentProcess()->HasSwitch(
switches::kCloudPrintDeleteFile);
- print_dialog_cloud::CreatePrintDialogForFile(
- ProfileManager::GetDefaultProfile(),
- NULL,
- cloud_print_file,
- print_job_title,
- print_job_print_ticket,
- file_type,
- delete_on_close);
+ print_dialog_cloud::CreatePrintDialogForFile(cloud_print_file,
+ print_job_title,
+ print_job_print_ticket,
+ file_type,
+ false,
+ delete_on_close);
return true;
}
}
diff --git a/chrome/browser/printing/print_dialog_cloud.h b/chrome/browser/printing/print_dialog_cloud.h
index bc6f9c0..2eca2a0 100644
--- a/chrome/browser/printing/print_dialog_cloud.h
+++ b/chrome/browser/printing/print_dialog_cloud.h
@@ -12,55 +12,39 @@
#include "base/callback.h"
#include "base/memory/ref_counted_memory.h"
#include "base/string16.h"
-#include "ui/gfx/native_widget_types.h"
class FilePath;
class CommandLine;
-namespace content {
-class BrowserContext;
-}
-
namespace print_dialog_cloud {
// Creates a print dialog to print a file on disk.
// Called on the FILE or UI thread. Even though this may start up a modal
// dialog, it will return immediately. The dialog is handled asynchronously.
-// If non-NULL, |modal_parent| specifies a window that the print dialog is modal
-// to.
-void CreatePrintDialogForFile(content::BrowserContext* browser_context,
- gfx::NativeWindow modal_parent,
- const FilePath& path_to_file,
+void CreatePrintDialogForFile(const FilePath& path_to_file,
const string16& print_job_title,
const string16& print_ticket,
const std::string& file_type,
+ bool modal,
bool delete_on_close);
// Creates a print dialog to print data in RAM.
// Called on the FILE or UI thread. Even though this may start up a modal
// dialog, it will return immediately. The dialog is handled asynchronously.
-// If non-NULL, |modal_parent| specifies a window that the print dialog is modal
-// to.
-void CreatePrintDialogForBytes(content::BrowserContext* browser_context,
- gfx::NativeWindow modal_parent,
- scoped_refptr<base::RefCountedBytes> data,
+void CreatePrintDialogForBytes(scoped_refptr<base::RefCountedBytes> data,
const string16& print_job_title,
const string16& print_ticket,
- const std::string& file_type);
+ const std::string& file_type,
+ bool modal);
// Parse switches from command_line and display the print dialog as appropriate.
-// Uses the default profile.
bool CreatePrintDialogFromCommandLine(const CommandLine& command_line);
// Creates a dialog for signing into cloud print.
// The dialog will call |callback| when complete.
// Called on the UI thread. Even though this starts up a modal
// dialog, it will return immediately. The dialog is handled asynchronously.
-// If non-NULL, |modal_parent| specifies a window that the print dialog is modal
-// to.
-void CreateCloudPrintSigninDialog(content::BrowserContext* browser_context,
- gfx::NativeWindow modal_parent,
- const base::Closure& callback);
+void CreateCloudPrintSigninDialog(const base::Closure& callback);
} // end namespace
diff --git a/chrome/browser/printing/print_dialog_cloud_interative_uitest.cc b/chrome/browser/printing/print_dialog_cloud_interative_uitest.cc
index 79fb2d4..7e811b1 100644
--- a/chrome/browser/printing/print_dialog_cloud_interative_uitest.cc
+++ b/chrome/browser/printing/print_dialog_cloud_interative_uitest.cc
@@ -16,8 +16,8 @@
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/printing/cloud_print/cloud_print_url.h"
-#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
#include "chrome/common/chrome_paths.h"
@@ -208,9 +208,8 @@ class PrintDialogCloudTest : public InProcessBrowserTest {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&internal_cloud_print_helpers::CreateDialogFullImpl,
- browser()->profile(), browser()->window()->GetNativeHandle(),
path_to_pdf, string16(), string16(),
- std::string("application/pdf"), false));
+ std::string("application/pdf"), true, false));
}
bool handler_added_;
@@ -240,6 +239,9 @@ net::URLRequestJob* PrintDialogCloudTest::Factory(net::URLRequest* request,
#define MAYBE_HandlersRegistered HandlersRegistered
#endif
IN_PROC_BROWSER_TEST_F(PrintDialogCloudTest, MAYBE_HandlersRegistered) {
+ BrowserList::SetLastActive(browser());
+ ASSERT_TRUE(BrowserList::GetLastActive());
+
AddTestHandlers();
TestController::GetInstance()->set_use_delegate(true);
diff --git a/chrome/browser/printing/print_dialog_cloud_internal.h b/chrome/browser/printing/print_dialog_cloud_internal.h
index 36c4ed8..3e4ef6c 100644
--- a/chrome/browser/printing/print_dialog_cloud_internal.h
+++ b/chrome/browser/printing/print_dialog_cloud_internal.h
@@ -159,13 +159,13 @@ class CloudPrintFlowHandler : public content::WebUIMessageHandler,
// is closed.
class CloudPrintWebDialogDelegate : public WebDialogDelegate {
public:
- CloudPrintWebDialogDelegate(content::BrowserContext* browser_context,
- gfx::NativeWindow modal_parent,
- const FilePath& path_to_file,
+ CloudPrintWebDialogDelegate(const FilePath& path_to_file,
+ int width, int height,
const std::string& json_arguments,
const string16& print_job_title,
const string16& print_ticket,
const std::string& file_type,
+ bool modal,
bool delete_on_close,
bool close_after_signin,
const base::Closure& callback);
@@ -190,16 +190,16 @@ class CloudPrintWebDialogDelegate : public WebDialogDelegate {
friend class ::CloudPrintWebDialogDelegateTest;
// For unit testing.
- CloudPrintWebDialogDelegate(const FilePath& path_to_file,
- CloudPrintFlowHandler* flow_handler,
+ CloudPrintWebDialogDelegate(CloudPrintFlowHandler* flow_handler,
+ int width, int height,
const std::string& json_arguments,
+ bool modal,
bool delete_on_close);
- void Init(content::BrowserContext* browser_context,
- const std::string& json_arguments);
+ void Init(int width, int height, const std::string& json_arguments);
bool delete_on_close_;
CloudPrintFlowHandler* flow_handler_;
- gfx::NativeWindow modal_parent_;
+ bool modal_;
mutable bool owns_flow_handler_;
FilePath path_to_file_;
@@ -209,16 +209,13 @@ class CloudPrintWebDialogDelegate : public WebDialogDelegate {
DISALLOW_COPY_AND_ASSIGN(CloudPrintWebDialogDelegate);
};
-void CreateDialogFullImpl(content::BrowserContext* browser_context,
- gfx::NativeWindow modal_parent,
- const FilePath& path_to_file,
+void CreateDialogFullImpl(const FilePath& path_to_file,
const string16& print_job_title,
const string16& print_ticket,
const std::string& file_type,
+ bool modal,
bool delete_on_close);
-void CreateDialogSigninImpl(content::BrowserContext* browser_context,
- gfx::NativeWindow modal_parent,
- const base::Closure& callback);
+void CreateDialogSigninImpl(const base::Closure& callback);
void Delete(const FilePath& path_to_file);
diff --git a/chrome/browser/printing/print_dialog_cloud_unittest.cc b/chrome/browser/printing/print_dialog_cloud_unittest.cc
index bb09cbc..cd967a4 100644
--- a/chrome/browser/printing/print_dialog_cloud_unittest.cc
+++ b/chrome/browser/printing/print_dialog_cloud_unittest.cc
@@ -317,7 +317,7 @@ class CloudPrintWebDialogDelegateTest : public testing::Test {
EXPECT_CALL(*mock_flow_handler_.get(), SetDialogDelegate(_));
EXPECT_CALL(*mock_flow_handler_.get(), SetDialogDelegate(NULL));
delegate_.reset(new CloudPrintWebDialogDelegate(
- mock_path, mock_flow_handler_.get(), std::string(), false));
+ mock_flow_handler_.get(), 100, 100, std::string(), true, false));
}
virtual void TearDown() {
@@ -333,6 +333,7 @@ class CloudPrintWebDialogDelegateTest : public testing::Test {
};
TEST_F(CloudPrintWebDialogDelegateTest, BasicChecks) {
+ EXPECT_EQ(ui::MODAL_TYPE_WINDOW, delegate_->GetDialogModalType());
EXPECT_THAT(delegate_->GetDialogContentURL().spec(),
StrEq(chrome::kChromeUICloudPrintResourcesURL));
EXPECT_TRUE(delegate_->GetDialogTitle().empty());
diff --git a/chrome/browser/printing/printing_message_filter.cc b/chrome/browser/printing/printing_message_filter.cc
index 7d153ef..4011023 100644
--- a/chrome/browser/printing/printing_message_filter.cc
+++ b/chrome/browser/printing/printing_message_filter.cc
@@ -22,10 +22,6 @@
#include "base/file_util.h"
#include "base/lazy_instance.h"
#include "chrome/browser/printing/print_dialog_cloud.h"
-#include "content/public/browser/render_view_host.h"
-#include "content/public/browser/render_view_host_delegate.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_view.h"
#endif
using content::BrowserThread;
@@ -80,9 +76,8 @@ void RenderParamsFromPrintSettings(const printing::PrintSettings& settings,
} // namespace
-PrintingMessageFilter::PrintingMessageFilter(int render_process_id)
- : print_job_manager_(g_browser_process->print_job_manager()),
- render_process_id_(render_process_id) {
+PrintingMessageFilter::PrintingMessageFilter()
+ : print_job_manager_(g_browser_process->print_job_manager()) {
}
PrintingMessageFilter::~PrintingMessageFilter() {
@@ -160,8 +155,7 @@ void PrintingMessageFilter::OnAllocateTempFileForPrinting(
}
}
-void PrintingMessageFilter::OnTempFileForPrintingWritten(int render_view_id,
- int sequence_number) {
+void PrintingMessageFilter::OnTempFileForPrintingWritten(int sequence_number) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
SequenceToPathMap* map = &g_printing_file_descriptor_map.Get().map;
SequenceToPathMap::iterator it = map->find(sequence_number);
@@ -171,16 +165,12 @@ void PrintingMessageFilter::OnTempFileForPrintingWritten(int render_view_id,
return;
}
- content::RenderViewHost* view = content::RenderViewHost::FromID(
- render_process_id_, render_view_id);
- content::WebContents* wc = view->GetDelegate()->GetAsWebContents();
print_dialog_cloud::CreatePrintDialogForFile(
- wc->GetBrowserContext(),
- wc->GetView()->GetTopLevelNativeWindow(),
it->second,
string16(),
string16(),
std::string("application/pdf"),
+ true,
false);
// Erase the entry in the map.
diff --git a/chrome/browser/printing/printing_message_filter.h b/chrome/browser/printing/printing_message_filter.h
index 6e1ea10..9405211 100644
--- a/chrome/browser/printing/printing_message_filter.h
+++ b/chrome/browser/printing/printing_message_filter.h
@@ -30,7 +30,7 @@ class PrintJobManager;
// renderer process on the IPC thread.
class PrintingMessageFilter : public content::BrowserMessageFilter {
public:
- explicit PrintingMessageFilter(int render_process_id);
+ PrintingMessageFilter();
// content::BrowserMessageFilter methods.
virtual void OverrideThreadForMessage(
@@ -53,7 +53,7 @@ class PrintingMessageFilter : public content::BrowserMessageFilter {
// to fill in resulting PDF in renderer.
void OnAllocateTempFileForPrinting(base::FileDescriptor* temp_file_fd,
int* sequence_number);
- void OnTempFileForPrintingWritten(int render_view_id, int sequence_number);
+ void OnTempFileForPrintingWritten(int sequence_number);
#endif
// Get the default print setting. The task is handled by the print
@@ -89,8 +89,6 @@ class PrintingMessageFilter : public content::BrowserMessageFilter {
printing::PrintJobManager* print_job_manager_;
- int render_process_id_;
-
DISALLOW_COPY_AND_ASSIGN(PrintingMessageFilter);
};
diff --git a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
index cbb356f..f9a9b29 100644
--- a/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
+++ b/chrome/browser/ui/webui/print_preview/print_preview_handler.cc
@@ -47,7 +47,6 @@
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_view.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_ui.h"
#include "printing/backend/print_backend.h"
@@ -548,11 +547,7 @@ void PrintPreviewHandler::OnSigninComplete(
}
void PrintPreviewHandler::HandleSignin(const ListValue* /*args*/) {
- gfx::NativeWindow modal_parent =
- web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow();
print_dialog_cloud::CreateCloudPrintSigninDialog(
- web_ui()->GetWebContents()->GetBrowserContext(),
- modal_parent,
base::Bind(&PrintPreviewHandler::OnSigninComplete, AsWeakPtr()));
}
@@ -571,16 +566,11 @@ void PrintPreviewHandler::HandlePrintWithCloudPrint() {
return;
}
DCHECK_GT(data->size(), 0U);
-
- gfx::NativeWindow modal_parent =
- web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow();
- print_dialog_cloud::CreatePrintDialogForBytes(
- web_ui()->GetWebContents()->GetBrowserContext(),
- modal_parent,
- data,
+ print_dialog_cloud::CreatePrintDialogForBytes(data,
string16(print_preview_ui->initiator_tab_title()),
string16(),
- std::string("application/pdf"));
+ std::string("application/pdf"),
+ true);
// Once the cloud print dialog comes up we're no longer in a background
// printing situation. Close the print preview.
diff --git a/chrome/common/print_messages.h b/chrome/common/print_messages.h
index 4d6fac1..4dcaa80 100644
--- a/chrome/common/print_messages.h
+++ b/chrome/common/print_messages.h
@@ -356,8 +356,7 @@ IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_ScriptedPrint,
IPC_SYNC_MESSAGE_CONTROL0_2(PrintHostMsg_AllocateTempFileForPrinting,
base::FileDescriptor /* temp file fd */,
int /* fd in browser*/)
-IPC_MESSAGE_CONTROL2(PrintHostMsg_TempFileForPrintingWritten,
- int /* render_view_id */,
+IPC_MESSAGE_CONTROL1(PrintHostMsg_TempFileForPrintingWritten,
int /* fd in browser */)
#endif
diff --git a/chrome/renderer/chrome_mock_render_thread.cc b/chrome/renderer/chrome_mock_render_thread.cc
index 418bf93..d3abcab 100644
--- a/chrome/renderer/chrome_mock_render_thread.cc
+++ b/chrome/renderer/chrome_mock_render_thread.cc
@@ -85,8 +85,7 @@ void ChromeMockRenderThread::OnAllocateTempFileForPrinting(
}
}
-void ChromeMockRenderThread::OnTempFileForPrintingWritten(int render_view_id,
- int browser_fd) {
+void ChromeMockRenderThread::OnTempFileForPrintingWritten(int browser_fd) {
close(browser_fd);
}
#endif // defined(OS_CHROMEOS)
diff --git a/chrome/renderer/chrome_mock_render_thread.h b/chrome/renderer/chrome_mock_render_thread.h
index b74a133..aca5597 100644
--- a/chrome/renderer/chrome_mock_render_thread.h
+++ b/chrome/renderer/chrome_mock_render_thread.h
@@ -60,7 +60,7 @@ class ChromeMockRenderThread : public content::MockRenderThread {
#if defined(OS_CHROMEOS)
void OnAllocateTempFileForPrinting(base::FileDescriptor* renderer_fd,
int* browser_fd);
- void OnTempFileForPrintingWritten(int render_view_id, int browser_fd);
+ void OnTempFileForPrintingWritten(int browser_fd);
#endif
// PrintWebViewHelper expects default print settings.
diff --git a/chrome/renderer/print_web_view_helper_linux.cc b/chrome/renderer/print_web_view_helper_linux.cc
index bde6966..a132019 100644
--- a/chrome/renderer/print_web_view_helper_linux.cc
+++ b/chrome/renderer/print_web_view_helper_linux.cc
@@ -82,8 +82,7 @@ bool PrintWebViewHelper::PrintPages(WebFrame* frame, const WebNode& node) {
return false;
// Tell the browser we've finished writing the file.
- Send(new PrintHostMsg_TempFileForPrintingWritten(routing_id(),
- sequence_number));
+ Send(new PrintHostMsg_TempFileForPrintingWritten(sequence_number));
return true;
#else
PrintHostMsg_DidPrintPage_Params printed_page_params;