OLD | NEW |
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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 // Careful: The returned value could be NULL if the pref has never been set. | 578 // Careful: The returned value could be NULL if the pref has never been set. |
579 if (host_zoom_dictionary != NULL) { | 579 if (host_zoom_dictionary != NULL) { |
580 for (DictionaryValue::key_iterator i(host_zoom_dictionary->begin_keys()); | 580 for (DictionaryValue::key_iterator i(host_zoom_dictionary->begin_keys()); |
581 i != host_zoom_dictionary->end_keys(); ++i) { | 581 i != host_zoom_dictionary->end_keys(); ++i) { |
582 const std::string& host(*i); | 582 const std::string& host(*i); |
583 double zoom_level = 0; | 583 double zoom_level = 0; |
584 | 584 |
585 bool success = host_zoom_dictionary->GetDoubleWithoutPathExpansion( | 585 bool success = host_zoom_dictionary->GetDoubleWithoutPathExpansion( |
586 host, &zoom_level); | 586 host, &zoom_level); |
587 DCHECK(success); | 587 DCHECK(success); |
588 host_zoom_map->SetZoomLevel(host, zoom_level); | 588 host_zoom_map->SetZoomLevelForHost(host, zoom_level); |
589 } | 589 } |
590 } | 590 } |
591 | 591 |
592 host_zoom_map->AddZoomLevelChangedCallback(zoom_callback_); | 592 host_zoom_map->AddZoomLevelChangedCallback(zoom_callback_); |
593 } | 593 } |
594 | 594 |
595 base::FilePath ProfileImpl::last_selected_directory() { | 595 base::FilePath ProfileImpl::last_selected_directory() { |
596 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); | 596 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); |
597 } | 597 } |
598 | 598 |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
950 | 950 |
951 history::TopSites* ProfileImpl::GetTopSitesWithoutCreating() { | 951 history::TopSites* ProfileImpl::GetTopSitesWithoutCreating() { |
952 return top_sites_; | 952 return top_sites_; |
953 } | 953 } |
954 | 954 |
955 void ProfileImpl::OnDefaultZoomLevelChanged() { | 955 void ProfileImpl::OnDefaultZoomLevelChanged() { |
956 HostZoomMap::GetForBrowserContext(this)->SetDefaultZoomLevel( | 956 HostZoomMap::GetForBrowserContext(this)->SetDefaultZoomLevel( |
957 pref_change_registrar_.prefs()->GetDouble(prefs::kDefaultZoomLevel)); | 957 pref_change_registrar_.prefs()->GetDouble(prefs::kDefaultZoomLevel)); |
958 } | 958 } |
959 | 959 |
960 void ProfileImpl::OnZoomLevelChanged(const std::string& host) { | 960 void ProfileImpl::OnZoomLevelChanged( |
961 if (host.empty()) | 961 const HostZoomMap::ZoomLevelChange& change) { |
| 962 |
| 963 if (change.mode != HostZoomMap::ZOOM_CHANGED_FOR_HOST) |
962 return; | 964 return; |
963 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); | 965 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); |
964 double level = host_zoom_map->GetZoomLevel(host); | 966 double level = change.zoom_level; |
965 DictionaryPrefUpdate update(prefs_.get(), prefs::kPerHostZoomLevels); | 967 DictionaryPrefUpdate update(prefs_.get(), prefs::kPerHostZoomLevels); |
966 DictionaryValue* host_zoom_dictionary = update.Get(); | 968 DictionaryValue* host_zoom_dictionary = update.Get(); |
967 if (level == host_zoom_map->GetDefaultZoomLevel()) { | 969 if (level == host_zoom_map->GetDefaultZoomLevel()) { |
968 host_zoom_dictionary->RemoveWithoutPathExpansion(host, NULL); | 970 host_zoom_dictionary->RemoveWithoutPathExpansion(change.host, NULL); |
969 } else { | 971 } else { |
970 host_zoom_dictionary->SetWithoutPathExpansion( | 972 host_zoom_dictionary->SetWithoutPathExpansion( |
971 host, Value::CreateDoubleValue(level)); | 973 change.host, Value::CreateDoubleValue(level)); |
972 } | 974 } |
973 } | 975 } |
974 | 976 |
975 #if defined(ENABLE_SESSION_SERVICE) | 977 #if defined(ENABLE_SESSION_SERVICE) |
976 void ProfileImpl::StopCreateSessionServiceTimer() { | 978 void ProfileImpl::StopCreateSessionServiceTimer() { |
977 create_session_service_timer_.Stop(); | 979 create_session_service_timer_.Stop(); |
978 } | 980 } |
979 | 981 |
980 void ProfileImpl::EnsureSessionServiceCreated() { | 982 void ProfileImpl::EnsureSessionServiceCreated() { |
981 SessionServiceFactory::GetForProfile(this); | 983 SessionServiceFactory::GetForProfile(this); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 base::FilePath* cache_path, | 1164 base::FilePath* cache_path, |
1163 int* max_size) { | 1165 int* max_size) { |
1164 DCHECK(cache_path); | 1166 DCHECK(cache_path); |
1165 DCHECK(max_size); | 1167 DCHECK(max_size); |
1166 base::FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); | 1168 base::FilePath path(prefs_->GetFilePath(prefs::kDiskCacheDir)); |
1167 if (!path.empty()) | 1169 if (!path.empty()) |
1168 *cache_path = path; | 1170 *cache_path = path; |
1169 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : | 1171 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : |
1170 prefs_->GetInteger(prefs::kDiskCacheSize); | 1172 prefs_->GetInteger(prefs::kDiskCacheSize); |
1171 } | 1173 } |
OLD | NEW |