| 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 std::set<std::string> changed_property_names; | 513 std::set<std::string> changed_property_names; |
| 511 changed_property_names.insert(tabs_constants::kPinnedKey); | 514 changed_property_names.insert(tabs_constants::kPinnedKey); |
| 512 DispatchTabUpdatedEvent(contents, std::move(changed_property_names)); | 515 DispatchTabUpdatedEvent(contents, std::move(changed_property_names)); |
| 513 } | 516 } |
| 514 | 517 |
| 515 void TabsEventRouter::OnZoomChanged( | 518 void TabsEventRouter::OnZoomChanged( |
| 516 const ZoomController::ZoomChangedEventData& data) { | 519 const ZoomController::ZoomChangedEventData& data) { |
| 517 DCHECK(data.web_contents); | 520 DCHECK(data.web_contents); |
| 518 int tab_id = ExtensionTabUtil::GetTabId(data.web_contents); | 521 int tab_id = ExtensionTabUtil::GetTabId(data.web_contents); |
| 519 if (tab_id < 0) | 522 if (tab_id < 0) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 } | 562 } |
| 560 | 563 |
| 561 void TabsEventRouter::OnAutoDiscardableStateChange(WebContents* contents, | 564 void TabsEventRouter::OnAutoDiscardableStateChange(WebContents* contents, |
| 562 bool is_auto_discardable) { | 565 bool is_auto_discardable) { |
| 563 std::set<std::string> changed_property_names; | 566 std::set<std::string> changed_property_names; |
| 564 changed_property_names.insert(tabs_constants::kAutoDiscardableKey); | 567 changed_property_names.insert(tabs_constants::kAutoDiscardableKey); |
| 565 DispatchTabUpdatedEvent(contents, std::move(changed_property_names)); | 568 DispatchTabUpdatedEvent(contents, std::move(changed_property_names)); |
| 566 } | 569 } |
| 567 | 570 |
| 568 } // namespace extensions | 571 } // namespace extensions |
| OLD | NEW |