| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_INSTANT_INSTANT_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 6 #define CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "base/timer.h" | 14 #include "base/timer.h" |
| 15 #include "chrome/browser/instant/instant_commit_type.h" | 15 #include "chrome/browser/instant/instant_commit_type.h" |
| 16 #include "chrome/browser/instant/instant_loader_delegate.h" | 16 #include "chrome/browser/instant/instant_loader_delegate.h" |
| 17 #include "chrome/browser/search_engines/template_url_id.h" | 17 #include "chrome/browser/search_engines/template_url_id.h" |
| 18 #include "chrome/common/page_transition_types.h" | 18 #include "chrome/common/page_transition_types.h" |
| 19 #include "gfx/rect.h" | 19 #include "gfx/rect.h" |
| 20 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
| 21 | 21 |
| 22 struct AutocompleteMatch; | 22 struct AutocompleteMatch; |
| 23 class InstantDelegate; | 23 class InstantDelegate; |
| 24 class InstantLoaderManager; | 24 class InstantLoaderManager; |
| 25 class PrefService; | 25 class PrefService; |
| 26 class Profile; | |
| 27 class TabContents; | 26 class TabContents; |
| 28 class TemplateURL; | 27 class TemplateURL; |
| 29 | 28 |
| 30 // InstantController maintains a TabContents that is intended to give a preview | 29 // InstantController maintains a TabContents that is intended to give a preview |
| 31 // of a URL. InstantController is owned by Browser. | 30 // of a URL. InstantController is owned by Browser. |
| 32 // | 31 // |
| 33 // At any time the TabContents maintained by InstantController may be destroyed | 32 // At any time the TabContents maintained by InstantController may be destroyed |
| 34 // by way of |DestroyPreviewContents|, which results in |HideInstant| being | 33 // by way of |DestroyPreviewContents|, which results in |HideInstant| being |
| 35 // invoked on the delegate. Similarly the preview may be committed at any time | 34 // invoked on the delegate. Similarly the preview may be committed at any time |
| 36 // by invoking |CommitCurrentPreview|, which results in |CommitInstant| | 35 // by invoking |CommitCurrentPreview|, which results in |CommitInstant| |
| 37 // being invoked on the delegate. | 36 // being invoked on the delegate. |
| 38 class InstantController : public InstantLoaderDelegate { | 37 class InstantController : public InstantLoaderDelegate { |
| 39 public: | 38 public: |
| 40 explicit InstantController(InstantDelegate* delegate); | 39 explicit InstantController(InstantDelegate* delegate); |
| 41 ~InstantController(); | 40 ~InstantController(); |
| 42 | 41 |
| 43 // Registers instant related preferences. | 42 // Registers instant related preferences. |
| 44 static void RegisterUserPrefs(PrefService* prefs); | 43 static void RegisterUserPrefs(PrefService* prefs); |
| 45 | 44 |
| 46 // Is InstantController enabled? | 45 // Is InstantController enabled? |
| 47 static bool IsEnabled(Profile* profile); | 46 static bool IsEnabled(); |
| 48 | 47 |
| 49 // Invoked as the user types in the omnibox with the url to navigate to. If | 48 // Invoked as the user types in the omnibox with the url to navigate to. If |
| 50 // the url is empty and there is a preview TabContents it is destroyed. If url | 49 // the url is empty and there is a preview TabContents it is destroyed. If url |
| 51 // is non-empty and the preview TabContents has not been created it is | 50 // is non-empty and the preview TabContents has not been created it is |
| 52 // created. | 51 // created. |
| 53 void Update(TabContents* tab_contents, | 52 void Update(TabContents* tab_contents, |
| 54 const AutocompleteMatch& match, | 53 const AutocompleteMatch& match, |
| 55 const string16& user_text, | 54 const string16& user_text, |
| 56 string16* suggested_text); | 55 string16* suggested_text); |
| 57 | 56 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 186 |
| 188 base::OneShotTimer<InstantController> update_timer_; | 187 base::OneShotTimer<InstantController> update_timer_; |
| 189 | 188 |
| 190 // URL last pased to ScheduleUpdate. | 189 // URL last pased to ScheduleUpdate. |
| 191 GURL scheduled_url_; | 190 GURL scheduled_url_; |
| 192 | 191 |
| 193 DISALLOW_COPY_AND_ASSIGN(InstantController); | 192 DISALLOW_COPY_AND_ASSIGN(InstantController); |
| 194 }; | 193 }; |
| 195 | 194 |
| 196 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 195 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
| OLD | NEW |