blob: 5cdd47d802390b43bb5bbe6464eb46ad70e80edc [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 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;
Peter Qiu1a72f542015-04-14 16:31:36 -070024#if !defined(DISABLE_WIFI)
Wade Guthrie60a37062013-04-02 11:39:09 -070025class WiFiProvider;
Peter Qiu1a72f542015-04-14 16:31:36 -070026#endif // DISABLE_WIFI
Chris Masone88cbd5f2011-07-03 14:30:04 -070027
28class DefaultProfile : public Profile {
29 public:
Paul Stewartd0a3b812012-03-28 22:48:22 -070030 static const char kDefaultId[];
31
Paul Stewarta794cd62015-06-16 13:13:10 -070032 DefaultProfile(ControlInterface* control,
33 Metrics* metrics,
34 Manager* manager,
35 const base::FilePath& storage_path,
36 const std::string& profile_id,
37 const Manager::Properties& manager_props);
Ben Chan5ea763b2014-08-13 11:07:54 -070038 ~DefaultProfile() override;
Chris Masone88cbd5f2011-07-03 14:30:04 -070039
Paul Stewart4d5efb72012-09-17 12:24:34 -070040 // Loads global configuration into manager properties. This should
41 // only be called by the Manager.
Paul Stewarta794cd62015-06-16 13:13:10 -070042 virtual void LoadManagerProperties(Manager::Properties* manager_props);
Paul Stewart870523b2012-01-11 17:00:42 -080043
Paul Stewartf284a232012-05-01 10:24:37 -070044 // Override the Profile superclass implementation to accept all Ethernet
45 // services, since these should have an affinity for the default profile.
Paul Stewarta794cd62015-06-16 13:13:10 -070046 bool ConfigureService(const ServiceRefPtr& service) override;
Paul Stewartf284a232012-05-01 10:24:37 -070047
Chris Masone877ff982011-09-21 16:18:24 -070048 // Persists profile information, as well as that of discovered devices
49 // and bound services, to disk.
50 // Returns true on success, false on failure.
Yunlian Jiang6acd9662015-01-30 08:36:10 -080051 bool Save() override;
Chris Masoneaa482372011-09-14 16:40:37 -070052
Darin Petkove7c6ad32012-06-29 10:22:09 +020053 // Inherited from Profile.
Paul Stewarta794cd62015-06-16 13:13:10 -070054 bool UpdateDevice(const DeviceRefPtr& device) override;
Darin Petkove7c6ad32012-06-29 10:22:09 +020055
Peter Qiu1a72f542015-04-14 16:31:36 -070056#if !defined(DISABLE_WIFI)
Wade Guthrie60a37062013-04-02 11:39:09 -070057 // Inherited from Profile.
Paul Stewarta794cd62015-06-16 13:13:10 -070058 bool UpdateWiFiProvider(const WiFiProvider& wifi_provider) override;
Peter Qiu1a72f542015-04-14 16:31:36 -070059#endif // DISABLE_WIFI
Wade Guthrie60a37062013-04-02 11:39:09 -070060
mukesh agrawal98424412014-09-30 15:21:52 -070061 bool IsDefault() const override { return true; }
62
Paul Stewart5dc40aa2011-10-28 19:43:43 -070063 protected:
Chris Masone2ae797d2011-08-23 20:41:00 -070064 // Sets |path| to the persistent store file path for the default, global
65 // profile. Returns true on success, and false if unable to determine an
66 // appropriate file location.
67 //
68 // In this implementation, |name_| is ignored.
Paul Stewarta794cd62015-06-16 13:13:10 -070069 bool GetStoragePath(base::FilePath* path) override;
Chris Masone2ae797d2011-08-23 20:41:00 -070070
Chris Masone88cbd5f2011-07-03 14:30:04 -070071 private:
Paul Stewart870523b2012-01-11 17:00:42 -080072 friend class DefaultProfileTest;
Paul Stewart5dc40aa2011-10-28 19:43:43 -070073 FRIEND_TEST(DefaultProfileTest, GetStoragePath);
Paul Stewarte6927402012-01-23 16:11:30 -080074 FRIEND_TEST(DefaultProfileTest, LoadManagerDefaultProperties);
Paul Stewart870523b2012-01-11 17:00:42 -080075 FRIEND_TEST(DefaultProfileTest, LoadManagerProperties);
76 FRIEND_TEST(DefaultProfileTest, Save);
Chris Masoneaa482372011-09-14 16:40:37 -070077
Chris Masoneaa482372011-09-14 16:40:37 -070078 static const char kStorageId[];
Paul Stewartd408fdf2012-05-07 17:15:57 -070079 static const char kStorageArpGateway[];
Chris Masoneaa482372011-09-14 16:40:37 -070080 static const char kStorageCheckPortalList[];
Paul Stewartff6be292014-11-24 17:05:03 -080081 static const char kStorageConnectionIdSalt[];
Paul Stewartd32f4842012-01-11 16:08:13 -080082 static const char kStorageHostName[];
Paul Stewart4d5efb72012-09-17 12:24:34 -070083 static const char kStorageIgnoredDNSSearchPaths[];
Paul Stewart036dba02012-08-07 12:34:41 -070084 static const char kStorageLinkMonitorTechnologies[];
Chris Masoneaa482372011-09-14 16:40:37 -070085 static const char kStorageName[];
Ben Chan8e6b8ef2014-07-14 21:50:18 -070086 static const char kStorageNoAutoConnectTechnologies[];
Chris Masoneaa482372011-09-14 16:40:37 -070087 static const char kStorageOfflineMode[];
Paul Stewartc681fa02012-03-02 19:40:04 -080088 static const char kStoragePortalCheckInterval[];
Paul Stewarte6927402012-01-23 16:11:30 -080089 static const char kStoragePortalURL[];
Paul Stewartff6be292014-11-24 17:05:03 -080090 static const char kStorageProhibitedTechnologies[];
Chris Masone7df0c672011-07-15 10:24:54 -070091
Albert Chaulk0e1cdea2013-02-27 15:32:55 -080092 const base::FilePath storage_path_;
Paul Stewartd0a3b812012-03-28 22:48:22 -070093 const std::string profile_id_;
Paul Stewarta794cd62015-06-16 13:13:10 -070094 const Manager::Properties& props_;
Alex Vakulenko37c5d942014-06-17 18:17:43 -070095 std::default_random_engine random_engine_;
Chris Masone2ae797d2011-08-23 20:41:00 -070096
Chris Masone88cbd5f2011-07-03 14:30:04 -070097 DISALLOW_COPY_AND_ASSIGN(DefaultProfile);
98};
99
100} // namespace shill
101
Wade Guthrie60a37062013-04-02 11:39:09 -0700102#endif // SHILL_DEFAULT_PROFILE_H_