OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_BROWSER_INSTANT_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/prefs/public/pref_change_registrar.h" | 10 #include "base/prefs/public/pref_change_registrar.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 public: | 36 public: |
37 explicit BrowserInstantController(Browser* browser); | 37 explicit BrowserInstantController(Browser* browser); |
38 virtual ~BrowserInstantController(); | 38 virtual ~BrowserInstantController(); |
39 | 39 |
40 // Returns true if Instant is enabled in a visible, preview-showing mode. | 40 // Returns true if Instant is enabled in a visible, preview-showing mode. |
41 static bool IsInstantEnabled(Profile* profile); | 41 static bool IsInstantEnabled(Profile* profile); |
42 | 42 |
43 // Registers Instant related preferences. | 43 // Registers Instant related preferences. |
44 static void RegisterUserPrefs(PrefServiceSyncable* prefs); | 44 static void RegisterUserPrefs(PrefServiceSyncable* prefs); |
45 | 45 |
| 46 // If |url| is the new tab page URL, set |target_contents| to the preloaded |
| 47 // NTP contents from InstantController. If |source_contents| is not NULL, we |
| 48 // replace it with the new |target_contents| in the tabstrip and delete |
| 49 // |source_contents|. Otherwise, the caller owns |target_contents| and is |
| 50 // responsible for inserting it into the tabstrip. |
| 51 // |
| 52 // Returns true if and only if we update |target_contents|. |
| 53 bool MaybeSwapInInstantNTPContents( |
| 54 const GURL& url, |
| 55 content::WebContents* source_contents, |
| 56 content::WebContents** target_contents); |
| 57 |
46 // Commits the current Instant, returning true on success. This is intended | 58 // Commits the current Instant, returning true on success. This is intended |
47 // for use from OpenCurrentURL. | 59 // for use from OpenCurrentURL. |
48 bool OpenInstant(WindowOpenDisposition disposition); | 60 bool OpenInstant(WindowOpenDisposition disposition); |
49 | 61 |
| 62 // Returns the Profile associated with the Browser that owns this object. |
| 63 Profile* profile() const; |
| 64 |
50 // Returns the InstantController or NULL if there is no InstantController for | 65 // Returns the InstantController or NULL if there is no InstantController for |
51 // this BrowserInstantController. | 66 // this BrowserInstantController. |
52 InstantController* instant() { return &instant_; } | 67 InstantController* instant() { return &instant_; } |
53 | 68 |
54 // Invoked by |instant_| to commit the |preview| by merging it into the active | 69 // Invoked by |instant_| to commit the |preview| by merging it into the active |
55 // tab or adding it as a new tab. We take ownership of |preview|. | 70 // tab or adding it as a new tab. |
56 void CommitInstant(content::WebContents* preview, bool in_new_tab); | 71 void CommitInstant(scoped_ptr<content::WebContents> preview, bool in_new_tab); |
57 | 72 |
58 // Invoked by |instant_| to autocomplete the |suggestion| into the omnibox. | 73 // Invoked by |instant_| to autocomplete the |suggestion| into the omnibox. |
59 void SetInstantSuggestion(const InstantSuggestion& suggestion); | 74 void SetInstantSuggestion(const InstantSuggestion& suggestion); |
60 | 75 |
61 // Invoked by |instant_| to get the bounds that the preview is placed at, | 76 // Invoked by |instant_| to get the bounds that the preview is placed at, |
62 // in screen coordinated. | 77 // in screen coordinated. |
63 gfx::Rect GetInstantBounds(); | 78 gfx::Rect GetInstantBounds(); |
64 | 79 |
65 // Invoked by |instant_| to notify that the preview gained focus, usually due | 80 // Invoked by |instant_| to notify that the preview gained focus, usually due |
66 // to the user clicking on it. | 81 // to the user clicking on it. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 virtual void Observe(int type, | 121 virtual void Observe(int type, |
107 const content::NotificationSource& source, | 122 const content::NotificationSource& source, |
108 const content::NotificationDetails& details) OVERRIDE; | 123 const content::NotificationDetails& details) OVERRIDE; |
109 | 124 |
110 // Helper for handling theme change. | 125 // Helper for handling theme change. |
111 void OnThemeChanged(ThemeService* theme_service); | 126 void OnThemeChanged(ThemeService* theme_service); |
112 | 127 |
113 // Helper for handling theme area height change. | 128 // Helper for handling theme area height change. |
114 void OnThemeAreaHeightChanged(int height); | 129 void OnThemeAreaHeightChanged(int height); |
115 | 130 |
| 131 // Replaces the contents at tab |index| with |new_contents| and deletes the |
| 132 // existing contents. |
| 133 void ReplaceWebContentsAt(int index, |
| 134 scoped_ptr<content::WebContents> new_contents); |
| 135 |
116 Browser* const browser_; | 136 Browser* const browser_; |
117 | 137 |
118 InstantController instant_; | 138 InstantController instant_; |
119 InstantUnloadHandler instant_unload_handler_; | 139 InstantUnloadHandler instant_unload_handler_; |
120 | 140 |
121 // Theme-related data for NTP preview to adopt themes. | 141 // Theme-related data for NTP preview to adopt themes. |
122 bool initialized_theme_info_; // True if theme_info_ has been initialized. | 142 bool initialized_theme_info_; // True if theme_info_ has been initialized. |
123 ThemeBackgroundInfo theme_info_; | 143 ThemeBackgroundInfo theme_info_; |
124 int theme_area_height_; | 144 int theme_area_height_; |
125 | 145 |
126 PrefChangeRegistrar profile_pref_registrar_; | 146 PrefChangeRegistrar profile_pref_registrar_; |
127 | 147 |
128 content::NotificationRegistrar registrar_; | 148 content::NotificationRegistrar registrar_; |
129 | 149 |
130 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); | 150 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); |
131 }; | 151 }; |
132 | 152 |
133 } // namespace chrome | 153 } // namespace chrome |
134 | 154 |
135 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ | 155 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ |
OLD | NEW |