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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 content::BrowserContext* context) { | 198 content::BrowserContext* context) { |
199 for (auto& observer : observers_) | 199 for (auto& observer : observers_) |
200 observer.OnExtensionActionUpdated(extension_action, web_contents, context); | 200 observer.OnExtensionActionUpdated(extension_action, web_contents, context); |
201 | 201 |
202 if (extension_action->action_type() == ActionInfo::TYPE_PAGE) | 202 if (extension_action->action_type() == ActionInfo::TYPE_PAGE) |
203 NotifyPageActionsChanged(web_contents); | 203 NotifyPageActionsChanged(web_contents); |
204 } | 204 } |
205 | 205 |
206 void ExtensionActionAPI::DispatchExtensionActionClicked( | 206 void ExtensionActionAPI::DispatchExtensionActionClicked( |
207 const ExtensionAction& extension_action, | 207 const ExtensionAction& extension_action, |
208 WebContents* web_contents) { | 208 WebContents* web_contents, |
| 209 const Extension* extension) { |
209 events::HistogramValue histogram_value = events::UNKNOWN; | 210 events::HistogramValue histogram_value = events::UNKNOWN; |
210 const char* event_name = NULL; | 211 const char* event_name = NULL; |
211 switch (extension_action.action_type()) { | 212 switch (extension_action.action_type()) { |
212 case ActionInfo::TYPE_BROWSER: | 213 case ActionInfo::TYPE_BROWSER: |
213 histogram_value = events::BROWSER_ACTION_ON_CLICKED; | 214 histogram_value = events::BROWSER_ACTION_ON_CLICKED; |
214 event_name = "browserAction.onClicked"; | 215 event_name = "browserAction.onClicked"; |
215 break; | 216 break; |
216 case ActionInfo::TYPE_PAGE: | 217 case ActionInfo::TYPE_PAGE: |
217 histogram_value = events::PAGE_ACTION_ON_CLICKED; | 218 histogram_value = events::PAGE_ACTION_ON_CLICKED; |
218 event_name = "pageAction.onClicked"; | 219 event_name = "pageAction.onClicked"; |
219 break; | 220 break; |
220 case ActionInfo::TYPE_SYSTEM_INDICATOR: | 221 case ActionInfo::TYPE_SYSTEM_INDICATOR: |
221 // The System Indicator handles its own clicks. | 222 // The System Indicator handles its own clicks. |
222 NOTREACHED(); | 223 NOTREACHED(); |
223 break; | 224 break; |
224 } | 225 } |
225 | 226 |
226 if (event_name) { | 227 if (event_name) { |
227 std::unique_ptr<base::ListValue> args(new base::ListValue()); | 228 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
228 args->Append(ExtensionTabUtil::CreateTabObject(web_contents)->ToValue()); | 229 args->Append( |
| 230 ExtensionTabUtil::CreateTabObject(web_contents, extension)->ToValue()); |
229 | 231 |
230 DispatchEventToExtension(web_contents->GetBrowserContext(), | 232 DispatchEventToExtension(web_contents->GetBrowserContext(), |
231 extension_action.extension_id(), histogram_value, | 233 extension_action.extension_id(), histogram_value, |
232 event_name, std::move(args)); | 234 event_name, std::move(args)); |
233 } | 235 } |
234 } | 236 } |
235 | 237 |
236 void ExtensionActionAPI::ClearAllValuesForTab( | 238 void ExtensionActionAPI::ClearAllValuesForTab( |
237 content::WebContents* web_contents) { | 239 content::WebContents* web_contents) { |
238 DCHECK(web_contents); | 240 DCHECK(web_contents); |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || | 615 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || |
614 host->extension()->id() != extension_->id()) | 616 host->extension()->id() != extension_->id()) |
615 return; | 617 return; |
616 | 618 |
617 SendResponse(true); | 619 SendResponse(true); |
618 response_sent_ = true; | 620 response_sent_ = true; |
619 registrar_.RemoveAll(); | 621 registrar_.RemoveAll(); |
620 } | 622 } |
621 | 623 |
622 } // namespace extensions | 624 } // namespace extensions |
OLD | NEW |