| 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/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "base/string_piece.h" | 11 #include "base/string_piece.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_
api_constants.h" | 13 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_
api_constants.h" |
| 14 #include "chrome/browser/extensions/extension_action.h" | 14 #include "chrome/browser/extensions/extension_action.h" |
| 15 #include "chrome/browser/extensions/extension_action_manager.h" | 15 #include "chrome/browser/extensions/extension_action_manager.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/extensions/extension_system.h" | 17 #include "chrome/browser/extensions/extension_system.h" |
| 18 #include "chrome/browser/extensions/extension_tab_util.h" | 18 #include "chrome/browser/extensions/extension_tab_util.h" |
| 19 #include "chrome/browser/extensions/location_bar_controller.h" | 19 #include "chrome/browser/extensions/location_bar_controller.h" |
| 20 #include "chrome/browser/extensions/state_store.h" | 20 #include "chrome/browser/extensions/state_store.h" |
| 21 #include "chrome/browser/extensions/tab_helper.h" | 21 #include "chrome/browser/extensions/tab_helper.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/common/chrome_notification_types.h" | 23 #include "chrome/common/chrome_notification_types.h" |
| 24 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
| 25 #include "chrome/common/extensions/extension_error_utils.h" | |
| 26 #include "chrome/common/render_messages.h" | 25 #include "chrome/common/render_messages.h" |
| 27 #include "content/public/browser/navigation_entry.h" | 26 #include "content/public/browser/navigation_entry.h" |
| 28 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
| 28 #include "extensions/common/extension_error_utils.h" |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 const char kBrowserActionStorageKey[] = "browser_action"; | 32 const char kBrowserActionStorageKey[] = "browser_action"; |
| 33 const char kPopupUrlStorageKey[] = "poupup_url"; | 33 const char kPopupUrlStorageKey[] = "poupup_url"; |
| 34 const char kTitleStorageKey[] = "title"; | 34 const char kTitleStorageKey[] = "title"; |
| 35 const char kIconStorageKey[] = "icon"; | 35 const char kIconStorageKey[] = "icon"; |
| 36 const char kBadgeTextStorageKey[] = "badge_text"; | 36 const char kBadgeTextStorageKey[] = "badge_text"; |
| 37 const char kBadgeBackgroundColorStorageKey[] = "badge_background_color"; | 37 const char kBadgeBackgroundColorStorageKey[] = "badge_background_color"; |
| 38 const char kBadgeTextColorStorageKey[] = "badge_text_color"; | 38 const char kBadgeTextColorStorageKey[] = "badge_text_color"; |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 344 |
| 345 // Find the WebContents that contains this tab id if one is required. | 345 // Find the WebContents that contains this tab id if one is required. |
| 346 if (tab_id_ == ExtensionAction::kDefaultTabId) { | 346 if (tab_id_ == ExtensionAction::kDefaultTabId) { |
| 347 EXTENSION_FUNCTION_VALIDATE( | 347 EXTENSION_FUNCTION_VALIDATE( |
| 348 extensions::ExtensionActionManager::Get(profile_)-> | 348 extensions::ExtensionActionManager::Get(profile_)-> |
| 349 GetBrowserAction(*GetExtension())); | 349 GetBrowserAction(*GetExtension())); |
| 350 } else { | 350 } else { |
| 351 ExtensionTabUtil::GetTabById( | 351 ExtensionTabUtil::GetTabById( |
| 352 tab_id_, profile(), include_incognito(), NULL, NULL, &contents_, NULL); | 352 tab_id_, profile(), include_incognito(), NULL, NULL, &contents_, NULL); |
| 353 if (!contents_) { | 353 if (!contents_) { |
| 354 error_ = ExtensionErrorUtils::FormatErrorMessage( | 354 error_ = extensions::ErrorUtils::FormatErrorMessage( |
| 355 kNoTabError, base::IntToString(tab_id_)); | 355 kNoTabError, base::IntToString(tab_id_)); |
| 356 return false; | 356 return false; |
| 357 } | 357 } |
| 358 } | 358 } |
| 359 | 359 |
| 360 return RunExtensionAction(); | 360 return RunExtensionAction(); |
| 361 } | 361 } |
| 362 | 362 |
| 363 void ExtensionActionFunction::NotifyChange() { | 363 void ExtensionActionFunction::NotifyChange() { |
| 364 switch (extension_action_->action_type()) { | 364 switch (extension_action_->action_type()) { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { | 555 bool ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() { |
| 556 ListValue* list = new ListValue(); | 556 ListValue* list = new ListValue(); |
| 557 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); | 557 SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_); |
| 558 list->Append(Value::CreateIntegerValue(SkColorGetR(color))); | 558 list->Append(Value::CreateIntegerValue(SkColorGetR(color))); |
| 559 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); | 559 list->Append(Value::CreateIntegerValue(SkColorGetG(color))); |
| 560 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); | 560 list->Append(Value::CreateIntegerValue(SkColorGetB(color))); |
| 561 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); | 561 list->Append(Value::CreateIntegerValue(SkColorGetA(color))); |
| 562 SetResult(list); | 562 SetResult(list); |
| 563 return true; | 563 return true; |
| 564 } | 564 } |
| OLD | NEW |