Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1000)

Side by Side Diff: chrome/browser/ui/webui/ntp/new_tab_ui.h

Issue 9224002: Make WebUI objects not derive from WebUI. WebUI objects own the controller. This is the ownership... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync to head to clear linux_chromeos browsertest failures Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 7 #pragma once
8 8
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/time.h" 12 #include "base/time.h"
13 #include "base/timer.h" 13 #include "base/timer.h"
14 #include "chrome/browser/sessions/tab_restore_service.h" 14 #include "chrome/browser/sessions/tab_restore_service.h"
15 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 15 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
16 #include "content/browser/webui/web_ui.h"
17 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
19 #include "content/public/browser/web_ui_controller.h" 18 #include "content/public/browser/web_ui_controller.h"
20 19
21 class GURL; 20 class GURL;
22 class PrefService; 21 class PrefService;
23 class Profile; 22 class Profile;
24 23
25 // The TabContents used for the New Tab page. 24 // The TabContents used for the New Tab page.
26 class NewTabUI : public WebUI, public content::WebUIController, 25 class NewTabUI : public content::WebUIController,
27 public content::NotificationObserver { 26 public content::NotificationObserver {
28 public: 27 public:
29 explicit NewTabUI(content::WebContents* manager); 28 explicit NewTabUI(WebUI* web_ui);
30 virtual ~NewTabUI(); 29 virtual ~NewTabUI();
31 30
32 static void RegisterUserPrefs(PrefService* prefs); 31 static void RegisterUserPrefs(PrefService* prefs);
33 32
34 // Adds "url", "title", and "direction" keys on incoming dictionary, setting 33 // Adds "url", "title", and "direction" keys on incoming dictionary, setting
35 // title as the url as a fallback on empty title. 34 // title as the url as a fallback on empty title.
36 static void SetURLTitleAndDirection(base::DictionaryValue* dictionary, 35 static void SetURLTitleAndDirection(base::DictionaryValue* dictionary,
37 const string16& title, 36 const string16& title,
38 const GURL& gurl); 37 const GURL& gurl);
39 38
40 // Returns a pointer to a NewTabUI if the WebUI object is a new tab page. 39 // Returns a pointer to a NewTabUI if the WebUIController object is a new tab
41 static NewTabUI* FromWebUI(WebUI* ui); 40 // page.
41 static NewTabUI* FromWebUIController(content::WebUIController* ui);
42 42
43 // The current preference version. 43 // The current preference version.
44 static int current_pref_version() { return current_pref_version_; } 44 static int current_pref_version() { return current_pref_version_; }
45 45
46 // WebUIController implementation: 46 // WebUIController implementation:
47 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; 47 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
48 virtual void RenderViewReused(RenderViewHost* render_view_host) OVERRIDE; 48 virtual void RenderViewReused(RenderViewHost* render_view_host) OVERRIDE;
49 49
50 // Returns true if the bookmark bar can be displayed over this webui, detached 50 // Returns true if the bookmark bar can be displayed over this webui, detached
51 // from the location bar. 51 // from the location bar.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 base::TimeTicks last_paint_; 97 base::TimeTicks last_paint_;
98 // Scoping so we can be sure our timeouts don't outlive us. 98 // Scoping so we can be sure our timeouts don't outlive us.
99 base::OneShotTimer<NewTabUI> timer_; 99 base::OneShotTimer<NewTabUI> timer_;
100 // The preference version. This used for migrating prefs of the NTP. 100 // The preference version. This used for migrating prefs of the NTP.
101 static const int current_pref_version_ = 3; 101 static const int current_pref_version_ = 3;
102 102
103 DISALLOW_COPY_AND_ASSIGN(NewTabUI); 103 DISALLOW_COPY_AND_ASSIGN(NewTabUI);
104 }; 104 };
105 105
106 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_ 106 #endif // CHROME_BROWSER_UI_WEBUI_NTP_NEW_TAB_UI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698