| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/tabs/tabs_event_router.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs_event_router.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 const base::DictionaryValue* listener_filter) { | 48 const base::DictionaryValue* listener_filter) { |
| 49 std::unique_ptr<api::tabs::Tab> tab_object = | 49 std::unique_ptr<api::tabs::Tab> tab_object = |
| 50 ExtensionTabUtil::CreateTabObject(contents, extension); | 50 ExtensionTabUtil::CreateTabObject(contents, extension); |
| 51 | 51 |
| 52 std::unique_ptr<base::DictionaryValue> tab_value = tab_object->ToValue(); | 52 std::unique_ptr<base::DictionaryValue> tab_value = tab_object->ToValue(); |
| 53 | 53 |
| 54 auto changed_properties = base::MakeUnique<base::DictionaryValue>(); | 54 auto changed_properties = base::MakeUnique<base::DictionaryValue>(); |
| 55 const base::Value* value = nullptr; | 55 const base::Value* value = nullptr; |
| 56 for (const auto& property : changed_property_names) { | 56 for (const auto& property : changed_property_names) { |
| 57 if (tab_value->Get(property, &value)) | 57 if (tab_value->Get(property, &value)) |
| 58 changed_properties->Set(property, value->CreateDeepCopy()); | 58 changed_properties->Set(property, base::MakeUnique<base::Value>(*value)); |
| 59 } | 59 } |
| 60 | 60 |
| 61 event->event_args->Set(1, std::move(changed_properties)); | 61 event->event_args->Set(1, std::move(changed_properties)); |
| 62 event->event_args->Set(2, std::move(tab_value)); | 62 event->event_args->Set(2, std::move(tab_value)); |
| 63 return true; | 63 return true; |
| 64 } | 64 } |
| 65 | 65 |
| 66 } // namespace | 66 } // namespace |
| 67 | 67 |
| 68 TabsEventRouter::TabEntry::TabEntry(TabsEventRouter* router, | 68 TabsEventRouter::TabEntry::TabEntry(TabsEventRouter* router, |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 347 } |
| 348 | 348 |
| 349 std::unique_ptr<base::ListValue> args(new base::ListValue); | 349 std::unique_ptr<base::ListValue> args(new base::ListValue); |
| 350 std::unique_ptr<base::DictionaryValue> select_info(new base::DictionaryValue); | 350 std::unique_ptr<base::DictionaryValue> select_info(new base::DictionaryValue); |
| 351 | 351 |
| 352 select_info->Set( | 352 select_info->Set( |
| 353 tabs_constants::kWindowIdKey, | 353 tabs_constants::kWindowIdKey, |
| 354 base::MakeUnique<Value>( | 354 base::MakeUnique<Value>( |
| 355 ExtensionTabUtil::GetWindowIdOfTabStripModel(tab_strip_model))); | 355 ExtensionTabUtil::GetWindowIdOfTabStripModel(tab_strip_model))); |
| 356 | 356 |
| 357 select_info->Set(tabs_constants::kTabIdsKey, all_tabs.release()); | 357 select_info->Set(tabs_constants::kTabIdsKey, std::move(all_tabs)); |
| 358 args->Append(std::move(select_info)); | 358 args->Append(std::move(select_info)); |
| 359 | 359 |
| 360 // The onHighlighted event replaced onHighlightChanged. | 360 // The onHighlighted event replaced onHighlightChanged. |
| 361 Profile* profile = tab_strip_model->profile(); | 361 Profile* profile = tab_strip_model->profile(); |
| 362 DispatchEvent(profile, events::TABS_ON_HIGHLIGHT_CHANGED, | 362 DispatchEvent(profile, events::TABS_ON_HIGHLIGHT_CHANGED, |
| 363 tabs::OnHighlightChanged::kEventName, | 363 tabs::OnHighlightChanged::kEventName, |
| 364 std::unique_ptr<base::ListValue>(args->DeepCopy()), | 364 std::unique_ptr<base::ListValue>(args->DeepCopy()), |
| 365 EventRouter::USER_GESTURE_UNKNOWN); | 365 EventRouter::USER_GESTURE_UNKNOWN); |
| 366 DispatchEvent(profile, events::TABS_ON_HIGHLIGHTED, | 366 DispatchEvent(profile, events::TABS_ON_HIGHLIGHTED, |
| 367 tabs::OnHighlighted::kEventName, std::move(args), | 367 tabs::OnHighlighted::kEventName, std::move(args), |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 } | 559 } |
| 560 | 560 |
| 561 void TabsEventRouter::OnAutoDiscardableStateChange(WebContents* contents, | 561 void TabsEventRouter::OnAutoDiscardableStateChange(WebContents* contents, |
| 562 bool is_auto_discardable) { | 562 bool is_auto_discardable) { |
| 563 std::set<std::string> changed_property_names; | 563 std::set<std::string> changed_property_names; |
| 564 changed_property_names.insert(tabs_constants::kAutoDiscardableKey); | 564 changed_property_names.insert(tabs_constants::kAutoDiscardableKey); |
| 565 DispatchTabUpdatedEvent(contents, std::move(changed_property_names)); | 565 DispatchTabUpdatedEvent(contents, std::move(changed_property_names)); |
| 566 } | 566 } |
| 567 | 567 |
| 568 } // namespace extensions | 568 } // namespace extensions |
| OLD | NEW |