| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_DOCUMENT_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_DOCUMENT_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_DOCUMENT_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_DOCUMENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 11 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
| 14 #include "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "net/url_request/url_fetcher_delegate.h" | 17 #include "net/url_request/url_fetcher_delegate.h" |
| 17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 18 | 19 |
| 19 class PrefRegistrySimple; | 20 class PrefRegistrySimple; |
| 20 | 21 |
| 21 namespace base { | 22 namespace base { |
| 22 class DictionaryValue; | 23 class DictionaryValue; |
| 23 class FilePath; | 24 class FilePath; |
| 24 } | 25 } |
| 25 | 26 |
| 26 namespace net { | 27 namespace net { |
| 27 class URLFetcher; | 28 class URLFetcher; |
| 28 } | 29 } |
| 29 | 30 |
| 31 // This test is in global namespace so it must be declared here. |
| 32 void Test__InitStartupCustomizationDocument(const std::string& manifest); |
| 33 |
| 30 namespace chromeos { | 34 namespace chromeos { |
| 31 | 35 |
| 32 namespace system { | 36 namespace system { |
| 33 class StatisticsProvider; | 37 class StatisticsProvider; |
| 34 } // system | 38 } // system |
| 35 | 39 |
| 36 // Base class for OEM customization document classes. | 40 // Base class for OEM customization document classes. |
| 37 class CustomizationDocument { | 41 class CustomizationDocument { |
| 38 public: | 42 public: |
| 39 virtual ~CustomizationDocument(); | 43 virtual ~CustomizationDocument(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 69 public: | 73 public: |
| 70 static StartupCustomizationDocument* GetInstance(); | 74 static StartupCustomizationDocument* GetInstance(); |
| 71 | 75 |
| 72 std::string GetHelpPage(const std::string& locale) const; | 76 std::string GetHelpPage(const std::string& locale) const; |
| 73 std::string GetEULAPage(const std::string& locale) const; | 77 std::string GetEULAPage(const std::string& locale) const; |
| 74 | 78 |
| 75 const std::string& registration_url() const { return registration_url_; } | 79 const std::string& registration_url() const { return registration_url_; } |
| 76 | 80 |
| 77 // These methods can be called even if !IsReady(), in this case VPD values | 81 // These methods can be called even if !IsReady(), in this case VPD values |
| 78 // will be returned. | 82 // will be returned. |
| 83 // |
| 84 // Raw value of "initial_locale" like initial_locale="en-US,sv,da,fi,no" . |
| 79 const std::string& initial_locale() const { return initial_locale_; } | 85 const std::string& initial_locale() const { return initial_locale_; } |
| 86 |
| 87 // Vector of individual locale values. |
| 88 const std::vector<std::string>& configured_locales() const; |
| 89 |
| 90 // Default locale value (first value in initial_locale list). |
| 91 const std::string& initial_locale_default() const; |
| 80 const std::string& initial_timezone() const { return initial_timezone_; } | 92 const std::string& initial_timezone() const { return initial_timezone_; } |
| 81 const std::string& keyboard_layout() const { return keyboard_layout_; } | 93 const std::string& keyboard_layout() const { return keyboard_layout_; } |
| 82 | 94 |
| 83 private: | 95 private: |
| 84 FRIEND_TEST_ALL_PREFIXES(StartupCustomizationDocumentTest, Basic); | 96 FRIEND_TEST_ALL_PREFIXES(StartupCustomizationDocumentTest, Basic); |
| 85 FRIEND_TEST_ALL_PREFIXES(StartupCustomizationDocumentTest, VPD); | 97 FRIEND_TEST_ALL_PREFIXES(StartupCustomizationDocumentTest, VPD); |
| 86 FRIEND_TEST_ALL_PREFIXES(StartupCustomizationDocumentTest, BadManifest); | 98 FRIEND_TEST_ALL_PREFIXES(StartupCustomizationDocumentTest, BadManifest); |
| 99 FRIEND_TEST_ALL_PREFIXES(ServicesCustomizationDocumentTest, MultiLanguage); |
| 100 friend void ::Test__InitStartupCustomizationDocument( |
| 101 const std::string& manifest); |
| 87 friend struct DefaultSingletonTraits<StartupCustomizationDocument>; | 102 friend struct DefaultSingletonTraits<StartupCustomizationDocument>; |
| 88 | 103 |
| 89 // C-tor for singleton construction. | 104 // C-tor for singleton construction. |
| 90 StartupCustomizationDocument(); | 105 StartupCustomizationDocument(); |
| 91 | 106 |
| 92 // C-tor for test construction. | 107 // C-tor for test construction. |
| 93 StartupCustomizationDocument(system::StatisticsProvider* provider, | 108 StartupCustomizationDocument(system::StatisticsProvider* provider, |
| 94 const std::string& manifest); | 109 const std::string& manifest); |
| 95 | 110 |
| 96 virtual ~StartupCustomizationDocument(); | 111 virtual ~StartupCustomizationDocument(); |
| 97 | 112 |
| 98 void Init(system::StatisticsProvider* provider); | 113 void Init(system::StatisticsProvider* provider); |
| 99 | 114 |
| 100 // If |attr| exists in machine stat, assign it to |value|. | 115 // If |attr| exists in machine stat, assign it to |value|. |
| 101 void InitFromMachineStatistic(const char* attr, std::string* value); | 116 void InitFromMachineStatistic(const char* attr, std::string* value); |
| 102 | 117 |
| 103 std::string initial_locale_; | 118 std::string initial_locale_; |
| 119 std::vector<std::string> configured_locales_; |
| 104 std::string initial_timezone_; | 120 std::string initial_timezone_; |
| 105 std::string keyboard_layout_; | 121 std::string keyboard_layout_; |
| 106 std::string registration_url_; | 122 std::string registration_url_; |
| 107 | 123 |
| 108 DISALLOW_COPY_AND_ASSIGN(StartupCustomizationDocument); | 124 DISALLOW_COPY_AND_ASSIGN(StartupCustomizationDocument); |
| 109 }; | 125 }; |
| 110 | 126 |
| 111 // OEM services customization document class. | 127 // OEM services customization document class. |
| 112 // ServicesCustomizationDocument is fetched from network or local file but on | 128 // ServicesCustomizationDocument is fetched from network or local file but on |
| 113 // FILE thread therefore it may not be ready just after creation. Fetching of | 129 // FILE thread therefore it may not be ready just after creation. Fetching of |
| (...skipping 17 matching lines...) Expand all Loading... |
| 131 // Apply customization and save in machine options that customization was | 147 // Apply customization and save in machine options that customization was |
| 132 // applied successfully. Return true if customization was applied. | 148 // applied successfully. Return true if customization was applied. |
| 133 bool ApplyCustomization(); | 149 bool ApplyCustomization(); |
| 134 | 150 |
| 135 std::string GetInitialStartPage(const std::string& locale) const; | 151 std::string GetInitialStartPage(const std::string& locale) const; |
| 136 std::string GetSupportPage(const std::string& locale) const; | 152 std::string GetSupportPage(const std::string& locale) const; |
| 137 | 153 |
| 138 private: | 154 private: |
| 139 FRIEND_TEST_ALL_PREFIXES(ServicesCustomizationDocumentTest, Basic); | 155 FRIEND_TEST_ALL_PREFIXES(ServicesCustomizationDocumentTest, Basic); |
| 140 FRIEND_TEST_ALL_PREFIXES(ServicesCustomizationDocumentTest, BadManifest); | 156 FRIEND_TEST_ALL_PREFIXES(ServicesCustomizationDocumentTest, BadManifest); |
| 157 FRIEND_TEST_ALL_PREFIXES(ServicesCustomizationDocumentTest, MultiLanguage); |
| 141 friend struct DefaultSingletonTraits<ServicesCustomizationDocument>; | 158 friend struct DefaultSingletonTraits<ServicesCustomizationDocument>; |
| 142 | 159 |
| 143 // C-tor for singleton construction. | 160 // C-tor for singleton construction. |
| 144 ServicesCustomizationDocument(); | 161 ServicesCustomizationDocument(); |
| 145 | 162 |
| 146 // C-tor for test construction. | 163 // C-tor for test construction. |
| 147 explicit ServicesCustomizationDocument(const std::string& manifest); | 164 explicit ServicesCustomizationDocument(const std::string& manifest); |
| 148 | 165 |
| 149 virtual ~ServicesCustomizationDocument(); | 166 virtual ~ServicesCustomizationDocument(); |
| 150 | 167 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 171 | 188 |
| 172 // How many times we already tried to fetch customization manifest file. | 189 // How many times we already tried to fetch customization manifest file. |
| 173 int num_retries_; | 190 int num_retries_; |
| 174 | 191 |
| 175 DISALLOW_COPY_AND_ASSIGN(ServicesCustomizationDocument); | 192 DISALLOW_COPY_AND_ASSIGN(ServicesCustomizationDocument); |
| 176 }; | 193 }; |
| 177 | 194 |
| 178 } // namespace chromeos | 195 } // namespace chromeos |
| 179 | 196 |
| 180 #endif // CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_DOCUMENT_H_ | 197 #endif // CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_DOCUMENT_H_ |
| OLD | NEW |