| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/printing/print_dialog_cloud.h" | 5 #include "chrome/browser/printing/print_dialog_cloud.h" |
| 6 #include "chrome/browser/printing/print_dialog_cloud_internal.h" | 6 #include "chrome/browser/printing/print_dialog_cloud_internal.h" |
| 7 | 7 |
| 8 #include "base/base64.h" | 8 #include "base/base64.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 web_ui_->RegisterMessageCallback( | 254 web_ui_->RegisterMessageCallback( |
| 255 "ShowDebugger", | 255 "ShowDebugger", |
| 256 NewCallback(this, &CloudPrintFlowHandler::HandleShowDebugger)); | 256 NewCallback(this, &CloudPrintFlowHandler::HandleShowDebugger)); |
| 257 web_ui_->RegisterMessageCallback( | 257 web_ui_->RegisterMessageCallback( |
| 258 "SendPrintData", | 258 "SendPrintData", |
| 259 NewCallback(this, &CloudPrintFlowHandler::HandleSendPrintData)); | 259 NewCallback(this, &CloudPrintFlowHandler::HandleSendPrintData)); |
| 260 web_ui_->RegisterMessageCallback( | 260 web_ui_->RegisterMessageCallback( |
| 261 "SetPageParameters", | 261 "SetPageParameters", |
| 262 NewCallback(this, &CloudPrintFlowHandler::HandleSetPageParameters)); | 262 NewCallback(this, &CloudPrintFlowHandler::HandleSetPageParameters)); |
| 263 | 263 |
| 264 if (web_ui_->tab_contents()) { | 264 // Register for appropriate notifications, and re-direct the URL |
| 265 // Register for appropriate notifications, and re-direct the URL | 265 // to the real server URL, now that we've gotten an HTML dialog |
| 266 // to the real server URL, now that we've gotten an HTML dialog | 266 // going. |
| 267 // going. | 267 NavigationController* controller = &web_ui_->tab_contents()->controller(); |
| 268 NavigationController* controller = &web_ui_->tab_contents()->controller(); | 268 NavigationEntry* pending_entry = controller->pending_entry(); |
| 269 NavigationEntry* pending_entry = controller->pending_entry(); | 269 if (pending_entry) { |
| 270 if (pending_entry) | 270 Profile* profile = Profile::FromWebUI(web_ui_); |
| 271 pending_entry->set_url(CloudPrintURL( | 271 pending_entry->set_url( |
| 272 web_ui_->GetProfile()).GetCloudPrintServiceDialogURL()); | 272 CloudPrintURL(profile).GetCloudPrintServiceDialogURL()); |
| 273 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, | |
| 274 Source<NavigationController>(controller)); | |
| 275 } | 273 } |
| 274 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, |
| 275 Source<NavigationController>(controller)); |
| 276 } | 276 } |
| 277 | 277 |
| 278 void CloudPrintFlowHandler::Observe(int type, | 278 void CloudPrintFlowHandler::Observe(int type, |
| 279 const NotificationSource& source, | 279 const NotificationSource& source, |
| 280 const NotificationDetails& details) { | 280 const NotificationDetails& details) { |
| 281 if (type == content::NOTIFICATION_LOAD_STOP) { | 281 if (type == content::NOTIFICATION_LOAD_STOP) { |
| 282 // Take the opportunity to set some (minimal) additional | 282 // Take the opportunity to set some (minimal) additional |
| 283 // script permissions required for the web UI. | 283 // script permissions required for the web UI. |
| 284 GURL url = web_ui_->tab_contents()->GetURL(); | 284 GURL url = web_ui_->tab_contents()->GetURL(); |
| 285 GURL dialog_url = CloudPrintURL( | 285 GURL dialog_url = CloudPrintURL( |
| 286 web_ui_->GetProfile()).GetCloudPrintServiceDialogURL(); | 286 Profile::FromWebUI(web_ui_)).GetCloudPrintServiceDialogURL(); |
| 287 if (url.host() == dialog_url.host() && | 287 if (url.host() == dialog_url.host() && |
| 288 url.path() == dialog_url.path() && | 288 url.path() == dialog_url.path() && |
| 289 url.scheme() == dialog_url.scheme()) { | 289 url.scheme() == dialog_url.scheme()) { |
| 290 RenderViewHost* rvh = web_ui_->tab_contents()->render_view_host(); | 290 RenderViewHost* rvh = web_ui_->tab_contents()->render_view_host(); |
| 291 if (rvh && rvh->delegate()) { | 291 if (rvh && rvh->delegate()) { |
| 292 WebPreferences webkit_prefs = rvh->delegate()->GetWebkitPrefs(); | 292 WebPreferences webkit_prefs = rvh->delegate()->GetWebkitPrefs(); |
| 293 webkit_prefs.allow_scripts_to_close_windows = true; | 293 webkit_prefs.allow_scripts_to_close_windows = true; |
| 294 rvh->Send(new ViewMsg_UpdateWebPreferences( | 294 rvh->Send(new ViewMsg_UpdateWebPreferences( |
| 295 rvh->routing_id(), webkit_prefs)); | 295 rvh->routing_id(), webkit_prefs)); |
| 296 } else { | 296 } else { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 // TODO(scottbyer) - Here is where we would kick the originating | 385 // TODO(scottbyer) - Here is where we would kick the originating |
| 386 // renderer thread with these new parameters in order to get it to | 386 // renderer thread with these new parameters in order to get it to |
| 387 // re-generate the PDF data and hand it back to us. window.print() is | 387 // re-generate the PDF data and hand it back to us. window.print() is |
| 388 // currently synchronous, so there's a lot of work to do to get to | 388 // currently synchronous, so there's a lot of work to do to get to |
| 389 // that point. | 389 // that point. |
| 390 } | 390 } |
| 391 | 391 |
| 392 void CloudPrintFlowHandler::StoreDialogClientSize() const { | 392 void CloudPrintFlowHandler::StoreDialogClientSize() const { |
| 393 if (web_ui_ && web_ui_->tab_contents() && web_ui_->tab_contents()->view()) { | 393 if (web_ui_ && web_ui_->tab_contents() && web_ui_->tab_contents()->view()) { |
| 394 gfx::Size size = web_ui_->tab_contents()->view()->GetContainerSize(); | 394 gfx::Size size = web_ui_->tab_contents()->view()->GetContainerSize(); |
| 395 web_ui_->GetProfile()->GetPrefs()->SetInteger( | 395 Profile* profile = Profile::FromWebUI(web_ui_); |
| 396 prefs::kCloudPrintDialogWidth, size.width()); | 396 profile->GetPrefs()->SetInteger(prefs::kCloudPrintDialogWidth, |
| 397 web_ui_->GetProfile()->GetPrefs()->SetInteger( | 397 size.width()); |
| 398 prefs::kCloudPrintDialogHeight, size.height()); | 398 profile->GetPrefs()->SetInteger(prefs::kCloudPrintDialogHeight, |
| 399 size.height()); |
| 399 } | 400 } |
| 400 } | 401 } |
| 401 | 402 |
| 402 CloudPrintHtmlDialogDelegate::CloudPrintHtmlDialogDelegate( | 403 CloudPrintHtmlDialogDelegate::CloudPrintHtmlDialogDelegate( |
| 403 const FilePath& path_to_file, | 404 const FilePath& path_to_file, |
| 404 int width, int height, | 405 int width, int height, |
| 405 const std::string& json_arguments, | 406 const std::string& json_arguments, |
| 406 const string16& print_job_title, | 407 const string16& print_job_title, |
| 407 const std::string& file_type, | 408 const std::string& file_type, |
| 408 bool modal) | 409 bool modal) |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 print_job_title, | 629 print_job_title, |
| 629 file_type, | 630 file_type, |
| 630 false); | 631 false); |
| 631 return true; | 632 return true; |
| 632 } | 633 } |
| 633 } | 634 } |
| 634 return false; | 635 return false; |
| 635 } | 636 } |
| 636 | 637 |
| 637 } // end namespace | 638 } // end namespace |
| OLD | NEW |