| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_LOGIN_SCREENS_SCREEN_CONTEXT_H_ | 5 #ifndef COMPONENTS_LOGIN_SCREENS_SCREEN_CONTEXT_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_SCREEN_CONTEXT_H_ | 6 #define COMPONENTS_LOGIN_SCREENS_SCREEN_CONTEXT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/containers/hash_tables.h" | 12 #include "base/containers/hash_tables.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "base/threading/non_thread_safe.h" | 16 #include "base/threading/non_thread_safe.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler_utils.h" | 18 #include "components/login/base_screen_handler_utils.h" |
| 19 #include "components/login/login_export.h" |
| 19 | 20 |
| 20 namespace chromeos { | 21 namespace login { |
| 21 | 22 |
| 22 // ScreenContext is a key-value storage for values that are shared | 23 // ScreenContext is a key-value storage for values that are shared |
| 23 // between C++ and JS sides. Objects of this class should be used in | 24 // between C++ and JS sides. Objects of this class should be used in |
| 24 // the following way: | 25 // the following way: |
| 25 // | 26 // |
| 26 // context.SetString("user", "john"); | 27 // context.SetString("user", "john"); |
| 27 // context.SetInteger("image-index", 0); | 28 // context.SetInteger("image-index", 0); |
| 28 // context.SetDouble("zoom", 1.25); | 29 // context.SetDouble("zoom", 1.25); |
| 29 // context.GetChangesAndReset(&dictionary); | 30 // context.GetChangesAndReset(&dictionary); |
| 30 // CallJS("onContextChanged", dictionary); | 31 // CallJS("onContextChanged", dictionary); |
| 31 // | 32 // |
| 32 // ScreenContext memorizes changed key-value pairs and returns them | 33 // ScreenContext memorizes changed key-value pairs and returns them |
| 33 // via GetChangesAndReset() method. After call to this method an | 34 // via GetChangesAndReset() method. After call to this method an |
| 34 // internal buffer of changes will be cleared. | 35 // internal buffer of changes will be cleared. |
| 35 class ScreenContext : public base::NonThreadSafe { | 36 class LOGIN_EXPORT ScreenContext : public base::NonThreadSafe { |
| 36 public: | 37 public: |
| 37 typedef std::string KeyType; | 38 typedef std::string KeyType; |
| 38 typedef base::Value ValueType; | 39 typedef base::Value ValueType; |
| 39 | 40 |
| 40 ScreenContext(); | 41 ScreenContext(); |
| 41 ~ScreenContext(); | 42 ~ScreenContext(); |
| 42 | 43 |
| 43 bool SetBoolean(const KeyType& key, bool value); | 44 bool SetBoolean(const KeyType& key, bool value); |
| 44 bool SetInteger(const KeyType& key, int value); | 45 bool SetInteger(const KeyType& key, int value); |
| 45 bool SetDouble(const KeyType& key, double value); | 46 bool SetDouble(const KeyType& key, double value); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 115 |
| 115 // Contains current state of <key, value> map. | 116 // Contains current state of <key, value> map. |
| 116 base::DictionaryValue storage_; | 117 base::DictionaryValue storage_; |
| 117 | 118 |
| 118 // Contains all pending changes. | 119 // Contains all pending changes. |
| 119 base::DictionaryValue changes_; | 120 base::DictionaryValue changes_; |
| 120 | 121 |
| 121 DISALLOW_COPY_AND_ASSIGN(ScreenContext); | 122 DISALLOW_COPY_AND_ASSIGN(ScreenContext); |
| 122 }; | 123 }; |
| 123 | 124 |
| 124 } // namespace chromeos | 125 } // namespace login |
| 125 | 126 |
| 126 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENS_SCREEN_CONTEXT_H_ | 127 #endif // COMPONENTS_LOGIN_SCREENS_SCREEN_CONTEXT_H_ |
| OLD | NEW |