diff options
Diffstat (limited to 'chrome/browser/dom_ui/tips_handler.cc')
-rw-r--r-- | chrome/browser/dom_ui/tips_handler.cc | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/chrome/browser/dom_ui/tips_handler.cc b/chrome/browser/dom_ui/tips_handler.cc index ee429f7..7fd5ac1 100644 --- a/chrome/browser/dom_ui/tips_handler.cc +++ b/chrome/browser/dom_ui/tips_handler.cc @@ -4,6 +4,7 @@ #include <string> +#include "app/l10n_util.h" #include "base/string_util.h" #include "base/values.h" #include "chrome/browser/browser_process.h" @@ -14,6 +15,7 @@ #include "chrome/common/web_resource/web_resource_unpacker.h" #include "chrome/common/url_constants.h" #include "googleurl/src/gurl.h" +#include "grit/generated_resources.h" DOMMessageHandler* TipsHandler::Attach(DOMUI* dom_ui) { dom_ui_ = dom_ui; @@ -28,7 +30,7 @@ void TipsHandler::RegisterMessages() { } void TipsHandler::HandleGetTips(const Value* content) { - // List containing the tips to be displayed. + // List containing the tips to be displayed. ListValue list_value; // Holds the web resource data found in the preferences cache. @@ -58,18 +60,34 @@ void TipsHandler::HandleGetTips(const Value* content) { tips_cache_->GetList( WebResourceService::kTipCachePrefName, &wr_list) && wr_list && wr_list->GetSize() > 0) { - if (wr_list->GetSize() <= static_cast<size_t>(current_tip_index)) + if (wr_list->GetSize() <= static_cast<size_t>(current_tip_index)) { + // Check to see whether the home page is set to NTP; if not, add tip + // to set home page before resetting tip index to 0. current_tip_index = 0; + if (!dom_ui_->GetProfile()->GetPrefs()->GetBoolean( + prefs::kHomePageIsNewTabPage)) { + SendTip(WideToASCII(l10n_util::GetString( + IDS_NEW_TAB_MAKE_THIS_HOMEPAGE)), L"set_homepage_tip", + current_tip_index); + return; + } + } if (wr_list->GetString(current_tip_index, ¤t_tip)) { - DictionaryValue* tip_dict = new DictionaryValue(); - tip_dict->SetString(L"tip_html_text", current_tip); - list_value.Append(tip_dict); - tips_cache_->SetInteger(WebResourceService::kCurrentTipPrefName, - current_tip_index + 1); + SendTip(current_tip, L"tip_html_text", current_tip_index + 1); } } } +} +void TipsHandler::SendTip(std::string tip, std::wstring tip_type, + int tip_index) { + // List containing the tips to be displayed. + ListValue list_value; + DictionaryValue* tip_dict = new DictionaryValue(); + tip_dict->SetString(tip_type, tip); + list_value.Append(tip_dict); + tips_cache_->SetInteger(WebResourceService::kCurrentTipPrefName, + tip_index); // Send list of web resource items back out to the DOM. dom_ui_->CallJavascriptFunction(L"tips", list_value); } |