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

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

Issue 301733006: Zoom Extension API (chrome) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add event manager for manual zoom events. Created 6 years, 6 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 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(content::WebContents* web_contents,
556 double old_zoom_level,
557 double new_zoom_level,
558 ZoomMode zoom_mode) {
559 DCHECK(web_contents);
560 int tab_id = ExtensionTabUtil::GetTabId(web_contents);
561 if (tab_id < 0)
562 return;
563
564 // Prepare the zoom change information.
565 api::tabs::OnZoomChange::ZoomChangeInfo zoom_change_info;
566 zoom_change_info.tab_id = tab_id;
567 zoom_change_info.old_zoom_factor =
568 content::ZoomLevelToZoomFactor(old_zoom_level);
569 zoom_change_info.new_zoom_factor =
570 content::ZoomLevelToZoomFactor(new_zoom_level);
571 ZoomModeToZoomSettings(zoom_mode,
572 &zoom_change_info.zoom_settings);
573
574 // Dispatch the |onZoomChange| event.
575 Profile* profile = Profile::FromBrowserContext(
576 web_contents->GetBrowserContext());
577 DispatchEvent(profile, tabs::OnZoomChange::kEventName,
Devlin 2014/06/16 19:04:47 nit: One argument per line (unless all fit on one
wjmaclean 2014/06/18 19:03:52 Done.
578 api::tabs::OnZoomChange::Create(zoom_change_info),
579 EventRouter::USER_GESTURE_UNKNOWN);
580 }
581
555 } // namespace extensions 582 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698