| 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/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 // Adds a localized string keyed by resource id to the dictionary. | 65 // Adds a localized string keyed by resource id to the dictionary. |
| 65 void AddString(base::DictionaryValue* dictionary, | 66 void AddString(base::DictionaryValue* dictionary, |
| 66 const std::string& key, | 67 const std::string& key, |
| 67 int resource_id) { | 68 int resource_id) { |
| 68 dictionary->SetString(key, l10n_util::GetStringUTF16(resource_id)); | 69 dictionary->SetString(key, l10n_util::GetStringUTF16(resource_id)); |
| 69 } | 70 } |
| 70 | 71 |
| 71 // Returns a JS dictionary of translated strings for the local NTP. | 72 // Returns a JS dictionary of translated strings for the local NTP. |
| 72 std::string GetTranslatedStrings() { | 73 std::string GetTranslatedStrings() { |
| 73 base::DictionaryValue translated_strings; | 74 base::DictionaryValue translated_strings; |
| 75 if (chrome::ShouldShowRecentTabsOnNTP()) |
| 76 AddString(&translated_strings, "recentTabs", IDS_RECENT_TABS_MENU); |
| 74 AddString(&translated_strings, "thumbnailRemovedNotification", | 77 AddString(&translated_strings, "thumbnailRemovedNotification", |
| 75 IDS_NEW_TAB_THUMBNAIL_REMOVED_NOTIFICATION); | 78 IDS_NEW_TAB_THUMBNAIL_REMOVED_NOTIFICATION); |
| 76 AddString(&translated_strings, "removeThumbnailTooltip", | 79 AddString(&translated_strings, "removeThumbnailTooltip", |
| 77 IDS_NEW_TAB_REMOVE_THUMBNAIL_TOOLTIP); | 80 IDS_NEW_TAB_REMOVE_THUMBNAIL_TOOLTIP); |
| 78 AddString(&translated_strings, "undoThumbnailRemove", | 81 AddString(&translated_strings, "undoThumbnailRemove", |
| 79 IDS_NEW_TAB_UNDO_THUMBNAIL_REMOVE); | 82 IDS_NEW_TAB_UNDO_THUMBNAIL_REMOVE); |
| 80 AddString(&translated_strings, "restoreThumbnailsShort", | 83 AddString(&translated_strings, "restoreThumbnailsShort", |
| 81 IDS_NEW_TAB_RESTORE_THUMBNAILS_SHORT_LINK); | 84 IDS_NEW_TAB_RESTORE_THUMBNAILS_SHORT_LINK); |
| 82 AddString(&translated_strings, "attributionIntro", | 85 AddString(&translated_strings, "attributionIntro", |
| 83 IDS_NEW_TAB_ATTRIBUTION_INTRO); | 86 IDS_NEW_TAB_ATTRIBUTION_INTRO); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } | 149 } |
| 147 return false; | 150 return false; |
| 148 } | 151 } |
| 149 | 152 |
| 150 std::string LocalNtpSource::GetContentSecurityPolicyFrameSrc() const { | 153 std::string LocalNtpSource::GetContentSecurityPolicyFrameSrc() const { |
| 151 // Allow embedding of suggestion and most visited iframes. | 154 // Allow embedding of suggestion and most visited iframes. |
| 152 return base::StringPrintf("frame-src %s %s;", | 155 return base::StringPrintf("frame-src %s %s;", |
| 153 chrome::kChromeSearchSuggestionUrl, | 156 chrome::kChromeSearchSuggestionUrl, |
| 154 chrome::kChromeSearchMostVisitedUrl); | 157 chrome::kChromeSearchMostVisitedUrl); |
| 155 } | 158 } |
| OLD | NEW |