| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
| 12 #include "base/prefs/public/pref_change_registrar.h" | 12 #include "base/prefs/public/pref_change_registrar.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "base/timer.h" | 14 #include "base/timer.h" |
| 15 #include "chrome/browser/sessions/tab_restore_service.h" | 15 #include "chrome/browser/sessions/tab_restore_service.h" |
| 16 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 16 #include "content/public/browser/url_data_source_delegate.h" |
| 17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
| 18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 19 #include "content/public/browser/web_ui_controller.h" | 19 #include "content/public/browser/web_ui_controller.h" |
| 20 | 20 |
| 21 class GURL; | 21 class GURL; |
| 22 class PrefServiceSyncable; | 22 class PrefServiceSyncable; |
| 23 class Profile; | 23 class Profile; |
| 24 | 24 |
| 25 namespace base { |
| 26 class DictionaryValue; |
| 27 } |
| 28 |
| 25 // The WebContents used for the New Tab page. | 29 // The WebContents used for the New Tab page. |
| 26 class NewTabUI : public content::WebUIController, | 30 class NewTabUI : public content::WebUIController, |
| 27 public content::NotificationObserver { | 31 public content::NotificationObserver { |
| 28 public: | 32 public: |
| 29 explicit NewTabUI(content::WebUI* web_ui); | 33 explicit NewTabUI(content::WebUI* web_ui); |
| 30 virtual ~NewTabUI(); | 34 virtual ~NewTabUI(); |
| 31 | 35 |
| 32 static void RegisterUserPrefs(PrefServiceSyncable* prefs); | 36 static void RegisterUserPrefs(PrefServiceSyncable* prefs); |
| 33 | 37 |
| 34 // Returns whether or not to show apps pages. | 38 // Returns whether or not to show apps pages. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 56 virtual void RenderViewReused( | 60 virtual void RenderViewReused( |
| 57 content::RenderViewHost* render_view_host) OVERRIDE; | 61 content::RenderViewHost* render_view_host) OVERRIDE; |
| 58 | 62 |
| 59 // Returns true if the bookmark bar can be displayed over this webui, detached | 63 // Returns true if the bookmark bar can be displayed over this webui, detached |
| 60 // from the location bar. | 64 // from the location bar. |
| 61 bool CanShowBookmarkBar() const; | 65 bool CanShowBookmarkBar() const; |
| 62 | 66 |
| 63 bool showing_sync_bubble() { return showing_sync_bubble_; } | 67 bool showing_sync_bubble() { return showing_sync_bubble_; } |
| 64 void set_showing_sync_bubble(bool showing) { showing_sync_bubble_ = showing; } | 68 void set_showing_sync_bubble(bool showing) { showing_sync_bubble_ = showing; } |
| 65 | 69 |
| 66 class NewTabHTMLSource : public ChromeURLDataManager::DataSource { | 70 class NewTabHTMLSource : public content::URLDataSourceDelegate { |
| 67 public: | 71 public: |
| 68 explicit NewTabHTMLSource(Profile* profile); | 72 explicit NewTabHTMLSource(Profile* profile); |
| 69 | 73 |
| 70 // Called when the network layer has requested a resource underneath | 74 // content::URLDataSourceDelegate implementation. |
| 71 // the path we registered. | 75 virtual std::string GetSource() OVERRIDE; |
| 72 virtual void StartDataRequest(const std::string& path, | 76 virtual void StartDataRequest(const std::string& path, |
| 73 bool is_incognito, | 77 bool is_incognito, |
| 74 int request_id) OVERRIDE; | 78 int request_id) OVERRIDE; |
| 75 | |
| 76 virtual std::string GetMimeType(const std::string&) const OVERRIDE; | 79 virtual std::string GetMimeType(const std::string&) const OVERRIDE; |
| 77 | |
| 78 virtual bool ShouldReplaceExistingSource() const OVERRIDE; | 80 virtual bool ShouldReplaceExistingSource() const OVERRIDE; |
| 79 | 81 |
| 80 // Adds |resource| to the source. |resource_id| is resource id or 0, | 82 // Adds |resource| to the source. |resource_id| is resource id or 0, |
| 81 // which means return empty data set. |mime_type| is mime type of the | 83 // which means return empty data set. |mime_type| is mime type of the |
| 82 // resource. | 84 // resource. |
| 83 void AddResource(const char* resource, | 85 void AddResource(const char* resource, |
| 84 const char *mime_type, | 86 const char *mime_type, |
| 85 int resource_id); | 87 int resource_id); |
| 86 | 88 |
| 87 private: | 89 private: |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 129 |
| 128 // If the sync promo NTP bubble is being shown. | 130 // If the sync promo NTP bubble is being shown. |
| 129 bool showing_sync_bubble_; | 131 bool showing_sync_bubble_; |
| 130 | 132 |
| 131 PrefChangeRegistrar pref_change_registrar_; | 133 PrefChangeRegistrar pref_change_registrar_; |
| 132 | 134 |
| 133 DISALLOW_COPY_AND_ASSIGN(NewTabUI); | 135 DISALLOW_COPY_AND_ASSIGN(NewTabUI); |
| 134 }; | 136 }; |
| 135 | 137 |
| 136 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_ | 138 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_ |
| OLD | NEW |