| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_page_actions_module.h" | 5 #include "chrome/browser/extensions/extension_page_actions_module.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "chrome/browser/browser.h" | 8 #include "chrome/browser/browser.h" |
| 9 #include "chrome/browser/browser_list.h" | 9 #include "chrome/browser/browser_list.h" |
| 10 #include "chrome/browser/profile.h" | 10 #include "chrome/browser/profile.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 return false; | 185 return false; |
| 186 | 186 |
| 187 std::string title; | 187 std::string title; |
| 188 EXTENSION_FUNCTION_VALIDATE(args->GetString(L"title", &title)); | 188 EXTENSION_FUNCTION_VALIDATE(args->GetString(L"title", &title)); |
| 189 | 189 |
| 190 state_->set_title(title); | 190 state_->set_title(title); |
| 191 contents_->PageActionStateChanged(); | 191 contents_->PageActionStateChanged(); |
| 192 return true; | 192 return true; |
| 193 } | 193 } |
| 194 | 194 |
| 195 // Not currently exposed to extensions. To re-enable, add mapping in |
| 196 // extension_function_dispatcher. |
| 195 bool PageActionSetBadgeBackgroundColorFunction::RunImpl() { | 197 bool PageActionSetBadgeBackgroundColorFunction::RunImpl() { |
| 196 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); | 198 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); |
| 197 const DictionaryValue* args = static_cast<const DictionaryValue*>(args_); | 199 const DictionaryValue* args = static_cast<const DictionaryValue*>(args_); |
| 198 | 200 |
| 199 int tab_id; | 201 int tab_id; |
| 200 EXTENSION_FUNCTION_VALIDATE(args->GetInteger(L"tabId", &tab_id)); | 202 EXTENSION_FUNCTION_VALIDATE(args->GetInteger(L"tabId", &tab_id)); |
| 201 if (!InitCommon(tab_id)) | 203 if (!InitCommon(tab_id)) |
| 202 return false; | 204 return false; |
| 203 | 205 |
| 204 ListValue* color_value; | 206 ListValue* color_value; |
| 205 EXTENSION_FUNCTION_VALIDATE(args->GetList(L"color", &color_value)); | 207 EXTENSION_FUNCTION_VALIDATE(args->GetList(L"color", &color_value)); |
| 206 EXTENSION_FUNCTION_VALIDATE(color_value->GetSize() == 4); | 208 EXTENSION_FUNCTION_VALIDATE(color_value->GetSize() == 4); |
| 207 | 209 |
| 208 int color_array[4] = {0}; | 210 int color_array[4] = {0}; |
| 209 for (size_t i = 0; i < arraysize(color_array); ++i) | 211 for (size_t i = 0; i < arraysize(color_array); ++i) |
| 210 EXTENSION_FUNCTION_VALIDATE(color_value->GetInteger(i, &color_array[i])); | 212 EXTENSION_FUNCTION_VALIDATE(color_value->GetInteger(i, &color_array[i])); |
| 211 | 213 |
| 212 SkColor color = SkColorSetARGB(color_array[3], color_array[0], color_array[1], | 214 SkColor color = SkColorSetARGB(color_array[3], color_array[0], color_array[1], |
| 213 color_array[2]); | 215 color_array[2]); |
| 214 state_->set_badge_background_color(color); | 216 state_->set_badge_background_color(color); |
| 215 contents_->PageActionStateChanged(); | 217 contents_->PageActionStateChanged(); |
| 216 return true; | 218 return true; |
| 217 } | 219 } |
| 218 | 220 |
| 221 // Not currently exposed to extensions. To re-enable, add mapping in |
| 222 // extension_function_dispatcher. |
| 219 bool PageActionSetBadgeTextColorFunction::RunImpl() { | 223 bool PageActionSetBadgeTextColorFunction::RunImpl() { |
| 220 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); | 224 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); |
| 221 const DictionaryValue* args = static_cast<const DictionaryValue*>(args_); | 225 const DictionaryValue* args = static_cast<const DictionaryValue*>(args_); |
| 222 | 226 |
| 223 int tab_id; | 227 int tab_id; |
| 224 EXTENSION_FUNCTION_VALIDATE(args->GetInteger(L"tabId", &tab_id)); | 228 EXTENSION_FUNCTION_VALIDATE(args->GetInteger(L"tabId", &tab_id)); |
| 225 if (!InitCommon(tab_id)) | 229 if (!InitCommon(tab_id)) |
| 226 return false; | 230 return false; |
| 227 | 231 |
| 228 ListValue* color_value; | 232 ListValue* color_value; |
| 229 EXTENSION_FUNCTION_VALIDATE(args->GetList(L"color", &color_value)); | 233 EXTENSION_FUNCTION_VALIDATE(args->GetList(L"color", &color_value)); |
| 230 EXTENSION_FUNCTION_VALIDATE(color_value->GetSize() == 4); | 234 EXTENSION_FUNCTION_VALIDATE(color_value->GetSize() == 4); |
| 231 | 235 |
| 232 int color_array[4] = {0}; | 236 int color_array[4] = {0}; |
| 233 for (size_t i = 0; i < arraysize(color_array); ++i) | 237 for (size_t i = 0; i < arraysize(color_array); ++i) |
| 234 EXTENSION_FUNCTION_VALIDATE(color_value->GetInteger(i, &color_array[i])); | 238 EXTENSION_FUNCTION_VALIDATE(color_value->GetInteger(i, &color_array[i])); |
| 235 | 239 |
| 236 SkColor color = SkColorSetARGB(color_array[3], color_array[0], color_array[1], | 240 SkColor color = SkColorSetARGB(color_array[3], color_array[0], color_array[1], |
| 237 color_array[2]); | 241 color_array[2]); |
| 238 state_->set_badge_text_color(color); | 242 state_->set_badge_text_color(color); |
| 239 contents_->PageActionStateChanged(); | 243 contents_->PageActionStateChanged(); |
| 240 return true; | 244 return true; |
| 241 } | 245 } |
| 242 | 246 |
| 247 // Not currently exposed to extensions. To re-enable, add mapping in |
| 248 // extension_function_dispatcher. |
| 243 bool PageActionSetBadgeTextFunction::RunImpl() { | 249 bool PageActionSetBadgeTextFunction::RunImpl() { |
| 244 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); | 250 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); |
| 245 const DictionaryValue* args = static_cast<const DictionaryValue*>(args_); | 251 const DictionaryValue* args = static_cast<const DictionaryValue*>(args_); |
| 246 | 252 |
| 247 int tab_id; | 253 int tab_id; |
| 248 EXTENSION_FUNCTION_VALIDATE(args->GetInteger(L"tabId", &tab_id)); | 254 EXTENSION_FUNCTION_VALIDATE(args->GetInteger(L"tabId", &tab_id)); |
| 249 if (!InitCommon(tab_id)) | 255 if (!InitCommon(tab_id)) |
| 250 return false; | 256 return false; |
| 251 | 257 |
| 252 std::string text; | 258 std::string text; |
| 253 EXTENSION_FUNCTION_VALIDATE(args->GetString(L"text", &text)); | 259 EXTENSION_FUNCTION_VALIDATE(args->GetString(L"text", &text)); |
| 254 | 260 |
| 255 state_->set_badge_text(text); | 261 state_->set_badge_text(text); |
| 256 contents_->PageActionStateChanged(); | 262 contents_->PageActionStateChanged(); |
| 257 return true; | 263 return true; |
| 258 } | 264 } |
| OLD | NEW |