Chromium Code Reviews| 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 <string> | 7 #include <set> |
|
Finnur
2013/10/15 10:44:21
Where's std::set used?
justinlin
2013/10/16 07:06:48
Done.
| |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
| 15 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_ api_constants.h" | 15 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_ api_constants.h" |
| 16 #include "chrome/browser/extensions/event_router.h" | 16 #include "chrome/browser/extensions/event_router.h" |
| 17 #include "chrome/browser/extensions/extension_action.h" | 17 #include "chrome/browser/extensions/extension_action.h" |
| 18 #include "chrome/browser/extensions/extension_action_manager.h" | 18 #include "chrome/browser/extensions/extension_action_manager.h" |
| 19 #include "chrome/browser/extensions/extension_function_registry.h" | 19 #include "chrome/browser/extensions/extension_function_registry.h" |
| 20 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
| 21 #include "chrome/browser/extensions/extension_system.h" | 21 #include "chrome/browser/extensions/extension_system.h" |
| 22 #include "chrome/browser/extensions/extension_tab_util.h" | 22 #include "chrome/browser/extensions/extension_tab_util.h" |
| 23 #include "chrome/browser/extensions/location_bar_controller.h" | 23 #include "chrome/browser/extensions/location_bar_controller.h" |
| 24 #include "chrome/browser/extensions/state_store.h" | 24 #include "chrome/browser/extensions/state_store.h" |
| 25 #include "chrome/browser/extensions/tab_helper.h" | 25 #include "chrome/browser/extensions/tab_helper.h" |
| 26 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
| 27 #include "chrome/common/extensions/api/extension_action/action_info.h" | 27 #include "chrome/common/extensions/api/extension_action/action_info.h" |
| 28 #include "chrome/common/extensions/features/simple_feature.h" | |
|
Finnur
2013/10/15 10:44:21
Don't need this?
justinlin
2013/10/16 07:06:48
Done.
| |
| 28 #include "chrome/common/render_messages.h" | 29 #include "chrome/common/render_messages.h" |
| 29 #include "content/public/browser/navigation_entry.h" | 30 #include "content/public/browser/navigation_entry.h" |
| 30 #include "content/public/browser/notification_service.h" | 31 #include "content/public/browser/notification_service.h" |
| 31 #include "extensions/common/error_utils.h" | 32 #include "extensions/common/error_utils.h" |
| 32 #include "ui/gfx/image/image.h" | 33 #include "ui/gfx/image/image.h" |
| 33 #include "ui/gfx/image/image_skia.h" | 34 #include "ui/gfx/image/image_skia.h" |
| 34 | 35 |
| 36 using chrome::VersionInfo; | |
|
Finnur
2013/10/15 10:44:21
Don't need this, right?
justinlin
2013/10/16 07:06:48
Done.
| |
| 35 using content::WebContents; | 37 using content::WebContents; |
| 36 | 38 |
| 37 namespace page_actions_keys = extension_page_actions_api_constants; | 39 namespace page_actions_keys = extension_page_actions_api_constants; |
| 38 | 40 |
| 39 namespace extensions { | 41 namespace extensions { |
| 40 | 42 |
| 41 namespace { | 43 namespace { |
| 42 | 44 |
| 43 const char kBrowserActionStorageKey[] = "browser_action"; | 45 const char kBrowserActionStorageKey[] = "browser_action"; |
| 44 const char kPopupUrlStorageKey[] = "poupup_url"; | 46 const char kPopupUrlStorageKey[] = "poupup_url"; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 registry->RegisterFunction<BrowserActionSetTitleFunction>(); | 204 registry->RegisterFunction<BrowserActionSetTitleFunction>(); |
| 203 registry->RegisterFunction<BrowserActionSetBadgeTextFunction>(); | 205 registry->RegisterFunction<BrowserActionSetBadgeTextFunction>(); |
| 204 registry->RegisterFunction<BrowserActionSetBadgeBackgroundColorFunction>(); | 206 registry->RegisterFunction<BrowserActionSetBadgeBackgroundColorFunction>(); |
| 205 registry->RegisterFunction<BrowserActionSetPopupFunction>(); | 207 registry->RegisterFunction<BrowserActionSetPopupFunction>(); |
| 206 registry->RegisterFunction<BrowserActionGetTitleFunction>(); | 208 registry->RegisterFunction<BrowserActionGetTitleFunction>(); |
| 207 registry->RegisterFunction<BrowserActionGetBadgeTextFunction>(); | 209 registry->RegisterFunction<BrowserActionGetBadgeTextFunction>(); |
| 208 registry->RegisterFunction<BrowserActionGetBadgeBackgroundColorFunction>(); | 210 registry->RegisterFunction<BrowserActionGetBadgeBackgroundColorFunction>(); |
| 209 registry->RegisterFunction<BrowserActionGetPopupFunction>(); | 211 registry->RegisterFunction<BrowserActionGetPopupFunction>(); |
| 210 registry->RegisterFunction<BrowserActionEnableFunction>(); | 212 registry->RegisterFunction<BrowserActionEnableFunction>(); |
| 211 registry->RegisterFunction<BrowserActionDisableFunction>(); | 213 registry->RegisterFunction<BrowserActionDisableFunction>(); |
| 214 registry->RegisterFunction<BrowserActionOpenPopupFunction>(); | |
| 212 | 215 |
| 213 // Page Actions | 216 // Page Actions |
| 214 registry->RegisterFunction<EnablePageActionsFunction>(); | 217 registry->RegisterFunction<EnablePageActionsFunction>(); |
| 215 registry->RegisterFunction<DisablePageActionsFunction>(); | 218 registry->RegisterFunction<DisablePageActionsFunction>(); |
| 216 registry->RegisterFunction<PageActionShowFunction>(); | 219 registry->RegisterFunction<PageActionShowFunction>(); |
| 217 registry->RegisterFunction<PageActionHideFunction>(); | 220 registry->RegisterFunction<PageActionHideFunction>(); |
| 218 registry->RegisterFunction<PageActionSetIconFunction>(); | 221 registry->RegisterFunction<PageActionSetIconFunction>(); |
| 219 registry->RegisterFunction<PageActionSetTitleFunction>(); | 222 registry->RegisterFunction<PageActionSetTitleFunction>(); |
| 220 registry->RegisterFunction<PageActionSetPopupFunction>(); | 223 registry->RegisterFunction<PageActionSetPopupFunction>(); |
| 221 registry->RegisterFunction<PageActionGetTitleFunction>(); | 224 registry->RegisterFunction<PageActionGetTitleFunction>(); |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 798 list->Append( | 801 list->Append( |
| 799 new base::FundamentalValue(static_cast<int>(SkColorGetG(color)))); | 802 new base::FundamentalValue(static_cast<int>(SkColorGetG(color)))); |
| 800 list->Append( | 803 list->Append( |
| 801 new base::FundamentalValue(static_cast<int>(SkColorGetB(color)))); | 804 new base::FundamentalValue(static_cast<int>(SkColorGetB(color)))); |
| 802 list->Append( | 805 list->Append( |
| 803 new base::FundamentalValue(static_cast<int>(SkColorGetA(color)))); | 806 new base::FundamentalValue(static_cast<int>(SkColorGetA(color)))); |
| 804 SetResult(list); | 807 SetResult(list); |
| 805 return true; | 808 return true; |
| 806 } | 809 } |
| 807 | 810 |
| 811 bool BrowserActionOpenPopupFunction::RunImpl() { | |
| 812 ExtensionService* service = | |
| 813 extensions::ExtensionSystem::Get(profile_)->extension_service(); | |
| 814 if (!service) { | |
| 815 SetResult(new base::DictionaryValue()); | |
| 816 return false; | |
|
Finnur
2013/10/15 10:44:21
Do you see these (service and model below) being N
justinlin
2013/10/16 07:06:48
yea, I think extension_service() would not be NULL
| |
| 817 } | |
| 818 | |
| 819 ExtensionToolbarModel *model = service->toolbar_model(); | |
|
Finnur
2013/10/15 10:44:21
Foo* foo
not
Foo *foo.
justinlin
2013/10/16 07:06:48
Done.
| |
| 820 if (!model) { | |
| 821 SetResult(new base::DictionaryValue()); | |
| 822 return false; | |
| 823 } | |
| 824 | |
| 825 model->ShowBrowserActionPopup(extension_); | |
| 826 | |
| 827 SetResult(new base::DictionaryValue()); | |
| 828 return true; | |
| 829 } | |
| 830 | |
| 808 // | 831 // |
| 809 // ScriptBadgeGetAttentionFunction | 832 // ScriptBadgeGetAttentionFunction |
| 810 // | 833 // |
| 811 | 834 |
| 812 ScriptBadgeGetAttentionFunction::~ScriptBadgeGetAttentionFunction() {} | 835 ScriptBadgeGetAttentionFunction::~ScriptBadgeGetAttentionFunction() {} |
| 813 | 836 |
| 814 bool ScriptBadgeGetAttentionFunction::RunExtensionAction() { | 837 bool ScriptBadgeGetAttentionFunction::RunExtensionAction() { |
| 815 tab_helper().location_bar_controller()->GetAttentionFor(extension_id()); | 838 tab_helper().location_bar_controller()->GetAttentionFor(extension_id()); |
| 816 return true; | 839 return true; |
| 817 } | 840 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 884 return true; | 907 return true; |
| 885 } | 908 } |
| 886 | 909 |
| 887 bool EnablePageActionsFunction::RunImpl() { | 910 bool EnablePageActionsFunction::RunImpl() { |
| 888 return SetPageActionEnabled(true); | 911 return SetPageActionEnabled(true); |
| 889 } | 912 } |
| 890 | 913 |
| 891 bool DisablePageActionsFunction::RunImpl() { | 914 bool DisablePageActionsFunction::RunImpl() { |
| 892 return SetPageActionEnabled(false); | 915 return SetPageActionEnabled(false); |
| 893 } | 916 } |
| OLD | NEW |