summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/dom_ui/dom_ui_thumbnail_source.cc6
-rw-r--r--chrome/browser/dom_ui/most_visited_handler.cc14
-rw-r--r--chrome/browser/history/history_backend.cc23
-rw-r--r--chrome/browser/history/history_backend_unittest.cc6
-rw-r--r--chrome/browser/history/history_database.cc36
-rw-r--r--chrome/browser/history/history_database.h9
-rw-r--r--chrome/browser/history/history_unittest.cc3
-rw-r--r--chrome/browser/history/thumbnail_database.cc10
-rw-r--r--chrome/browser/history/thumbnail_database_unittest.cc13
-rw-r--r--chrome/browser/history/top_sites.cc5
-rw-r--r--chrome/browser/history/top_sites.h3
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc2
-rw-r--r--chrome/common/chrome_switches.cc6
-rw-r--r--chrome/common/chrome_switches.h2
14 files changed, 63 insertions, 75 deletions
diff --git a/chrome/browser/dom_ui/dom_ui_thumbnail_source.cc b/chrome/browser/dom_ui/dom_ui_thumbnail_source.cc
index ebff335..f17586f 100644
--- a/chrome/browser/dom_ui/dom_ui_thumbnail_source.cc
+++ b/chrome/browser/dom_ui/dom_ui_thumbnail_source.cc
@@ -6,10 +6,8 @@
#include "app/resource_bundle.h"
#include "base/callback.h"
-#include "base/command_line.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/history/top_sites.h"
-#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/url_constants.h"
#include "gfx/codec/jpeg_codec.h"
@@ -28,7 +26,7 @@ DOMUIThumbnailSource::~DOMUIThumbnailSource() {
void DOMUIThumbnailSource::StartDataRequest(const std::string& path,
bool is_off_the_record,
int request_id) {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites)) {
+ if (history::TopSites::IsEnabled()) {
history::TopSites* top_sites = profile_->GetTopSites();
RefCountedBytes* data = NULL;
if (top_sites->GetPageThumbnail(GURL(path), &data)) {
@@ -38,7 +36,7 @@ void DOMUIThumbnailSource::StartDataRequest(const std::string& path,
SendDefaultThumbnail(request_id);
}
return;
- } // end --top-sites switch
+ }
HistoryService* hs = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS);
if (hs) {
diff --git a/chrome/browser/dom_ui/most_visited_handler.cc b/chrome/browser/dom_ui/most_visited_handler.cc
index 3542198..95d326f 100644
--- a/chrome/browser/dom_ui/most_visited_handler.cc
+++ b/chrome/browser/dom_ui/most_visited_handler.cc
@@ -144,7 +144,7 @@ void MostVisitedHandler::SendPagesValue() {
}
void MostVisitedHandler::StartQueryForMostVisited() {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites)) {
+ if (history::TopSites::IsEnabled()) {
// Use TopSites.
history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
ts->GetMostVisitedURLs(
@@ -189,7 +189,7 @@ void MostVisitedHandler::HandleRemoveURLsFromBlacklist(const ListValue* args) {
}
UserMetrics::RecordAction(UserMetricsAction("MostVisited_UrlRemoved"),
dom_ui_->GetProfile());
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites)) {
+ if (history::TopSites::IsEnabled()) {
history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
ts->RemoveBlacklistedURL(GURL(url));
return;
@@ -204,7 +204,7 @@ void MostVisitedHandler::HandleClearBlacklist(const ListValue* args) {
UserMetrics::RecordAction(UserMetricsAction("MostVisited_BlacklistCleared"),
dom_ui_->GetProfile());
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites)) {
+ if (history::TopSites::IsEnabled()) {
history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
ts->ClearBlacklistedURLs();
return;
@@ -248,7 +248,7 @@ void MostVisitedHandler::HandleAddPinnedURL(const ListValue* args) {
}
void MostVisitedHandler::AddPinnedURL(const MostVisitedPage& page, int index) {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites)) {
+ if (history::TopSites::IsEnabled()) {
history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
ts->AddPinnedURL(page.url, index);
return;
@@ -277,7 +277,7 @@ void MostVisitedHandler::HandleRemovePinnedURL(const ListValue* args) {
}
void MostVisitedHandler::RemovePinnedURL(const GURL& url) {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites)) {
+ if (history::TopSites::IsEnabled()) {
history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
ts->RemovePinnedURL(url);
return;
@@ -410,7 +410,7 @@ void MostVisitedHandler::SetPagesValue(std::vector<PageUsageData*>* data) {
void MostVisitedHandler::SetPagesValueFromTopSites(
const history::MostVisitedURLList& data) {
- DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites));
+ DCHECK(history::TopSites::IsEnabled());
pages_value_.reset(new ListValue);
for (size_t i = 0; i < data.size(); i++) {
const history::MostVisitedURL& url = data[i];
@@ -512,7 +512,7 @@ void MostVisitedHandler::Observe(NotificationType type,
}
void MostVisitedHandler::BlacklistURL(const GURL& url) {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites)) {
+ if (history::TopSites::IsEnabled()) {
history::TopSites* ts = dom_ui_->GetProfile()->GetTopSites();
ts->AddBlacklistedURL(url);
return;
diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc
index 027c559..4472b9e 100644
--- a/chrome/browser/history/history_backend.cc
+++ b/chrome/browser/history/history_backend.cc
@@ -22,6 +22,7 @@
#include "chrome/browser/history/history_publisher.h"
#include "chrome/browser/history/in_memory_history_backend.h"
#include "chrome/browser/history/page_usage_data.h"
+#include "chrome/browser/history/top_sites.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_type.h"
@@ -582,11 +583,12 @@ void HistoryBackend::InitImpl() {
// Thumbnail database.
thumbnail_db_.reset(new ThumbnailDatabase());
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites)) {
- if (!db_->needs_version_18_migration()) {
- // No convertion needed - use new filename right away.
- thumbnail_name = GetFaviconsFileName();
- }
+ if (history::TopSites::IsEnabled()) {
+ // TODO(sky): once we reenable top sites this needs to be fixed.
+ // if (!db_->needs_version_18_migration()) {
+ // No convertion needed - use new filename right away.
+ // thumbnail_name = GetFaviconsFileName();
+ // }
}
if (thumbnail_db_->Init(thumbnail_name,
history_publisher_.get()) != sql::INIT_OK) {
@@ -599,11 +601,12 @@ void HistoryBackend::InitImpl() {
thumbnail_db_.reset();
}
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites)) {
- if (db_->needs_version_18_migration()) {
- LOG(INFO) << "Starting TopSites migration";
- delegate_->StartTopSitesMigration();
- }
+ if (history::TopSites::IsEnabled()) {
+ // TODO(sky): fix when reenabling top sites migration.
+ // if (db_->needs_version_18_migration()) {
+ // LOG(INFO) << "Starting TopSites migration";
+ // delegate_->StartTopSitesMigration();
+ // }
}
// Archived database.
diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc
index 68fd2e2..907b7b6 100644
--- a/chrome/browser/history/history_backend_unittest.cc
+++ b/chrome/browser/history/history_backend_unittest.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/history/history_notifications.h"
#include "chrome/browser/history/in_memory_history_backend.h"
#include "chrome/browser/history/in_memory_database.h"
+#include "chrome/browser/history/top_sites.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
@@ -412,10 +413,9 @@ TEST_F(HistoryBackendTest, URLsNoLongerBookmarked) {
TEST_F(HistoryBackendTest, GetPageThumbnailAfterRedirects) {
ASSERT_TRUE(backend_.get());
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites))
+ if (history::TopSites::IsEnabled())
return;
-
const char* base_url = "http://mail";
const char* thumbnail_url = "http://mail.google.com";
const char* first_chain[] = {
@@ -613,7 +613,7 @@ TEST_F(HistoryBackendTest, StripUsernamePasswordTest) {
}
TEST_F(HistoryBackendTest, DeleteThumbnailsDatabaseTest) {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites))
+ if (history::TopSites::IsEnabled())
return;
EXPECT_TRUE(backend_->thumbnail_db_->NeedsMigrationToTopSites());
diff --git a/chrome/browser/history/history_database.cc b/chrome/browser/history/history_database.cc
index 4fab291..4661814 100644
--- a/chrome/browser/history/history_database.cc
+++ b/chrome/browser/history/history_database.cc
@@ -56,8 +56,7 @@ void ComputeDatabaseMetrics(const FilePath& history_name,
} // namespace
HistoryDatabase::HistoryDatabase()
- : needs_version_17_migration_(false),
- needs_version_18_migration_(false) {
+ : needs_version_17_migration_(false) {
}
HistoryDatabase::~HistoryDatabase() {
@@ -134,11 +133,7 @@ void HistoryDatabase::BeginExclusiveMode() {
// static
int HistoryDatabase::GetCurrentVersion() {
- // If we don't use TopSites, we stay at the last pre-TopSites version.
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites))
- return 17; // Last pre-TopSites version.
- else
- return kCurrentVersionNumber;
+ return kCurrentVersionNumber;
}
void HistoryDatabase::BeginTransaction() {
@@ -280,17 +275,14 @@ sql::InitStatus HistoryDatabase::EnsureCurrentVersion(
meta_table_.SetVersionNumber(cur_version);
}
- if (cur_version == 17)
- needs_version_18_migration_ = true;
-
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites) &&
- (cur_version == 18 || cur_version == 19)) {
- // Set DB version back to pre-top sites.
- cur_version = 17;
+ if (cur_version == 17) {
+ // Version 17 was for thumbnails to top sites migration. We ended up
+ // disabling it though, so 17->18 does nothing.
+ ++cur_version;
meta_table_.SetVersionNumber(cur_version);
}
- if (needs_version_18_migration_ || cur_version == 18) {
+ if (cur_version == 18) {
// This is the version prior to adding url_source column. We need to
// migrate the database.
cur_version = 19;
@@ -299,9 +291,8 @@ sql::InitStatus HistoryDatabase::EnsureCurrentVersion(
// When the version is too old, we just try to continue anyway, there should
// not be a released product that makes a database too old for us to handle.
- LOG_IF(WARNING, (cur_version < GetCurrentVersion() &&
- !needs_version_18_migration_)) <<
- "History database version " << cur_version << " is too old to handle.";
+ LOG_IF(WARNING, cur_version < GetCurrentVersion()) <<
+ "History database version " << cur_version << " is too old to handle.";
return sql::INIT_OK;
}
@@ -332,14 +323,7 @@ void HistoryDatabase::MigrateTimeEpoch() {
#endif
void HistoryDatabase::MigrationToTopSitesDone() {
- // Migration should only happen for version 17 and 19.
- int version = meta_table_.GetVersionNumber();
- DCHECK(17 == version || 19 == version);
- if (17 == version) {
- // We should be migrating from 17 to 18.
- meta_table_.SetVersionNumber(18);
- }
- needs_version_18_migration_ = false;
+ // TODO(sky): implement me.
}
} // namespace history
diff --git a/chrome/browser/history/history_database.h b/chrome/browser/history/history_database.h
index fe49dca..fe74e89 100644
--- a/chrome/browser/history/history_database.h
+++ b/chrome/browser/history/history_database.h
@@ -123,14 +123,6 @@ class HistoryDatabase : public DownloadDatabase,
return needs_version_17_migration_;
}
- // Returns true if the Thumbnails database should be renamed to
- // Favicons database. 17 -> 18 is migration to TopSites. ThumbnailsDatabase
- // doesn't store the thumbnails any more, only the favicons. Hence, its file
- // is renamed from Thumbnails to Favicons.
- bool needs_version_18_migration() const {
- return needs_version_18_migration_;
- }
-
// Update the database version after the TopSites migration.
void MigrationToTopSitesDone();
@@ -179,7 +171,6 @@ class HistoryDatabase : public DownloadDatabase,
// See the getters above.
bool needs_version_17_migration_;
- bool needs_version_18_migration_;
DISALLOW_COPY_AND_ASSIGN(HistoryDatabase);
};
diff --git a/chrome/browser/history/history_unittest.cc b/chrome/browser/history/history_unittest.cc
index 37e95dff..7bb5565 100644
--- a/chrome/browser/history/history_unittest.cc
+++ b/chrome/browser/history/history_unittest.cc
@@ -43,6 +43,7 @@
#include "chrome/browser/history/in_memory_database.h"
#include "chrome/browser/history/in_memory_history_backend.h"
#include "chrome/browser/history/page_usage_data.h"
+#include "chrome/browser/history/top_sites.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_service.h"
@@ -697,7 +698,7 @@ TEST_F(HistoryTest, Segments) {
// This just tests history system -> thumbnail database integration, the actual
// thumbnail tests are in its own file.
TEST_F(HistoryTest, Thumbnails) {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites))
+ if (history::TopSites::IsEnabled())
return; // TopSitesTest replaces this.
scoped_refptr<HistoryService> history(new HistoryService);
diff --git a/chrome/browser/history/thumbnail_database.cc b/chrome/browser/history/thumbnail_database.cc
index ecc7a3c..36b8a20 100644
--- a/chrome/browser/history/thumbnail_database.cc
+++ b/chrome/browser/history/thumbnail_database.cc
@@ -8,21 +8,23 @@
#include "app/sql/transaction.h"
#include "base/command_line.h"
#include "base/file_util.h"
-#if defined(OS_MACOSX)
-#include "base/mac_util.h"
-#endif
#include "base/ref_counted_memory.h"
#include "base/time.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/diagnostics/sqlite_diagnostics.h"
#include "chrome/browser/history/history_publisher.h"
+#include "chrome/browser/history/top_sites.h"
#include "chrome/browser/history/url_database.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/thumbnail_score.h"
#include "gfx/codec/jpeg_codec.h"
#include "third_party/skia/include/core/SkBitmap.h"
+#if defined(OS_MACOSX)
+#include "base/mac_util.h"
+#endif
+
namespace history {
// Version number of the database.
@@ -130,7 +132,7 @@ sql::InitStatus ThumbnailDatabase::OpenDatabase(sql::Connection* db,
bool ThumbnailDatabase::InitThumbnailTable() {
if (!db_.DoesTableExist("thumbnails")) {
- if (!CommandLine::ForCurrentProcess()-> HasSwitch(switches::kNoTopSites)) {
+ if (history::TopSites::IsEnabled()) {
use_top_sites_ = true;
return true;
}
diff --git a/chrome/browser/history/thumbnail_database_unittest.cc b/chrome/browser/history/thumbnail_database_unittest.cc
index 24c990b..23eccef 100644
--- a/chrome/browser/history/thumbnail_database_unittest.cc
+++ b/chrome/browser/history/thumbnail_database_unittest.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/history/thumbnail_database.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/browser/history/top_sites.h"
#include "chrome/common/thumbnail_score.h"
#include "chrome/tools/profiles/thumbnail-inl.h"
#include "gfx/codec/jpeg_codec.h"
@@ -72,7 +73,7 @@ class ThumbnailDatabaseTest : public testing::Test {
};
TEST_F(ThumbnailDatabaseTest, AddDelete) {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites))
+ if (history::TopSites::IsEnabled())
return; // TopSitesTest replaces this.
ThumbnailDatabase db;
@@ -117,7 +118,7 @@ TEST_F(ThumbnailDatabaseTest, AddDelete) {
}
TEST_F(ThumbnailDatabaseTest, UseLessBoringThumbnails) {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites))
+ if (history::TopSites::IsEnabled())
return; // TopSitesTest replaces this.
ThumbnailDatabase db;
@@ -154,7 +155,7 @@ TEST_F(ThumbnailDatabaseTest, UseLessBoringThumbnails) {
}
TEST_F(ThumbnailDatabaseTest, UseAtTopThumbnails) {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites))
+ if (history::TopSites::IsEnabled())
return; // TopSitesTest replaces this.
ThumbnailDatabase db;
@@ -228,7 +229,7 @@ TEST_F(ThumbnailDatabaseTest, UseAtTopThumbnails) {
}
TEST_F(ThumbnailDatabaseTest, ThumbnailTimeDegradation) {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites))
+ if (history::TopSites::IsEnabled())
return; // TopSitesTest replaces this.
ThumbnailDatabase db;
@@ -275,7 +276,7 @@ TEST_F(ThumbnailDatabaseTest, NeverAcceptTotallyBoringThumbnail) {
// should replace a thumbnail with another because of reasons other
// than straight up boringness score, still reject because the
// thumbnail is totally boring.
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites))
+ if (history::TopSites::IsEnabled())
return; // TopSitesTest replaces this.
ThumbnailDatabase db;
@@ -349,7 +350,7 @@ TEST_F(ThumbnailDatabaseTest, NeverAcceptTotallyBoringThumbnail) {
}
TEST_F(ThumbnailDatabaseTest, NeedsMigrationToTopSites) {
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites))
+ if (history::TopSites::IsEnabled())
return; // TopSitesTest replaces this.
ThumbnailDatabase db;
diff --git a/chrome/browser/history/top_sites.cc b/chrome/browser/history/top_sites.cc
index 69bc468..c9f4a94 100644
--- a/chrome/browser/history/top_sites.cc
+++ b/chrome/browser/history/top_sites.cc
@@ -68,6 +68,11 @@ TopSites::TopSites(Profile* profile) : profile_(profile),
GetMutableDictionary(prefs::kNTPMostVisitedPinnedURLs);
}
+// static
+bool TopSites::IsEnabled() {
+ return CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableTopSites);
+}
+
TopSites::~TopSites() {
timer_.Stop();
}
diff --git a/chrome/browser/history/top_sites.h b/chrome/browser/history/top_sites.h
index 1b57a61..c491066 100644
--- a/chrome/browser/history/top_sites.h
+++ b/chrome/browser/history/top_sites.h
@@ -56,6 +56,9 @@ class TopSites :
public:
explicit TopSites(Profile* profile);
+ // Returns whether top sites is enabled.
+ static bool IsEnabled();
+
class MockHistoryService {
// A mockup of a HistoryService used for testing TopSites.
public:
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 1d702bd..d40b99d 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -2560,7 +2560,7 @@ void TabContents::UpdateThumbnail(const GURL& url,
const SkBitmap& bitmap,
const ThumbnailScore& score) {
// Tell History about this thumbnail
- if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoTopSites)) {
+ if (history::TopSites::IsEnabled()) {
if (!profile()->IsOffTheRecord())
profile()->GetTopSites()->SetPageThumbnail(url, bitmap, score);
} else {
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 5a609ac..fbed4f8 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -522,6 +522,9 @@ const char kEnableSyncTypedUrls[] = "enable-sync-typed-urls";
// Enable tabbed options, ie: dom-ui version of options window.
const char kEnableTabbedOptions[] = "enable-tabbed-options";
+// Enables TopSites.
+const char kEnableTopSites[] = "enable-top-sites";
+
// Whether or not the touch events API is exposed.
const char kEnableTouch[] = "enable-touch";
@@ -775,9 +778,6 @@ const char kNoSandbox[] = "no-sandbox";
// Chrome for the purpose of hosting background apps).
const char kNoStartupWindow[] = "no-startup-window";
-// Don't use TopSites; use old ThumbnailDatabase code instead.
-const char kNoTopSites[] = "no-top-sites";
-
// Specifies the maximum number of threads to use for running the Proxy
// Autoconfig (PAC) script.
const char kNumPacThreads[] = "num-pac-threads";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 984e2d8..5be3d28 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -161,6 +161,7 @@ extern const char kEnableSyncSessions[];
extern const char kEnableSyncThemes[];
extern const char kEnableSyncTypedUrls[];
extern const char kEnableTabbedOptions[];
+extern const char kEnableTopSites[];
extern const char kEnableTouch[];
extern const char kEnableVerticalTabs[];
extern const char kEnableVideoFullscreen[];
@@ -225,7 +226,6 @@ extern const char kNoProxyServer[];
extern const char kNoReferrers[];
extern const char kNoSandbox[];
extern const char kNoStartupWindow[];
-extern const char kNoTopSites[];
extern const char kNumPacThreads[];
extern const char kOpenInNewWindow[];
extern const char kOrganicInstall[];