| 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 "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 switch (extension_action.action_type()) { | 391 switch (extension_action.action_type()) { |
| 392 case ActionInfo::TYPE_BROWSER: | 392 case ActionInfo::TYPE_BROWSER: |
| 393 event_name = "browserAction.onClicked"; | 393 event_name = "browserAction.onClicked"; |
| 394 break; | 394 break; |
| 395 case ActionInfo::TYPE_PAGE: | 395 case ActionInfo::TYPE_PAGE: |
| 396 event_name = "pageAction.onClicked"; | 396 event_name = "pageAction.onClicked"; |
| 397 break; | 397 break; |
| 398 case ActionInfo::TYPE_SYSTEM_INDICATOR: | 398 case ActionInfo::TYPE_SYSTEM_INDICATOR: |
| 399 // The System Indicator handles its own clicks. | 399 // The System Indicator handles its own clicks. |
| 400 break; | 400 break; |
| 401 case ActionInfo::TYPE_ACTIVE_SCRIPT: |
| 402 NOTREACHED(); // We shouldn't get these calls (yet). |
| 403 return; |
| 401 } | 404 } |
| 402 | 405 |
| 403 if (event_name) { | 406 if (event_name) { |
| 404 scoped_ptr<base::ListValue> args(new base::ListValue()); | 407 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 405 base::DictionaryValue* tab_value = | 408 base::DictionaryValue* tab_value = |
| 406 extensions::ExtensionTabUtil::CreateTabValue(web_contents); | 409 extensions::ExtensionTabUtil::CreateTabValue(web_contents); |
| 407 args->Append(tab_value); | 410 args->Append(tab_value); |
| 408 | 411 |
| 409 DispatchEventToExtension( | 412 DispatchEventToExtension( |
| 410 context, extension_action.extension_id(), event_name, args.Pass()); | 413 context, extension_action.extension_id(), event_name, args.Pass()); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 ->GetBrowserAction(*extension_.get())) { | 616 ->GetBrowserAction(*extension_.get())) { |
| 614 NotifyBrowserActionChange(); | 617 NotifyBrowserActionChange(); |
| 615 } else if (ExtensionActionManager::Get(GetProfile()) | 618 } else if (ExtensionActionManager::Get(GetProfile()) |
| 616 ->GetPageAction(*extension_.get())) { | 619 ->GetPageAction(*extension_.get())) { |
| 617 NotifyLocationBarChange(); | 620 NotifyLocationBarChange(); |
| 618 } | 621 } |
| 619 return; | 622 return; |
| 620 case ActionInfo::TYPE_SYSTEM_INDICATOR: | 623 case ActionInfo::TYPE_SYSTEM_INDICATOR: |
| 621 NotifySystemIndicatorChange(); | 624 NotifySystemIndicatorChange(); |
| 622 return; | 625 return; |
| 626 case ActionInfo::TYPE_ACTIVE_SCRIPT: |
| 627 NOTREACHED(); // We shouldn't get these calls (yet). |
| 628 return; |
| 623 } | 629 } |
| 624 NOTREACHED(); | 630 NOTREACHED(); |
| 625 } | 631 } |
| 626 | 632 |
| 627 void ExtensionActionFunction::NotifyBrowserActionChange() { | 633 void ExtensionActionFunction::NotifyBrowserActionChange() { |
| 628 content::NotificationService::current()->Notify( | 634 content::NotificationService::current()->Notify( |
| 629 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, | 635 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, |
| 630 content::Source<ExtensionAction>(extension_action_), | 636 content::Source<ExtensionAction>(extension_action_), |
| 631 content::Details<Profile>(GetProfile())); | 637 content::Details<Profile>(GetProfile())); |
| 632 } | 638 } |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 915 return true; | 921 return true; |
| 916 } | 922 } |
| 917 | 923 |
| 918 bool EnablePageActionsFunction::RunSync() { | 924 bool EnablePageActionsFunction::RunSync() { |
| 919 return SetPageActionEnabled(true); | 925 return SetPageActionEnabled(true); |
| 920 } | 926 } |
| 921 | 927 |
| 922 bool DisablePageActionsFunction::RunSync() { | 928 bool DisablePageActionsFunction::RunSync() { |
| 923 return SetPageActionEnabled(false); | 929 return SetPageActionEnabled(false); |
| 924 } | 930 } |
| OLD | NEW |