Paul Stewart | e692740 | 2012-01-23 16:11:30 -0800 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Wade Guthrie | 60a3706 | 2013-04-02 11:39:09 -0700 | [diff] [blame] | 5 | #ifndef SHILL_DEFAULT_PROFILE_H_ |
| 6 | #define SHILL_DEFAULT_PROFILE_H_ |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 7 | |
Alex Vakulenko | 37c5d94 | 2014-06-17 18:17:43 -0700 | [diff] [blame] | 8 | #include <random> |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 9 | #include <string> |
| 10 | #include <vector> |
| 11 | |
Ben Chan | a0ddf46 | 2014-02-06 11:32:42 -0800 | [diff] [blame] | 12 | #include <base/files/file_path.h> |
Chris Masone | aa48237 | 2011-09-14 16:40:37 -0700 | [diff] [blame] | 13 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 14 | |
Paul Stewart | 26b327e | 2011-10-19 11:38:09 -0700 | [diff] [blame] | 15 | #include "shill/event_dispatcher.h" |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 16 | #include "shill/manager.h" |
| 17 | #include "shill/profile.h" |
| 18 | #include "shill/property_store.h" |
| 19 | #include "shill/refptr_types.h" |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 20 | |
| 21 | namespace shill { |
| 22 | |
| 23 | class ControlInterface; |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 24 | #if !defined(DISABLE_WIFI) |
Wade Guthrie | 60a3706 | 2013-04-02 11:39:09 -0700 | [diff] [blame] | 25 | class WiFiProvider; |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 26 | #endif // DISABLE_WIFI |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 27 | |
| 28 | class DefaultProfile : public Profile { |
| 29 | public: |
Paul Stewart | d0a3b81 | 2012-03-28 22:48:22 -0700 | [diff] [blame] | 30 | static const char kDefaultId[]; |
| 31 | |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 32 | 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 Chan | 5ea763b | 2014-08-13 11:07:54 -0700 | [diff] [blame] | 38 | ~DefaultProfile() override; |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 39 | |
Paul Stewart | 4d5efb7 | 2012-09-17 12:24:34 -0700 | [diff] [blame] | 40 | // Loads global configuration into manager properties. This should |
| 41 | // only be called by the Manager. |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 42 | virtual void LoadManagerProperties(Manager::Properties* manager_props); |
Paul Stewart | 870523b | 2012-01-11 17:00:42 -0800 | [diff] [blame] | 43 | |
Paul Stewart | f284a23 | 2012-05-01 10:24:37 -0700 | [diff] [blame] | 44 | // Override the Profile superclass implementation to accept all Ethernet |
| 45 | // services, since these should have an affinity for the default profile. |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 46 | bool ConfigureService(const ServiceRefPtr& service) override; |
Paul Stewart | f284a23 | 2012-05-01 10:24:37 -0700 | [diff] [blame] | 47 | |
Chris Masone | 877ff98 | 2011-09-21 16:18:24 -0700 | [diff] [blame] | 48 | // 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 Jiang | 6acd966 | 2015-01-30 08:36:10 -0800 | [diff] [blame] | 51 | bool Save() override; |
Chris Masone | aa48237 | 2011-09-14 16:40:37 -0700 | [diff] [blame] | 52 | |
Darin Petkov | e7c6ad3 | 2012-06-29 10:22:09 +0200 | [diff] [blame] | 53 | // Inherited from Profile. |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 54 | bool UpdateDevice(const DeviceRefPtr& device) override; |
Darin Petkov | e7c6ad3 | 2012-06-29 10:22:09 +0200 | [diff] [blame] | 55 | |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 56 | #if !defined(DISABLE_WIFI) |
Wade Guthrie | 60a3706 | 2013-04-02 11:39:09 -0700 | [diff] [blame] | 57 | // Inherited from Profile. |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 58 | bool UpdateWiFiProvider(const WiFiProvider& wifi_provider) override; |
Peter Qiu | 1a72f54 | 2015-04-14 16:31:36 -0700 | [diff] [blame] | 59 | #endif // DISABLE_WIFI |
Wade Guthrie | 60a3706 | 2013-04-02 11:39:09 -0700 | [diff] [blame] | 60 | |
mukesh agrawal | 9842441 | 2014-09-30 15:21:52 -0700 | [diff] [blame] | 61 | bool IsDefault() const override { return true; } |
| 62 | |
Paul Stewart | 5dc40aa | 2011-10-28 19:43:43 -0700 | [diff] [blame] | 63 | protected: |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 64 | // 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 Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 69 | bool GetStoragePath(base::FilePath* path) override; |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 70 | |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 71 | private: |
Paul Stewart | 870523b | 2012-01-11 17:00:42 -0800 | [diff] [blame] | 72 | friend class DefaultProfileTest; |
Paul Stewart | 5dc40aa | 2011-10-28 19:43:43 -0700 | [diff] [blame] | 73 | FRIEND_TEST(DefaultProfileTest, GetStoragePath); |
Paul Stewart | e692740 | 2012-01-23 16:11:30 -0800 | [diff] [blame] | 74 | FRIEND_TEST(DefaultProfileTest, LoadManagerDefaultProperties); |
Paul Stewart | 870523b | 2012-01-11 17:00:42 -0800 | [diff] [blame] | 75 | FRIEND_TEST(DefaultProfileTest, LoadManagerProperties); |
| 76 | FRIEND_TEST(DefaultProfileTest, Save); |
Chris Masone | aa48237 | 2011-09-14 16:40:37 -0700 | [diff] [blame] | 77 | |
Chris Masone | aa48237 | 2011-09-14 16:40:37 -0700 | [diff] [blame] | 78 | static const char kStorageId[]; |
Paul Stewart | d408fdf | 2012-05-07 17:15:57 -0700 | [diff] [blame] | 79 | static const char kStorageArpGateway[]; |
Chris Masone | aa48237 | 2011-09-14 16:40:37 -0700 | [diff] [blame] | 80 | static const char kStorageCheckPortalList[]; |
Paul Stewart | ff6be29 | 2014-11-24 17:05:03 -0800 | [diff] [blame] | 81 | static const char kStorageConnectionIdSalt[]; |
Paul Stewart | d32f484 | 2012-01-11 16:08:13 -0800 | [diff] [blame] | 82 | static const char kStorageHostName[]; |
Paul Stewart | 4d5efb7 | 2012-09-17 12:24:34 -0700 | [diff] [blame] | 83 | static const char kStorageIgnoredDNSSearchPaths[]; |
Paul Stewart | 036dba0 | 2012-08-07 12:34:41 -0700 | [diff] [blame] | 84 | static const char kStorageLinkMonitorTechnologies[]; |
Chris Masone | aa48237 | 2011-09-14 16:40:37 -0700 | [diff] [blame] | 85 | static const char kStorageName[]; |
Ben Chan | 8e6b8ef | 2014-07-14 21:50:18 -0700 | [diff] [blame] | 86 | static const char kStorageNoAutoConnectTechnologies[]; |
Chris Masone | aa48237 | 2011-09-14 16:40:37 -0700 | [diff] [blame] | 87 | static const char kStorageOfflineMode[]; |
Paul Stewart | c681fa0 | 2012-03-02 19:40:04 -0800 | [diff] [blame] | 88 | static const char kStoragePortalCheckInterval[]; |
Paul Stewart | e692740 | 2012-01-23 16:11:30 -0800 | [diff] [blame] | 89 | static const char kStoragePortalURL[]; |
Paul Stewart | ff6be29 | 2014-11-24 17:05:03 -0800 | [diff] [blame] | 90 | static const char kStorageProhibitedTechnologies[]; |
Chris Masone | 7df0c67 | 2011-07-15 10:24:54 -0700 | [diff] [blame] | 91 | |
Albert Chaulk | 0e1cdea | 2013-02-27 15:32:55 -0800 | [diff] [blame] | 92 | const base::FilePath storage_path_; |
Paul Stewart | d0a3b81 | 2012-03-28 22:48:22 -0700 | [diff] [blame] | 93 | const std::string profile_id_; |
Paul Stewart | a794cd6 | 2015-06-16 13:13:10 -0700 | [diff] [blame] | 94 | const Manager::Properties& props_; |
Alex Vakulenko | 37c5d94 | 2014-06-17 18:17:43 -0700 | [diff] [blame] | 95 | std::default_random_engine random_engine_; |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 96 | |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 97 | DISALLOW_COPY_AND_ASSIGN(DefaultProfile); |
| 98 | }; |
| 99 | |
| 100 | } // namespace shill |
| 101 | |
Wade Guthrie | 60a3706 | 2013-04-02 11:39:09 -0700 | [diff] [blame] | 102 | #endif // SHILL_DEFAULT_PROFILE_H_ |