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

Side by Side Diff: chrome/service/cloud_print/connector_settings.cc

Issue 10968031: Added ConnectorSettings class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/service/cloud_print/connector_settings.h"
6
7 #include "base/values.h"
8 #include "chrome/common/pref_names.h"
9 #include "chrome/service/cloud_print/cloud_print_consts.h"
10 #include "chrome/service/cloud_print/print_system.h"
11 #include "chrome/service/service_process_prefs.h"
12
13 const char kDeleteOnEnumFail[] = "delete_on_enum_fail";
Lei Zhang 2012/09/21 20:26:22 nit: this goes in an anonymous namespace.
Vitaly Buka (NO REVIEWS) 2012/09/21 20:36:37 Done.
14
15 ConnectorSettings::ConnectorSettings() : remove_missing_printers_(false) {
16 }
17
18 ConnectorSettings::~ConnectorSettings() {
19 }
20
21 void ConnectorSettings::InitFrom(ServiceProcessPrefs* prefs) {
22 CopyFrom(ConnectorSettings());
23
24 prefs->GetString(prefs::kCloudPrintProxyId, &proxy_id_);
25 if (proxy_id_.empty()) {
26 proxy_id_ = cloud_print::PrintSystem::GenerateProxyId();
27 prefs->SetString(prefs::kCloudPrintProxyId, proxy_id_);
28 prefs->WritePrefs();
29 }
30
31 // Getting print system specific settings from the preferences.
32 const base::DictionaryValue* print_system_settings = NULL;
33 prefs->GetDictionary(prefs::kCloudPrintPrintSystemSettings,
34 &print_system_settings);
35 if (print_system_settings) {
36 print_system_settings_.reset(print_system_settings->DeepCopy());
37 // TODO(vitalybuka) : Consider to move option from print_system_settings.
38 print_system_settings_->GetBoolean(kDeleteOnEnumFail,
39 &remove_missing_printers_);
40 }
41
42 // Check if there is an override for the cloud print server URL.
43 std::string cloud_print_server_url_str;
44 prefs->GetString(prefs::kCloudPrintServiceURL,
45 &cloud_print_server_url_str);
46 if (cloud_print_server_url_str.empty()) {
47 cloud_print_server_url_str = kDefaultCloudPrintServerUrl;
48 }
49 cloud_print_server_url_ = GURL(cloud_print_server_url_str.c_str());
50 DCHECK(cloud_print_server_url_.is_valid());
51 }
52
53 void ConnectorSettings::CopyFrom(const ConnectorSettings& source) {
54 cloud_print_server_url_ = source.cloud_print_server_url();
55 proxy_id_ = source.proxy_id();
56 if (source.print_system_settings())
57 print_system_settings_.reset(source.print_system_settings()->DeepCopy());
58 }
59
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698