| 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/api/extension_action/extension_action_api.h" | 5 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 160 |
| 161 void ExtensionActionAPI::SetBrowserActionVisibility( | 161 void ExtensionActionAPI::SetBrowserActionVisibility( |
| 162 const std::string& extension_id, | 162 const std::string& extension_id, |
| 163 bool visible) { | 163 bool visible) { |
| 164 if (GetBrowserActionVisibility(extension_id) == visible) | 164 if (GetBrowserActionVisibility(extension_id) == visible) |
| 165 return; | 165 return; |
| 166 | 166 |
| 167 GetExtensionPrefs()->UpdateExtensionPref(extension_id, | 167 GetExtensionPrefs()->UpdateExtensionPref(extension_id, |
| 168 kBrowserActionVisible, | 168 kBrowserActionVisible, |
| 169 new base::FundamentalValue(visible)); | 169 new base::FundamentalValue(visible)); |
| 170 FOR_EACH_OBSERVER(Observer, observers_, OnExtensionActionVisibilityChanged( | 170 for (auto& observer : observers_) |
| 171 extension_id, visible)); | 171 observer.OnExtensionActionVisibilityChanged(extension_id, visible); |
| 172 } | 172 } |
| 173 | 173 |
| 174 bool ExtensionActionAPI::ShowExtensionActionPopup( | 174 bool ExtensionActionAPI::ShowExtensionActionPopup( |
| 175 const Extension* extension, | 175 const Extension* extension, |
| 176 Browser* browser, | 176 Browser* browser, |
| 177 bool grant_active_tab_permissions) { | 177 bool grant_active_tab_permissions) { |
| 178 ExtensionAction* extension_action = | 178 ExtensionAction* extension_action = |
| 179 ExtensionActionManager::Get(browser_context_)->GetExtensionAction( | 179 ExtensionActionManager::Get(browser_context_)->GetExtensionAction( |
| 180 *extension); | 180 *extension); |
| 181 if (!extension_action) | 181 if (!extension_action) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 198 // ToolbarActionsBar could be null if, e.g., this is a popup window with no | 198 // ToolbarActionsBar could be null if, e.g., this is a popup window with no |
| 199 // toolbar. | 199 // toolbar. |
| 200 return toolbar_actions_bar && | 200 return toolbar_actions_bar && |
| 201 toolbar_actions_bar->ShowToolbarActionPopup( | 201 toolbar_actions_bar->ShowToolbarActionPopup( |
| 202 extension->id(), grant_active_tab_permissions); | 202 extension->id(), grant_active_tab_permissions); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void ExtensionActionAPI::NotifyChange(ExtensionAction* extension_action, | 205 void ExtensionActionAPI::NotifyChange(ExtensionAction* extension_action, |
| 206 content::WebContents* web_contents, | 206 content::WebContents* web_contents, |
| 207 content::BrowserContext* context) { | 207 content::BrowserContext* context) { |
| 208 FOR_EACH_OBSERVER( | 208 for (auto& observer : observers_) |
| 209 Observer, | 209 observer.OnExtensionActionUpdated(extension_action, web_contents, context); |
| 210 observers_, | |
| 211 OnExtensionActionUpdated(extension_action, web_contents, context)); | |
| 212 | 210 |
| 213 if (extension_action->action_type() == ActionInfo::TYPE_PAGE) | 211 if (extension_action->action_type() == ActionInfo::TYPE_PAGE) |
| 214 NotifyPageActionsChanged(web_contents); | 212 NotifyPageActionsChanged(web_contents); |
| 215 } | 213 } |
| 216 | 214 |
| 217 void ExtensionActionAPI::DispatchExtensionActionClicked( | 215 void ExtensionActionAPI::DispatchExtensionActionClicked( |
| 218 const ExtensionAction& extension_action, | 216 const ExtensionAction& extension_action, |
| 219 WebContents* web_contents) { | 217 WebContents* web_contents) { |
| 220 events::HistogramValue histogram_value = events::UNKNOWN; | 218 events::HistogramValue histogram_value = events::UNKNOWN; |
| 221 const char* event_name = NULL; | 219 const char* event_name = NULL; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 content::WebContents* web_contents) { | 293 content::WebContents* web_contents) { |
| 296 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 294 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
| 297 if (!browser) | 295 if (!browser) |
| 298 return; | 296 return; |
| 299 LocationBar* location_bar = | 297 LocationBar* location_bar = |
| 300 browser->window() ? browser->window()->GetLocationBar() : NULL; | 298 browser->window() ? browser->window()->GetLocationBar() : NULL; |
| 301 if (!location_bar) | 299 if (!location_bar) |
| 302 return; | 300 return; |
| 303 location_bar->UpdatePageActions(); | 301 location_bar->UpdatePageActions(); |
| 304 | 302 |
| 305 FOR_EACH_OBSERVER(Observer, observers_, OnPageActionsUpdated(web_contents)); | 303 for (auto& observer : observers_) |
| 304 observer.OnPageActionsUpdated(web_contents); |
| 306 } | 305 } |
| 307 | 306 |
| 308 void ExtensionActionAPI::Shutdown() { | 307 void ExtensionActionAPI::Shutdown() { |
| 309 FOR_EACH_OBSERVER(Observer, observers_, OnExtensionActionAPIShuttingDown()); | 308 for (auto& observer : observers_) |
| 309 observer.OnExtensionActionAPIShuttingDown(); |
| 310 } | 310 } |
| 311 | 311 |
| 312 // | 312 // |
| 313 // ExtensionActionFunction | 313 // ExtensionActionFunction |
| 314 // | 314 // |
| 315 | 315 |
| 316 ExtensionActionFunction::ExtensionActionFunction() | 316 ExtensionActionFunction::ExtensionActionFunction() |
| 317 : details_(NULL), | 317 : details_(NULL), |
| 318 tab_id_(ExtensionAction::kDefaultTabId), | 318 tab_id_(ExtensionAction::kDefaultTabId), |
| 319 contents_(NULL), | 319 contents_(NULL), |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || | 627 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || |
| 628 host->extension()->id() != extension_->id()) | 628 host->extension()->id() != extension_->id()) |
| 629 return; | 629 return; |
| 630 | 630 |
| 631 SendResponse(true); | 631 SendResponse(true); |
| 632 response_sent_ = true; | 632 response_sent_ = true; |
| 633 registrar_.RemoveAll(); | 633 registrar_.RemoveAll(); |
| 634 } | 634 } |
| 635 | 635 |
| 636 } // namespace extensions | 636 } // namespace extensions |
| OLD | NEW |