2011-01-25 16:34:50 +01:00
|
|
|
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
|
|
|
// reserved. Use of this source code is governed by a BSD-style license that can
|
|
|
|
// be found in the LICENSE file.
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
#include "libcef/browser_zoom_map.h"
|
|
|
|
#include "libcef/cef_thread.h"
|
2011-01-25 16:34:50 +01:00
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
ZoomMap* ZoomMap::GetInstance() {
|
2011-01-25 16:34:50 +01:00
|
|
|
return Singleton<ZoomMap>::get();
|
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
void ZoomMap::set(const GURL& url, double zoomLevel) {
|
2011-01-25 16:34:50 +01:00
|
|
|
REQUIRE_UIT();
|
|
|
|
|
|
|
|
if (zoomLevel == 0.) {
|
|
|
|
// Remove the entry for this host.
|
|
|
|
Map::iterator iter = map_.find(url.host());
|
|
|
|
if (iter != map_.end())
|
|
|
|
map_.erase(iter);
|
|
|
|
} else {
|
|
|
|
// Update the entry for this host.
|
|
|
|
map_[url.host()] = zoomLevel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-10 00:46:23 +01:00
|
|
|
bool ZoomMap::get(const GURL& url, double& zoomLevel) {
|
2011-01-25 16:34:50 +01:00
|
|
|
REQUIRE_UIT();
|
|
|
|
|
|
|
|
Map::const_iterator iter = map_.find(url.host());
|
|
|
|
if (iter == map_.end())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
zoomLevel = iter->second;
|
|
|
|
return true;
|
|
|
|
}
|