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