| 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 events::TABS_ON_CREATED, tabs::OnCreated::kEventName, std::move(args))); | 210 events::TABS_ON_CREATED, tabs::OnCreated::kEventName, std::move(args))); |
| 211 event->restrict_to_browser_context = profile; | 211 event->restrict_to_browser_context = profile; |
| 212 event->user_gesture = EventRouter::USER_GESTURE_NOT_ENABLED; | 212 event->user_gesture = EventRouter::USER_GESTURE_NOT_ENABLED; |
| 213 event->will_dispatch_callback = | 213 event->will_dispatch_callback = |
| 214 base::Bind(&WillDispatchTabCreatedEvent, contents, active); | 214 base::Bind(&WillDispatchTabCreatedEvent, contents, active); |
| 215 EventRouter::Get(profile)->BroadcastEvent(std::move(event)); | 215 EventRouter::Get(profile)->BroadcastEvent(std::move(event)); |
| 216 | 216 |
| 217 RegisterForTabNotifications(contents); | 217 RegisterForTabNotifications(contents); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void TabsEventRouter::TabInsertedAt(WebContents* contents, | 220 void TabsEventRouter::TabInsertedAt(TabStripModel* tab_strip_model, |
| 221 WebContents* contents, |
| 221 int index, | 222 int index, |
| 222 bool active) { | 223 bool active) { |
| 223 if (!GetTabEntry(contents)) { | 224 if (!GetTabEntry(contents)) { |
| 224 // We've never seen this tab, send create event as long as we're not in the | 225 // We've never seen this tab, send create event as long as we're not in the |
| 225 // constructor. | 226 // constructor. |
| 226 if (browser_tab_strip_tracker_.is_processing_initial_browsers()) | 227 if (browser_tab_strip_tracker_.is_processing_initial_browsers()) |
| 227 RegisterForTabNotifications(contents); | 228 RegisterForTabNotifications(contents); |
| 228 else | 229 else |
| 229 TabCreatedAt(contents, index, active); | 230 TabCreatedAt(contents, index, active); |
| 230 return; | 231 return; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 DispatchEvent(Profile::FromBrowserContext(new_contents->GetBrowserContext()), | 500 DispatchEvent(Profile::FromBrowserContext(new_contents->GetBrowserContext()), |
| 500 events::TABS_ON_REPLACED, tabs::OnReplaced::kEventName, | 501 events::TABS_ON_REPLACED, tabs::OnReplaced::kEventName, |
| 501 std::move(args), EventRouter::USER_GESTURE_UNKNOWN); | 502 std::move(args), EventRouter::USER_GESTURE_UNKNOWN); |
| 502 | 503 |
| 503 UnregisterForTabNotifications(old_contents); | 504 UnregisterForTabNotifications(old_contents); |
| 504 | 505 |
| 505 if (!GetTabEntry(new_contents)) | 506 if (!GetTabEntry(new_contents)) |
| 506 RegisterForTabNotifications(new_contents); | 507 RegisterForTabNotifications(new_contents); |
| 507 } | 508 } |
| 508 | 509 |
| 509 void TabsEventRouter::TabPinnedStateChanged(WebContents* contents, int index) { | 510 void TabsEventRouter::TabPinnedStateChanged(TabStripModel* tab_strip_model, |
| 511 WebContents* contents, |
| 512 int index) { |
| 510 TabStripModel* tab_strip = NULL; | 513 TabStripModel* tab_strip = NULL; |
| 511 int tab_index; | 514 int tab_index; |
| 512 | 515 |
| 513 if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) { | 516 if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) { |
| 514 std::set<std::string> changed_property_names; | 517 std::set<std::string> changed_property_names; |
| 515 changed_property_names.insert(tabs_constants::kPinnedKey); | 518 changed_property_names.insert(tabs_constants::kPinnedKey); |
| 516 DispatchTabUpdatedEvent(contents, std::move(changed_property_names)); | 519 DispatchTabUpdatedEvent(contents, std::move(changed_property_names)); |
| 517 } | 520 } |
| 518 } | 521 } |
| 519 | 522 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 int tab_index = -1; | 577 int tab_index = -1; |
| 575 | 578 |
| 576 if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) { | 579 if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) { |
| 577 std::set<std::string> changed_property_names; | 580 std::set<std::string> changed_property_names; |
| 578 changed_property_names.insert(tabs_constants::kAutoDiscardableKey); | 581 changed_property_names.insert(tabs_constants::kAutoDiscardableKey); |
| 579 DispatchTabUpdatedEvent(contents, std::move(changed_property_names)); | 582 DispatchTabUpdatedEvent(contents, std::move(changed_property_names)); |
| 580 } | 583 } |
| 581 } | 584 } |
| 582 | 585 |
| 583 } // namespace extensions | 586 } // namespace extensions |
| OLD | NEW |