blob: fa843271aa8c9e0f131aa1839cf3cd1dd80046db [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
Alex Vakulenko37c5d942014-06-17 18:17:43 -07008#include <random>
Chris Masone88cbd5f2011-07-03 14:30:04 -07009#include <string>
10#include <vector>
11
Ben Chana0ddf462014-02-06 11:32:42 -080012#include <base/files/file_path.h>
Chris Masone88cbd5f2011-07-03 14:30:04 -070013#include <base/memory/scoped_ptr.h>
Chris Masoneaa482372011-09-14 16:40:37 -070014#include <gtest/gtest_prod.h> // for FRIEND_TEST
Chris Masone88cbd5f2011-07-03 14:30:04 -070015
Paul Stewart26b327e2011-10-19 11:38:09 -070016#include "shill/event_dispatcher.h"
Chris Masone88cbd5f2011-07-03 14:30:04 -070017#include "shill/manager.h"
18#include "shill/profile.h"
19#include "shill/property_store.h"
20#include "shill/refptr_types.h"
Chris Masone88cbd5f2011-07-03 14:30:04 -070021
22namespace shill {
23
24class ControlInterface;
Wade Guthrie60a37062013-04-02 11:39:09 -070025class WiFiProvider;
Chris Masone88cbd5f2011-07-03 14:30:04 -070026
27class DefaultProfile : public Profile {
28 public:
Paul Stewartd0a3b812012-03-28 22:48:22 -070029 static const char kDefaultId[];
30
Chris Masone2ae797d2011-08-23 20:41:00 -070031 DefaultProfile(ControlInterface *control,
Thieu Le5133b712013-02-19 14:47:21 -080032 Metrics *metrics,
Chris Masone6791a432011-07-12 13:23:19 -070033 Manager *manager,
Albert Chaulk0e1cdea2013-02-27 15:32:55 -080034 const base::FilePath &storage_path,
Paul Stewartd0a3b812012-03-28 22:48:22 -070035 const std::string &profile_id,
Chris Masone88cbd5f2011-07-03 14:30:04 -070036 const Manager::Properties &manager_props);
Ben Chan5ea763b2014-08-13 11:07:54 -070037 ~DefaultProfile() override;
Chris Masone88cbd5f2011-07-03 14:30:04 -070038
Paul Stewart4d5efb72012-09-17 12:24:34 -070039 // Loads global configuration into manager properties. This should
40 // only be called by the Manager.
mukesh agrawal92496a42014-04-08 16:04:43 -070041 virtual void LoadManagerProperties(Manager::Properties *manager_props);
Paul Stewart870523b2012-01-11 17:00:42 -080042
Paul Stewartf284a232012-05-01 10:24:37 -070043 // Override the Profile superclass implementation to accept all Ethernet
44 // services, since these should have an affinity for the default profile.
45 virtual bool ConfigureService(const ServiceRefPtr &service);
46
Chris Masone877ff982011-09-21 16:18:24 -070047 // Persists profile information, as well as that of discovered devices
48 // and bound services, to disk.
49 // Returns true on success, false on failure.
Chris Masoneb9c00592011-10-06 13:10:39 -070050 virtual bool Save();
Chris Masoneaa482372011-09-14 16:40:37 -070051
Darin Petkove7c6ad32012-06-29 10:22:09 +020052 // Inherited from Profile.
53 virtual bool UpdateDevice(const DeviceRefPtr &device);
54
Wade Guthrie60a37062013-04-02 11:39:09 -070055 // Inherited from Profile.
56 virtual bool UpdateWiFiProvider(const WiFiProvider &wifi_provider);
57
Paul Stewart5dc40aa2011-10-28 19:43:43 -070058 protected:
Chris Masone2ae797d2011-08-23 20:41:00 -070059 // Sets |path| to the persistent store file path for the default, global
60 // profile. Returns true on success, and false if unable to determine an
61 // appropriate file location.
62 //
63 // In this implementation, |name_| is ignored.
Albert Chaulk0e1cdea2013-02-27 15:32:55 -080064 virtual bool GetStoragePath(base::FilePath *path);
Chris Masone2ae797d2011-08-23 20:41:00 -070065
Chris Masone88cbd5f2011-07-03 14:30:04 -070066 private:
Paul Stewart870523b2012-01-11 17:00:42 -080067 friend class DefaultProfileTest;
Paul Stewart5dc40aa2011-10-28 19:43:43 -070068 FRIEND_TEST(DefaultProfileTest, GetStoragePath);
Paul Stewarte6927402012-01-23 16:11:30 -080069 FRIEND_TEST(DefaultProfileTest, LoadManagerDefaultProperties);
Paul Stewart870523b2012-01-11 17:00:42 -080070 FRIEND_TEST(DefaultProfileTest, LoadManagerProperties);
71 FRIEND_TEST(DefaultProfileTest, Save);
Chris Masoneaa482372011-09-14 16:40:37 -070072
Chris Masoneaa482372011-09-14 16:40:37 -070073 static const char kStorageId[];
Paul Stewartd408fdf2012-05-07 17:15:57 -070074 static const char kStorageArpGateway[];
Chris Masoneaa482372011-09-14 16:40:37 -070075 static const char kStorageCheckPortalList[];
Paul Stewartd32f4842012-01-11 16:08:13 -080076 static const char kStorageHostName[];
Paul Stewart4d5efb72012-09-17 12:24:34 -070077 static const char kStorageIgnoredDNSSearchPaths[];
Paul Stewart036dba02012-08-07 12:34:41 -070078 static const char kStorageLinkMonitorTechnologies[];
Chris Masoneaa482372011-09-14 16:40:37 -070079 static const char kStorageName[];
80 static const char kStorageOfflineMode[];
Paul Stewartc681fa02012-03-02 19:40:04 -080081 static const char kStoragePortalCheckInterval[];
Paul Stewarte6927402012-01-23 16:11:30 -080082 static const char kStoragePortalURL[];
Peter Qiu9d581932014-04-14 16:37:37 -070083 static const char kStorageConnectionIdSalt[];
Chris Masone7df0c672011-07-15 10:24:54 -070084
Albert Chaulk0e1cdea2013-02-27 15:32:55 -080085 const base::FilePath storage_path_;
Paul Stewartd0a3b812012-03-28 22:48:22 -070086 const std::string profile_id_;
Chris Masoneaa482372011-09-14 16:40:37 -070087 const Manager::Properties &props_;
Alex Vakulenko37c5d942014-06-17 18:17:43 -070088 std::default_random_engine random_engine_;
Chris Masone2ae797d2011-08-23 20:41:00 -070089
Chris Masone88cbd5f2011-07-03 14:30:04 -070090 DISALLOW_COPY_AND_ASSIGN(DefaultProfile);
91};
92
93} // namespace shill
94
Wade Guthrie60a37062013-04-02 11:39:09 -070095#endif // SHILL_DEFAULT_PROFILE_H_