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 "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/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 | 547 |
548 if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) { | 548 if (ExtensionTabUtil::GetTabStripModel(contents, &tab_strip, &tab_index)) { |
549 scoped_ptr<base::DictionaryValue> changed_properties( | 549 scoped_ptr<base::DictionaryValue> changed_properties( |
550 new base::DictionaryValue()); | 550 new base::DictionaryValue()); |
551 changed_properties->SetBoolean(tabs_constants::kPinnedKey, | 551 changed_properties->SetBoolean(tabs_constants::kPinnedKey, |
552 tab_strip->IsTabPinned(tab_index)); | 552 tab_strip->IsTabPinned(tab_index)); |
553 DispatchTabUpdatedEvent(contents, changed_properties.Pass()); | 553 DispatchTabUpdatedEvent(contents, changed_properties.Pass()); |
554 } | 554 } |
555 } | 555 } |
556 | 556 |
| 557 void TabsEventRouter::TabZoomChange(content::WebContents* contents, |
| 558 double old_zoom_level, |
| 559 double new_zoom_level, |
| 560 content::ZoomMode zoom_mode) { |
| 561 DCHECK(contents); |
| 562 int tab_id = ExtensionTabUtil::GetTabId(contents); |
| 563 if (tab_id < 0) |
| 564 return; |
| 565 |
| 566 // Prepare the zoom change information. |
| 567 api::tabs::OnZoomChange::ZoomChangeInfo zoom_change_info; |
| 568 zoom_change_info.tab_id = tab_id; |
| 569 zoom_change_info.old_zoom_factor = |
| 570 content::ZoomLevelToZoomFactor(old_zoom_level); |
| 571 zoom_change_info.new_zoom_factor = |
| 572 content::ZoomLevelToZoomFactor(new_zoom_level); |
| 573 ZoomModeToZoomSettings(zoom_mode, &zoom_change_info.zoom_settings); |
| 574 |
| 575 // Dispatch the |onZoomChange| event. |
| 576 Profile* profile = Profile::FromBrowserContext( |
| 577 contents->GetBrowserContext()); |
| 578 DispatchEvent(profile, tabs::OnZoomChange::kEventName, |
| 579 api::tabs::OnZoomChange::Create(zoom_change_info), |
| 580 EventRouter::USER_GESTURE_UNKNOWN); |
| 581 } |
| 582 |
557 } // namespace extensions | 583 } // namespace extensions |
OLD | NEW |