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

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
« no previous file with comments | « chrome/service/cloud_print/connector_settings.h ('k') | chrome/service/service_process_prefs.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 kDefaultCloudPrintServerUrl[] = "https://www.google.com/cloudprint";
16 const char kDeleteOnEnumFail[] = "delete_on_enum_fail";
17
18 } // namespace
19
20 ConnectorSettings::ConnectorSettings() : delete_on_enum_fail_(false) {
21 }
22
23 ConnectorSettings::~ConnectorSettings() {
24 }
25
26 void ConnectorSettings::InitFrom(ServiceProcessPrefs* prefs) {
27 CopyFrom(ConnectorSettings());
28
29 prefs->GetString(prefs::kCloudPrintProxyId, &proxy_id_);
30 if (proxy_id_.empty()) {
31 proxy_id_ = cloud_print::PrintSystem::GenerateProxyId();
32 prefs->SetString(prefs::kCloudPrintProxyId, proxy_id_);
33 prefs->WritePrefs();
34 }
35
36 // Getting print system specific settings from the preferences.
37 const base::DictionaryValue* print_system_settings = NULL;
38 prefs->GetDictionary(prefs::kCloudPrintPrintSystemSettings,
39 &print_system_settings);
40 if (print_system_settings) {
41 print_system_settings_.reset(print_system_settings->DeepCopy());
42 // TODO(vitalybuka) : Consider to move option from print_system_settings.
43 print_system_settings_->GetBoolean(kDeleteOnEnumFail,
44 &delete_on_enum_fail_);
45 }
46
47 // Check if there is an override for the cloud print server URL.
48 std::string cloud_print_server_url_str;
49 prefs->GetString(prefs::kCloudPrintServiceURL,
50 &cloud_print_server_url_str);
51 if (cloud_print_server_url_str.empty()) {
52 cloud_print_server_url_str = kDefaultCloudPrintServerUrl;
53 }
54 server_url_ = GURL(cloud_print_server_url_str.c_str());
55 DCHECK(server_url_.is_valid());
56 }
57
58 void ConnectorSettings::CopyFrom(const ConnectorSettings& source) {
59 server_url_ = source.server_url();
60 proxy_id_ = source.proxy_id();
61 delete_on_enum_fail_ = source.delete_on_enum_fail();
62 if (source.print_system_settings())
63 print_system_settings_.reset(source.print_system_settings()->DeepCopy());
64 }
65
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/connector_settings.h ('k') | chrome/service/service_process_prefs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698