| 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_EXTENSIONS_MENU_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 } | 102 } |
| 103 | 103 |
| 104 bool Contains(Context context) const { | 104 bool Contains(Context context) const { |
| 105 return (value_ & context) > 0; | 105 return (value_ & context) > 0; |
| 106 } | 106 } |
| 107 | 107 |
| 108 void Add(Context context) { | 108 void Add(Context context) { |
| 109 value_ |= context; | 109 value_ |= context; |
| 110 } | 110 } |
| 111 | 111 |
| 112 scoped_ptr<Value> ToValue() const { | 112 scoped_ptr<base::Value> ToValue() const { |
| 113 return scoped_ptr<Value>(Value::CreateIntegerValue(value_)); | 113 return scoped_ptr<base::Value>(base::Value::CreateIntegerValue(value_)); |
| 114 } | 114 } |
| 115 | 115 |
| 116 bool Populate(const Value& value) { | 116 bool Populate(const base::Value& value) { |
| 117 int int_value; | 117 int int_value; |
| 118 if (!value.GetAsInteger(&int_value) || int_value < 0) | 118 if (!value.GetAsInteger(&int_value) || int_value < 0) |
| 119 return false; | 119 return false; |
| 120 value_ = int_value; | 120 value_ = int_value; |
| 121 return true; | 121 return true; |
| 122 } | 122 } |
| 123 | 123 |
| 124 private: | 124 private: |
| 125 uint32 value_; // A bitmask of Context values. | 125 uint32 value_; // A bitmask of Context values. |
| 126 }; | 126 }; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 171 |
| 172 // Sets the checked state to |checked|. Returns true if successful. | 172 // Sets the checked state to |checked|. Returns true if successful. |
| 173 bool SetChecked(bool checked); | 173 bool SetChecked(bool checked); |
| 174 | 174 |
| 175 // Converts to Value for serialization to preferences. | 175 // Converts to Value for serialization to preferences. |
| 176 scoped_ptr<base::DictionaryValue> ToValue() const; | 176 scoped_ptr<base::DictionaryValue> ToValue() const; |
| 177 | 177 |
| 178 // Returns a new MenuItem created from |value|, or NULL if there is | 178 // Returns a new MenuItem created from |value|, or NULL if there is |
| 179 // an error. The caller takes ownership of the MenuItem. | 179 // an error. The caller takes ownership of the MenuItem. |
| 180 static MenuItem* Populate(const std::string& extension_id, | 180 static MenuItem* Populate(const std::string& extension_id, |
| 181 const DictionaryValue& value, | 181 const base::DictionaryValue& value, |
| 182 std::string* error); | 182 std::string* error); |
| 183 | 183 |
| 184 // Sets any document and target URL patterns from |properties|. | 184 // Sets any document and target URL patterns from |properties|. |
| 185 bool PopulateURLPatterns(std::vector<std::string>* document_url_patterns, | 185 bool PopulateURLPatterns(std::vector<std::string>* document_url_patterns, |
| 186 std::vector<std::string>* target_url_patterns, | 186 std::vector<std::string>* target_url_patterns, |
| 187 std::string* error); | 187 std::string* error); |
| 188 | 188 |
| 189 protected: | 189 protected: |
| 190 friend class MenuManager; | 190 friend class MenuManager; |
| 191 | 191 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 ExtensionIconManager icon_manager_; | 349 ExtensionIconManager icon_manager_; |
| 350 | 350 |
| 351 Profile* profile_; | 351 Profile* profile_; |
| 352 | 352 |
| 353 DISALLOW_COPY_AND_ASSIGN(MenuManager); | 353 DISALLOW_COPY_AND_ASSIGN(MenuManager); |
| 354 }; | 354 }; |
| 355 | 355 |
| 356 } // namespace extensions | 356 } // namespace extensions |
| 357 | 357 |
| 358 #endif // CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_ | 358 #endif // CHROME_BROWSER_EXTENSIONS_MENU_MANAGER_H_ |
| OLD | NEW |