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

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

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

Powered by Google App Engine
This is Rietveld 408576698