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 #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/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/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/browser/devtools/devtools_window.h" | 16 #include "chrome/browser/devtools/devtools_window.h" |
17 #include "chrome/browser/lifetime/application_lifetime.h" | 17 #include "chrome/browser/lifetime/application_lifetime.h" |
| 18 #include "chrome/browser/prefs/pref_registry_syncable.h" |
18 #include "chrome/browser/prefs/pref_service.h" | 19 #include "chrome/browser/prefs/pref_service.h" |
19 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" | 20 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" |
22 #include "chrome/browser/ui/browser_dialogs.h" | 23 #include "chrome/browser/ui/browser_dialogs.h" |
23 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
25 #include "chrome/common/print_messages.h" | 26 #include "chrome/common/print_messages.h" |
26 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
27 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 int* width, | 525 int* width, |
525 int* height) { | 526 int* height) { |
526 const int kDefaultWidth = 912; | 527 const int kDefaultWidth = 912; |
527 const int kDefaultHeight = 633; | 528 const int kDefaultHeight = 633; |
528 if (!browser_context) { | 529 if (!browser_context) { |
529 *width = kDefaultWidth; | 530 *width = kDefaultWidth; |
530 *height = kDefaultHeight; | 531 *height = kDefaultHeight; |
531 return; | 532 return; |
532 } | 533 } |
533 | 534 |
534 Profile* profile = Profile::FromBrowserContext(browser_context); | 535 // TODO(joi): Do registration up front. |
535 if (!profile->GetPrefs()->FindPreference(prefs::kCloudPrintDialogWidth)) { | 536 PrefService* prefs = Profile::FromBrowserContext(browser_context)->GetPrefs(); |
536 profile->GetPrefs()->RegisterIntegerPref( | 537 scoped_refptr<PrefRegistrySyncable> registry( |
| 538 static_cast<PrefRegistrySyncable*>(prefs->DeprecatedGetPrefRegistry())); |
| 539 if (!prefs->FindPreference(prefs::kCloudPrintDialogWidth)) { |
| 540 registry->RegisterIntegerPref( |
537 prefs::kCloudPrintDialogWidth, | 541 prefs::kCloudPrintDialogWidth, |
538 kDefaultWidth, | 542 kDefaultWidth, |
539 PrefServiceSyncable::UNSYNCABLE_PREF); | 543 PrefRegistrySyncable::UNSYNCABLE_PREF); |
540 } | 544 } |
541 if (!profile->GetPrefs()->FindPreference(prefs::kCloudPrintDialogHeight)) { | 545 if (!prefs->FindPreference(prefs::kCloudPrintDialogHeight)) { |
542 profile->GetPrefs()->RegisterIntegerPref( | 546 registry->RegisterIntegerPref( |
543 prefs::kCloudPrintDialogHeight, | 547 prefs::kCloudPrintDialogHeight, |
544 kDefaultHeight, | 548 kDefaultHeight, |
545 PrefServiceSyncable::UNSYNCABLE_PREF); | 549 PrefRegistrySyncable::UNSYNCABLE_PREF); |
546 } | 550 } |
547 | 551 |
548 *width = profile->GetPrefs()->GetInteger(prefs::kCloudPrintDialogWidth); | 552 *width = prefs->GetInteger(prefs::kCloudPrintDialogWidth); |
549 *height = profile->GetPrefs()->GetInteger(prefs::kCloudPrintDialogHeight); | 553 *height = prefs->GetInteger(prefs::kCloudPrintDialogHeight); |
550 } | 554 } |
551 | 555 |
552 void CloudPrintWebDialogDelegate::Init(content::BrowserContext* browser_context, | 556 void CloudPrintWebDialogDelegate::Init(content::BrowserContext* browser_context, |
553 const std::string& json_arguments) { | 557 const std::string& json_arguments) { |
554 // This information is needed to show the dialog HTML content. | 558 // This information is needed to show the dialog HTML content. |
555 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 559 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
556 | 560 |
557 params_.url = GURL(chrome::kChromeUICloudPrintResourcesURL); | 561 params_.url = GURL(chrome::kChromeUICloudPrintResourcesURL); |
558 GetDialogWidthAndHeightFromPrefs(browser_context, | 562 GetDialogWidthAndHeightFromPrefs(browser_context, |
559 ¶ms_.width, | 563 ¶ms_.width, |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 print_job_print_ticket, | 839 print_job_print_ticket, |
836 file_type, | 840 file_type, |
837 delete_on_close); | 841 delete_on_close); |
838 return true; | 842 return true; |
839 } | 843 } |
840 } | 844 } |
841 return false; | 845 return false; |
842 } | 846 } |
843 | 847 |
844 } // end namespace | 848 } // end namespace |
OLD | NEW |