OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/extensions/extension_action_storage_manager.h" | 5 #include "chrome/browser/extensions/extension_action_storage_manager.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 return false; | 73 return false; |
74 | 74 |
75 bool success = gfx::PNGCodec::Decode( | 75 bool success = gfx::PNGCodec::Decode( |
76 reinterpret_cast<unsigned const char*>(raw_str.data()), raw_str.size(), | 76 reinterpret_cast<unsigned const char*>(raw_str.data()), raw_str.size(), |
77 bitmap); | 77 bitmap); |
78 return success; | 78 return success; |
79 } | 79 } |
80 | 80 |
81 // Conversion function for reading/writing to storage. | 81 // Conversion function for reading/writing to storage. |
82 std::string BitmapToString(const SkBitmap& bitmap) { | 82 std::string BitmapToString(const SkBitmap& bitmap) { |
83 SkAutoLockPixels lock_image(bitmap); | |
84 std::vector<unsigned char> data; | 83 std::vector<unsigned char> data; |
85 bool success = gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &data); | 84 bool success = gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &data); |
86 if (!success) | 85 if (!success) |
87 return std::string(); | 86 return std::string(); |
88 | 87 |
89 base::StringPiece raw_str( | 88 base::StringPiece raw_str( |
90 reinterpret_cast<const char*>(&data[0]), data.size()); | 89 reinterpret_cast<const char*>(&data[0]), data.size()); |
91 std::string base64_str; | 90 std::string base64_str; |
92 base::Base64Encode(raw_str, &base64_str); | 91 base::Base64Encode(raw_str, &base64_str); |
93 return base64_str; | 92 return base64_str; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 return; | 276 return; |
278 | 277 |
279 SetDefaultsFromValue(dict, browser_action); | 278 SetDefaultsFromValue(dict, browser_action); |
280 } | 279 } |
281 | 280 |
282 StateStore* ExtensionActionStorageManager::GetStateStore() { | 281 StateStore* ExtensionActionStorageManager::GetStateStore() { |
283 return ExtensionSystem::Get(browser_context_)->state_store(); | 282 return ExtensionSystem::Get(browser_context_)->state_store(); |
284 } | 283 } |
285 | 284 |
286 } // namespace extensions | 285 } // namespace extensions |
OLD | NEW |