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_actions_api.h " | 5 #include "chrome/browser/extensions/api/extension_action/extension_actions_api.h " |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 return false; | 151 return false; |
152 if (color_ints[i] > 255 || color_ints[i] < 0) | 152 if (color_ints[i] > 255 || color_ints[i] < 0) |
153 return false; | 153 return false; |
154 } | 154 } |
155 | 155 |
156 *result = SkColorSetARGB(255, color_ints[0], color_ints[1], color_ints[2]); | 156 *result = SkColorSetARGB(255, color_ints[0], color_ints[1], color_ints[2]); |
157 return true; | 157 return true; |
158 } | 158 } |
159 | 159 |
160 bool ExtensionActionFunction::SetVisible(bool visible) { | 160 bool ExtensionActionFunction::SetVisible(bool visible) { |
161 // If --browser-actions-for-all is enabled there will be a browser_action | 161 // If --extension-action-box is enabled there will be a browser_action |
Aaron Boodman
2012/05/17 04:34:29
--enable-action-box
not at google - send to devlin
2012/05/17 04:38:17
Done.
| |
162 // here instead of a page action. Until we decide what to do with that, just | 162 // here instead of a page action. Until we decide what to do with that, just |
163 // ignore. | 163 // ignore. |
164 if (!GetExtension()->page_action()) | 164 if (!GetExtension()->page_action()) |
165 return true; | 165 return true; |
166 extension_action_->SetIsVisible(tab_id_, visible); | 166 extension_action_->SetIsVisible(tab_id_, visible); |
167 NotifyChange(); | 167 NotifyChange(); |
168 return true; | 168 return true; |
169 } | 169 } |
170 | 170 |
171 bool ExtensionActionShowFunction::RunExtensionAction() { | 171 bool ExtensionActionShowFunction::RunExtensionAction() { |
(...skipping 10 matching lines...) Expand all Loading... | |
182 base::BinaryValue* binary = NULL; | 182 base::BinaryValue* binary = NULL; |
183 int icon_index; | 183 int icon_index; |
184 if (details_->GetBinary("imageData", &binary)) { | 184 if (details_->GetBinary("imageData", &binary)) { |
185 IPC::Message bitmap_pickle(binary->GetBuffer(), binary->GetSize()); | 185 IPC::Message bitmap_pickle(binary->GetBuffer(), binary->GetSize()); |
186 PickleIterator iter(bitmap_pickle); | 186 PickleIterator iter(bitmap_pickle); |
187 SkBitmap bitmap; | 187 SkBitmap bitmap; |
188 EXTENSION_FUNCTION_VALIDATE( | 188 EXTENSION_FUNCTION_VALIDATE( |
189 IPC::ReadParam(&bitmap_pickle, &iter, &bitmap)); | 189 IPC::ReadParam(&bitmap_pickle, &iter, &bitmap)); |
190 extension_action_->SetIcon(tab_id_, bitmap); | 190 extension_action_->SetIcon(tab_id_, bitmap); |
191 } else if (details_->GetInteger("iconIndex", &icon_index)) { | 191 } else if (details_->GetInteger("iconIndex", &icon_index)) { |
192 // If --browser-actions-for-all is enabled there might legitimately be an | 192 // If --extension-action-box is enabled there might legitimately be an |
193 // iconIndex set. Until we decide what to do with that, ignore. | 193 // iconIndex set. Until we decide what to do with that, ignore. |
194 if (!GetExtension()->page_action()) | 194 if (!GetExtension()->page_action()) |
195 return true; | 195 return true; |
196 if (icon_index < 0 || | 196 if (icon_index < 0 || |
197 static_cast<size_t>(icon_index) >= | 197 static_cast<size_t>(icon_index) >= |
198 extension_action_->icon_paths()->size()) { | 198 extension_action_->icon_paths()->size()) { |
199 error_ = kIconIndexOutOfBounds; | 199 error_ = kIconIndexOutOfBounds; |
200 return false; | 200 return false; |
201 } | 201 } |
202 extension_action_->SetIcon(tab_id_, SkBitmap()); | 202 extension_action_->SetIcon(tab_id_, SkBitmap()); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { | 285 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { |
286 ListValue* list = new ListValue(); | 286 ListValue* list = new ListValue(); |
287 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); | 287 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); |
288 list->Append(Value::CreateIntegerValue(SkColorGetR(color))); | 288 list->Append(Value::CreateIntegerValue(SkColorGetR(color))); |
289 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); | 289 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); |
290 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); | 290 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); |
291 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); | 291 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); |
292 result_.reset(list); | 292 result_.reset(list); |
293 return true; | 293 return true; |
294 } | 294 } |
OLD | NEW |