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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 events::TABS_ON_REPLACED, tabs::OnReplaced::kEventName, | 500 events::TABS_ON_REPLACED, tabs::OnReplaced::kEventName, |
501 std::move(args), EventRouter::USER_GESTURE_UNKNOWN); | 501 std::move(args), EventRouter::USER_GESTURE_UNKNOWN); |
502 | 502 |
503 UnregisterForTabNotifications(old_contents); | 503 UnregisterForTabNotifications(old_contents); |
504 | 504 |
505 if (!GetTabEntry(new_contents)) | 505 if (!GetTabEntry(new_contents)) |
506 RegisterForTabNotifications(new_contents); | 506 RegisterForTabNotifications(new_contents); |
507 } | 507 } |
508 | 508 |
509 void TabsEventRouter::TabPinnedStateChanged(WebContents* contents, int index) { | 509 void TabsEventRouter::TabPinnedStateChanged(WebContents* contents, int index) { |
510 TabStripModel* tab_strip = NULL; | 510 std::set<std::string> changed_property_names; |
511 int tab_index; | 511 changed_property_names.insert(tabs_constants::kPinnedKey); |
512 | 512 DispatchTabUpdatedEvent(contents, std::move(changed_property_names)); |
513 if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) { | |
514 std::set<std::string> changed_property_names; | |
515 changed_property_names.insert(tabs_constants::kPinnedKey); | |
516 DispatchTabUpdatedEvent(contents, std::move(changed_property_names)); | |
517 } | |
518 } | 513 } |
519 | 514 |
520 void TabsEventRouter::OnZoomChanged( | 515 void TabsEventRouter::OnZoomChanged( |
521 const ZoomController::ZoomChangedEventData& data) { | 516 const ZoomController::ZoomChangedEventData& data) { |
522 DCHECK(data.web_contents); | 517 DCHECK(data.web_contents); |
523 int tab_id = ExtensionTabUtil::GetTabId(data.web_contents); | 518 int tab_id = ExtensionTabUtil::GetTabId(data.web_contents); |
524 if (tab_id < 0) | 519 if (tab_id < 0) |
525 return; | 520 return; |
526 | 521 |
527 // Prepare the zoom change information. | 522 // Prepare the zoom change information. |
(...skipping 23 matching lines...) Expand all Loading... |
551 const gfx::Image& image) { | 546 const gfx::Image& image) { |
552 if (notification_icon_type == NON_TOUCH_16_DIP && icon_url_changed) { | 547 if (notification_icon_type == NON_TOUCH_16_DIP && icon_url_changed) { |
553 favicon::ContentFaviconDriver* content_favicon_driver = | 548 favicon::ContentFaviconDriver* content_favicon_driver = |
554 static_cast<favicon::ContentFaviconDriver*>(favicon_driver); | 549 static_cast<favicon::ContentFaviconDriver*>(favicon_driver); |
555 FaviconUrlUpdated(content_favicon_driver->web_contents()); | 550 FaviconUrlUpdated(content_favicon_driver->web_contents()); |
556 } | 551 } |
557 } | 552 } |
558 | 553 |
559 void TabsEventRouter::OnDiscardedStateChange(WebContents* contents, | 554 void TabsEventRouter::OnDiscardedStateChange(WebContents* contents, |
560 bool is_discarded) { | 555 bool is_discarded) { |
561 TabStripModel* tab_strip = nullptr; | 556 std::set<std::string> changed_property_names; |
562 int tab_index = -1; | 557 changed_property_names.insert(tabs_constants::kDiscardedKey); |
563 | 558 DispatchTabUpdatedEvent(contents, std::move(changed_property_names)); |
564 if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) { | |
565 std::set<std::string> changed_property_names; | |
566 changed_property_names.insert(tabs_constants::kDiscardedKey); | |
567 DispatchTabUpdatedEvent(contents, std::move(changed_property_names)); | |
568 } | |
569 } | 559 } |
570 | 560 |
571 void TabsEventRouter::OnAutoDiscardableStateChange(WebContents* contents, | 561 void TabsEventRouter::OnAutoDiscardableStateChange(WebContents* contents, |
572 bool is_auto_discardable) { | 562 bool is_auto_discardable) { |
573 TabStripModel* tab_strip = nullptr; | 563 std::set<std::string> changed_property_names; |
574 int tab_index = -1; | 564 changed_property_names.insert(tabs_constants::kAutoDiscardableKey); |
575 | 565 DispatchTabUpdatedEvent(contents, std::move(changed_property_names)); |
576 if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) { | |
577 std::set<std::string> changed_property_names; | |
578 changed_property_names.insert(tabs_constants::kAutoDiscardableKey); | |
579 DispatchTabUpdatedEvent(contents, std::move(changed_property_names)); | |
580 } | |
581 } | 566 } |
582 | 567 |
583 } // namespace extensions | 568 } // namespace extensions |
OLD | NEW |