| 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 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 5 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // Conversion function for reading/writing to storage. | 106 // Conversion function for reading/writing to storage. |
| 107 std::string RepresentationToString(const gfx::ImageSkia& image, float scale) { | 107 std::string RepresentationToString(const gfx::ImageSkia& image, float scale) { |
| 108 SkBitmap bitmap = image.GetRepresentation(scale).sk_bitmap(); | 108 SkBitmap bitmap = image.GetRepresentation(scale).sk_bitmap(); |
| 109 IPC::Message bitmap_pickle; | 109 IPC::Message bitmap_pickle; |
| 110 // Clear the header values so they don't vary in serialization. | 110 // Clear the header values so they don't vary in serialization. |
| 111 bitmap_pickle.SetHeaderValues(0, 0, 0); | 111 bitmap_pickle.SetHeaderValues(0, 0, 0); |
| 112 IPC::WriteParam(&bitmap_pickle, bitmap); | 112 IPC::WriteParam(&bitmap_pickle, bitmap); |
| 113 std::string raw_str(static_cast<const char*>(bitmap_pickle.data()), | 113 std::string raw_str(static_cast<const char*>(bitmap_pickle.data()), |
| 114 bitmap_pickle.size()); | 114 bitmap_pickle.size()); |
| 115 std::string base64_str; | 115 std::string base64_str; |
| 116 base::Base64Encode(raw_str, &base64_str); | 116 if (!base::Base64Encode(raw_str, &base64_str)) |
| 117 return std::string(); |
| 117 return base64_str; | 118 return base64_str; |
| 118 } | 119 } |
| 119 | 120 |
| 120 // Set |action|'s default values to those specified in |dict|. | 121 // Set |action|'s default values to those specified in |dict|. |
| 121 void SetDefaultsFromValue(const base::DictionaryValue* dict, | 122 void SetDefaultsFromValue(const base::DictionaryValue* dict, |
| 122 ExtensionAction* action) { | 123 ExtensionAction* action) { |
| 123 const int kTabId = ExtensionAction::kDefaultTabId; | 124 const int kTabId = ExtensionAction::kDefaultTabId; |
| 124 std::string str_value; | 125 std::string str_value; |
| 125 int int_value; | 126 int int_value; |
| 126 SkBitmap bitmap; | 127 SkBitmap bitmap; |
| (...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 return true; | 954 return true; |
| 954 } | 955 } |
| 955 | 956 |
| 956 bool EnablePageActionsFunction::RunImpl() { | 957 bool EnablePageActionsFunction::RunImpl() { |
| 957 return SetPageActionEnabled(true); | 958 return SetPageActionEnabled(true); |
| 958 } | 959 } |
| 959 | 960 |
| 960 bool DisablePageActionsFunction::RunImpl() { | 961 bool DisablePageActionsFunction::RunImpl() { |
| 961 return SetPageActionEnabled(false); | 962 return SetPageActionEnabled(false); |
| 962 } | 963 } |
| OLD | NEW |