| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 histogram_value = events::PAGE_ACTION_ON_CLICKED; | 227 histogram_value = events::PAGE_ACTION_ON_CLICKED; |
| 228 event_name = "pageAction.onClicked"; | 228 event_name = "pageAction.onClicked"; |
| 229 break; | 229 break; |
| 230 case ActionInfo::TYPE_SYSTEM_INDICATOR: | 230 case ActionInfo::TYPE_SYSTEM_INDICATOR: |
| 231 // The System Indicator handles its own clicks. | 231 // The System Indicator handles its own clicks. |
| 232 NOTREACHED(); | 232 NOTREACHED(); |
| 233 break; | 233 break; |
| 234 } | 234 } |
| 235 | 235 |
| 236 if (event_name) { | 236 if (event_name) { |
| 237 scoped_ptr<base::ListValue> args(new base::ListValue()); | 237 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
| 238 args->Append( | 238 args->Append( |
| 239 ExtensionTabUtil::CreateTabObject(web_contents)->ToValue().release()); | 239 ExtensionTabUtil::CreateTabObject(web_contents)->ToValue().release()); |
| 240 | 240 |
| 241 DispatchEventToExtension(web_contents->GetBrowserContext(), | 241 DispatchEventToExtension(web_contents->GetBrowserContext(), |
| 242 extension_action.extension_id(), histogram_value, | 242 extension_action.extension_id(), histogram_value, |
| 243 event_name, std::move(args)); | 243 event_name, std::move(args)); |
| 244 } | 244 } |
| 245 } | 245 } |
| 246 | 246 |
| 247 void ExtensionActionAPI::ClearAllValuesForTab( | 247 void ExtensionActionAPI::ClearAllValuesForTab( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 272 if (!extension_prefs_) | 272 if (!extension_prefs_) |
| 273 extension_prefs_ = ExtensionPrefs::Get(browser_context_); | 273 extension_prefs_ = ExtensionPrefs::Get(browser_context_); |
| 274 return extension_prefs_; | 274 return extension_prefs_; |
| 275 } | 275 } |
| 276 | 276 |
| 277 void ExtensionActionAPI::DispatchEventToExtension( | 277 void ExtensionActionAPI::DispatchEventToExtension( |
| 278 content::BrowserContext* context, | 278 content::BrowserContext* context, |
| 279 const std::string& extension_id, | 279 const std::string& extension_id, |
| 280 events::HistogramValue histogram_value, | 280 events::HistogramValue histogram_value, |
| 281 const std::string& event_name, | 281 const std::string& event_name, |
| 282 scoped_ptr<base::ListValue> event_args) { | 282 std::unique_ptr<base::ListValue> event_args) { |
| 283 if (!EventRouter::Get(context)) | 283 if (!EventRouter::Get(context)) |
| 284 return; | 284 return; |
| 285 | 285 |
| 286 scoped_ptr<Event> event( | 286 std::unique_ptr<Event> event( |
| 287 new Event(histogram_value, event_name, std::move(event_args))); | 287 new Event(histogram_value, event_name, std::move(event_args))); |
| 288 event->restrict_to_browser_context = context; | 288 event->restrict_to_browser_context = context; |
| 289 event->user_gesture = EventRouter::USER_GESTURE_ENABLED; | 289 event->user_gesture = EventRouter::USER_GESTURE_ENABLED; |
| 290 EventRouter::Get(context) | 290 EventRouter::Get(context) |
| 291 ->DispatchEventToExtension(extension_id, std::move(event)); | 291 ->DispatchEventToExtension(extension_id, std::move(event)); |
| 292 } | 292 } |
| 293 | 293 |
| 294 void ExtensionActionAPI::NotifyPageActionsChanged( | 294 void ExtensionActionAPI::NotifyPageActionsChanged( |
| 295 content::WebContents* web_contents) { | 295 content::WebContents* web_contents) { |
| 296 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 296 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || | 632 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || |
| 633 host->extension()->id() != extension_->id()) | 633 host->extension()->id() != extension_->id()) |
| 634 return; | 634 return; |
| 635 | 635 |
| 636 SendResponse(true); | 636 SendResponse(true); |
| 637 response_sent_ = true; | 637 response_sent_ = true; |
| 638 registrar_.RemoveAll(); | 638 registrar_.RemoveAll(); |
| 639 } | 639 } |
| 640 | 640 |
| 641 } // namespace extensions | 641 } // namespace extensions |
| OLD | NEW |