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

Side by Side Diff: chrome/browser/profiles/profile_impl.cc

Issue 12039058: content: convert zoom notifications to observer usage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/profiles/profile_impl.h" 5 #include "chrome/browser/profiles/profile_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 const std::string& host(*i); 561 const std::string& host(*i);
562 double zoom_level = 0; 562 double zoom_level = 0;
563 563
564 bool success = host_zoom_dictionary->GetDoubleWithoutPathExpansion( 564 bool success = host_zoom_dictionary->GetDoubleWithoutPathExpansion(
565 host, &zoom_level); 565 host, &zoom_level);
566 DCHECK(success); 566 DCHECK(success);
567 host_zoom_map->SetZoomLevel(host, zoom_level); 567 host_zoom_map->SetZoomLevel(host, zoom_level);
568 } 568 }
569 } 569 }
570 570
571 registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED, 571 content::HostZoomMap::Observer::Observe(host_zoom_map);
572 content::Source<HostZoomMap>(host_zoom_map));
573 } 572 }
574 573
575 FilePath ProfileImpl::last_selected_directory() { 574 FilePath ProfileImpl::last_selected_directory() {
576 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); 575 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory);
577 } 576 }
578 577
579 void ProfileImpl::set_last_selected_directory(const FilePath& path) { 578 void ProfileImpl::set_last_selected_directory(const FilePath& path) {
580 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); 579 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path);
581 } 580 }
582 581
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 top_sites_ = new history::TopSites(this); 906 top_sites_ = new history::TopSites(this);
908 top_sites_->Init(GetPath().Append(chrome::kTopSitesFilename)); 907 top_sites_->Init(GetPath().Append(chrome::kTopSitesFilename));
909 } 908 }
910 return top_sites_; 909 return top_sites_;
911 } 910 }
912 911
913 history::TopSites* ProfileImpl::GetTopSitesWithoutCreating() { 912 history::TopSites* ProfileImpl::GetTopSitesWithoutCreating() {
914 return top_sites_; 913 return top_sites_;
915 } 914 }
916 915
916 void ProfileImpl::OnZoomLevelChanged(const std::string& host) {
917 if (host.empty())
918 return;
919 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this);
920 double level = host_zoom_map->GetZoomLevel(host);
921 DictionaryPrefUpdate update(prefs_.get(), prefs::kPerHostZoomLevels);
922 DictionaryValue* host_zoom_dictionary = update.Get();
923 if (level == host_zoom_map->GetDefaultZoomLevel()) {
924 host_zoom_dictionary->RemoveWithoutPathExpansion(host, NULL);
925 } else {
926 host_zoom_dictionary->SetWithoutPathExpansion(
927 host, Value::CreateDoubleValue(level));
928 }
929 }
930
917 void ProfileImpl::Observe(int type, 931 void ProfileImpl::Observe(int type,
918 const content::NotificationSource& source, 932 const content::NotificationSource& source,
919 const content::NotificationDetails& details) { 933 const content::NotificationDetails& details) {
920 switch (type) { 934 switch (type) {
921 case chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED: 935 case chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED:
922 // Causes lazy-load if sync is enabled. 936 // Causes lazy-load if sync is enabled.
923 ProfileSyncServiceFactory::GetInstance()->GetForProfile(this); 937 ProfileSyncServiceFactory::GetInstance()->GetForProfile(this);
924 registrar_.Remove(this, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED, 938 registrar_.Remove(this, chrome::NOTIFICATION_BOOKMARK_MODEL_LOADED,
925 content::Source<Profile>(this)); 939 content::Source<Profile>(this));
926 break; 940 break;
927 case content::NOTIFICATION_ZOOM_LEVEL_CHANGED: {
928 const std::string& host =
929 *(content::Details<const std::string>(details).ptr());
930 if (!host.empty()) {
931 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this);
932 double level = host_zoom_map->GetZoomLevel(host);
933 DictionaryPrefUpdate update(prefs_.get(), prefs::kPerHostZoomLevels);
934 DictionaryValue* host_zoom_dictionary = update.Get();
935 if (level == host_zoom_map->GetDefaultZoomLevel()) {
936 host_zoom_dictionary->RemoveWithoutPathExpansion(host, NULL);
937 } else {
938 host_zoom_dictionary->SetWithoutPathExpansion(
939 host, Value::CreateDoubleValue(level));
940 }
941 }
942 break;
943 }
944 default: 941 default:
945 NOTREACHED(); 942 NOTREACHED();
946 } 943 }
947 } 944 }
948 945
949 void ProfileImpl::OnDefaultZoomLevelChanged() { 946 void ProfileImpl::OnDefaultZoomLevelChanged() {
950 HostZoomMap::GetForBrowserContext(this)->SetDefaultZoomLevel( 947 HostZoomMap::GetForBrowserContext(this)->SetDefaultZoomLevel(
951 pref_change_registrar_.prefs()->GetDouble(prefs::kDefaultZoomLevel)); 948 pref_change_registrar_.prefs()->GetDouble(prefs::kDefaultZoomLevel));
952 } 949 }
953 950
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 if (!path.empty()) 1143 if (!path.empty())
1147 *cache_path = path; 1144 *cache_path = path;
1148 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : 1145 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) :
1149 prefs_->GetInteger(prefs::kDiskCacheSize); 1146 prefs_->GetInteger(prefs::kDiskCacheSize);
1150 } 1147 }
1151 1148
1152 base::Callback<ChromeURLDataManagerBackend*(void)> 1149 base::Callback<ChromeURLDataManagerBackend*(void)>
1153 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { 1150 ProfileImpl::GetChromeURLDataManagerBackendGetter() const {
1154 return io_data_.GetChromeURLDataManagerBackendGetter(); 1151 return io_data_.GetChromeURLDataManagerBackendGetter();
1155 } 1152 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698