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

Side by Side Diff: chrome/browser/printing/print_dialog_cloud.cc

Issue 7554008: Removal of Profile from content part 6. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 4 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
OLDNEW
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
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 =
271 pending_entry->set_url(CloudPrintURL( 271 Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context());
272 web_ui_->GetProfile()).GetCloudPrintServiceDialogURL()); 272 pending_entry->set_url(
273 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, 273 CloudPrintURL(profile).GetCloudPrintServiceDialogURL());
274 Source<NavigationController>(controller));
275 } 274 }
275 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP,
276 Source<NavigationController>(controller));
276 } 277 }
277 278
278 void CloudPrintFlowHandler::Observe(int type, 279 void CloudPrintFlowHandler::Observe(int type,
279 const NotificationSource& source, 280 const NotificationSource& source,
280 const NotificationDetails& details) { 281 const NotificationDetails& details) {
281 if (type == content::NOTIFICATION_LOAD_STOP) { 282 if (type == content::NOTIFICATION_LOAD_STOP) {
282 // Take the opportunity to set some (minimal) additional 283 // Take the opportunity to set some (minimal) additional
283 // script permissions required for the web UI. 284 // script permissions required for the web UI.
284 GURL url = web_ui_->tab_contents()->GetURL(); 285 GURL url = web_ui_->tab_contents()->GetURL();
285 GURL dialog_url = CloudPrintURL( 286 Profile* profile =
286 web_ui_->GetProfile()).GetCloudPrintServiceDialogURL(); 287 Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context());
288 GURL dialog_url = CloudPrintURL(profile).GetCloudPrintServiceDialogURL();
287 if (url.host() == dialog_url.host() && 289 if (url.host() == dialog_url.host() &&
288 url.path() == dialog_url.path() && 290 url.path() == dialog_url.path() &&
289 url.scheme() == dialog_url.scheme()) { 291 url.scheme() == dialog_url.scheme()) {
290 RenderViewHost* rvh = web_ui_->tab_contents()->render_view_host(); 292 RenderViewHost* rvh = web_ui_->tab_contents()->render_view_host();
291 if (rvh && rvh->delegate()) { 293 if (rvh && rvh->delegate()) {
292 WebPreferences webkit_prefs = rvh->delegate()->GetWebkitPrefs(); 294 WebPreferences webkit_prefs = rvh->delegate()->GetWebkitPrefs();
293 webkit_prefs.allow_scripts_to_close_windows = true; 295 webkit_prefs.allow_scripts_to_close_windows = true;
294 rvh->Send(new ViewMsg_UpdateWebPreferences( 296 rvh->Send(new ViewMsg_UpdateWebPreferences(
295 rvh->routing_id(), webkit_prefs)); 297 rvh->routing_id(), webkit_prefs));
296 } else { 298 } else {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // TODO(scottbyer) - Here is where we would kick the originating 387 // TODO(scottbyer) - Here is where we would kick the originating
386 // renderer thread with these new parameters in order to get it to 388 // 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 389 // 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 390 // currently synchronous, so there's a lot of work to do to get to
389 // that point. 391 // that point.
390 } 392 }
391 393
392 void CloudPrintFlowHandler::StoreDialogClientSize() const { 394 void CloudPrintFlowHandler::StoreDialogClientSize() const {
393 if (web_ui_ && web_ui_->tab_contents() && web_ui_->tab_contents()->view()) { 395 if (web_ui_ && web_ui_->tab_contents() && web_ui_->tab_contents()->view()) {
394 gfx::Size size = web_ui_->tab_contents()->view()->GetContainerSize(); 396 gfx::Size size = web_ui_->tab_contents()->view()->GetContainerSize();
395 web_ui_->GetProfile()->GetPrefs()->SetInteger( 397 Profile* profile =
396 prefs::kCloudPrintDialogWidth, size.width()); 398 Profile::FromBrowserContext(web_ui_->tab_contents()->browser_context());
397 web_ui_->GetProfile()->GetPrefs()->SetInteger( 399 profile->GetPrefs()->SetInteger(prefs::kCloudPrintDialogWidth,
398 prefs::kCloudPrintDialogHeight, size.height()); 400 size.width());
401 profile->GetPrefs()->SetInteger(prefs::kCloudPrintDialogHeight,
402 size.height());
399 } 403 }
400 } 404 }
401 405
402 CloudPrintHtmlDialogDelegate::CloudPrintHtmlDialogDelegate( 406 CloudPrintHtmlDialogDelegate::CloudPrintHtmlDialogDelegate(
403 const FilePath& path_to_file, 407 const FilePath& path_to_file,
404 int width, int height, 408 int width, int height,
405 const std::string& json_arguments, 409 const std::string& json_arguments,
406 const string16& print_job_title, 410 const string16& print_job_title,
407 const std::string& file_type, 411 const std::string& file_type,
408 bool modal) 412 bool modal)
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 print_job_title, 632 print_job_title,
629 file_type, 633 file_type,
630 false); 634 false);
631 return true; 635 return true;
632 } 636 }
633 } 637 }
634 return false; 638 return false;
635 } 639 }
636 640
637 } // end namespace 641 } // end namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698