| 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/ui/extensions/extension_action_view_controller.h" | 5 #include "chrome/browser/ui/extensions/extension_action_view_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 ExtensionAction* extension_action, | 42 ExtensionAction* extension_action, |
| 43 ToolbarActionsBar* toolbar_actions_bar) | 43 ToolbarActionsBar* toolbar_actions_bar) |
| 44 : extension_(extension), | 44 : extension_(extension), |
| 45 browser_(browser), | 45 browser_(browser), |
| 46 extension_action_(extension_action), | 46 extension_action_(extension_action), |
| 47 toolbar_actions_bar_(toolbar_actions_bar), | 47 toolbar_actions_bar_(toolbar_actions_bar), |
| 48 popup_host_(nullptr), | 48 popup_host_(nullptr), |
| 49 view_delegate_(nullptr), | 49 view_delegate_(nullptr), |
| 50 platform_delegate_(ExtensionActionPlatformDelegate::Create(this)), | 50 platform_delegate_(ExtensionActionPlatformDelegate::Create(this)), |
| 51 icon_factory_(browser->profile(), extension, extension_action, this), | 51 icon_factory_(browser->profile(), extension, extension_action, this), |
| 52 icon_observer_(nullptr), | |
| 53 extension_registry_( | 52 extension_registry_( |
| 54 extensions::ExtensionRegistry::Get(browser_->profile())), | 53 extensions::ExtensionRegistry::Get(browser_->profile())), |
| 55 popup_host_observer_(this), | 54 popup_host_observer_(this), |
| 56 weak_factory_(this) { | 55 weak_factory_(this) { |
| 57 DCHECK(extension_action); | 56 DCHECK(extension_action); |
| 58 DCHECK(extension_action->action_type() == ActionInfo::TYPE_PAGE || | 57 DCHECK(extension_action->action_type() == ActionInfo::TYPE_PAGE || |
| 59 extension_action->action_type() == ActionInfo::TYPE_BROWSER); | 58 extension_action->action_type() == ActionInfo::TYPE_BROWSER); |
| 60 DCHECK(extension); | 59 DCHECK(extension); |
| 61 } | 60 } |
| 62 | 61 |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 235 |
| 237 void ExtensionActionViewController::InspectPopup() { | 236 void ExtensionActionViewController::InspectPopup() { |
| 238 ExecuteAction(SHOW_POPUP_AND_INSPECT, true); | 237 ExecuteAction(SHOW_POPUP_AND_INSPECT, true); |
| 239 } | 238 } |
| 240 | 239 |
| 241 void ExtensionActionViewController::OnIconUpdated() { | 240 void ExtensionActionViewController::OnIconUpdated() { |
| 242 // We update the view first, so that if the observer relies on its UI it can | 241 // We update the view first, so that if the observer relies on its UI it can |
| 243 // be ready. | 242 // be ready. |
| 244 if (view_delegate_) | 243 if (view_delegate_) |
| 245 view_delegate_->UpdateState(); | 244 view_delegate_->UpdateState(); |
| 246 if (icon_observer_) | |
| 247 icon_observer_->OnIconUpdated(); | |
| 248 } | 245 } |
| 249 | 246 |
| 250 void ExtensionActionViewController::OnExtensionHostDestroyed( | 247 void ExtensionActionViewController::OnExtensionHostDestroyed( |
| 251 const extensions::ExtensionHost* host) { | 248 const extensions::ExtensionHost* host) { |
| 252 OnPopupClosed(); | 249 OnPopupClosed(); |
| 253 } | 250 } |
| 254 | 251 |
| 255 bool ExtensionActionViewController::ExtensionIsValid() const { | 252 bool ExtensionActionViewController::ExtensionIsValid() const { |
| 256 return extension_registry_->enabled_extensions().Contains(extension_->id()); | 253 return extension_registry_->enabled_extensions().Contains(extension_->id()); |
| 257 } | 254 } |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 extension_action_->GetIsVisible( | 418 extension_action_->GetIsVisible( |
| 422 SessionTabHelper::IdForTab(web_contents)); | 419 SessionTabHelper::IdForTab(web_contents)); |
| 423 } | 420 } |
| 424 | 421 |
| 425 bool ExtensionActionViewController::HasBeenBlocked( | 422 bool ExtensionActionViewController::HasBeenBlocked( |
| 426 content::WebContents* web_contents) const { | 423 content::WebContents* web_contents) const { |
| 427 ExtensionActionRunner* action_runner = | 424 ExtensionActionRunner* action_runner = |
| 428 ExtensionActionRunner::GetForWebContents(web_contents); | 425 ExtensionActionRunner::GetForWebContents(web_contents); |
| 429 return action_runner && action_runner->WantsToRun(extension()); | 426 return action_runner && action_runner->WantsToRun(extension()); |
| 430 } | 427 } |
| OLD | NEW |