summaryrefslogtreecommitdiffstats
path: root/chrome/browser/dom_ui/new_tab_ui.h
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-08 20:10:13 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-08 20:10:13 +0000
commit43a8c4099061e842fc4ae18e3e072df416984717 (patch)
tree1e4317c568b1b7c0bb2fc444f5b6944f94cd4e36 /chrome/browser/dom_ui/new_tab_ui.h
parentd68f0ecb7767c313536b6cefbd14879b41522e62 (diff)
downloadchromium_src-43a8c4099061e842fc4ae18e3e072df416984717.zip
chromium_src-43a8c4099061e842fc4ae18e3e072df416984717.tar.gz
chromium_src-43a8c4099061e842fc4ae18e3e072df416984717.tar.bz2
Move MostVisitedHandler into a separate file because it's big.
I'm going to be modifying this file a lot and the single big file was hard to work with. Review URL: http://codereview.chromium.org/265040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28435 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui/new_tab_ui.h')
-rw-r--r--chrome/browser/dom_ui/new_tab_ui.h72
1 files changed, 67 insertions, 5 deletions
diff --git a/chrome/browser/dom_ui/new_tab_ui.h b/chrome/browser/dom_ui/new_tab_ui.h
index e5d1094..d208b23 100644
--- a/chrome/browser/dom_ui/new_tab_ui.h
+++ b/chrome/browser/dom_ui/new_tab_ui.h
@@ -6,16 +6,14 @@
#define CHROME_BROWSER_DOM_UI_NEW_TAB_UI_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"
class GURL;
+class MessageLoop;
class PrefService;
class Profile;
-namespace {
- class NewTabHTMLSource;
-}
-
// The TabContents used for the New Tab page.
class NewTabUI : public DOMUI,
public NotificationObserver {
@@ -40,7 +38,71 @@ class NewTabUI : public DOMUI,
// line switch.
static bool FirstRunDisabled();
-private:
+ // Adds "url", "title", and "direction" keys on incoming dictionary, setting
+ // title as the url as a fallback on empty title.
+ static void SetURLTitleAndDirection(DictionaryValue* dictionary,
+ const string16& title,
+ const GURL& gurl);
+
+ class NewTabHTMLSource : public ChromeURLDataManager::DataSource {
+ public:
+ explicit NewTabHTMLSource(Profile* profile);
+
+ // Called when the network layer has requested a resource underneath
+ // the path we registered.
+ virtual void StartDataRequest(const std::string& path, int request_id);
+
+ virtual std::string GetMimeType(const std::string&) const {
+ return "text/html";
+ }
+
+ virtual MessageLoop* MessageLoopForRequestPath(const std::string& path)
+ const {
+ // NewTabHTMLSource does all of the operations that need to be on the
+ // UI thread from InitFullHTML, called by the constructor. It is safe
+ // to call StartDataRequest from any thread, so return NULL.
+ return NULL;
+ }
+
+ // 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_; }
+
+ // Setters and getters for first_run.
+ static void set_first_run(bool first_run) { first_run_ = first_run; }
+ static bool first_run() { return first_run_; }
+
+ private:
+ // In case a file path to the new tab page was provided this tries to load
+ // the file and returns the file content if successful. This returns an
+ // empty string in case of failure.
+ static std::string GetCustomNewTabPageFromCommandLine();
+
+ // Populate full_html_. This must be called from the UI thread because it
+ // involves profile access.
+ //
+ // A new NewTabHTMLSource object is used for each new tab page instance
+ // and each reload of an existing new tab page, so there is no concern
+ // about cached data becoming stale.
+ void InitFullHTML();
+
+ // The content to be served by StartDataRequest, stored by InitFullHTML.
+ std::string full_html_;
+
+ // Whether this is the first viewing of the new tab page and
+ // we think it is the user's startup page.
+ static bool first_view_;
+
+ // Whether this is the first run.
+ static bool first_run_;
+
+ // The user's profile.
+ Profile* profile_;
+
+ DISALLOW_COPY_AND_ASSIGN(NewTabHTMLSource);
+ };
+
+ private:
void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);