| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/search/local_ntp_source.h" | 5 #include "chrome/browser/search/local_ntp_source.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/search/search.h" |
| 12 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
| 13 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 14 #include "grit/browser_resources.h" | 15 #include "grit/browser_resources.h" |
| 15 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 16 #include "grit/ui_resources.h" | 17 #include "grit/ui_resources.h" |
| 17 #include "net/url_request/url_request.h" | 18 #include "net/url_request/url_request.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 20 #include "ui/webui/jstemplate_builder.h" | 21 #include "ui/webui/jstemplate_builder.h" |
| 21 | 22 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 // Adds a localized string keyed by resource id to the dictionary. | 64 // Adds a localized string keyed by resource id to the dictionary. |
| 64 void AddString(base::DictionaryValue* dictionary, | 65 void AddString(base::DictionaryValue* dictionary, |
| 65 const std::string& key, | 66 const std::string& key, |
| 66 int resource_id) { | 67 int resource_id) { |
| 67 dictionary->SetString(key, l10n_util::GetStringUTF16(resource_id)); | 68 dictionary->SetString(key, l10n_util::GetStringUTF16(resource_id)); |
| 68 } | 69 } |
| 69 | 70 |
| 70 // Returns a JS dictionary of translated strings for the local NTP. | 71 // Returns a JS dictionary of translated strings for the local NTP. |
| 71 std::string GetTranslatedStrings() { | 72 std::string GetTranslatedStrings() { |
| 72 base::DictionaryValue translated_strings; | 73 base::DictionaryValue translated_strings; |
| 74 if (chrome::ShouldShowRecentTabsOnNTP()) |
| 75 AddString(&translated_strings, "recentTabs", IDS_RECENT_TABS_MENU); |
| 73 AddString(&translated_strings, "thumbnailRemovedNotification", | 76 AddString(&translated_strings, "thumbnailRemovedNotification", |
| 74 IDS_NEW_TAB_THUMBNAIL_REMOVED_NOTIFICATION); | 77 IDS_NEW_TAB_THUMBNAIL_REMOVED_NOTIFICATION); |
| 75 AddString(&translated_strings, "removeThumbnailTooltip", | 78 AddString(&translated_strings, "removeThumbnailTooltip", |
| 76 IDS_NEW_TAB_REMOVE_THUMBNAIL_TOOLTIP); | 79 IDS_NEW_TAB_REMOVE_THUMBNAIL_TOOLTIP); |
| 77 AddString(&translated_strings, "undoThumbnailRemove", | 80 AddString(&translated_strings, "undoThumbnailRemove", |
| 78 IDS_NEW_TAB_UNDO_THUMBNAIL_REMOVE); | 81 IDS_NEW_TAB_UNDO_THUMBNAIL_REMOVE); |
| 79 AddString(&translated_strings, "restoreThumbnailsShort", | 82 AddString(&translated_strings, "restoreThumbnailsShort", |
| 80 IDS_NEW_TAB_RESTORE_THUMBNAILS_SHORT_LINK); | 83 IDS_NEW_TAB_RESTORE_THUMBNAILS_SHORT_LINK); |
| 81 AddString(&translated_strings, "attributionIntro", | 84 AddString(&translated_strings, "attributionIntro", |
| 82 IDS_NEW_TAB_ATTRIBUTION_INTRO); | 85 IDS_NEW_TAB_ATTRIBUTION_INTRO); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 148 } |
| 146 return false; | 149 return false; |
| 147 } | 150 } |
| 148 | 151 |
| 149 std::string LocalNtpSource::GetContentSecurityPolicyFrameSrc() const { | 152 std::string LocalNtpSource::GetContentSecurityPolicyFrameSrc() const { |
| 150 // Allow embedding of suggestion and most visited iframes. | 153 // Allow embedding of suggestion and most visited iframes. |
| 151 return base::StringPrintf("frame-src %s %s;", | 154 return base::StringPrintf("frame-src %s %s;", |
| 152 chrome::kChromeSearchSuggestionUrl, | 155 chrome::kChromeSearchSuggestionUrl, |
| 153 chrome::kChromeSearchMostVisitedUrl); | 156 chrome::kChromeSearchMostVisitedUrl); |
| 154 } | 157 } |
| OLD | NEW |