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 if (!base::Base64Encode(raw_str, &base64_str)) | 116 base::Base64Encode(raw_str, &base64_str); |
117 return std::string(); | |
118 return base64_str; | 117 return base64_str; |
119 } | 118 } |
120 | 119 |
121 // Set |action|'s default values to those specified in |dict|. | 120 // Set |action|'s default values to those specified in |dict|. |
122 void SetDefaultsFromValue(const base::DictionaryValue* dict, | 121 void SetDefaultsFromValue(const base::DictionaryValue* dict, |
123 ExtensionAction* action) { | 122 ExtensionAction* action) { |
124 const int kTabId = ExtensionAction::kDefaultTabId; | 123 const int kTabId = ExtensionAction::kDefaultTabId; |
125 std::string str_value; | 124 std::string str_value; |
126 int int_value; | 125 int int_value; |
127 SkBitmap bitmap; | 126 SkBitmap bitmap; |
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 return true; | 953 return true; |
955 } | 954 } |
956 | 955 |
957 bool EnablePageActionsFunction::RunImpl() { | 956 bool EnablePageActionsFunction::RunImpl() { |
958 return SetPageActionEnabled(true); | 957 return SetPageActionEnabled(true); |
959 } | 958 } |
960 | 959 |
961 bool DisablePageActionsFunction::RunImpl() { | 960 bool DisablePageActionsFunction::RunImpl() { |
962 return SetPageActionEnabled(false); | 961 return SetPageActionEnabled(false); |
963 } | 962 } |
OLD | NEW |