| 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/script_badge_controller.h" | 5 #include "chrome/browser/extensions/script_badge_controller.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 7 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
| 10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 it != service->extensions()->end(); ++it) { | 42 it != service->extensions()->end(); ++it) { |
| 43 const Extension* extension = *it; | 43 const Extension* extension = *it; |
| 44 if (extension->HasContentScriptAtURL(current_url) || | 44 if (extension->HasContentScriptAtURL(current_url) || |
| 45 extensions_executing_scripts_.count(extension->id())) { | 45 extensions_executing_scripts_.count(extension->id())) { |
| 46 current_actions->push_back(GetScriptBadge(extension)); | 46 current_actions->push_back(GetScriptBadge(extension)); |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 return current_actions.Pass(); | 49 return current_actions.Pass(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 ActionBoxController::Action ScriptBadgeController::OnClicked( | 52 LocationBarController::Action ScriptBadgeController::OnClicked( |
| 53 const std::string& extension_id, int mouse_button) { | 53 const std::string& extension_id, int mouse_button) { |
| 54 ExtensionService* service = GetExtensionService(); | 54 ExtensionService* service = GetExtensionService(); |
| 55 if (!service) | 55 if (!service) |
| 56 return ACTION_NONE; | 56 return ACTION_NONE; |
| 57 | 57 |
| 58 const Extension* extension = service->extensions()->GetByID(extension_id); | 58 const Extension* extension = service->extensions()->GetByID(extension_id); |
| 59 CHECK(extension); | 59 CHECK(extension); |
| 60 | 60 |
| 61 switch (mouse_button) { | 61 switch (mouse_button) { |
| 62 case 3: // right | 62 case 3: // right |
| (...skipping 16 matching lines...) Expand all Loading... |
| 79 script_type, | 79 script_type, |
| 80 code, | 80 code, |
| 81 frame_scope, | 81 frame_scope, |
| 82 run_at, | 82 run_at, |
| 83 world_type, | 83 world_type, |
| 84 callback); | 84 callback); |
| 85 | 85 |
| 86 // This tab should now show that the extension executing a script. | 86 // This tab should now show that the extension executing a script. |
| 87 extensions_executing_scripts_.insert(extension_id); | 87 extensions_executing_scripts_.insert(extension_id); |
| 88 content::NotificationService::current()->Notify( | 88 content::NotificationService::current()->Notify( |
| 89 chrome::NOTIFICATION_EXTENSION_ACTION_BOX_UPDATED, | 89 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, |
| 90 content::Source<Profile>(tab_contents_->profile()), | 90 content::Source<Profile>(tab_contents_->profile()), |
| 91 content::Details<TabContentsWrapper>(tab_contents_)); | 91 content::Details<TabContentsWrapper>(tab_contents_)); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void ScriptBadgeController::DidNavigateMainFrame( | 94 void ScriptBadgeController::DidNavigateMainFrame( |
| 95 const content::LoadCommittedDetails& details, | 95 const content::LoadCommittedDetails& details, |
| 96 const content::FrameNavigateParams& params) { | 96 const content::FrameNavigateParams& params) { |
| 97 extensions_executing_scripts_.clear(); | 97 extensions_executing_scripts_.clear(); |
| 98 } | 98 } |
| 99 | 99 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 127 | 127 |
| 128 script_badges_[extension->id()] = badge; | 128 script_badges_[extension->id()] = badge; |
| 129 return badge.get(); | 129 return badge.get(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 ExtensionService* ScriptBadgeController::GetExtensionService() { | 132 ExtensionService* ScriptBadgeController::GetExtensionService() { |
| 133 return ExtensionSystem::Get(tab_contents_->profile())->extension_service(); | 133 return ExtensionSystem::Get(tab_contents_->profile())->extension_service(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 } // namespace extensions | 136 } // namespace extensions |
| OLD | NEW |