summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-12 22:17:26 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-12 22:17:26 +0000
commitc0d08e0a834e0b9e8c3a367452708f8f1624f721 (patch)
treedb1ba71d6f77c6cdf8778ab3c85e4e01ace8a073 /chrome/browser
parenta5545a2c04a692492362da278c2c0b6215d22f48 (diff)
downloadchromium_src-c0d08e0a834e0b9e8c3a367452708f8f1624f721.zip
chromium_src-c0d08e0a834e0b9e8c3a367452708f8f1624f721.tar.gz
chromium_src-c0d08e0a834e0b9e8c3a367452708f8f1624f721.tar.bz2
Resource cleanup and de-duping
- remove duplicate code between most_visited_handler.cc and top_sites.cc - remove dead code in most_visited_handler.cc - remove duplicate favicon resources - update favicon resources by adding 32x32s resource for NTP stock most visited pages - uniformly refer to PRODUCT_NAME rather than sometimes using "google chrome" in chromium builds on the NTP - consolidate some resources (IDR_CHROME_STORE_PAGE_FAVICON and IDR_WESBTORE_ICON_16 for example) - remove unused thumbnail for webstore (which is slightly distinct from the themes gallery because there's no &category=theme in the URL) as a precursor, I had to add an icon to chrome/app/theme/google_chrome (internal repository) as a cleanup after, I will have to remove an icon from the same BUG=none TEST=trybots; manual Review URL: http://codereview.chromium.org/7342001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92249 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/automation/automation_provider_observers.cc5
-rw-r--r--chrome/browser/first_run/try_chrome_dialog_view.cc2
-rw-r--r--chrome/browser/history/top_sites.cc15
-rw-r--r--chrome/browser/history/top_sites.h6
-rw-r--r--chrome/browser/notifications/desktop_notification_service.cc2
-rw-r--r--chrome/browser/resources/new_tab.js2
-rw-r--r--chrome/browser/resources/ntp/most_visited.js2
-rw-r--r--chrome/browser/resources/ntp4/most_visited_page.js1
-rw-r--r--chrome/browser/resources/ntp4/new_tab.js2
-rw-r--r--chrome/browser/ui/browser_init.cc2
-rw-r--r--chrome/browser/ui/cocoa/keystone_infobar.mm2
-rw-r--r--chrome/browser/ui/gtk/gtk_util.cc2
-rw-r--r--chrome/browser/ui/webui/ntp/most_visited_handler.cc47
-rw-r--r--chrome/browser/ui/webui/ntp/most_visited_handler.h9
14 files changed, 25 insertions, 74 deletions
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc
index 45a50f1..38d001c 100644
--- a/chrome/browser/automation/automation_provider_observers.cc
+++ b/chrome/browser/automation/automation_provider_observers.cc
@@ -32,6 +32,7 @@
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_tabs_module.h"
#include "chrome/browser/extensions/extension_updater.h"
+#include "chrome/browser/history/history_types.h"
#include "chrome/browser/history/top_sites.h"
#include "chrome/browser/metrics/metric_event_duration_details.h"
#include "chrome/browser/notifications/balloon.h"
@@ -2044,10 +2045,10 @@ NTPInfoObserver::NTPInfoObserver(
// Add default site URLs.
ListValue* default_sites_list = new ListValue;
- std::vector<GURL> urls = MostVisitedHandler::GetPrePopulatedUrls();
+ history::MostVisitedURLList urls = history::TopSites::GetPrepopulatePages();
for (size_t i = 0; i < urls.size(); ++i) {
default_sites_list->Append(Value::CreateStringValue(
- urls[i].possibly_invalid_spec()));
+ urls[i].url.possibly_invalid_spec()));
}
ntp_info_->Set("default_sites", default_sites_list);
diff --git a/chrome/browser/first_run/try_chrome_dialog_view.cc b/chrome/browser/first_run/try_chrome_dialog_view.cc
index 501cff7..db9757a 100644
--- a/chrome/browser/first_run/try_chrome_dialog_view.cc
+++ b/chrome/browser/first_run/try_chrome_dialog_view.cc
@@ -63,7 +63,7 @@ TryChromeDialogView::Result TryChromeDialogView::ShowModal(
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
views::ImageView* icon = new views::ImageView();
- icon->SetImage(*rb.GetNativeImageNamed(IDR_PRODUCT_ICON_32));
+ icon->SetImage(*rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_32));
gfx::Size icon_size = icon->GetPreferredSize();
// An approximate window size. After Layout() we'll get better bounds.
diff --git a/chrome/browser/history/top_sites.cc b/chrome/browser/history/top_sites.cc
index 0ab324b..d0e3619 100644
--- a/chrome/browser/history/top_sites.cc
+++ b/chrome/browser/history/top_sites.cc
@@ -59,9 +59,13 @@ static const int kPrepopulatePageIDs[] =
{ IDS_CHROME_WELCOME_URL, IDS_THEMES_GALLERY_URL };
// Favicons of the sites we force into top sites.
-static const char kPrepopulateFaviconURLs[][54] =
- { "chrome://theme/IDR_NEWTAB_CHROME_WELCOME_PAGE_FAVICON",
- "chrome://theme/IDR_NEWTAB_THEMES_GALLERY_FAVICON" };
+static const char kPrepopulateFaviconURLs[][100] =
+ { "chrome://theme/IDR_PRODUCT_LOGO_16",
+ "chrome://theme/IDR_WEBSTORE_ICON_16" };
+// Same as above, but for NTP4. TODO(estade): remove the above.
+static const char kNewPrepopulateFaviconURLs[][100] =
+ { "chrome://theme/IDR_PRODUCT_LOGO_32",
+ "chrome://theme/IDR_WEBSTORE_ICON_32" };
static const int kPrepopulateTitleIDs[] =
{ IDS_NEW_TAB_CHROME_WELCOME_PAGE_TITLE,
@@ -652,7 +656,10 @@ MostVisitedURLList TopSites::GetPrepopulatePages() {
MostVisitedURL& url = urls[i];
url.url = GURL(l10n_util::GetStringUTF8(kPrepopulatePageIDs[i]));
url.redirects.push_back(url.url);
- url.favicon_url = GURL(kPrepopulateFaviconURLs[i]);
+ url.favicon_url =
+ CommandLine::ForCurrentProcess()->HasSwitch(switches::kNewTabPage4) ?
+ GURL(kNewPrepopulateFaviconURLs[i]) :
+ GURL(kPrepopulateFaviconURLs[i]);
url.title = l10n_util::GetStringUTF16(kPrepopulateTitleIDs[i]);
}
return urls;
diff --git a/chrome/browser/history/top_sites.h b/chrome/browser/history/top_sites.h
index fc99b28..fc508246 100644
--- a/chrome/browser/history/top_sites.h
+++ b/chrome/browser/history/top_sites.h
@@ -170,6 +170,9 @@ class TopSites
// TopSites isn't loaded yet.
virtual bool IsFull();
+ // Returns the set of prepopulate pages.
+ static MostVisitedURLList GetPrepopulatePages();
+
protected:
// For allowing inheritance.
virtual ~TopSites();
@@ -243,9 +246,6 @@ class TopSites
static int GetRedirectDistanceForURL(const MostVisitedURL& most_visited,
const GURL& url);
- // Returns the set of prepopulate pages.
- static MostVisitedURLList GetPrepopulatePages();
-
// Add prepopulated pages: 'welcome to Chrome' and themes gallery to |urls|.
// Returns true if any pages were added.
static bool AddPrepopulatedPages(MostVisitedURLList* urls);
diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc
index f897361..29dff9d 100644
--- a/chrome/browser/notifications/desktop_notification_service.cc
+++ b/chrome/browser/notifications/desktop_notification_service.cc
@@ -159,7 +159,7 @@ NotificationPermissionInfoBarDelegate::
gfx::Image* NotificationPermissionInfoBarDelegate::GetIcon() const {
return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
- IDR_PRODUCT_ICON_32);
+ IDR_PRODUCT_LOGO_32);
}
InfoBarDelegate::Type
diff --git a/chrome/browser/resources/new_tab.js b/chrome/browser/resources/new_tab.js
index 148dcb1..849e16d 100644
--- a/chrome/browser/resources/new_tab.js
+++ b/chrome/browser/resources/new_tab.js
@@ -1438,7 +1438,7 @@ var mostVisited = new MostVisited(
useSmallGrid(),
shownSections & Section.THUMB);
-function setMostVisitedPages(data, firstRun, hasBlacklistedUrls) {
+function setMostVisitedPages(data, hasBlacklistedUrls) {
logEvent('received most visited pages');
mostVisited.updateSettingsLink(hasBlacklistedUrls);
diff --git a/chrome/browser/resources/ntp/most_visited.js b/chrome/browser/resources/ntp/most_visited.js
index 0978f8c..f19d8cf 100644
--- a/chrome/browser/resources/ntp/most_visited.js
+++ b/chrome/browser/resources/ntp/most_visited.js
@@ -136,7 +136,7 @@ var MostVisited = (function() {
// Send 'getMostVisitedPages' with a callback since we want to find the
// new page and add that in the place of the removed page.
chromeSend('getMostVisited', [], 'setMostVisitedPages',
- function(data, firstRun, hasBlacklistedUrls) {
+ function(data, hasBlacklistedUrls) {
// Update settings link.
self.updateSettingsLink(hasBlacklistedUrls);
diff --git a/chrome/browser/resources/ntp4/most_visited_page.js b/chrome/browser/resources/ntp4/most_visited_page.js
index 4e89c12..d88770c 100644
--- a/chrome/browser/resources/ntp4/most_visited_page.js
+++ b/chrome/browser/resources/ntp4/most_visited_page.js
@@ -224,7 +224,6 @@ cr.define('ntp4', function() {
initialize: function() {
this.classList.add('most-visited-page');
-
this.data_ = null;
this.mostVisitedTiles_ = this.getElementsByClassName('most-visited real');
},
diff --git a/chrome/browser/resources/ntp4/new_tab.js b/chrome/browser/resources/ntp4/new_tab.js
index 7a6c920..f6dc354 100644
--- a/chrome/browser/resources/ntp4/new_tab.js
+++ b/chrome/browser/resources/ntp4/new_tab.js
@@ -547,7 +547,7 @@ cr.define('ntp4', function() {
$('recently-closed-menu-button').dataItems = dataItems;
}
- function setMostVisitedPages(data, firstRun, hasBlacklistedUrls) {
+ function setMostVisitedPages(data, hasBlacklistedUrls) {
mostVisitedPage.data = data;
}
diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc
index 675ff14..e91aac0 100644
--- a/chrome/browser/ui/browser_init.cc
+++ b/chrome/browser/ui/browser_init.cc
@@ -192,7 +192,7 @@ bool DefaultBrowserInfoBarDelegate::ShouldExpire(
gfx::Image* DefaultBrowserInfoBarDelegate::GetIcon() const {
return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
- IDR_PRODUCT_ICON_32);
+ IDR_PRODUCT_LOGO_32);
}
string16 DefaultBrowserInfoBarDelegate::GetMessageText() const {
diff --git a/chrome/browser/ui/cocoa/keystone_infobar.mm b/chrome/browser/ui/cocoa/keystone_infobar.mm
index c999411..fd1ba9f 100644
--- a/chrome/browser/ui/cocoa/keystone_infobar.mm
+++ b/chrome/browser/ui/cocoa/keystone_infobar.mm
@@ -89,7 +89,7 @@ bool KeystonePromotionInfoBarDelegate::ShouldExpire(
gfx::Image* KeystonePromotionInfoBarDelegate::GetIcon() const {
return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
- IDR_PRODUCT_ICON_32);
+ IDR_PRODUCT_LOGO_32);
}
string16 KeystonePromotionInfoBarDelegate::GetMessageText() const {
diff --git a/chrome/browser/ui/gtk/gtk_util.cc b/chrome/browser/ui/gtk/gtk_util.cc
index ff9604b..c366664 100644
--- a/chrome/browser/ui/gtk/gtk_util.cc
+++ b/chrome/browser/ui/gtk/gtk_util.cc
@@ -134,7 +134,7 @@ GList* GetIconList() {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
GList* icon_list = NULL;
icon_list = g_list_append(icon_list,
- rb.GetNativeImageNamed(IDR_PRODUCT_ICON_32));
+ rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_32));
icon_list = g_list_append(icon_list,
rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16));
return icon_list;
diff --git a/chrome/browser/ui/webui/ntp/most_visited_handler.cc b/chrome/browser/ui/webui/ntp/most_visited_handler.cc
index 6b539c8..98446f2 100644
--- a/chrome/browser/ui/webui/ntp/most_visited_handler.cc
+++ b/chrome/browser/ui/webui/ntp/most_visited_handler.cc
@@ -121,11 +121,9 @@ void MostVisitedHandler::SendPagesValue() {
history::TopSites* ts = profile->GetTopSites();
if (ts)
has_blacklisted_urls = ts->HasBlacklistedItems();
- FundamentalValue first_run(IsFirstRun());
FundamentalValue has_blacklisted_urls_value(has_blacklisted_urls);
web_ui_->CallJavascriptFunction("setMostVisitedPages",
*(pages_value_.get()),
- first_run,
has_blacklisted_urls_value);
pages_value_.reset();
}
@@ -314,41 +312,6 @@ void MostVisitedHandler::OnMostVisitedURLsAvailable(
}
}
-bool MostVisitedHandler::IsFirstRun() {
- // If we found no pages we treat this as the first run.
- bool first_run = NewTabUI::NewTabHTMLSource::first_run() &&
- pages_value_->GetSize() ==
- MostVisitedHandler::GetPrePopulatedPages().size();
- // but first_run should only be true once.
- NewTabUI::NewTabHTMLSource::set_first_run(false);
- return first_run;
-}
-
-// static
-const std::vector<MostVisitedHandler::MostVisitedPage>&
- MostVisitedHandler::GetPrePopulatedPages() {
- // TODO(arv): This needs to get the data from some configurable place.
- // http://crbug.com/17630
- static std::vector<MostVisitedPage> pages;
- if (pages.empty()) {
- MostVisitedPage welcome_page = {
- l10n_util::GetStringUTF16(IDS_NEW_TAB_CHROME_WELCOME_PAGE_TITLE),
- GURL(l10n_util::GetStringUTF8(IDS_CHROME_WELCOME_URL)),
- GURL("chrome://theme/IDR_NEWTAB_CHROME_WELCOME_PAGE_THUMBNAIL"),
- GURL("chrome://theme/IDR_NEWTAB_CHROME_WELCOME_PAGE_FAVICON")};
- pages.push_back(welcome_page);
-
- MostVisitedPage gallery_page = {
- l10n_util::GetStringUTF16(IDS_NEW_TAB_THEMES_GALLERY_PAGE_TITLE),
- GURL(l10n_util::GetStringUTF8(IDS_THEMES_GALLERY_URL)),
- GURL("chrome://theme/IDR_NEWTAB_THEMES_GALLERY_THUMBNAIL"),
- GURL("chrome://theme/IDR_NEWTAB_THEMES_GALLERY_FAVICON")};
- pages.push_back(gallery_page);
- }
-
- return pages;
-}
-
void MostVisitedHandler::Observe(int type,
const NotificationSource& source,
const NotificationDetails& details) {
@@ -376,13 +339,3 @@ void MostVisitedHandler::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterDictionaryPref(prefs::kNTPMostVisitedPinnedURLs,
PrefService::UNSYNCABLE_PREF);
}
-
-// static
-std::vector<GURL> MostVisitedHandler::GetPrePopulatedUrls() {
- const std::vector<MostVisitedPage> pages =
- MostVisitedHandler::GetPrePopulatedPages();
- std::vector<GURL> page_urls;
- for (size_t i = 0; i < pages.size(); ++i)
- page_urls.push_back(pages[i].url);
- return page_urls;
-}
diff --git a/chrome/browser/ui/webui/ntp/most_visited_handler.h b/chrome/browser/ui/webui/ntp/most_visited_handler.h
index bad04c3..adc8afb 100644
--- a/chrome/browser/ui/webui/ntp/most_visited_handler.h
+++ b/chrome/browser/ui/webui/ntp/most_visited_handler.h
@@ -74,10 +74,6 @@ class MostVisitedHandler : public WebUIMessageHandler,
static void RegisterUserPrefs(PrefService* prefs);
- // Returns a vector containing the urls for the prepopulated pages.
- // Used only in testing.
- static std::vector<GURL> GetPrePopulatedUrls();
-
private:
struct MostVisitedPage;
@@ -107,11 +103,6 @@ class MostVisitedHandler : public WebUIMessageHandler,
// Sends pages_value_ to the javascript side to and resets page_value_.
void SendPagesValue();
- // Returns true if we should treat this as the first run of the new tab page.
- bool IsFirstRun();
-
- static const std::vector<MostVisitedPage>& GetPrePopulatedPages();
-
NotificationRegistrar registrar_;
// Our consumer for the history service.