OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/location_bar_controller.h" | 5 #include "chrome/browser/extensions/location_bar_controller.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/extensions/active_script_controller.h" | 8 #include "chrome/browser/extensions/active_script_controller.h" |
9 #include "chrome/browser/extensions/extension_action.h" | 9 #include "chrome/browser/extensions/extension_action.h" |
10 #include "chrome/browser/extensions/page_action_controller.h" | 10 #include "chrome/browser/extensions/page_action_controller.h" |
11 #include "chrome/common/extensions/api/extension_action/action_info.h" | 11 #include "chrome/common/extensions/api/extension_action/action_info.h" |
12 #include "content/public/browser/invalidate_type.h" | 12 #include "content/public/browser/invalidate_type.h" |
13 #include "content/public/browser/navigation_details.h" | 13 #include "content/public/browser/navigation_details.h" |
14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
15 #include "extensions/browser/extension_registry.h" | 15 #include "extensions/browser/extension_registry.h" |
16 | 16 |
17 namespace extensions { | 17 namespace extensions { |
18 | 18 |
19 LocationBarController::LocationBarController( | 19 LocationBarController::LocationBarController( |
20 content::WebContents* web_contents) | 20 content::WebContents* web_contents) |
21 : WebContentsObserver(web_contents), | 21 : WebContentsObserver(web_contents), |
22 web_contents_(web_contents), | 22 web_contents_(web_contents), |
23 active_script_controller_(new ActiveScriptController(web_contents_)), | 23 active_script_controller_(new ActiveScriptController(web_contents_)), |
24 page_action_controller_(new PageActionController(web_contents_)) { | 24 page_action_controller_(new PageActionController(web_contents_)), |
| 25 extension_registry_observer_(this) { |
| 26 extension_registry_observer_.Add( |
| 27 ExtensionRegistry::Get(web_contents_->GetBrowserContext())); |
25 } | 28 } |
26 | 29 |
27 LocationBarController::~LocationBarController() { | 30 LocationBarController::~LocationBarController() { |
28 } | 31 } |
29 | 32 |
30 std::vector<ExtensionAction*> LocationBarController::GetCurrentActions() { | 33 std::vector<ExtensionAction*> LocationBarController::GetCurrentActions() { |
31 const ExtensionSet& extensions = | 34 const ExtensionSet& extensions = |
32 ExtensionRegistry::Get(web_contents_->GetBrowserContext()) | 35 ExtensionRegistry::Get(web_contents_->GetBrowserContext()) |
33 ->enabled_extensions(); | 36 ->enabled_extensions(); |
34 std::vector<ExtensionAction*> current_actions; | 37 std::vector<ExtensionAction*> current_actions; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 void LocationBarController::DidNavigateMainFrame( | 81 void LocationBarController::DidNavigateMainFrame( |
79 const content::LoadCommittedDetails& details, | 82 const content::LoadCommittedDetails& details, |
80 const content::FrameNavigateParams& params) { | 83 const content::FrameNavigateParams& params) { |
81 if (details.is_in_page) | 84 if (details.is_in_page) |
82 return; | 85 return; |
83 | 86 |
84 page_action_controller_->OnNavigated(); | 87 page_action_controller_->OnNavigated(); |
85 active_script_controller_->OnNavigated(); | 88 active_script_controller_->OnNavigated(); |
86 } | 89 } |
87 | 90 |
| 91 void LocationBarController::OnExtensionUnloaded( |
| 92 content::BrowserContext* browser_context, |
| 93 const Extension* extension, |
| 94 UnloadedExtensionInfo::Reason reason) { |
| 95 bool should_update = false; |
| 96 if (page_action_controller_->GetActionForExtension(extension)) { |
| 97 page_action_controller_->OnExtensionUnloaded(extension); |
| 98 should_update = true; |
| 99 } |
| 100 if (active_script_controller_->GetActionForExtension(extension)) { |
| 101 active_script_controller_->OnExtensionUnloaded(extension); |
| 102 should_update = true; |
| 103 } |
| 104 |
| 105 if (should_update) |
| 106 NotifyChange(web_contents()); |
| 107 } |
| 108 |
88 } // namespace extensions | 109 } // namespace extensions |
OLD | NEW |