| 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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 context, extension_action.extension_id(), event_name, args.Pass()); | 409 context, extension_action.extension_id(), event_name, args.Pass()); |
| 410 } | 410 } |
| 411 } | 411 } |
| 412 | 412 |
| 413 // | 413 // |
| 414 // ExtensionActionStorageManager | 414 // ExtensionActionStorageManager |
| 415 // | 415 // |
| 416 | 416 |
| 417 ExtensionActionStorageManager::ExtensionActionStorageManager(Profile* profile) | 417 ExtensionActionStorageManager::ExtensionActionStorageManager(Profile* profile) |
| 418 : profile_(profile) { | 418 : profile_(profile) { |
| 419 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 419 registrar_.Add(this, |
| 420 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 420 content::Source<Profile>(profile_)); | 421 content::Source<Profile>(profile_)); |
| 421 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, | 422 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, |
| 422 content::NotificationService::AllBrowserContextsAndSources()); | 423 content::NotificationService::AllBrowserContextsAndSources()); |
| 423 | 424 |
| 424 StateStore* storage = ExtensionSystem::Get(profile_)->state_store(); | 425 StateStore* storage = ExtensionSystem::Get(profile_)->state_store(); |
| 425 if (storage) | 426 if (storage) |
| 426 storage->RegisterKey(kBrowserActionStorageKey); | 427 storage->RegisterKey(kBrowserActionStorageKey); |
| 427 } | 428 } |
| 428 | 429 |
| 429 ExtensionActionStorageManager::~ExtensionActionStorageManager() { | 430 ExtensionActionStorageManager::~ExtensionActionStorageManager() { |
| 430 } | 431 } |
| 431 | 432 |
| 432 void ExtensionActionStorageManager::Observe( | 433 void ExtensionActionStorageManager::Observe( |
| 433 int type, | 434 int type, |
| 434 const content::NotificationSource& source, | 435 const content::NotificationSource& source, |
| 435 const content::NotificationDetails& details) { | 436 const content::NotificationDetails& details) { |
| 436 switch (type) { | 437 switch (type) { |
| 437 case chrome::NOTIFICATION_EXTENSION_LOADED: { | 438 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { |
| 438 const Extension* extension = | 439 const Extension* extension = |
| 439 content::Details<const Extension>(details).ptr(); | 440 content::Details<const Extension>(details).ptr(); |
| 440 if (!ExtensionActionManager::Get(profile_)-> | 441 if (!ExtensionActionManager::Get(profile_)-> |
| 441 GetBrowserAction(*extension)) { | 442 GetBrowserAction(*extension)) { |
| 442 break; | 443 break; |
| 443 } | 444 } |
| 444 | 445 |
| 445 StateStore* storage = ExtensionSystem::Get(profile_)->state_store(); | 446 StateStore* storage = ExtensionSystem::Get(profile_)->state_store(); |
| 446 if (storage) { | 447 if (storage) { |
| 447 storage->GetExtensionValue(extension->id(), kBrowserActionStorageKey, | 448 storage->GetExtensionValue(extension->id(), kBrowserActionStorageKey, |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 return true; | 921 return true; |
| 921 } | 922 } |
| 922 | 923 |
| 923 bool EnablePageActionsFunction::RunImpl() { | 924 bool EnablePageActionsFunction::RunImpl() { |
| 924 return SetPageActionEnabled(true); | 925 return SetPageActionEnabled(true); |
| 925 } | 926 } |
| 926 | 927 |
| 927 bool DisablePageActionsFunction::RunImpl() { | 928 bool DisablePageActionsFunction::RunImpl() { |
| 928 return SetPageActionEnabled(false); | 929 return SetPageActionEnabled(false); |
| 929 } | 930 } |
| OLD | NEW |