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

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

Issue 12079097: Introduce PrefRegistrySyncable, simplifying PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add to PrefRegistrySyncable and PrefServiceSyncable to let sync know of pre-registered prefs. Created 7 years, 10 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) 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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 int* width, 524 int* width,
524 int* height) { 525 int* height) {
525 const int kDefaultWidth = 912; 526 const int kDefaultWidth = 912;
526 const int kDefaultHeight = 633; 527 const int kDefaultHeight = 633;
527 if (!browser_context) { 528 if (!browser_context) {
528 *width = kDefaultWidth; 529 *width = kDefaultWidth;
529 *height = kDefaultHeight; 530 *height = kDefaultHeight;
530 return; 531 return;
531 } 532 }
532 533
533 Profile* profile = Profile::FromBrowserContext(browser_context); 534 // TODO(joi): Do registration up front.
534 if (!profile->GetPrefs()->FindPreference(prefs::kCloudPrintDialogWidth)) { 535 PrefService* prefs = Profile::FromBrowserContext(browser_context)->GetPrefs();
535 profile->GetPrefs()->RegisterIntegerPref( 536 scoped_refptr<PrefRegistrySyncable> registry(
537 static_cast<PrefRegistrySyncable*>(prefs->DeprecatedGetPrefRegistry()));
538 if (!prefs->FindPreference(prefs::kCloudPrintDialogWidth)) {
539 registry->RegisterIntegerPref(
536 prefs::kCloudPrintDialogWidth, 540 prefs::kCloudPrintDialogWidth,
537 kDefaultWidth, 541 kDefaultWidth,
538 PrefServiceSyncable::UNSYNCABLE_PREF); 542 PrefRegistrySyncable::UNSYNCABLE_PREF);
539 } 543 }
540 if (!profile->GetPrefs()->FindPreference(prefs::kCloudPrintDialogHeight)) { 544 if (!prefs->FindPreference(prefs::kCloudPrintDialogHeight)) {
541 profile->GetPrefs()->RegisterIntegerPref( 545 registry->RegisterIntegerPref(
542 prefs::kCloudPrintDialogHeight, 546 prefs::kCloudPrintDialogHeight,
543 kDefaultHeight, 547 kDefaultHeight,
544 PrefServiceSyncable::UNSYNCABLE_PREF); 548 PrefRegistrySyncable::UNSYNCABLE_PREF);
545 } 549 }
546 550
547 *width = profile->GetPrefs()->GetInteger(prefs::kCloudPrintDialogWidth); 551 *width = prefs->GetInteger(prefs::kCloudPrintDialogWidth);
548 *height = profile->GetPrefs()->GetInteger(prefs::kCloudPrintDialogHeight); 552 *height = prefs->GetInteger(prefs::kCloudPrintDialogHeight);
549 } 553 }
550 554
551 void CloudPrintWebDialogDelegate::Init(content::BrowserContext* browser_context, 555 void CloudPrintWebDialogDelegate::Init(content::BrowserContext* browser_context,
552 const std::string& json_arguments) { 556 const std::string& json_arguments) {
553 // This information is needed to show the dialog HTML content. 557 // This information is needed to show the dialog HTML content.
554 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 558 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
555 559
556 params_.url = GURL(chrome::kChromeUICloudPrintResourcesURL); 560 params_.url = GURL(chrome::kChromeUICloudPrintResourcesURL);
557 GetDialogWidthAndHeightFromPrefs(browser_context, 561 GetDialogWidthAndHeightFromPrefs(browser_context,
558 &params_.width, 562 &params_.width,
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 print_job_print_ticket, 838 print_job_print_ticket,
835 file_type, 839 file_type,
836 delete_on_close); 840 delete_on_close);
837 return true; 841 return true;
838 } 842 }
839 } 843 }
840 return false; 844 return false;
841 } 845 }
842 846
843 } // end namespace 847 } // end namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698