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

Unified Diff: chrome/browser/dom_ui/new_tab_ui.cc

Issue 151054: Enable the NNTP by default... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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
« no previous file with comments | « chrome/browser/dom_ui/new_tab_ui.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/dom_ui/new_tab_ui.cc
===================================================================
--- chrome/browser/dom_ui/new_tab_ui.cc (revision 19580)
+++ chrome/browser/dom_ui/new_tab_ui.cc (working copy)
@@ -203,10 +203,10 @@
static bool first_view() { return first_view_; }
private:
- // In case a file path to the new new tab page was provided this tries to load
+ // In case a file path to the new tab page was provided this tries to load
// the file and returns the file content if successful. This returns an empty
// string in case of failure.
- static std::string GetNewNewTabFromCommandLine();
+ static std::string GetCustomNewTabPageFromCommandLine();
// Whether this is the is the first viewing of the new tab page and
// we think it is the user's startup page.
@@ -354,20 +354,17 @@
// the resource bundle.
StringPiece new_tab_html;
std::string new_tab_html_str;
- if (NewTabUI::EnableNewNewTabPage()) {
- new_tab_html_str = GetNewNewTabFromCommandLine();
+ new_tab_html_str = GetCustomNewTabPageFromCommandLine();
- if (!new_tab_html_str.empty()) {
- new_tab_html = StringPiece(new_tab_html_str);
- } else {
- // Use the new new tab page from the resource bundle.
- new_tab_html = ResourceBundle::GetSharedInstance().GetRawDataResource(
- IDR_NEW_NEW_TAB_HTML);
- }
- } else {
- // Use the default new tab page resource.
+ if (!new_tab_html_str.empty()) {
+ new_tab_html = StringPiece(new_tab_html_str);
+ }
+
+ if (new_tab_html.empty()) {
new_tab_html = ResourceBundle::GetSharedInstance().GetRawDataResource(
- IDR_NEW_TAB_HTML);
+ NewTabUI::UseOldNewTabPage() ?
+ IDR_NEW_TAB_HTML :
+ IDR_NEW_NEW_TAB_HTML);
}
const std::string full_html = jstemplate_builder::GetTemplateHtml(
@@ -381,10 +378,10 @@
}
// static
-std::string NewTabHTMLSource::GetNewNewTabFromCommandLine() {
+std::string NewTabHTMLSource::GetCustomNewTabPageFromCommandLine() {
const CommandLine* command_line = CommandLine::ForCurrentProcess();
const std::wstring file_path_wstring = command_line->GetSwitchValue(
- switches::kNewNewTabPage);
+ switches::kNewTabPage);
#if defined(OS_WIN)
const FilePath::StringType file_path = file_path_wstring;
@@ -994,7 +991,7 @@
virtual ~RecentlyBookmarkedHandler();
// DOMMessageHandler implementation.
- virtual void RegisterMessages();
+ virtual void RegisterMessages();
// Callback which navigates to the bookmarks page.
void HandleShowBookmarkPage(const Value*);
@@ -1337,10 +1334,10 @@
public:
MetricsHandler() {}
virtual ~MetricsHandler() {}
-
+
// DOMMessageHandler implementation.
virtual void RegisterMessages();
-
+
// Callback which records a user action.
void HandleMetrics(const Value* content);
@@ -1409,26 +1406,31 @@
&ChromeURLDataManager::AddDataSource,
html_source));
} else {
- if (EnableNewNewTabPage()) {
+ DownloadManager* dlm = GetProfile()->GetDownloadManager();
+ // This might be null in the case of running inside a unit test.
+ // TODO(arv): Fix unit tests to provide a working mock download manager.
+ if (dlm) {
DownloadManager* dlm = GetProfile()->GetDownloadManager();
DownloadsDOMHandler* downloads_handler =
new DownloadsDOMHandler(dlm);
downloads_handler->Attach(this);
AddMessageHandler(downloads_handler);
downloads_handler->Init();
-
- AddMessageHandler((new ShownSectionsHandler())->Attach(this));
}
- AddMessageHandler((new TemplateURLHandler())->Attach(this));
+ AddMessageHandler((new ShownSectionsHandler())->Attach(this));
AddMessageHandler((new MostVisitedHandler())->Attach(this));
- AddMessageHandler((new RecentlyBookmarkedHandler())->Attach(this));
AddMessageHandler((new RecentlyClosedTabsHandler())->Attach(this));
- AddMessageHandler((new HistoryHandler())->Attach(this));
AddMessageHandler((new MetricsHandler())->Attach(this));
if (EnableWebResources())
AddMessageHandler((new TipsHandler())->Attach(this));
+ if (UseOldNewTabPage()) {
+ AddMessageHandler((new TemplateURLHandler())->Attach(this));
+ AddMessageHandler((new RecentlyBookmarkedHandler())->Attach(this));
+ AddMessageHandler((new HistoryHandler())->Attach(this));
+ }
+
#ifdef CHROME_PERSONALIZATION
if (!Personalization::IsP13NDisabled(GetProfile())) {
AddMessageHandler(Personalization::CreateNewTabPageHandler(this));
@@ -1474,24 +1476,21 @@
}
}
-
// static
void NewTabUI::RegisterUserPrefs(PrefService* prefs) {
MostVisitedHandler::RegisterUserPrefs(prefs);
+ ShownSectionsHandler::RegisterUserPrefs(prefs);
if (NewTabUI::EnableWebResources())
TipsHandler::RegisterUserPrefs(prefs);
- if (NewTabUI::EnableNewNewTabPage())
- ShownSectionsHandler::RegisterUserPrefs(prefs);
}
// static
-bool NewTabUI::EnableNewNewTabPage() {
+bool NewTabUI::UseOldNewTabPage() {
const CommandLine* command_line = CommandLine::ForCurrentProcess();
- return command_line->HasSwitch(switches::kNewNewTabPage);
+ return command_line->HasSwitch(switches::kOldNewTabPage);
}
bool NewTabUI::EnableWebResources() {
const CommandLine* command_line = CommandLine::ForCurrentProcess();
return command_line->HasSwitch(switches::kWebResources);
}
-
« no previous file with comments | « chrome/browser/dom_ui/new_tab_ui.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698