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

Unified Diff: chrome/browser/profiles/host_zoom_map_browsertest.cc

Issue 393133002: Migrate HostZoomMap to live in StoragePartition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to 291677. Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
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..9cdab897884a106b969138075f64604fb4c385f2 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)));
}
@@ -75,13 +77,15 @@ class HostZoomMapBrowserTest : public InProcessBrowserTest {
protected:
void SetDefaultZoomLevel(double level) {
- browser()->profile()->GetPrefs()->SetDouble(
- prefs::kDefaultZoomLevel, level);
+ content::BrowserContext::GetDefaultStoragePartition(browser()->profile())
+ ->GetZoomLevelPrefs()
+ ->SetDouble(prefs::kDefaultZoomLevel, level);
}
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 +93,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 +105,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;
@@ -147,20 +153,21 @@ class HostZoomMapSanitizationBrowserTest : public HostZoomMapBrowserTest {
// empty host; and a value for 'host1' that only differs from the default by
// epsilon. Neither should have been persisted.
const char kBrokenPrefs[] =
- "{'profile': {"
+ "{'partition': {"
" 'default_zoom_level': 1.2,"
" 'per_host_zoom_levels': {'': 1.1, 'host1': 1.20001, 'host2': 1.3}"
"}}";
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_broken_prefs;
PathService::Get(chrome::DIR_USER_DATA, &user_data_directory);
- path_to_prefs = user_data_directory
+ path_to_broken_prefs = user_data_directory
.AppendASCII(TestingProfile::kTestUserProfileDir)
- .Append(chrome::kPreferencesFilename);
- base::CreateDirectory(path_to_prefs.DirName());
- base::WriteFile(path_to_prefs, broken_prefs.c_str(), broken_prefs.size());
+ .Append(chrome::kZoomLevelPreferencesFilename);
+ base::CreateDirectory(path_to_broken_prefs.DirName());
+ base::WriteFile(
+ path_to_broken_prefs, broken_prefs.c_str(), broken_prefs.size());
return true;
}

Powered by Google App Engine
This is Rietveld 408576698