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

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 namespace {
14
15 const char kDeleteOnEnumFail[] = "delete_on_enum_fail";
16
17 } // namespace
18
19 ConnectorSettings::ConnectorSettings() : remove_missing_printers_(false) {
20 }
21
22 ConnectorSettings::~ConnectorSettings() {
23 }
24
25 void ConnectorSettings::InitFrom(ServiceProcessPrefs* prefs) {
26 CopyFrom(ConnectorSettings());
27
28 prefs->GetString(prefs::kCloudPrintProxyId, &proxy_id_);
29 if (proxy_id_.empty()) {
30 proxy_id_ = cloud_print::PrintSystem::GenerateProxyId();
31 prefs->SetString(prefs::kCloudPrintProxyId, proxy_id_);
32 prefs->WritePrefs();
33 }
34
35 // Getting print system specific settings from the preferences.
36 const base::DictionaryValue* print_system_settings = NULL;
37 prefs->GetDictionary(prefs::kCloudPrintPrintSystemSettings,
38 &print_system_settings);
39 if (print_system_settings) {
40 print_system_settings_.reset(print_system_settings->DeepCopy());
41 // TODO(vitalybuka) : Consider to move option from print_system_settings.
42 print_system_settings_->GetBoolean(kDeleteOnEnumFail,
43 &remove_missing_printers_);
44 }
45
46 // Check if there is an override for the cloud print server URL.
47 std::string cloud_print_server_url_str;
48 prefs->GetString(prefs::kCloudPrintServiceURL,
49 &cloud_print_server_url_str);
50 if (cloud_print_server_url_str.empty()) {
51 cloud_print_server_url_str = kDefaultCloudPrintServerUrl;
52 }
53 server_url_ = GURL(cloud_print_server_url_str.c_str());
54 DCHECK(server_url_.is_valid());
55 }
56
57 void ConnectorSettings::CopyFrom(const ConnectorSettings& source) {
58 server_url_ = source.server_url();
59 proxy_id_ = source.proxy_id();
60 if (source.print_system_settings())
61 print_system_settings_.reset(source.print_system_settings()->DeepCopy());
gene 2012/09/21 22:08:36 copy remove_missing_printers_ as well here?
Vitaly Buka (NO REVIEWS) 2012/09/21 22:35:28 Done.
62 }
63
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698