blob: 387d3d051ade4c35edcbbb0c2c54ad5105d4f045 [file] [log] [blame]
Paul Stewarte6927402012-01-23 16:11:30 -08001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Chris Masone88cbd5f2011-07-03 14:30:04 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Wade Guthrie60a37062013-04-02 11:39:09 -07005#ifndef SHILL_DEFAULT_PROFILE_H_
6#define SHILL_DEFAULT_PROFILE_H_
Chris Masone88cbd5f2011-07-03 14:30:04 -07007
8#include <string>
9#include <vector>
10
Chris Masone2ae797d2011-08-23 20:41:00 -070011#include <base/file_path.h>
Chris Masone88cbd5f2011-07-03 14:30:04 -070012#include <base/memory/scoped_ptr.h>
Chris Masoneaa482372011-09-14 16:40:37 -070013#include <gtest/gtest_prod.h> // for FRIEND_TEST
Chris Masone88cbd5f2011-07-03 14:30:04 -070014
Paul Stewart26b327e2011-10-19 11:38:09 -070015#include "shill/event_dispatcher.h"
Chris Masone88cbd5f2011-07-03 14:30:04 -070016#include "shill/manager.h"
17#include "shill/profile.h"
18#include "shill/property_store.h"
19#include "shill/refptr_types.h"
Chris Masone88cbd5f2011-07-03 14:30:04 -070020
21namespace shill {
22
23class ControlInterface;
Wade Guthrie60a37062013-04-02 11:39:09 -070024class WiFiProvider;
Chris Masone88cbd5f2011-07-03 14:30:04 -070025
26class DefaultProfile : public Profile {
27 public:
Paul Stewartd0a3b812012-03-28 22:48:22 -070028 static const char kDefaultId[];
29
Chris Masone2ae797d2011-08-23 20:41:00 -070030 DefaultProfile(ControlInterface *control,
Thieu Le5133b712013-02-19 14:47:21 -080031 Metrics *metrics,
Chris Masone6791a432011-07-12 13:23:19 -070032 Manager *manager,
Albert Chaulk0e1cdea2013-02-27 15:32:55 -080033 const base::FilePath &storage_path,
Paul Stewartd0a3b812012-03-28 22:48:22 -070034 const std::string &profile_id,
Chris Masone88cbd5f2011-07-03 14:30:04 -070035 const Manager::Properties &manager_props);
36 virtual ~DefaultProfile();
37
Paul Stewart4d5efb72012-09-17 12:24:34 -070038 // Loads global configuration into manager properties. This should
39 // only be called by the Manager.
Paul Stewart870523b2012-01-11 17:00:42 -080040 virtual bool LoadManagerProperties(Manager::Properties *manager_props);
41
Paul Stewartf284a232012-05-01 10:24:37 -070042 // Override the Profile superclass implementation to accept all Ethernet
43 // services, since these should have an affinity for the default profile.
44 virtual bool ConfigureService(const ServiceRefPtr &service);
45
Chris Masone877ff982011-09-21 16:18:24 -070046 // Persists profile information, as well as that of discovered devices
47 // and bound services, to disk.
48 // Returns true on success, false on failure.
Chris Masoneb9c00592011-10-06 13:10:39 -070049 virtual bool Save();
Chris Masoneaa482372011-09-14 16:40:37 -070050
Darin Petkove7c6ad32012-06-29 10:22:09 +020051 // Inherited from Profile.
52 virtual bool UpdateDevice(const DeviceRefPtr &device);
53
Wade Guthrie60a37062013-04-02 11:39:09 -070054 // Inherited from Profile.
55 virtual bool UpdateWiFiProvider(const WiFiProvider &wifi_provider);
56
Paul Stewart5dc40aa2011-10-28 19:43:43 -070057 protected:
Chris Masone2ae797d2011-08-23 20:41:00 -070058 // Sets |path| to the persistent store file path for the default, global
59 // profile. Returns true on success, and false if unable to determine an
60 // appropriate file location.
61 //
62 // In this implementation, |name_| is ignored.
Albert Chaulk0e1cdea2013-02-27 15:32:55 -080063 virtual bool GetStoragePath(base::FilePath *path);
Chris Masone2ae797d2011-08-23 20:41:00 -070064
Chris Masone88cbd5f2011-07-03 14:30:04 -070065 private:
Paul Stewart870523b2012-01-11 17:00:42 -080066 friend class DefaultProfileTest;
Paul Stewart5dc40aa2011-10-28 19:43:43 -070067 FRIEND_TEST(DefaultProfileTest, GetStoragePath);
Paul Stewarte6927402012-01-23 16:11:30 -080068 FRIEND_TEST(DefaultProfileTest, LoadManagerDefaultProperties);
Paul Stewart870523b2012-01-11 17:00:42 -080069 FRIEND_TEST(DefaultProfileTest, LoadManagerProperties);
70 FRIEND_TEST(DefaultProfileTest, Save);
Chris Masoneaa482372011-09-14 16:40:37 -070071
Chris Masoneaa482372011-09-14 16:40:37 -070072 static const char kStorageId[];
Paul Stewartd408fdf2012-05-07 17:15:57 -070073 static const char kStorageArpGateway[];
Chris Masoneaa482372011-09-14 16:40:37 -070074 static const char kStorageCheckPortalList[];
Paul Stewartd32f4842012-01-11 16:08:13 -080075 static const char kStorageHostName[];
Paul Stewart4d5efb72012-09-17 12:24:34 -070076 static const char kStorageIgnoredDNSSearchPaths[];
Paul Stewart036dba02012-08-07 12:34:41 -070077 static const char kStorageLinkMonitorTechnologies[];
Chris Masoneaa482372011-09-14 16:40:37 -070078 static const char kStorageName[];
79 static const char kStorageOfflineMode[];
Paul Stewartc681fa02012-03-02 19:40:04 -080080 static const char kStoragePortalCheckInterval[];
Paul Stewarte6927402012-01-23 16:11:30 -080081 static const char kStoragePortalURL[];
Chris Masone7df0c672011-07-15 10:24:54 -070082
Albert Chaulk0e1cdea2013-02-27 15:32:55 -080083 const base::FilePath storage_path_;
Paul Stewartd0a3b812012-03-28 22:48:22 -070084 const std::string profile_id_;
Chris Masoneaa482372011-09-14 16:40:37 -070085 const Manager::Properties &props_;
Chris Masone2ae797d2011-08-23 20:41:00 -070086
Chris Masone88cbd5f2011-07-03 14:30:04 -070087 DISALLOW_COPY_AND_ASSIGN(DefaultProfile);
88};
89
90} // namespace shill
91
Wade Guthrie60a37062013-04-02 11:39:09 -070092#endif // SHILL_DEFAULT_PROFILE_H_