OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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/ui/zoom/chrome_zoom_level_prefs.h" | 5 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/common/chrome_constants.h" | 12 #include "chrome/common/chrome_constants.h" |
13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
14 #include "components/prefs/json_pref_store.h" | 14 #include "components/prefs/json_pref_store.h" |
15 #include "components/prefs/pref_filter.h" | 15 #include "components/prefs/pref_filter.h" |
16 #include "components/prefs/pref_registry_simple.h" | 16 #include "components/prefs/pref_registry_simple.h" |
17 #include "components/prefs/pref_service_factory.h" | 17 #include "components/prefs/pref_service_factory.h" |
18 #include "components/prefs/scoped_user_pref_update.h" | 18 #include "components/prefs/scoped_user_pref_update.h" |
19 #include "components/ui/zoom/zoom_event_manager.h" | 19 #include "components/zoom/zoom_event_manager.h" |
20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/browser/host_zoom_map.h" | 21 #include "content/public/browser/host_zoom_map.h" |
22 #include "content/public/common/page_zoom.h" | 22 #include "content/public/common/page_zoom.h" |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 std::string GetHash(const base::FilePath& relative_path) { | 26 std::string GetHash(const base::FilePath& relative_path) { |
27 size_t int_key = BASE_HASH_NAMESPACE::hash<base::FilePath>()(relative_path); | 27 size_t int_key = BASE_HASH_NAMESPACE::hash<base::FilePath>()(relative_path); |
28 return base::SizeTToString(int_key); | 28 return base::SizeTToString(int_key); |
29 } | 29 } |
30 | 30 |
31 } // namespace | 31 } // namespace |
32 | 32 |
33 ChromeZoomLevelPrefs::ChromeZoomLevelPrefs( | 33 ChromeZoomLevelPrefs::ChromeZoomLevelPrefs( |
34 PrefService* pref_service, | 34 PrefService* pref_service, |
35 const base::FilePath& profile_path, | 35 const base::FilePath& profile_path, |
36 const base::FilePath& partition_path, | 36 const base::FilePath& partition_path, |
37 base::WeakPtr<ui_zoom::ZoomEventManager> zoom_event_manager) | 37 base::WeakPtr<zoom::ZoomEventManager> zoom_event_manager) |
38 : pref_service_(pref_service), | 38 : pref_service_(pref_service), |
39 zoom_event_manager_(zoom_event_manager), | 39 zoom_event_manager_(zoom_event_manager), |
40 host_zoom_map_(nullptr) { | 40 host_zoom_map_(nullptr) { |
41 DCHECK(pref_service_); | 41 DCHECK(pref_service_); |
42 | 42 |
43 DCHECK(!partition_path.empty()); | 43 DCHECK(!partition_path.empty()); |
44 DCHECK((partition_path == profile_path) || | 44 DCHECK((partition_path == profile_path) || |
45 profile_path.IsParent(partition_path)); | 45 profile_path.IsParent(partition_path)); |
46 // Create a partition_key string with no '.'s in it. For the default | 46 // Create a partition_key string with no '.'s in it. For the default |
47 // StoragePartition, this string will always be "0". | 47 // StoragePartition, this string will always be "0". |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 &host_zoom_dictionary)) { | 196 &host_zoom_dictionary)) { |
197 // Since we're calling this before setting up zoom_subscription_ below we | 197 // Since we're calling this before setting up zoom_subscription_ below we |
198 // don't need to worry that host_zoom_dictionary is indirectly affected | 198 // don't need to worry that host_zoom_dictionary is indirectly affected |
199 // by calls to HostZoomMap::SetZoomLevelForHost(). | 199 // by calls to HostZoomMap::SetZoomLevelForHost(). |
200 ExtractPerHostZoomLevels(host_zoom_dictionary, | 200 ExtractPerHostZoomLevels(host_zoom_dictionary, |
201 true /* sanitize_partition_host_zoom_levels */); | 201 true /* sanitize_partition_host_zoom_levels */); |
202 } | 202 } |
203 zoom_subscription_ = host_zoom_map_->AddZoomLevelChangedCallback(base::Bind( | 203 zoom_subscription_ = host_zoom_map_->AddZoomLevelChangedCallback(base::Bind( |
204 &ChromeZoomLevelPrefs::OnZoomLevelChanged, base::Unretained(this))); | 204 &ChromeZoomLevelPrefs::OnZoomLevelChanged, base::Unretained(this))); |
205 } | 205 } |
OLD | NEW |