| 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" |
| 11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/prefs/pref_service.h" | 14 #include "chrome/browser/prefs/pref_service.h" |
| 15 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" | 15 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
| 18 #include "chrome/browser/ui/browser_dialogs.h" | 18 #include "chrome/browser/ui/browser_dialogs.h" |
| 19 #include "chrome/browser/ui/browser_list.h" | 19 #include "chrome/browser/ui/browser_list.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/common/print_messages.h" | 22 #include "chrome/common/print_messages.h" |
| 23 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 24 #include "content/browser/browser_thread.h" | 24 #include "content/browser/browser_thread.h" |
| 25 #include "content/browser/debugger/devtools_window.h" | 25 #include "content/browser/debugger/devtools_window.h" |
| 26 #include "content/browser/renderer_host/render_view_host.h" | 26 #include "content/browser/renderer_host/render_view_host.h" |
| 27 #include "content/browser/tab_contents/tab_contents.h" | 27 #include "content/browser/tab_contents/tab_contents.h" |
| 28 #include "content/browser/tab_contents/tab_contents_view.h" | 28 #include "content/browser/tab_contents/tab_contents_view.h" |
| 29 #include "content/browser/webui/web_ui.h" | 29 #include "content/browser/webui/web_ui.h" |
| 30 #include "content/common/content_notification_types.h" |
| 30 #include "content/common/notification_registrar.h" | 31 #include "content/common/notification_registrar.h" |
| 31 #include "content/common/notification_source.h" | 32 #include "content/common/notification_source.h" |
| 32 #include "content/common/notification_type.h" | |
| 33 #include "content/common/view_messages.h" | 33 #include "content/common/view_messages.h" |
| 34 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
| 35 #include "webkit/glue/webpreferences.h" | 35 #include "webkit/glue/webpreferences.h" |
| 36 | 36 |
| 37 #include "grit/generated_resources.h" | 37 #include "grit/generated_resources.h" |
| 38 | 38 |
| 39 // This module implements the UI support in Chrome for cloud printing. | 39 // This module implements the UI support in Chrome for cloud printing. |
| 40 // This means hosting a dialog containing HTML/JavaScript and using | 40 // This means hosting a dialog containing HTML/JavaScript and using |
| 41 // the published cloud print user interface integration APIs to get | 41 // the published cloud print user interface integration APIs to get |
| 42 // page setup settings from the dialog contents and provide the | 42 // page setup settings from the dialog contents and provide the |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 | 263 |
| 264 if (web_ui_->tab_contents()) { | 264 if (web_ui_->tab_contents()) { |
| 265 // Register for appropriate notifications, and re-direct the URL | 265 // Register for appropriate notifications, and re-direct the URL |
| 266 // 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 |
| 267 // going. | 267 // going. |
| 268 NavigationController* controller = &web_ui_->tab_contents()->controller(); | 268 NavigationController* controller = &web_ui_->tab_contents()->controller(); |
| 269 NavigationEntry* pending_entry = controller->pending_entry(); | 269 NavigationEntry* pending_entry = controller->pending_entry(); |
| 270 if (pending_entry) | 270 if (pending_entry) |
| 271 pending_entry->set_url(CloudPrintURL( | 271 pending_entry->set_url(CloudPrintURL( |
| 272 web_ui_->GetProfile()).GetCloudPrintServiceDialogURL()); | 272 web_ui_->GetProfile()).GetCloudPrintServiceDialogURL()); |
| 273 registrar_.Add(this, NotificationType::LOAD_STOP, | 273 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, |
| 274 Source<NavigationController>(controller)); | 274 Source<NavigationController>(controller)); |
| 275 } | 275 } |
| 276 } | 276 } |
| 277 | 277 |
| 278 void CloudPrintFlowHandler::Observe(NotificationType 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.value == NotificationType::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 web_ui_->GetProfile()).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()) { |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 print_job_title, | 628 print_job_title, |
| 629 file_type, | 629 file_type, |
| 630 false); | 630 false); |
| 631 return true; | 631 return true; |
| 632 } | 632 } |
| 633 } | 633 } |
| 634 return false; | 634 return false; |
| 635 } | 635 } |
| 636 | 636 |
| 637 } // end namespace | 637 } // end namespace |
| OLD | NEW |