summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-28 22:13:35 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-28 22:13:35 +0000
commitaf49cd83538f45f0a8813155444dd53b9dbfeb96 (patch)
treedb1830ecb8b1f7fb894838b8298f924d853c70e6 /chrome/browser/dom_ui
parent4405b1ea8368b261564414b317abf796b0cf9c3d (diff)
downloadchromium_src-af49cd83538f45f0a8813155444dd53b9dbfeb96.zip
chromium_src-af49cd83538f45f0a8813155444dd53b9dbfeb96.tar.gz
chromium_src-af49cd83538f45f0a8813155444dd53b9dbfeb96.tar.bz2
Show Make this my homepage link on new tab page.
BUG=20254 Review URL: http://codereview.chromium.org/179012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@24813 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.cc47
1 files changed, 47 insertions, 0 deletions
diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc
index e3d2182..1742b0a 100644
--- a/chrome/browser/dom_ui/new_tab_ui.cc
+++ b/chrome/browser/dom_ui/new_tab_ui.cc
@@ -340,6 +340,8 @@ void NewTabHTMLSource::StartDataRequest(const std::string& path,
l10n_util::GetString(IDS_NEW_TAB_FIRST_RUN_NOTIFICATION));
localized_strings.SetString(L"closefirstrunnotification",
l10n_util::GetString(IDS_NEW_TAB_CLOSE_FIRST_RUN_NOTIFICATION));
+ localized_strings.SetString(L"makethishomepage",
+ l10n_util::GetString(IDS_NEW_TAB_MAKE_THIS_HOMEPAGE));
// Don't initiate the sync related message passing with the page if the sync
// code is not present.
@@ -348,6 +350,9 @@ void NewTabHTMLSource::StartDataRequest(const std::string& path,
else
localized_strings.SetString(L"syncispresent", "false");
+ if (!profile_->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage))
+ localized_strings.SetString(L"showsetashomepage", "true");
+
SetFontAndTextDirection(&localized_strings);
// Let the tab know whether it's the first tab being viewed.
@@ -1481,6 +1486,46 @@ void MetricsHandler::HandleMetrics(const Value* content) {
}
}
+///////////////////////////////////////////////////////////////////////////////
+// NewTabPageSetHomepageHandler
+
+// Sets the new tab page as homepage when user clicks on "make this my homepage"
+// link.
+class NewTabPageSetHomepageHandler : public DOMMessageHandler {
+ public:
+ NewTabPageSetHomepageHandler() {}
+ virtual ~NewTabPageSetHomepageHandler() {}
+
+ // DOMMessageHandler implementation.
+ virtual void RegisterMessages();
+
+ // Callback for "SetHomepageLinkClicked".
+ void HandleSetHomepageLinkClicked(const Value* value);
+
+ private:
+
+ DISALLOW_COPY_AND_ASSIGN(NewTabPageSetHomepageHandler);
+};
+
+void NewTabPageSetHomepageHandler::RegisterMessages() {
+ dom_ui_->RegisterMessageCallback("SetHomepageLinkClicked", NewCallback(
+ this, &NewTabPageSetHomepageHandler::HandleSetHomepageLinkClicked));
+}
+
+void NewTabPageSetHomepageHandler::HandleSetHomepageLinkClicked(
+ const Value* value) {
+ dom_ui_->GetProfile()->GetPrefs()->SetBoolean(prefs::kHomePageIsNewTabPage,
+ true);
+ // TODO(rahulk): Show some kind of notification that new tab page has been
+ // set as homepage. This tip only shows up for a brief moment and disappears
+ // when new tab page gets refreshed.
+ ListValue list_value;
+ DictionaryValue* tip_dict = new DictionaryValue();
+ tip_dict->SetString(L"tip_html_text", L"Welcome to your home page!");
+ list_value.Append(tip_dict);
+ dom_ui_->CallJavascriptFunction(L"tips", list_value);
+}
+
} // namespace
///////////////////////////////////////////////////////////////////////////////
@@ -1543,6 +1588,8 @@ NewTabUI::NewTabUI(TabContents* contents)
}
#endif
+ AddMessageHandler((new NewTabPageSetHomepageHandler())->Attach(this));
+
// In testing mode there may not be an I/O thread.
if (g_browser_process->io_thread()) {
g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,