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 | 9 |
9 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
10 #include "base/location.h" | 11 #include "base/location.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
14 #include "base/thread_task_runner_handle.h" | 15 #include "base/thread_task_runner_handle.h" |
15 #include "base/values.h" | 16 #include "base/values.h" |
16 #include "chrome/browser/extensions/active_script_controller.h" | 17 #include "chrome/browser/extensions/active_script_controller.h" |
17 #include "chrome/browser/extensions/extension_action_manager.h" | 18 #include "chrome/browser/extensions/extension_action_manager.h" |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 void ExtensionActionAPI::DispatchEventToExtension( | 301 void ExtensionActionAPI::DispatchEventToExtension( |
301 content::BrowserContext* context, | 302 content::BrowserContext* context, |
302 const std::string& extension_id, | 303 const std::string& extension_id, |
303 events::HistogramValue histogram_value, | 304 events::HistogramValue histogram_value, |
304 const std::string& event_name, | 305 const std::string& event_name, |
305 scoped_ptr<base::ListValue> event_args) { | 306 scoped_ptr<base::ListValue> event_args) { |
306 if (!EventRouter::Get(context)) | 307 if (!EventRouter::Get(context)) |
307 return; | 308 return; |
308 | 309 |
309 scoped_ptr<Event> event( | 310 scoped_ptr<Event> event( |
310 new Event(histogram_value, event_name, event_args.Pass())); | 311 new Event(histogram_value, event_name, std::move(event_args))); |
311 event->restrict_to_browser_context = context; | 312 event->restrict_to_browser_context = context; |
312 event->user_gesture = EventRouter::USER_GESTURE_ENABLED; | 313 event->user_gesture = EventRouter::USER_GESTURE_ENABLED; |
313 EventRouter::Get(context) | 314 EventRouter::Get(context) |
314 ->DispatchEventToExtension(extension_id, event.Pass()); | 315 ->DispatchEventToExtension(extension_id, std::move(event)); |
315 } | 316 } |
316 | 317 |
317 void ExtensionActionAPI::ExtensionActionExecuted( | 318 void ExtensionActionAPI::ExtensionActionExecuted( |
318 const ExtensionAction& extension_action, | 319 const ExtensionAction& extension_action, |
319 WebContents* web_contents) { | 320 WebContents* web_contents) { |
320 events::HistogramValue histogram_value = events::UNKNOWN; | 321 events::HistogramValue histogram_value = events::UNKNOWN; |
321 const char* event_name = NULL; | 322 const char* event_name = NULL; |
322 switch (extension_action.action_type()) { | 323 switch (extension_action.action_type()) { |
323 case ActionInfo::TYPE_BROWSER: | 324 case ActionInfo::TYPE_BROWSER: |
324 histogram_value = events::BROWSER_ACTION_ON_CLICKED; | 325 histogram_value = events::BROWSER_ACTION_ON_CLICKED; |
(...skipping 10 matching lines...) Expand all Loading... |
335 } | 336 } |
336 | 337 |
337 if (event_name) { | 338 if (event_name) { |
338 scoped_ptr<base::ListValue> args(new base::ListValue()); | 339 scoped_ptr<base::ListValue> args(new base::ListValue()); |
339 base::DictionaryValue* tab_value = | 340 base::DictionaryValue* tab_value = |
340 ExtensionTabUtil::CreateTabValue(web_contents); | 341 ExtensionTabUtil::CreateTabValue(web_contents); |
341 args->Append(tab_value); | 342 args->Append(tab_value); |
342 | 343 |
343 DispatchEventToExtension(web_contents->GetBrowserContext(), | 344 DispatchEventToExtension(web_contents->GetBrowserContext(), |
344 extension_action.extension_id(), histogram_value, | 345 extension_action.extension_id(), histogram_value, |
345 event_name, args.Pass()); | 346 event_name, std::move(args)); |
346 } | 347 } |
347 } | 348 } |
348 | 349 |
349 void ExtensionActionAPI::NotifyPageActionsChanged( | 350 void ExtensionActionAPI::NotifyPageActionsChanged( |
350 content::WebContents* web_contents) { | 351 content::WebContents* web_contents) { |
351 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 352 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
352 if (!browser) | 353 if (!browser) |
353 return; | 354 return; |
354 LocationBar* location_bar = | 355 LocationBar* location_bar = |
355 browser->window() ? browser->window()->GetLocationBar() : NULL; | 356 browser->window() ? browser->window()->GetLocationBar() : NULL; |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || | 682 if (host->extension_host_type() != VIEW_TYPE_EXTENSION_POPUP || |
682 host->extension()->id() != extension_->id()) | 683 host->extension()->id() != extension_->id()) |
683 return; | 684 return; |
684 | 685 |
685 SendResponse(true); | 686 SendResponse(true); |
686 response_sent_ = true; | 687 response_sent_ = true; |
687 registrar_.RemoveAll(); | 688 registrar_.RemoveAll(); |
688 } | 689 } |
689 | 690 |
690 } // namespace extensions | 691 } // namespace extensions |
OLD | NEW |