summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui
diff options
context:
space:
mode:
authorglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-30 20:43:36 +0000
committerglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-30 20:43:36 +0000
commit9c73c15a06b48fad46fc7a2524bf7b227dabbba6 (patch)
tree98769ef0db0211c74e9a9bf3c894870e6a587432 /chrome/browser/dom_ui
parent61ab26f4fb056fae95db04b64f10b3eb9bc1277c (diff)
downloadchromium_src-9c73c15a06b48fad46fc7a2524bf7b227dabbba6.zip
chromium_src-9c73c15a06b48fad46fc7a2524bf7b227dabbba6.tar.gz
chromium_src-9c73c15a06b48fad46fc7a2524bf7b227dabbba6.tar.bz2
Reland arv's NNTP enablery after it was reverted in 19603
TBR=arv Review URL: http://codereview.chromium.org/151108 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19651 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.cc61
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.h4
2 files changed, 32 insertions, 33 deletions
diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc
index 71779a8..5c1f704 100644
--- a/chrome/browser/dom_ui/new_tab_ui.cc
+++ b/chrome/browser/dom_ui/new_tab_ui.cc
@@ -203,10 +203,10 @@ class NewTabHTMLSource : public ChromeURLDataManager::DataSource {
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 @@ void NewTabHTMLSource::StartDataRequest(const std::string& path,
// 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 @@ void NewTabHTMLSource::StartDataRequest(const std::string& path,
}
// 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 @@ class RecentlyBookmarkedHandler : public DOMMessageHandler,
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 @@ class MetricsHandler : public DOMMessageHandler {
public:
MetricsHandler() {}
virtual ~MetricsHandler() {}
-
+
// DOMMessageHandler implementation.
virtual void RegisterMessages();
-
+
// Callback which records a user action.
void HandleMetrics(const Value* content);
@@ -1409,26 +1406,31 @@ NewTabUI::NewTabUI(TabContents* contents)
&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 @@ void NewTabUI::Observe(NotificationType type,
}
}
-
// 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);
}
-
diff --git a/chrome/browser/dom_ui/new_tab_ui.h b/chrome/browser/dom_ui/new_tab_ui.h
index 851dbfa..b387115 100644
--- a/chrome/browser/dom_ui/new_tab_ui.h
+++ b/chrome/browser/dom_ui/new_tab_ui.h
@@ -25,8 +25,8 @@ class NewTabUI : public DOMUI,
static void RegisterUserPrefs(PrefService* prefs);
- // Whether we should use the prototype new tab page.
- static bool EnableNewNewTabPage();
+ // Whether we should use the old new tab page.
+ static bool UseOldNewTabPage();
// Whether we should enable the web resources backend service
static bool EnableWebResources();