| 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_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" |
| 9 #include "base/compiler_specific.h" |
| 8 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/string16.h" |
| 9 #include "chrome/browser/instant/instant_controller_delegate.h" | 12 #include "chrome/browser/instant/instant_controller_delegate.h" |
| 10 #include "chrome/browser/prefs/pref_change_registrar.h" | 13 #include "chrome/browser/prefs/pref_change_registrar.h" |
| 11 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
| 15 #include "chrome/common/instant_types.h" |
| 12 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 13 #include "webkit/glue/window_open_disposition.h" | 17 #include "webkit/glue/window_open_disposition.h" |
| 14 | 18 |
| 15 class Browser; | 19 class Browser; |
| 16 class InstantController; | 20 class InstantController; |
| 21 class InstantTest; |
| 17 class InstantUnloadHandler; | 22 class InstantUnloadHandler; |
| 18 class TabContents; | 23 class TabContents; |
| 19 | 24 |
| 25 namespace content { |
| 26 class NotificationDetails; |
| 27 class NotificationSource; |
| 28 } |
| 29 |
| 30 namespace gfx { |
| 31 class Rect; |
| 32 } |
| 33 |
| 20 namespace chrome { | 34 namespace chrome { |
| 21 | 35 |
| 22 class BrowserInstantController : public InstantControllerDelegate, | 36 class BrowserInstantController : public InstantControllerDelegate, |
| 23 public TabStripModelObserver, | 37 public TabStripModelObserver, |
| 24 public content::NotificationObserver { | 38 public content::NotificationObserver { |
| 25 public: | 39 public: |
| 26 explicit BrowserInstantController(Browser* browser); | 40 explicit BrowserInstantController(Browser* browser); |
| 27 virtual ~BrowserInstantController(); | 41 virtual ~BrowserInstantController(); |
| 28 | 42 |
| 29 // Commits the current instant, returning true on success. This is intended | 43 // Commits the current Instant, returning true on success. This is intended |
| 30 // for use from OpenCurrentURL. | 44 // for use from OpenCurrentURL. |
| 31 bool OpenInstant(WindowOpenDisposition disposition); | 45 bool OpenInstant(WindowOpenDisposition disposition); |
| 32 | 46 |
| 33 // Returns the InstantController or NULL if there is no InstantController for | 47 // Returns the InstantController or NULL if there is no InstantController for |
| 34 // this BrowserInstantController. | 48 // this BrowserInstantController. |
| 35 InstantController* instant() const { return instant_.get(); } | 49 InstantController* instant() const { return instant_.get(); } |
| 36 | 50 |
| 37 private: | 51 private: |
| 38 // Overridden from InstantControllerDelegate: | 52 // Overridden from InstantControllerDelegate: |
| 39 virtual void ShowInstant(TabContents* preview_contents) OVERRIDE; | 53 virtual void ShowInstant() OVERRIDE; |
| 40 virtual void HideInstant() OVERRIDE; | 54 virtual void HideInstant() OVERRIDE; |
| 41 virtual void CommitInstant(TabContents* preview_contents) OVERRIDE; | 55 virtual void CommitInstant(TabContents* preview) OVERRIDE; |
| 42 virtual void SetSuggestedText(const string16& text, | 56 virtual void SetSuggestedText(const string16& text, |
| 43 InstantCompleteBehavior behavior) OVERRIDE; | 57 InstantCompleteBehavior behavior) OVERRIDE; |
| 44 virtual gfx::Rect GetInstantBounds() OVERRIDE; | 58 virtual gfx::Rect GetInstantBounds() OVERRIDE; |
| 45 virtual void InstantPreviewFocused() OVERRIDE; | 59 virtual void InstantPreviewFocused() OVERRIDE; |
| 46 virtual TabContents* GetInstantHostTabContents() const OVERRIDE; | 60 virtual TabContents* GetActiveTabContents() const OVERRIDE; |
| 47 | 61 |
| 48 // Overridden from content::NotificationObserver: | 62 // Overridden from content::NotificationObserver: |
| 49 virtual void Observe(int type, | 63 virtual void Observe(int type, |
| 50 const content::NotificationSource& source, | 64 const content::NotificationSource& source, |
| 51 const content::NotificationDetails& details) OVERRIDE; | 65 const content::NotificationDetails& details) OVERRIDE; |
| 52 | 66 |
| 53 // Overridden from TabStripModelObserver: | 67 // Overridden from TabStripModelObserver: |
| 54 virtual void TabDeactivated(TabContents* contents) OVERRIDE; | 68 virtual void TabDeactivated(TabContents* contents) OVERRIDE; |
| 55 | 69 |
| 56 // If this browser should have instant one is created, otherwise does nothing. | 70 // If this browser should have Instant, a new InstantController created; |
| 57 void CreateInstantIfNecessary(); | 71 // otherwise any existing InstantController is destroyed. |
| 72 void ResetInstant(); |
| 58 | 73 |
| 59 Browser* browser_; | 74 Browser* browser_; |
| 60 | 75 |
| 61 scoped_ptr<InstantController> instant_; | 76 scoped_ptr<InstantController> instant_; |
| 62 scoped_ptr<InstantUnloadHandler> instant_unload_handler_; | 77 scoped_ptr<InstantUnloadHandler> instant_unload_handler_; |
| 63 | 78 |
| 64 PrefChangeRegistrar profile_pref_registrar_; | 79 PrefChangeRegistrar profile_pref_registrar_; |
| 65 | 80 |
| 66 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); | 81 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); |
| 67 }; | 82 }; |
| 68 | 83 |
| 69 } // namespace chrome | 84 } // namespace chrome |
| 70 | 85 |
| 71 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ | 86 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ |
| OLD | NEW |