Chromium Code Reviews| 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" |
| 11 #include "chrome/browser/instant/instant_controller.h" | 11 #include "chrome/browser/instant/instant_controller.h" |
| 12 #include "chrome/browser/instant/instant_unload_handler.h" | 12 #include "chrome/browser/instant/instant_unload_handler.h" |
| 13 #include "chrome/browser/ui/browser.h" | |
| 13 #include "chrome/browser/ui/search/search_model_observer.h" | 14 #include "chrome/browser/ui/search/search_model_observer.h" |
| 14 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 16 #include "webkit/glue/window_open_disposition.h" | 17 #include "webkit/glue/window_open_disposition.h" |
| 17 | 18 |
| 18 class Browser; | 19 class Browser; |
| 19 struct InstantSuggestion; | 20 struct InstantSuggestion; |
| 20 class PrefServiceSyncable; | 21 class PrefServiceSyncable; |
| 21 class Profile; | 22 class Profile; |
| 22 class ThemeService; | 23 class ThemeService; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 36 public: | 37 public: |
| 37 explicit BrowserInstantController(Browser* browser); | 38 explicit BrowserInstantController(Browser* browser); |
| 38 virtual ~BrowserInstantController(); | 39 virtual ~BrowserInstantController(); |
| 39 | 40 |
| 40 // Returns true if Instant is enabled in a visible, preview-showing mode. | 41 // Returns true if Instant is enabled in a visible, preview-showing mode. |
| 41 static bool IsInstantEnabled(Profile* profile); | 42 static bool IsInstantEnabled(Profile* profile); |
| 42 | 43 |
| 43 // Registers Instant related preferences. | 44 // Registers Instant related preferences. |
| 44 static void RegisterUserPrefs(PrefServiceSyncable* prefs); | 45 static void RegisterUserPrefs(PrefServiceSyncable* prefs); |
| 45 | 46 |
| 47 // If |url| is the new tab page URL, set |target_contents| to the preloaded | |
| 48 // NTP contents from InstantController. If |source_contents| is not NULL, we | |
| 49 // replace it with the new |target_contents| in the tabstrip and delete | |
| 50 // |source_contents|. Returns true if and only if we update |target_contents|. | |
| 51 bool MaybeSwapInInstantContents(const GURL& url, | |
| 52 content::WebContents* source_contents, | |
| 53 content::WebContents** target_contents); | |
| 54 | |
| 46 // Commits the current Instant, returning true on success. This is intended | 55 // Commits the current Instant, returning true on success. This is intended |
| 47 // for use from OpenCurrentURL. | 56 // for use from OpenCurrentURL. |
| 48 bool OpenInstant(WindowOpenDisposition disposition); | 57 bool OpenInstant(WindowOpenDisposition disposition); |
| 49 | 58 |
| 59 // Returns the Profile associated with the Browser that owns this object. | |
| 60 Profile* profile() const { return browser_->profile(); } | |
| 61 | |
| 50 // Returns the InstantController or NULL if there is no InstantController for | 62 // Returns the InstantController or NULL if there is no InstantController for |
| 51 // this BrowserInstantController. | 63 // this BrowserInstantController. |
| 52 InstantController* instant() { return &instant_; } | 64 InstantController* instant() { return &instant_; } |
| 53 | 65 |
| 54 // Invoked by |instant_| to commit the |preview| by merging it into the active | 66 // 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|. | 67 // tab or adding it as a new tab. We take ownership of |preview|. |
| 56 void CommitInstant(content::WebContents* preview, bool in_new_tab); | 68 void CommitInstant(content::WebContents* preview, bool in_new_tab); |
| 57 | 69 |
| 58 // Invoked by |instant_| to autocomplete the |suggestion| into the omnibox. | 70 // Invoked by |instant_| to autocomplete the |suggestion| into the omnibox. |
| 59 void SetInstantSuggestion(const InstantSuggestion& suggestion); | 71 void SetInstantSuggestion(const InstantSuggestion& suggestion); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 virtual void Observe(int type, | 118 virtual void Observe(int type, |
| 107 const content::NotificationSource& source, | 119 const content::NotificationSource& source, |
| 108 const content::NotificationDetails& details) OVERRIDE; | 120 const content::NotificationDetails& details) OVERRIDE; |
| 109 | 121 |
| 110 // Helper for handling theme change. | 122 // Helper for handling theme change. |
| 111 void OnThemeChanged(ThemeService* theme_service); | 123 void OnThemeChanged(ThemeService* theme_service); |
| 112 | 124 |
| 113 // Helper for handling theme area height change. | 125 // Helper for handling theme area height change. |
| 114 void OnThemeAreaHeightChanged(int height); | 126 void OnThemeAreaHeightChanged(int height); |
| 115 | 127 |
| 128 // Replaces the contents at tab |index| with |new_contents| and deletes the | |
| 129 // existing contents. | |
| 130 void ReplaceWebContentsAt(int index, content::WebContents* new_contents); | |
|
dhollowa
2013/01/22 22:34:58
scoped_ptr<WebContents> new_contents.
samarth
2013/01/25 21:08:40
Done.
| |
| 131 | |
| 116 Browser* const browser_; | 132 Browser* const browser_; |
| 117 | 133 |
| 118 InstantController instant_; | 134 InstantController instant_; |
| 119 InstantUnloadHandler instant_unload_handler_; | 135 InstantUnloadHandler instant_unload_handler_; |
| 120 | 136 |
| 121 // Theme-related data for NTP preview to adopt themes. | 137 // Theme-related data for NTP preview to adopt themes. |
| 122 bool initialized_theme_info_; // True if theme_info_ has been initialized. | 138 bool initialized_theme_info_; // True if theme_info_ has been initialized. |
| 123 ThemeBackgroundInfo theme_info_; | 139 ThemeBackgroundInfo theme_info_; |
| 124 int theme_area_height_; | 140 int theme_area_height_; |
| 125 | 141 |
| 126 PrefChangeRegistrar profile_pref_registrar_; | 142 PrefChangeRegistrar profile_pref_registrar_; |
| 127 | 143 |
| 128 content::NotificationRegistrar registrar_; | 144 content::NotificationRegistrar registrar_; |
| 129 | 145 |
| 130 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); | 146 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); |
| 131 }; | 147 }; |
| 132 | 148 |
| 133 } // namespace chrome | 149 } // namespace chrome |
| 134 | 150 |
| 135 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ | 151 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ |
| OLD | NEW |