| 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 page_action_->SetTitle(tab_id, title); | 190 page_action_->SetTitle(tab_id, title); |
| 191 contents_->PageActionStateChanged(); | 191 contents_->PageActionStateChanged(); |
| 192 return true; | 192 return true; |
| 193 } | 193 } |
| 194 | 194 |
| 195 bool PageActionSetPopupFunction::RunImpl() { |
| 196 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); |
| 197 const DictionaryValue* args = args_as_dictionary(); |
| 198 |
| 199 int tab_id; |
| 200 EXTENSION_FUNCTION_VALIDATE(args->GetInteger(L"tabId", &tab_id)); |
| 201 if (!InitCommon(tab_id)) |
| 202 return false; |
| 203 |
| 204 // TODO(skerner): Consider allowing null and undefined to mean the popup |
| 205 // should be removed. |
| 206 std::string popup_string; |
| 207 EXTENSION_FUNCTION_VALIDATE(args->GetString(L"popup", &popup_string)); |
| 208 |
| 209 GURL popup_url; |
| 210 if (!popup_string.empty()) |
| 211 popup_url = GetExtension()->GetResourceURL(popup_string); |
| 212 |
| 213 page_action_->SetPopupUrl(tab_id, popup_url); |
| 214 contents_->PageActionStateChanged(); |
| 215 return true; |
| 216 } |
| 217 |
| 195 // Not currently exposed to extensions. To re-enable, add mapping in | 218 // Not currently exposed to extensions. To re-enable, add mapping in |
| 196 // extension_function_dispatcher. | 219 // extension_function_dispatcher. |
| 197 bool PageActionSetBadgeBackgroundColorFunction::RunImpl() { | 220 bool PageActionSetBadgeBackgroundColorFunction::RunImpl() { |
| 198 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); | 221 EXTENSION_FUNCTION_VALIDATE(args_->IsType(Value::TYPE_DICTIONARY)); |
| 199 const DictionaryValue* args = args_as_dictionary(); | 222 const DictionaryValue* args = args_as_dictionary(); |
| 200 | 223 |
| 201 int tab_id; | 224 int tab_id; |
| 202 EXTENSION_FUNCTION_VALIDATE(args->GetInteger(L"tabId", &tab_id)); | 225 EXTENSION_FUNCTION_VALIDATE(args->GetInteger(L"tabId", &tab_id)); |
| 203 if (!InitCommon(tab_id)) | 226 if (!InitCommon(tab_id)) |
| 204 return false; | 227 return false; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 if (!InitCommon(tab_id)) | 278 if (!InitCommon(tab_id)) |
| 256 return false; | 279 return false; |
| 257 | 280 |
| 258 std::string text; | 281 std::string text; |
| 259 EXTENSION_FUNCTION_VALIDATE(args->GetString(L"text", &text)); | 282 EXTENSION_FUNCTION_VALIDATE(args->GetString(L"text", &text)); |
| 260 | 283 |
| 261 page_action_->SetBadgeText(tab_id, text); | 284 page_action_->SetBadgeText(tab_id, text); |
| 262 contents_->PageActionStateChanged(); | 285 contents_->PageActionStateChanged(); |
| 263 return true; | 286 return true; |
| 264 } | 287 } |
| OLD | NEW |