Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: chrome/browser/extensions/api/extension_action/extension_action_api.cc

Issue 270153004: Introduce ActiveScriptController; track active extension scripts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 438
439 StateStore* storage = ExtensionSystem::Get(profile_)->state_store(); 439 StateStore* storage = ExtensionSystem::Get(profile_)->state_store();
440 if (storage) { 440 if (storage) {
441 storage->GetExtensionValue( 441 storage->GetExtensionValue(
442 extension->id(), 442 extension->id(),
443 kBrowserActionStorageKey, 443 kBrowserActionStorageKey,
444 base::Bind(&ExtensionActionStorageManager::ReadFromStorage, 444 base::Bind(&ExtensionActionStorageManager::ReadFromStorage,
445 AsWeakPtr(), 445 AsWeakPtr(),
446 extension->id())); 446 extension->id()));
447 } 447 }
448 }; 448 }
449 449
450 void ExtensionActionStorageManager::Observe( 450 void ExtensionActionStorageManager::Observe(
451 int type, 451 int type,
452 const content::NotificationSource& source, 452 const content::NotificationSource& source,
453 const content::NotificationDetails& details) { 453 const content::NotificationDetails& details) {
454 DCHECK_EQ(type, chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED); 454 DCHECK_EQ(type, chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED);
455 ExtensionAction* extension_action = 455 ExtensionAction* extension_action =
456 content::Source<ExtensionAction>(source).ptr(); 456 content::Source<ExtensionAction>(source).ptr();
457 Profile* profile = content::Details<Profile>(details).ptr(); 457 Profile* profile = content::Details<Profile>(details).ptr();
458 if (profile != profile_) 458 if (profile != profile_)
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 } 625 }
626 626
627 void ExtensionActionFunction::NotifyBrowserActionChange() { 627 void ExtensionActionFunction::NotifyBrowserActionChange() {
628 content::NotificationService::current()->Notify( 628 content::NotificationService::current()->Notify(
629 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED, 629 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_UPDATED,
630 content::Source<ExtensionAction>(extension_action_), 630 content::Source<ExtensionAction>(extension_action_),
631 content::Details<Profile>(GetProfile())); 631 content::Details<Profile>(GetProfile()));
632 } 632 }
633 633
634 void ExtensionActionFunction::NotifyLocationBarChange() { 634 void ExtensionActionFunction::NotifyLocationBarChange() {
635 TabHelper::FromWebContents(contents_)-> 635 LocationBarController::NotifyChange(contents_);
636 location_bar_controller()->NotifyChange();
637 } 636 }
638 637
639 void ExtensionActionFunction::NotifySystemIndicatorChange() { 638 void ExtensionActionFunction::NotifySystemIndicatorChange() {
640 content::NotificationService::current()->Notify( 639 content::NotificationService::current()->Notify(
641 chrome::NOTIFICATION_EXTENSION_SYSTEM_INDICATOR_UPDATED, 640 chrome::NOTIFICATION_EXTENSION_SYSTEM_INDICATOR_UPDATED,
642 content::Source<Profile>(GetProfile()), 641 content::Source<Profile>(GetProfile()),
643 content::Details<ExtensionAction>(extension_action_)); 642 content::Details<ExtensionAction>(extension_action_));
644 } 643 }
645 644
646 bool ExtensionActionFunction::SetVisible(bool visible) { 645 bool ExtensionActionFunction::SetVisible(bool visible) {
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
902 content::NavigationEntry* entry = contents->GetController().GetVisibleEntry(); 901 content::NavigationEntry* entry = contents->GetController().GetVisibleEntry();
903 if (!entry || url != entry->GetURL().spec()) { 902 if (!entry || url != entry->GetURL().spec()) {
904 error_ = extensions::ErrorUtils::FormatErrorMessage( 903 error_ = extensions::ErrorUtils::FormatErrorMessage(
905 extensions::kUrlNotActiveError, url); 904 extensions::kUrlNotActiveError, url);
906 return false; 905 return false;
907 } 906 }
908 907
909 // Set visibility and broadcast notifications that the UI should be updated. 908 // Set visibility and broadcast notifications that the UI should be updated.
910 page_action->SetIsVisible(tab_id, enable); 909 page_action->SetIsVisible(tab_id, enable);
911 page_action->SetTitle(tab_id, title); 910 page_action->SetTitle(tab_id, title);
912 extensions::TabHelper::FromWebContents(contents)-> 911 extensions::LocationBarController::NotifyChange(contents);
913 location_bar_controller()->NotifyChange();
914 912
915 return true; 913 return true;
916 } 914 }
917 915
918 bool EnablePageActionsFunction::RunSync() { 916 bool EnablePageActionsFunction::RunSync() {
919 return SetPageActionEnabled(true); 917 return SetPageActionEnabled(true);
920 } 918 }
921 919
922 bool DisablePageActionsFunction::RunSync() { 920 bool DisablePageActionsFunction::RunSync() {
923 return SetPageActionEnabled(false); 921 return SetPageActionEnabled(false);
924 } 922 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/activity_log/uma_policy_unittest.cc ('k') | chrome/browser/extensions/location_bar_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698