Chromium Code Reviews| Index: content/browser/host_zoom_map_impl.cc |
| diff --git a/content/browser/host_zoom_map_impl.cc b/content/browser/host_zoom_map_impl.cc |
| index 66a03d66f8d1ea556644710f4b11c87ccc606878..8ee5c1f4a5e78adfa1c1c7b64119f88eef46ab04 100644 |
| --- a/content/browser/host_zoom_map_impl.cc |
| +++ b/content/browser/host_zoom_map_impl.cc |
| @@ -45,6 +45,14 @@ HostZoomMapImpl::HostZoomMapImpl() |
| NotificationService::AllSources()); |
| } |
| +void HostZoomMapImpl::CopyHostZoomLevels(const HostZoomLevels &source, |
| + HostZoomLevels &dest) { |
| + for (HostZoomLevels::const_iterator i(source.begin()); |
|
sky
2013/01/11 20:33:32
dest->insert(source.begin(), source.end()) , at wh
Denis Kuznetsov (DE-MUC)
2013/01/17 13:23:47
Done.
|
| + i != source.end(); ++i) { |
| + dest[i->first] = i->second; |
| + } |
| +} |
| + |
| void HostZoomMapImpl::CopyFrom(HostZoomMap* copy_interface) { |
| // This can only be called on the UI thread to avoid deadlocks, otherwise |
| // UI: a.CopyFrom(b); |
| @@ -54,9 +62,12 @@ void HostZoomMapImpl::CopyFrom(HostZoomMap* copy_interface) { |
| HostZoomMapImpl* copy = static_cast<HostZoomMapImpl*>(copy_interface); |
| base::AutoLock auto_lock(lock_); |
| base::AutoLock copy_auto_lock(copy->lock_); |
| - for (HostZoomLevels::const_iterator i(copy->host_zoom_levels_.begin()); |
| - i != copy->host_zoom_levels_.end(); ++i) { |
| - host_zoom_levels_[i->first] = i->second; |
| + CopyHostZoomLevels(copy->host_zoom_levels_, host_zoom_levels_); |
| + for (SchemeHostZoomLevels::const_iterator i(copy-> |
| + scheme_host_zoom_levels_.begin()); |
| + i != copy->scheme_host_zoom_levels_.end(); ++i) { |
| + scheme_host_zoom_levels_[i->first] = HostZoomLevels(); |
| + CopyHostZoomLevels(i->second, scheme_host_zoom_levels_[i->first]); |
| } |
| } |
| @@ -66,6 +77,21 @@ double HostZoomMapImpl::GetZoomLevel(const std::string& host) const { |
| return (i == host_zoom_levels_.end()) ? default_zoom_level_ : i->second; |
| } |
| +double HostZoomMapImpl::GetZoomLevel(const std::string& scheme, |
| + const std::string& host) const { |
| + { |
| + base::AutoLock auto_lock(lock_); |
| + SchemeHostZoomLevels::const_iterator scheme_iterator( |
| + scheme_host_zoom_levels_.find(scheme)); |
| + if (scheme_iterator != scheme_host_zoom_levels_.end()) { |
| + HostZoomLevels::const_iterator i(scheme_iterator->second.find(host)); |
| + if (i != scheme_iterator->second.end()) |
| + return i->second; |
| + } |
| + } |
| + return GetZoomLevel(host); |
| +} |
| + |
| void HostZoomMapImpl::SetZoomLevel(const std::string& host, double level) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| @@ -85,7 +111,7 @@ void HostZoomMapImpl::SetZoomLevel(const std::string& host, double level) { |
| if (HostZoomMap::GetForBrowserContext( |
| render_process_host->GetBrowserContext()) == this) { |
| render_process_host->Send( |
| - new ViewMsg_SetZoomLevelForCurrentURL(host, level)); |
| + new ViewMsg_SetZoomLevelForCurrentURL(std::string(), host, level)); |
| } |
| } |
| @@ -95,6 +121,33 @@ void HostZoomMapImpl::SetZoomLevel(const std::string& host, double level) { |
| Details<const std::string>(&host)); |
| } |
| +void HostZoomMapImpl::SetZoomLevel(const std::string& scheme, |
| + const std::string& host, |
| + double level) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + { |
| + base::AutoLock auto_lock(lock_); |
| + scheme_host_zoom_levels_[scheme][host] = level; |
| + } |
| + |
| + // Notify renderers from this browser context. |
| + for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); |
| + !i.IsAtEnd(); i.Advance()) { |
| + RenderProcessHost* render_process_host = i.GetCurrentValue(); |
| + if (HostZoomMap::GetForBrowserContext( |
| + render_process_host->GetBrowserContext()) == this) { |
| + render_process_host->Send( |
| + new ViewMsg_SetZoomLevelForCurrentURL(scheme, host, level)); |
| + } |
| + } |
| + |
| + NotificationService::current()->Notify( |
| + NOTIFICATION_ZOOM_LEVEL_CHANGED, |
| + Source<HostZoomMap>(this), |
| + Details<const std::string>(&host)); |
| +} |
| + |
| + |
|
sky
2013/01/11 20:33:32
remove one newline.
Denis Kuznetsov (DE-MUC)
2013/01/17 13:23:47
Done.
Denis Kuznetsov (DE-MUC)
2013/01/17 13:23:47
Done.
|
| double HostZoomMapImpl::GetDefaultZoomLevel() const { |
| return default_zoom_level_; |
| } |