| 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" | |
| 8 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_system.h" | 8 #include "chrome/browser/extensions/extension_system.h" |
| 9 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
| 11 #include "chrome/common/extensions/extension_action.h" | 11 #include "chrome/common/extensions/extension_action.h" |
| 12 #include "chrome/common/extensions/extension_messages.h" | 12 #include "chrome/common/extensions/extension_messages.h" |
| 13 #include "chrome/common/extensions/extension_set.h" | 13 #include "chrome/common/extensions/extension_set.h" |
| 14 #include "chrome/common/chrome_notification_types.h" | 14 #include "chrome/common/chrome_notification_types.h" |
| 15 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/navigation_controller.h" |
| 16 #include "content/public/browser/navigation_entry.h" | 16 #include "content/public/browser/navigation_entry.h" |
| 17 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 19 #include "ipc/ipc_message.h" | 19 #include "ipc/ipc_message.h" |
| 20 #include "ipc/ipc_message_macros.h" | 20 #include "ipc/ipc_message_macros.h" |
| 21 | 21 |
| 22 namespace extensions { | 22 namespace extensions { |
| 23 | 23 |
| 24 ScriptBadgeController::ScriptBadgeController(TabContentsWrapper* tab_contents) | 24 ScriptBadgeController::ScriptBadgeController(TabContents* tab_contents) |
| 25 : content::WebContentsObserver(tab_contents->web_contents()), | 25 : content::WebContentsObserver(tab_contents->web_contents()), |
| 26 script_executor_(tab_contents->web_contents()), | 26 script_executor_(tab_contents->web_contents()), |
| 27 tab_contents_(tab_contents) {} | 27 tab_contents_(tab_contents) {} |
| 28 | 28 |
| 29 ScriptBadgeController::~ScriptBadgeController() {} | 29 ScriptBadgeController::~ScriptBadgeController() {} |
| 30 | 30 |
| 31 scoped_ptr<std::vector<ExtensionAction*> > | 31 scoped_ptr<std::vector<ExtensionAction*> > |
| 32 ScriptBadgeController::GetCurrentActions() { | 32 ScriptBadgeController::GetCurrentActions() { |
| 33 scoped_ptr<std::vector<ExtensionAction*> > current_actions( | 33 scoped_ptr<std::vector<ExtensionAction*> > current_actions( |
| 34 new std::vector<ExtensionAction*>()); | 34 new std::vector<ExtensionAction*>()); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 112 |
| 113 int32 ScriptBadgeController::GetPageID() { | 113 int32 ScriptBadgeController::GetPageID() { |
| 114 return tab_contents_->web_contents()->GetController().GetActiveEntry()-> | 114 return tab_contents_->web_contents()->GetController().GetActiveEntry()-> |
| 115 GetPageID(); | 115 GetPageID(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void ScriptBadgeController::Notify() { | 118 void ScriptBadgeController::Notify() { |
| 119 content::NotificationService::current()->Notify( | 119 content::NotificationService::current()->Notify( |
| 120 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, | 120 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, |
| 121 content::Source<Profile>(tab_contents_->profile()), | 121 content::Source<Profile>(tab_contents_->profile()), |
| 122 content::Details<TabContentsWrapper>(tab_contents_)); | 122 content::Details<TabContents>(tab_contents_)); |
| 123 } | 123 } |
| 124 | 124 |
| 125 void ScriptBadgeController::DidNavigateMainFrame( | 125 void ScriptBadgeController::DidNavigateMainFrame( |
| 126 const content::LoadCommittedDetails& details, | 126 const content::LoadCommittedDetails& details, |
| 127 const content::FrameNavigateParams& params) { | 127 const content::FrameNavigateParams& params) { |
| 128 extensions_executing_scripts_.clear(); | 128 extensions_executing_scripts_.clear(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 bool ScriptBadgeController::OnMessageReceived(const IPC::Message& message) { | 131 bool ScriptBadgeController::OnMessageReceived(const IPC::Message& message) { |
| 132 bool handled = true; | 132 bool handled = true; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 143 if (page_id == GetPageID()) { | 143 if (page_id == GetPageID()) { |
| 144 size_t original_size = extensions_executing_scripts_.size(); | 144 size_t original_size = extensions_executing_scripts_.size(); |
| 145 extensions_executing_scripts_.insert(extension_ids.begin(), | 145 extensions_executing_scripts_.insert(extension_ids.begin(), |
| 146 extension_ids.end()); | 146 extension_ids.end()); |
| 147 if (extensions_executing_scripts_.size() > original_size) | 147 if (extensions_executing_scripts_.size() > original_size) |
| 148 Notify(); | 148 Notify(); |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 | 151 |
| 152 } // namespace extensions | 152 } // namespace extensions |
| OLD | NEW |