summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/browser.cc1
-rw-r--r--chrome/browser/dom_ui/dom_ui_unittest.cc1
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.cc61
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.h27
-rw-r--r--chrome/browser/dom_ui/new_tab_ui_uitest.cc67
-rw-r--r--chrome/browser/dom_ui/tips_handler.cc11
-rw-r--r--chrome/browser/resources/new_new_tab.css1
-rw-r--r--chrome/browser/resources/new_new_tab.js24
-rw-r--r--chrome/browser/tab_contents/web_contents_unittest.cc1
-rw-r--r--chrome/common/pref_names.cc5
-rw-r--r--chrome/common/pref_names.h1
11 files changed, 14 insertions, 186 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 071c9b2..b740d07 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -1916,7 +1916,6 @@ void Browser::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterBooleanPref(prefs::kWebAppCreateInQuickLaunchBar, true);
prefs->RegisterBooleanPref(prefs::kUseVerticalTabs, false);
prefs->RegisterBooleanPref(prefs::kEnableTranslate, true);
- prefs->RegisterIntegerPref(prefs::kNTPPromoViewsRemaining, 5);
}
// static
diff --git a/chrome/browser/dom_ui/dom_ui_unittest.cc b/chrome/browser/dom_ui/dom_ui_unittest.cc
index 8c00663..51f5e1e 100644
--- a/chrome/browser/dom_ui/dom_ui_unittest.cc
+++ b/chrome/browser/dom_ui/dom_ui_unittest.cc
@@ -84,7 +84,6 @@ class DOMUITest : public RenderViewHostTestHarness {
// TabContents when we first navigate to a DOM UI page, then to a standard
// non-DOM-UI page.
TEST_F(DOMUITest, DOMUIToStandard) {
- profile_->CreateBookmarkModel(true);
DoNavigationTest(contents(), 1);
// Test the case where we're not doing the initial navigation. This is
diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc
index d367db3..6d2bdde 100644
--- a/chrome/browser/dom_ui/new_tab_ui.cc
+++ b/chrome/browser/dom_ui/new_tab_ui.cc
@@ -15,9 +15,7 @@
#include "base/i18n/rtl.h"
#include "base/singleton.h"
#include "base/thread.h"
-#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/browser.h"
-#include "chrome/browser/browser_window.h"
#include "chrome/browser/chrome_thread.h"
#include "chrome/browser/dom_ui/app_launcher_handler.h"
#include "chrome/browser/dom_ui/dom_ui_theme_source.h"
@@ -26,7 +24,6 @@
#include "chrome/browser/dom_ui/ntp_resource_cache.h"
#include "chrome/browser/dom_ui/shown_sections_handler.h"
#include "chrome/browser/dom_ui/tips_handler.h"
-#include "chrome/browser/importer/importer_data_types.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/pref_service.h"
#include "chrome/browser/profile.h"
@@ -41,11 +38,6 @@
#include "chrome/common/url_constants.h"
#include "grit/generated_resources.h"
-#if defined(OS_WIN)
-#include "chrome/browser/views/importer_view.h"
-#include "views/window/window.h"
-#endif
-
namespace {
// The number of recent bookmarks we show.
@@ -437,43 +429,6 @@ void NewTabPageSetHomePageHandler::HandleSetHomePage(
dom_ui_->CallJavascriptFunction(L"onHomePageSet", list_value);
}
-///////////////////////////////////////////////////////////////////////////////
-// NewTabPageImportBookmarksHandler
-class NewTabPageImportBookmarksHandler : public DOMMessageHandler {
- public:
- NewTabPageImportBookmarksHandler() {}
- virtual ~NewTabPageImportBookmarksHandler() {}
-
- // DOMMessageHandler implementation.
- virtual void RegisterMessages();
-
- // Callback for "importBookmarks".
- void HandleImportBookmarks(const Value* value);
- private:
-
- DISALLOW_COPY_AND_ASSIGN(NewTabPageImportBookmarksHandler);
-};
-
-void NewTabPageImportBookmarksHandler::RegisterMessages() {
- dom_ui_->RegisterMessageCallback("importBookmarks", NewCallback(
- this, &NewTabPageImportBookmarksHandler::HandleImportBookmarks));
-}
-
-void NewTabPageImportBookmarksHandler::HandleImportBookmarks(
- const Value* value) {
- Browser* browser = NULL;
- TabContentsDelegate* delegate = dom_ui_->tab_contents()->delegate();
- if (delegate)
- browser = delegate->GetBrowser();
- DCHECK(browser);
-#if defined(OS_WIN)
- views::Window::CreateChromeWindow(
- browser->window()->GetNativeHandle(),
- gfx::Rect(),
- new ImporterView(dom_ui_->GetProfile(), importer::FAVORITES))->Show();
-#endif
-}
-
} // namespace
///////////////////////////////////////////////////////////////////////////////
@@ -499,10 +454,6 @@ NewTabUI::NewTabUI(TabContents* contents)
static bool first_view = true;
if (first_view) {
- Profile* profile = GetProfile();
- profile->GetPrefs()->SetInteger(prefs::kNTPPromoViewsRemaining,
- profile->GetPrefs()->GetInteger(prefs::kNTPPromoViewsRemaining) - 1);
- profile->GetBookmarkModel()->AddObserver(this);
first_view = false;
}
@@ -525,7 +476,6 @@ NewTabUI::NewTabUI(TabContents* contents)
}
AddMessageHandler((new NewTabPageSetHomePageHandler())->Attach(this));
- AddMessageHandler((new NewTabPageImportBookmarksHandler())->Attach(this));
}
// Initializing the CSS and HTML can require some CPU, so do it after
@@ -550,9 +500,6 @@ NewTabUI::NewTabUI(TabContents* contents)
}
NewTabUI::~NewTabUI() {
- BookmarkModel* bookmark_model = GetProfile()->GetBookmarkModel();
- if (bookmark_model)
- bookmark_model->RemoveObserver(this);
}
void NewTabUI::RenderViewCreated(RenderViewHost* render_view_host) {
@@ -563,14 +510,6 @@ void NewTabUI::RenderViewReused(RenderViewHost* render_view_host) {
render_view_host->set_paint_observer(new PaintTimer);
}
-void NewTabUI::BookmarkNodeAdded(BookmarkModel* model,
- const BookmarkNode* parent,
- int index) {
- // Stop showing the promo, and no longer observe the bookmark model.
- GetProfile()->GetPrefs()->SetInteger(prefs::kNTPPromoViewsRemaining, 0);
- GetProfile()->GetBookmarkModel()->RemoveObserver(this);
-}
-
void NewTabUI::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
diff --git a/chrome/browser/dom_ui/new_tab_ui.h b/chrome/browser/dom_ui/new_tab_ui.h
index 08a2fa0..b6358c4 100644
--- a/chrome/browser/dom_ui/new_tab_ui.h
+++ b/chrome/browser/dom_ui/new_tab_ui.h
@@ -9,7 +9,6 @@
#include <string>
#include "base/gtest_prod_util.h"
-#include "chrome/browser/bookmarks/bookmark_model_observer.h"
#include "chrome/browser/dom_ui/dom_ui.h"
#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
#include "chrome/common/notification_registrar.h"
@@ -21,8 +20,7 @@ class Profile;
// The TabContents used for the New Tab page.
class NewTabUI : public DOMUI,
- public NotificationObserver,
- public BookmarkModelObserver {
+ public NotificationObserver {
public:
explicit NewTabUI(TabContents* manager);
~NewTabUI();
@@ -32,29 +30,6 @@ class NewTabUI : public DOMUI,
virtual void RenderViewCreated(RenderViewHost* render_view_host);
virtual void RenderViewReused(RenderViewHost* render_view_host);
- // Overridden from BookmarkModelObserver so we can remove the promo for
- // importing bookmarks if the user adds a bookmark in any way.
- virtual void BookmarkNodeAdded(BookmarkModel* model,
- const BookmarkNode* parent,
- int index);
-
- // These methods must be overridden so that the NTP can be a
- // BookmarkModelObserver.
- virtual void Loaded(BookmarkModel* model) {}
- virtual void BookmarkModelBeingDeleted(BookmarkModel* model) {}
- virtual void BookmarkNodeMoved(BookmarkModel* model,
- const BookmarkNode* old_parent, int old_index,
- const BookmarkNode* new_parent, int new_index) {}
- virtual void BookmarkNodeRemoved(BookmarkModel* model,
- const BookmarkNode* parent, int old_index,
- const BookmarkNode* node) {}
- virtual void BookmarkNodeChanged(BookmarkModel* model,
- const BookmarkNode* node) {}
- virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model,
- const BookmarkNode* node) {}
- virtual void BookmarkNodeChildrenReordered(BookmarkModel* model,
- const BookmarkNode* node) {}
-
static void RegisterUserPrefs(PrefService* prefs);
static void MigrateUserPrefs(PrefService* prefs, int old_pref_version,
int new_pref_version);
diff --git a/chrome/browser/dom_ui/new_tab_ui_uitest.cc b/chrome/browser/dom_ui/new_tab_ui_uitest.cc
index e2a33688..e82a1cda 100644
--- a/chrome/browser/dom_ui/new_tab_ui_uitest.cc
+++ b/chrome/browser/dom_ui/new_tab_ui_uitest.cc
@@ -95,70 +95,3 @@ TEST_F(NewTabUITest, UpdateUserPrefsVersion) {
migrated = NewTabUI::UpdateUserPrefsVersion(prefs.get());
ASSERT_FALSE(migrated);
}
-
-TEST_F(NewTabUITest, HomePageLink) {
- scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
- ASSERT_TRUE(browser.get());
-
- ASSERT_TRUE(
- browser->SetBooleanPreference(prefs::kHomePageIsNewTabPage, false));
-
- // Bring up a new tab page.
- ASSERT_TRUE(browser->RunCommand(IDC_NEW_TAB));
- int load_time;
- ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time));
-
- scoped_refptr<TabProxy> tab = browser->GetActiveTab();
- ASSERT_TRUE(tab.get());
-
- // TODO(arv): Extract common patterns for doing js testing.
-
- // Fire click. Because tip service is turned off for testing, we first
- // force the "make this my home page" tip to appear.
- // TODO(arv): Find screen position of element and use a lower level click
- // emulation.
- bool result;
- ASSERT_TRUE(tab->ExecuteAndExtractBool(L"",
- L"window.domAutomationController.send("
- L"(function() {"
- L" tipCache = [{\"set_homepage_tip\":\"Make this the home page\"}];"
- L" renderTip();"
- L" var e = document.createEvent('Event');"
- L" e.initEvent('click', true, true);"
- L" var el = document.querySelector('#tip-line > button');"
- L" el.dispatchEvent(e);"
- L" return true;"
- L"})()"
- L")",
- &result));
- ASSERT_TRUE(result);
-
- // Make sure text of "set as home page" tip has been removed.
- std::wstring tip_text_content;
- ASSERT_TRUE(tab->ExecuteAndExtractString(L"",
- L"window.domAutomationController.send("
- L"(function() {"
- L" var el = document.querySelector('#tip-line');"
- L" return el.textContent;"
- L"})()"
- L")",
- &tip_text_content));
- ASSERT_EQ(L"", tip_text_content);
-
- // Make sure that the notification is visible
- bool has_class;
- ASSERT_TRUE(tab->ExecuteAndExtractBool(L"",
- L"window.domAutomationController.send("
- L"(function() {"
- L" var el = document.querySelector('#notification');"
- L" return el.classList.contains('show');"
- L"})()"
- L")",
- &has_class));
- ASSERT_TRUE(has_class);
-
- bool is_home_page;
- ASSERT_TRUE(browser->GetBooleanPreference(prefs::kHomePageIsNewTabPage,
- &is_home_page));
- ASSERT_TRUE(is_home_page);
-}
diff --git a/chrome/browser/dom_ui/tips_handler.cc b/chrome/browser/dom_ui/tips_handler.cc
index 6a8a2f4f..1a7b59c 100644
--- a/chrome/browser/dom_ui/tips_handler.cc
+++ b/chrome/browser/dom_ui/tips_handler.cc
@@ -54,17 +54,6 @@ void TipsHandler::HandleGetTips(const Value* content) {
}
}
- // If the user has just started using Chrome with a fresh profile, send only
- // the "Import bookmarks" promo until the user has either seen it five times
- // or added or imported bookmarks.
- if (current_prefs->GetInteger(prefs::kNTPPromoViewsRemaining) > 0) {
- SendTip(WideToUTF8(l10n_util::GetStringF(IDS_IMPORT_BOOKMARKS_PROMO,
- std::wstring(L"<button class='link'>"),
- std::wstring(L"</button>"))),
- L"set_promo_tip", 0);
- return;
- }
-
if (tips_cache_ != NULL && !tips_cache_->empty()) {
if (tips_cache_->GetInteger(
WebResourceService::kCurrentTipPrefName, &current_tip_index) &&
diff --git a/chrome/browser/resources/new_new_tab.css b/chrome/browser/resources/new_new_tab.css
index b842877..a201da6 100644
--- a/chrome/browser/resources/new_new_tab.css
+++ b/chrome/browser/resources/new_new_tab.css
@@ -281,7 +281,6 @@ html[dir=rtl] .item {
#tip-line button {
/* We do not want a trailing single word from a link on the last line */
white-space: nowrap;
- padding: 0;
}
#option-button {
diff --git a/chrome/browser/resources/new_new_tab.js b/chrome/browser/resources/new_new_tab.js
index 0274b9b7..5728d58 100644
--- a/chrome/browser/resources/new_new_tab.js
+++ b/chrome/browser/resources/new_new_tab.js
@@ -27,12 +27,6 @@ function createTip(data) {
homepageButton.textContent = data[0].set_homepage_tip;
homepageButton.addEventListener('click', setAsHomePageLinkClicked);
return homepageButton;
- } else if (data[0].set_promo_tip) {
- var promoMessage = document.createElement('span');
- promoMessage.innerHTML = data[0].set_promo_tip;
- var promoButton = promoMessage.querySelector('button');
- promoButton.addEventListener('click', importBookmarksLinkClicked);
- return promoMessage;
} else {
try {
return parseHtmlSubset(data[0].tip_html_text);
@@ -447,6 +441,14 @@ function hideNotification() {
actionLink.blur();
}
+function showFirstRunNotification() {
+ showNotification(localStrings.getString('firstrunnotification'),
+ localStrings.getString('closefirstrunnotification'),
+ null, 30000);
+ var notificationElement = $('notification');
+ notification.classList.add('first-run');
+}
+
/**
* This handles the option menu.
* @param {Element} button The button element.
@@ -850,11 +852,6 @@ function setAsHomePageLinkClicked(e) {
e.preventDefault();
}
-function importBookmarksLinkClicked(e) {
- chrome.send('importBookmarks');
- e.preventDefault();
-}
-
function onHomePageSet(data) {
showNotification(data[0], data[1]);
// Removes the "make this my home page" tip.
@@ -934,6 +931,11 @@ function mostVisitedPages(data, firstRun) {
mostVisited.ensureSmallGridCorrect();
document.body.classList.remove('loading');
}, 1);
+
+ // Only show the first run notification if first run.
+ if (firstRun) {
+ showFirstRunNotification();
+ }
}
// Log clicked links from the tips section.
diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc
index cb3d4d4..3a96e1a 100644
--- a/chrome/browser/tab_contents/web_contents_unittest.cc
+++ b/chrome/browser/tab_contents/web_contents_unittest.cc
@@ -184,7 +184,6 @@ class TabContentsTest : public RenderViewHostTestHarness {
// is not supposed to overwrite a profile if it's already created.
virtual void SetUp() {
TestingProfile* profile = new TestingProfile();
- profile->CreateBookmarkModel(false);
profile_.reset(profile);
// Set some (WebKit) user preferences.
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 215db8e..dd994ac 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -454,11 +454,6 @@ const wchar_t kUseCustomChromeFrame[] = L"browser.custom_chrome_frame";
// done directly from the omnibox should be shown.
const wchar_t kShowOmniboxSearchHint[] = L"browser.show_omnibox_search_hint";
-// Int which specifies how many times left to show a promotional message on the
-// NTP. This value decrements each time the NTP is shown for the first time
-// in a session.
-const wchar_t kNTPPromoViewsRemaining[] = L"browser.ntp.promo_remaining";
-
// The list of origins which are allowed|denied to show desktop notifications.
const wchar_t kDesktopNotificationDefaultContentSetting[] =
L"profile.notifications_default_content_setting";
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index 4d9b1ef..44fbfdb 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -173,7 +173,6 @@ extern const wchar_t kShowUpdatePromotionInfoBar[];
#endif
extern const wchar_t kUseCustomChromeFrame[];
extern const wchar_t kShowOmniboxSearchHint[];
-extern const wchar_t kNTPPromoViewsRemaining[];
extern const wchar_t kDesktopNotificationDefaultContentSetting[];
extern const wchar_t kDesktopNotificationAllowedOrigins[];
extern const wchar_t kDesktopNotificationDeniedOrigins[];