Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / zoom / chrome_zoom_level_otr_delegate.cc
blob829ae2c25d37011382a68dd8f3b0bdae712817c5
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/zoom/chrome_zoom_level_otr_delegate.h"
7 #include "base/bind.h"
8 #include "components/ui/zoom/zoom_event_manager.h"
10 namespace chrome {
12 ChromeZoomLevelOTRDelegate::ChromeZoomLevelOTRDelegate(
13 base::WeakPtr<ui_zoom::ZoomEventManager> zoom_event_manager)
14 : zoom_event_manager_(zoom_event_manager), host_zoom_map_(nullptr) {
17 ChromeZoomLevelOTRDelegate::~ChromeZoomLevelOTRDelegate() {
20 void ChromeZoomLevelOTRDelegate::InitHostZoomMap(
21 content::HostZoomMap* host_zoom_map) {
22 // This init function must be called only once.
23 DCHECK(!host_zoom_map_);
24 DCHECK(host_zoom_map);
25 host_zoom_map_ = host_zoom_map;
27 zoom_subscription_ = host_zoom_map_->AddZoomLevelChangedCallback(base::Bind(
28 &ChromeZoomLevelOTRDelegate::OnZoomLevelChanged, base::Unretained(this)));
31 void ChromeZoomLevelOTRDelegate::OnZoomLevelChanged(
32 const content::HostZoomMap::ZoomLevelChange& change) {
33 // If there's a manager to aggregate ZoomLevelChanged events, pass this event
34 // along. Since we already hold a subscription to our associated HostZoomMap,
35 // we don't need to create a separate subscription for this.
36 if (zoom_event_manager_)
37 zoom_event_manager_->OnZoomLevelChanged(change);
40 } // namespace chrome