Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: chrome/browser/extensions/api/tabs/tabs_event_router.cc

Issue 225093019: Zoom Extension API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698