OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 6 |
7 | 7 |
8 #include "base/base64.h" | 8 #include "base/base64.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
14 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/devtools/devtools_window.h" | 18 #include "chrome/browser/devtools/devtools_window.h" |
18 #include "chrome/browser/google/google_util.h" | 19 #include "chrome/browser/google/google_util.h" |
19 #include "chrome/browser/lifetime/application_lifetime.h" | 20 #include "chrome/browser/lifetime/application_lifetime.h" |
20 #include "chrome/browser/printing/print_dialog_cloud_internal.h" | 21 #include "chrome/browser/printing/print_dialog_cloud_internal.h" |
21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
23 #include "chrome/browser/ui/browser_dialogs.h" | 24 #include "chrome/browser/ui/browser_dialogs.h" |
24 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
26 #include "chrome/common/print_messages.h" | 27 #include "chrome/common/print_messages.h" |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 base::Unretained(this))); | 330 base::Unretained(this))); |
330 | 331 |
331 // Register for appropriate notifications, and re-direct the URL | 332 // Register for appropriate notifications, and re-direct the URL |
332 // to the real server URL, now that we've gotten an HTML dialog | 333 // to the real server URL, now that we've gotten an HTML dialog |
333 // going. | 334 // going. |
334 NavigationController* controller = | 335 NavigationController* controller = |
335 &web_ui()->GetWebContents()->GetController(); | 336 &web_ui()->GetWebContents()->GetController(); |
336 NavigationEntry* pending_entry = controller->GetPendingEntry(); | 337 NavigationEntry* pending_entry = controller->GetPendingEntry(); |
337 if (pending_entry) { | 338 if (pending_entry) { |
338 pending_entry->SetURL(google_util::AppendGoogleLocaleParam( | 339 pending_entry->SetURL(google_util::AppendGoogleLocaleParam( |
339 cloud_devices::GetCloudPrintRelativeURL("client/dialog.html"))); | 340 cloud_devices::GetCloudPrintRelativeURL("client/dialog.html"), |
| 341 g_browser_process->GetApplicationLocale())); |
340 } | 342 } |
341 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, | 343 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, |
342 content::Source<NavigationController>(controller)); | 344 content::Source<NavigationController>(controller)); |
343 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 345 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
344 content::Source<NavigationController>(controller)); | 346 content::Source<NavigationController>(controller)); |
345 } | 347 } |
346 | 348 |
347 void CloudPrintFlowHandler::Observe( | 349 void CloudPrintFlowHandler::Observe( |
348 int type, | 350 int type, |
349 const content::NotificationSource& source, | 351 const content::NotificationSource& source, |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 browser_context, modal_parent, path_to_file, print_job_title, | 706 browser_context, modal_parent, path_to_file, print_job_title, |
705 print_ticket, file_type)); | 707 print_ticket, file_type)); |
706 } | 708 } |
707 | 709 |
708 void CreateCloudPrintSigninTab(Browser* browser, | 710 void CreateCloudPrintSigninTab(Browser* browser, |
709 bool add_account, | 711 bool add_account, |
710 const base::Closure& callback) { | 712 const base::Closure& callback) { |
711 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 713 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
712 GURL url = add_account ? cloud_devices::GetCloudPrintAddAccountURL() | 714 GURL url = add_account ? cloud_devices::GetCloudPrintAddAccountURL() |
713 : cloud_devices::GetCloudPrintSigninURL(); | 715 : cloud_devices::GetCloudPrintSigninURL(); |
714 content::WebContents* web_contents = browser->OpenURL( | 716 content::WebContents* web_contents = browser->OpenURL(content::OpenURLParams( |
715 content::OpenURLParams(google_util::AppendGoogleLocaleParam(url), | 717 google_util::AppendGoogleLocaleParam( |
716 content::Referrer(), | 718 url, g_browser_process->GetApplicationLocale()), |
717 NEW_FOREGROUND_TAB, | 719 content::Referrer(), |
718 content::PAGE_TRANSITION_AUTO_BOOKMARK, | 720 NEW_FOREGROUND_TAB, |
719 false)); | 721 content::PAGE_TRANSITION_AUTO_BOOKMARK, |
| 722 false)); |
720 new SignInObserver(web_contents, cloud_devices::GetCloudPrintURL(), callback); | 723 new SignInObserver(web_contents, cloud_devices::GetCloudPrintURL(), callback); |
721 } | 724 } |
722 | 725 |
723 void CreatePrintDialogForBytes(content::BrowserContext* browser_context, | 726 void CreatePrintDialogForBytes(content::BrowserContext* browser_context, |
724 gfx::NativeWindow modal_parent, | 727 gfx::NativeWindow modal_parent, |
725 const base::RefCountedMemory* data, | 728 const base::RefCountedMemory* data, |
726 const base::string16& print_job_title, | 729 const base::string16& print_job_title, |
727 const base::string16& print_ticket, | 730 const base::string16& print_ticket, |
728 const std::string& file_type) { | 731 const std::string& file_type) { |
729 internal_cloud_print_helpers::CreateDialogImpl(browser_context, modal_parent, | 732 internal_cloud_print_helpers::CreateDialogImpl(browser_context, modal_parent, |
(...skipping 29 matching lines...) Expand all Loading... |
759 | 762 |
760 print_dialog_cloud::CreatePrintDialogForFile(profile, NULL, | 763 print_dialog_cloud::CreatePrintDialogForFile(profile, NULL, |
761 cloud_print_file, print_job_title, print_job_print_ticket, file_type); | 764 cloud_print_file, print_job_title, print_job_print_ticket, file_type); |
762 return true; | 765 return true; |
763 } | 766 } |
764 } | 767 } |
765 return false; | 768 return false; |
766 } | 769 } |
767 | 770 |
768 } // namespace print_dialog_cloud | 771 } // namespace print_dialog_cloud |
OLD | NEW |