Index: chrome/browser/profiles/host_zoom_map_browsertest.cc |
diff --git a/chrome/browser/profiles/host_zoom_map_browsertest.cc b/chrome/browser/profiles/host_zoom_map_browsertest.cc |
index f485636874b4fbdcd6f508ee2f43c03579163498..923f21f5fc6c6b694157ebe374962202abdc0280 100644 |
--- a/chrome/browser/profiles/host_zoom_map_browsertest.cc |
+++ b/chrome/browser/profiles/host_zoom_map_browsertest.cc |
@@ -27,6 +27,8 @@ |
#include "chrome/test/base/in_process_browser_test.h" |
#include "chrome/test/base/testing_profile.h" |
#include "chrome/test/base/ui_test_utils.h" |
+#include "content/public/browser/browser_context.h" |
+#include "content/public/browser/storage_partition.h" |
#include "content/public/test/test_utils.h" |
#include "net/dns/mock_host_resolver.h" |
#include "net/test/embedded_test_server/embedded_test_server.h" |
@@ -41,7 +43,7 @@ class ZoomLevelChangeObserver { |
explicit ZoomLevelChangeObserver(Profile* profile) |
: message_loop_runner_(new content::MessageLoopRunner) { |
content::HostZoomMap* host_zoom_map = static_cast<content::HostZoomMap*>( |
- content::HostZoomMap::GetForBrowserContext(profile)); |
+ content::HostZoomMap::GetDefaultForBrowserContext(profile)); |
subscription_ = host_zoom_map->AddZoomLevelChangedCallback(base::Bind( |
&ZoomLevelChangeObserver::OnZoomLevelChanged, base::Unretained(this))); |
} |
@@ -81,7 +83,8 @@ class HostZoomMapBrowserTest : public InProcessBrowserTest { |
double GetZoomLevel(const GURL& url) { |
content::HostZoomMap* host_zoom_map = static_cast<content::HostZoomMap*>( |
- content::HostZoomMap::GetForBrowserContext(browser()->profile())); |
+ content::HostZoomMap::GetDefaultForBrowserContext( |
+ browser()->profile())); |
return host_zoom_map->GetZoomLevelForHostAndScheme(url.scheme(), |
url.host()); |
} |
@@ -89,7 +92,8 @@ class HostZoomMapBrowserTest : public InProcessBrowserTest { |
std::vector<std::string> GetHostsWithZoomLevels() { |
typedef content::HostZoomMap::ZoomLevelVector ZoomLevelVector; |
content::HostZoomMap* host_zoom_map = static_cast<content::HostZoomMap*>( |
- content::HostZoomMap::GetForBrowserContext(browser()->profile())); |
+ content::HostZoomMap::GetDefaultForBrowserContext( |
+ browser()->profile())); |
content::HostZoomMap::ZoomLevelVector zoom_levels = |
host_zoom_map->GetAllZoomLevels(); |
std::vector<std::string> results; |
@@ -100,7 +104,8 @@ class HostZoomMapBrowserTest : public InProcessBrowserTest { |
} |
std::vector<std::string> GetHostsWithZoomLevelsFromPrefs() { |
- PrefService* prefs = browser()->profile()->GetPrefs(); |
+ PrefService* prefs = content::BrowserContext::GetDefaultStoragePartition( |
+ browser()->profile())->GetZoomLevelPrefs(); |
const base::DictionaryValue* values = |
prefs->GetDictionary(prefs::kPerHostZoomLevels); |
std::vector<std::string> results; |
@@ -146,21 +151,31 @@ class HostZoomMapSanitizationBrowserTest : public HostZoomMapBrowserTest { |
// caused by the bug. They incorrectly contain a per-host zoom level for the |
// empty host; and a value for 'host1' that only differs from the default by |
// epsilon. Neither should have been persisted. |
+ const char kPrefs[] = |
+ "{'profile': {" |
+ " 'default_zoom_level': 1.2" |
+ "}}"; |
const char kBrokenPrefs[] = |
"{'profile': {" |
- " 'default_zoom_level': 1.2," |
" 'per_host_zoom_levels': {'': 1.1, 'host1': 1.20001, 'host2': 1.3}" |
"}}"; |
+ std::string prefs(kPrefs); |
+ std::replace(prefs.begin(), prefs.end(), '\'', '\"'); |
std::string broken_prefs(kBrokenPrefs); |
std::replace(broken_prefs.begin(), broken_prefs.end(), '\'', '\"'); |
- base::FilePath user_data_directory, path_to_prefs; |
+ base::FilePath user_data_directory, path_to_prefs, path_to_broken_prefs; |
PathService::Get(chrome::DIR_USER_DATA, &user_data_directory); |
path_to_prefs = user_data_directory |
.AppendASCII(TestingProfile::kTestUserProfileDir) |
.Append(chrome::kPreferencesFilename); |
+ path_to_broken_prefs = user_data_directory |
+ .AppendASCII(TestingProfile::kTestUserProfileDir) |
+ .Append(chrome::kZoomLevelPreferencesFilename); |
base::CreateDirectory(path_to_prefs.DirName()); |
- base::WriteFile(path_to_prefs, broken_prefs.c_str(), broken_prefs.size()); |
+ base::WriteFile(path_to_prefs, prefs.c_str(), prefs.size()); |
+ base::WriteFile( |
+ path_to_broken_prefs, broken_prefs.c_str(), broken_prefs.size()); |
return true; |
} |