Chromium Code Reviews| 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/browser_event_router.h" | 5 #include "chrome/browser/extensions/browser_event_router.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_ api_constants.h" | 9 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_ api_constants.h" |
| 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 void BrowserEventRouter::TabChangedAt(WebContents* contents, | 464 void BrowserEventRouter::TabChangedAt(WebContents* contents, |
| 465 int index, | 465 int index, |
| 466 TabChangeType change_type) { | 466 TabChangeType change_type) { |
| 467 TabUpdated(contents, false); | 467 TabUpdated(contents, false); |
| 468 } | 468 } |
| 469 | 469 |
| 470 void BrowserEventRouter::TabReplacedAt(TabStripModel* tab_strip_model, | 470 void BrowserEventRouter::TabReplacedAt(TabStripModel* tab_strip_model, |
| 471 WebContents* old_contents, | 471 WebContents* old_contents, |
| 472 WebContents* new_contents, | 472 WebContents* new_contents, |
| 473 int index) { | 473 int index) { |
| 474 // Notify listeners that the next tabs closing or being added are due to | |
| 475 // WebContents being swapped. | |
| 476 scoped_ptr<ListValue> args(new ListValue()); | |
| 477 args->Append(Value::CreateIntegerValue( | |
| 478 ExtensionTabUtil::GetTabId(new_contents))); | |
| 479 args->Append(Value::CreateIntegerValue( | |
| 480 ExtensionTabUtil::GetTabId(old_contents))); | |
| 481 | |
| 482 DispatchEvent(Profile::FromBrowserContext(new_contents->GetBrowserContext()), | |
| 483 events::kOnTabSwapped, | |
| 484 args.Pass(), | |
| 485 EventRouter::USER_GESTURE_UNKNOWN); | |
| 486 | |
| 474 TabClosingAt(tab_strip_model, old_contents, index); | 487 TabClosingAt(tab_strip_model, old_contents, index); |
| 475 TabInsertedAt(new_contents, index, tab_strip_model->active_index() == index); | 488 TabInsertedAt(new_contents, index, tab_strip_model->active_index() == index); |
|
Matt Perry
2012/12/18 18:04:02
Can we remove these two calls? The downside is tha
justinlin
2012/12/19 23:42:42
Yea, I thought about removing at first, but wanted
| |
| 476 } | 489 } |
| 477 | 490 |
| 478 void BrowserEventRouter::TabPinnedStateChanged(WebContents* contents, | 491 void BrowserEventRouter::TabPinnedStateChanged(WebContents* contents, |
| 479 int index) { | 492 int index) { |
| 480 TabStripModel* tab_strip = NULL; | 493 TabStripModel* tab_strip = NULL; |
| 481 int tab_index; | 494 int tab_index; |
| 482 | 495 |
| 483 if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) { | 496 if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) { |
| 484 DictionaryValue* changed_properties = new DictionaryValue(); | 497 DictionaryValue* changed_properties = new DictionaryValue(); |
| 485 changed_properties->SetBoolean(tab_keys::kPinnedKey, | 498 changed_properties->SetBoolean(tab_keys::kPinnedKey, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 577 | 590 |
| 578 DispatchEventToExtension(profile, | 591 DispatchEventToExtension(profile, |
| 579 extension_action.extension_id(), | 592 extension_action.extension_id(), |
| 580 event_name, | 593 event_name, |
| 581 args.Pass(), | 594 args.Pass(), |
| 582 EventRouter::USER_GESTURE_ENABLED); | 595 EventRouter::USER_GESTURE_ENABLED); |
| 583 } | 596 } |
| 584 } | 597 } |
| 585 | 598 |
| 586 } // namespace extensions | 599 } // namespace extensions |
| OLD | NEW |