diff options
author | glen@google.com <glen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-31 23:27:13 +0000 |
---|---|---|
committer | glen@google.com <glen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-07-31 23:27:13 +0000 |
commit | 652bcad9d05b36b4905b896bcf93628e18647893 (patch) | |
tree | 2b2b53e41b766c48f5c189c27e9e7fff16b1824b | |
parent | eaea8ab540171542f7c1ac6f6ce47130da5d1a0e (diff) | |
download | chromium_src-652bcad9d05b36b4905b896bcf93628e18647893.zip chromium_src-652bcad9d05b36b4905b896bcf93628e18647893.tar.gz chromium_src-652bcad9d05b36b4905b896bcf93628e18647893.tar.bz2 |
Stop the new tab page fading in if it's not your startup tab.
BUG=1295355
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/dom_ui/new_tab_ui.cc | 34 | ||||
-rw-r--r-- | chrome/browser/dom_ui/new_tab_ui.h | 13 | ||||
-rw-r--r-- | chrome/browser/resources/new_tab.html | 21 |
3 files changed, 28 insertions, 40 deletions
diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc index 894414c..e45c6ef 100644 --- a/chrome/browser/dom_ui/new_tab_ui.cc +++ b/chrome/browser/dom_ui/new_tab_ui.cc @@ -43,8 +43,9 @@ #include "chrome/browser/template_url.h" #include "chrome/browser/user_metrics.h" #include "chrome/browser/views/keyword_editor_view.h" -#include "chrome/common/l10n_util.h" #include "chrome/common/jstemplate_builder.h" +#include "chrome/common/l10n_util.h" +#include "chrome/common/pref_names.h" #include "chrome/common/resource_bundle.h" #include "generated_resources.h" @@ -72,6 +73,8 @@ static const int kRecentBookmarks = 9; static const wchar_t kRTLHtmlTextDirection[] = L"rtl"; static const wchar_t kDefaultHtmlTextDirection[] = L"ltr"; +bool NewTabHTMLSource::first_view_ = true; + namespace { // To measure end-to-end performance of the new tab page, we observe paint @@ -166,9 +169,8 @@ void SetURLAndTitle(DictionaryValue* dictionary, std::wstring title, } // end anonymous namespace -NewTabHTMLSource::NewTabHTMLSource(int message_id) - : DataSource("new-tab", MessageLoop::current()), - message_id_(message_id) { +NewTabHTMLSource::NewTabHTMLSource() + : DataSource("new-tab", MessageLoop::current()) { } void NewTabHTMLSource::StartDataRequest(const std::string& path, @@ -202,17 +204,10 @@ void NewTabHTMLSource::StartDataRequest(const std::string& path, (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) ? kRTLHtmlTextDirection : kDefaultHtmlTextDirection); - // Let the page know whether this is the first New Tab view for - // this session (and let it trigger all manner of fancy). - static bool new_session = true; - localized_strings.SetString(L"newsession", - new_session ? L"true" : std::wstring()); - new_session = false; - - if (message_id_) - localized_strings.SetString(L"motd", l10n_util::GetString(message_id_)); - else - localized_strings.SetString(L"motd", std::wstring()); + // Let the tab know whether it's the first tab being viewed. + localized_strings.SetString(L"firstview", + first_view_ ? L"true" : std::wstring()); + first_view_ = false; static const StringPiece new_tab_html( ResourceBundle::GetSharedInstance().GetRawDataResource( @@ -751,6 +746,13 @@ NewTabUIContents::NewTabUIContents(Profile* profile, if (profile->IsOffTheRecord()) incognito_ = true; + if (NewTabHTMLSource::first_view() && + (profile->GetPrefs()->GetInteger(prefs::kRestoreOnStartup) != 0 || + !profile->GetPrefs()->GetBoolean(prefs::kHomePageIsNewTabPage)) + ) { + NewTabHTMLSource::set_first_view(false); + } + render_view_host()->SetPaintObserver(new PaintTimer); } @@ -783,7 +785,7 @@ void NewTabUIContents::AttachMessageHandlers() { AddMessageHandler(new RecentlyClosedTabsHandler(this)); AddMessageHandler(new HistoryHandler(this)); - NewTabHTMLSource* html_source = new NewTabHTMLSource(0); + NewTabHTMLSource* html_source = new NewTabHTMLSource(); g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(&chrome_url_data_manager, diff --git a/chrome/browser/dom_ui/new_tab_ui.h b/chrome/browser/dom_ui/new_tab_ui.h index e7adf4c..71a4f50 100644 --- a/chrome/browser/dom_ui/new_tab_ui.h +++ b/chrome/browser/dom_ui/new_tab_ui.h @@ -54,17 +54,19 @@ bool NewTabUIHandleURL(GURL* url, TabContentsType* result_type); class NewTabHTMLSource : public ChromeURLDataManager::DataSource { public: - // Creates our datasource and sets our user message to a specific message - // from our string bundle. - NewTabHTMLSource(int message_id); + NewTabHTMLSource(); // Called when the network layer has requested a resource underneath // the path we registered. virtual void StartDataRequest(const std::string& path, int request_id); + // Setters and getters for first_view. + static void set_first_view(bool first_view) { first_view_ = first_view; } + static bool first_view() { return first_view_; } private: - // The ID of the message from our string bundle to display to the user. - int message_id_; + // Whether this is the is the first viewing of the new tab page and + // we think it is the user's startup page. + static bool first_view_; DISALLOW_EVIL_CONSTRUCTORS(NewTabHTMLSource); }; @@ -306,7 +308,6 @@ class NewTabUIContents : public DOMUIHost { // Clicking a URL on the page should count as an autobookmark click. virtual void RequestOpenURL(const GURL& url, WindowOpenDisposition disposition); - private: // The message id that should be displayed in this NewTabUIContents // instance's motd area. diff --git a/chrome/browser/resources/new_tab.html b/chrome/browser/resources/new_tab.html index fed6f9e..3c16644 100644 --- a/chrome/browser/resources/new_tab.html +++ b/chrome/browser/resources/new_tab.html @@ -1,4 +1,4 @@ -<html id="t" jsvalues="dir:textdirection;newsession:newsession"> +<html id="t" jsvalues="dir:textdirection;firstview:firstview"> <!-- This page is optimized for perceived performance. Our enemies are the time taken for the backend to generate our data, and the time taken to parse @@ -119,10 +119,6 @@ function handleInputBlur() { function handleDOMContentLoaded() { logEvent('domcontentloaded fired'); - - if (document.getElementById('motd').innerHTML) { - document.getElementById('motd').style.display = 'block'; - } } logEvent('log start'); @@ -136,11 +132,11 @@ body { font-size:84%; margin:0px; } -html[newsession='true'] #main { +html[firstview='true'] #main { opacity:0.0; -webkit-transition:all 0.4s; } -html[newsession='true'] #main.visible { +html[firstview='true'] #main.visible { /* unfortunately, 1.0 results in no animation */ opacity:0.999; } @@ -184,13 +180,6 @@ html[dir='rtl'] #mostvisited td { -webkit-box-shadow: 5px 5px 10px #ccc; -webkit-transition:all 0.12s; } -#motd { - background-color:#ffc; - padding:5px; - margin-bottom:9px; - width:610px; - -webkit-transition:all 0.12s; -} .thumbnail-title { background-image:url(chrome-resource://favicon/); display:block; @@ -221,9 +210,6 @@ a.thumbnail { border:1px solid #abe; } -.small #motd { - width:480px; -} .small .thumbnail-title { width:127px; } @@ -322,7 +308,6 @@ document.addEventListener('DOMContentLoaded', handleDOMContentLoaded); <tr> <td valign="top"> <div id="mostvisitedsection" class="section"> - <div id="motd" jscontent="motd" style="display:none;"></div> <div id="mostvisited" style="position:relative;"> <div class="section-title" jscontent="mostvisited"></div> <div id="mostvisitedintro" style="display:none;"> |