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 <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 14 matching lines...) Loading... | |
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/render_messages.h" | 28 #include "chrome/common/render_messages.h" |
29 #include "content/public/browser/navigation_entry.h" | 29 #include "content/public/browser/navigation_entry.h" |
30 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
31 #include "extensions/common/error_utils.h" | 31 #include "extensions/common/error_utils.h" |
32 #include "ui/gfx/image/image.h" | 32 #include "ui/gfx/image/image.h" |
33 #include "ui/gfx/image/image_skia.h" | 33 #include "ui/gfx/image/image_skia.h" |
34 | 34 |
35 #include "chrome/browser/ui/browser_finder.h" | |
36 | |
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...) 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...) 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 Browser* browser = | |
813 chrome::FindOrCreateTabbedBrowser(profile_, chrome::GetActiveDesktop()); | |
mark a. foltz
2013/10/07 22:08:14
Need to decide which window gets the popup.
- W
justinlin
2013/10/09 18:19:32
Yes, we should use the last active.
| |
814 std::pair<const std::string, void* /*gfx::NativeWindow*/> details = | |
815 std::make_pair(extension_id(), browser/*browser->window()->GetNativeWindow ()*/); | |
816 content::NotificationService::current()->Notify( | |
mark a. foltz
2013/10/07 22:08:14
It looks like only the Mac UI handles this notific
justinlin
2013/10/09 18:19:32
Using an observer notification instead now.
| |
817 chrome::NOTIFICATION_EXTENSION_COMMAND_BROWSER_ACTION_MAC, | |
818 content::Source<Profile>(profile_), | |
819 content::Details< | |
820 std::pair<const std::string, void* /*gfx::NativeWindow*/> >(&details)) ; | |
821 return true; | |
822 } | |
823 | |
808 // | 824 // |
809 // ScriptBadgeGetAttentionFunction | 825 // ScriptBadgeGetAttentionFunction |
810 // | 826 // |
811 | 827 |
812 ScriptBadgeGetAttentionFunction::~ScriptBadgeGetAttentionFunction() {} | 828 ScriptBadgeGetAttentionFunction::~ScriptBadgeGetAttentionFunction() {} |
813 | 829 |
814 bool ScriptBadgeGetAttentionFunction::RunExtensionAction() { | 830 bool ScriptBadgeGetAttentionFunction::RunExtensionAction() { |
815 tab_helper().location_bar_controller()->GetAttentionFor(extension_id()); | 831 tab_helper().location_bar_controller()->GetAttentionFor(extension_id()); |
816 return true; | 832 return true; |
817 } | 833 } |
(...skipping 66 matching lines...) Loading... | |
884 return true; | 900 return true; |
885 } | 901 } |
886 | 902 |
887 bool EnablePageActionsFunction::RunImpl() { | 903 bool EnablePageActionsFunction::RunImpl() { |
888 return SetPageActionEnabled(true); | 904 return SetPageActionEnabled(true); |
889 } | 905 } |
890 | 906 |
891 bool DisablePageActionsFunction::RunImpl() { | 907 bool DisablePageActionsFunction::RunImpl() { |
892 return SetPageActionEnabled(false); | 908 return SetPageActionEnabled(false); |
893 } | 909 } |
OLD | NEW |