diff options
author | vitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-09 04:49:52 +0000 |
---|---|---|
committer | vitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-09 04:49:52 +0000 |
commit | 6e536cdf138d65ede0844654966a0c0ed0cfd430 (patch) | |
tree | 6beecebe0111aa8428e2df1db404f9047e9658c6 | |
parent | 11906d7871be7aea40e60b7db28087d85bd6def2 (diff) | |
download | chromium_src-6e536cdf138d65ede0844654966a0c0ed0cfd430.zip chromium_src-6e536cdf138d65ede0844654966a0c0ed0cfd430.tar.gz chromium_src-6e536cdf138d65ede0844654966a0c0ed0cfd430.tar.bz2 |
Make cloud print dialog work with cloud printer on first signin.
Better check for current URL.
Assign data only to cloud print URLs.
Don't reset data_.
BUG=236786
Review URL: https://chromiumcodereview.appspot.com/14864005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@199109 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/printing/print_dialog_cloud.cc | 42 | ||||
-rw-r--r-- | chrome/browser/printing/print_dialog_cloud_internal.h | 1 |
2 files changed, 20 insertions, 23 deletions
diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc index 22edf13..9b2c0c9 100644 --- a/chrome/browser/printing/print_dialog_cloud.cc +++ b/chrome/browser/printing/print_dialog_cloud.cc @@ -221,7 +221,6 @@ void CloudPrintDataSender::SendPrintData() { base::StringPiece(reinterpret_cast<const char*>(data_->front()), data_->size()), &base64_data); - data_ = NULL; std::string header("data:"); header.append(file_type_); header.append(";base64,"); @@ -332,14 +331,10 @@ void CloudPrintFlowHandler::Observe( break; } case content::NOTIFICATION_LOAD_STOP: { - // Take the opportunity to set some (minimal) additional - // script permissions required for the web UI. GURL url = web_ui()->GetWebContents()->GetURL(); - GURL dialog_url = CloudPrintURL( - Profile::FromWebUI(web_ui())).GetCloudPrintServiceDialogURL(); - if (url.host() == dialog_url.host() && - url.path() == dialog_url.path() && - url.scheme() == dialog_url.scheme()) { + if (IsCloudPrintDialogUrl(url)) { + // Take the opportunity to set some (minimal) additional + // script permissions required for the web UI. RenderViewHost* rvh = web_ui()->GetWebContents()->GetRenderViewHost(); if (rvh) { WebPreferences webkit_prefs = rvh->GetWebkitPreferences(); @@ -348,15 +343,14 @@ void CloudPrintFlowHandler::Observe( } else { NOTREACHED(); } + // Choose one or the other. If you need to debug, bring up the + // debugger. You can then use the various chrome.send() + // registrations above to kick of the various function calls, + // including chrome.send("SendPrintData") in the javaScript + // console and watch things happen with: + // HandleShowDebugger(NULL); + HandleSendPrintData(NULL); } - - // Choose one or the other. If you need to debug, bring up the - // debugger. You can then use the various chrome.send() - // registrations above to kick of the various function calls, - // including chrome.send("SendPrintData") in the javaScript - // console and watch things happen with: - // HandleShowDebugger(NULL); - HandleSendPrintData(NULL); break; } } @@ -381,7 +375,6 @@ CloudPrintFlowHandler::CreateCloudPrintDataSender() { scoped_refptr<CloudPrintDataSender> sender( new CloudPrintDataSender(print_data_helper_.get(), print_job_title_, print_ticket_, file_type_, data_)); - data_ = NULL; return sender; } @@ -461,12 +454,7 @@ void CloudPrintFlowHandler::StoreDialogClientSize() const { bool CloudPrintFlowHandler::NavigationToURLDidCloseDialog(const GURL& url) { if (close_after_signin_) { - GURL dialog_url = CloudPrintURL( - Profile::FromWebUI(web_ui())).GetCloudPrintServiceURL(); - - if (url.host() == dialog_url.host() && - StartsWithASCII(url.path(), dialog_url.path(), false) && - url.scheme() == dialog_url.scheme()) { + if (IsCloudPrintDialogUrl(url)) { StoreDialogClientSize(); web_ui()->GetWebContents()->GetRenderViewHost()->ClosePage(); callback_.Run(); @@ -476,6 +464,14 @@ bool CloudPrintFlowHandler::NavigationToURLDidCloseDialog(const GURL& url) { return false; } +bool CloudPrintFlowHandler::IsCloudPrintDialogUrl(const GURL& url) { + GURL cloud_print_url = + CloudPrintURL(Profile::FromWebUI(web_ui())).GetCloudPrintServiceURL(); + return url.host() == cloud_print_url.host() && + StartsWithASCII(url.path(), cloud_print_url.path(), false) && + url.scheme() == cloud_print_url.scheme(); +} + CloudPrintWebDialogDelegate::CloudPrintWebDialogDelegate( content::BrowserContext* browser_context, gfx::NativeWindow modal_parent, diff --git a/chrome/browser/printing/print_dialog_cloud_internal.h b/chrome/browser/printing/print_dialog_cloud_internal.h index bab63fa..c2a4d4d 100644 --- a/chrome/browser/printing/print_dialog_cloud_internal.h +++ b/chrome/browser/printing/print_dialog_cloud_internal.h @@ -138,6 +138,7 @@ class CloudPrintFlowHandler : public content::WebUIMessageHandler, void ShowDebugger(); void CancelAnyRunningTask(); + bool IsCloudPrintDialogUrl(const GURL& url); CloudPrintWebDialogDelegate* dialog_delegate_; content::NotificationRegistrar registrar_; |