| 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 "chrome/browser/extensions/active_script_controller.h" | 7 #include "chrome/browser/extensions/active_script_controller.h" |
| 8 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 8 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 9 #include "chrome/browser/extensions/extension_action_manager.h" | 9 #include "chrome/browser/extensions/extension_action_manager.h" |
| 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_finder.h" |
| 12 #include "chrome/browser/ui/browser_window.h" |
| 13 #include "chrome/browser/ui/location_bar/location_bar.h" |
| 14 #include "chrome/common/extensions/manifest_handlers/ui_overrides_handler.h" |
| 10 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 11 #include "extensions/browser/extension_registry.h" | 16 #include "extensions/browser/extension_registry.h" |
| 12 #include "extensions/common/feature_switch.h" | 17 #include "extensions/common/feature_switch.h" |
| 13 | 18 |
| 14 namespace extensions { | 19 namespace extensions { |
| 15 | 20 |
| 16 LocationBarController::LocationBarController( | 21 LocationBarController::LocationBarController( |
| 17 content::WebContents* web_contents) | 22 content::WebContents* web_contents) |
| 18 : web_contents_(web_contents), | 23 : web_contents_(web_contents), |
| 19 browser_context_(web_contents->GetBrowserContext()), | 24 browser_context_(web_contents->GetBrowserContext()), |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 } | 58 } |
| 54 | 59 |
| 55 void LocationBarController::OnExtensionLoaded( | 60 void LocationBarController::OnExtensionLoaded( |
| 56 content::BrowserContext* browser_context, | 61 content::BrowserContext* browser_context, |
| 57 const Extension* extension) { | 62 const Extension* extension) { |
| 58 if (action_manager_->GetPageAction(*extension) || | 63 if (action_manager_->GetPageAction(*extension) || |
| 59 active_script_controller_->GetActionForExtension(extension)) { | 64 active_script_controller_->GetActionForExtension(extension)) { |
| 60 ExtensionActionAPI::Get(browser_context)-> | 65 ExtensionActionAPI::Get(browser_context)-> |
| 61 NotifyPageActionsChanged(web_contents_); | 66 NotifyPageActionsChanged(web_contents_); |
| 62 } | 67 } |
| 68 |
| 69 // We might also need to update the location bar if the extension can remove |
| 70 // the bookmark star. |
| 71 if (UIOverrides::RemovesBookmarkButton(extension)) { |
| 72 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); |
| 73 if (!browser) |
| 74 return; |
| 75 LocationBar* location_bar = |
| 76 browser->window() ? browser->window()->GetLocationBar() : NULL; |
| 77 if (!location_bar) |
| 78 return; |
| 79 location_bar->UpdateBookmarkStarVisibility(); |
| 80 } |
| 63 } | 81 } |
| 64 | 82 |
| 65 void LocationBarController::OnExtensionUnloaded( | 83 void LocationBarController::OnExtensionUnloaded( |
| 66 content::BrowserContext* browser_context, | 84 content::BrowserContext* browser_context, |
| 67 const Extension* extension, | 85 const Extension* extension, |
| 68 UnloadedExtensionInfo::Reason reason) { | 86 UnloadedExtensionInfo::Reason reason) { |
| 69 if (action_manager_->GetPageAction(*extension)) { | 87 if (action_manager_->GetPageAction(*extension)) { |
| 70 ExtensionActionAPI::Get(browser_context)-> | 88 ExtensionActionAPI::Get(browser_context)-> |
| 71 NotifyPageActionsChanged(web_contents_); | 89 NotifyPageActionsChanged(web_contents_); |
| 72 } | 90 } |
| 73 } | 91 } |
| 74 | 92 |
| 75 } // namespace extensions | 93 } // namespace extensions |
| OLD | NEW |