| 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" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/prefs/public/pref_change_registrar.h" | 11 #include "base/prefs/public/pref_change_registrar.h" |
| 12 #include "base/prefs/public/pref_observer.h" |
| 12 #include "base/string16.h" | 13 #include "base/string16.h" |
| 13 #include "chrome/browser/instant/instant_unload_handler.h" | 14 #include "chrome/browser/instant/instant_unload_handler.h" |
| 14 #include "chrome/browser/ui/search/search_model_observer.h" | 15 #include "chrome/browser/ui/search/search_model_observer.h" |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
| 16 #include "chrome/common/instant_types.h" | 17 #include "chrome/common/instant_types.h" |
| 17 #include "content/public/browser/notification_observer.h" | |
| 18 #include "webkit/glue/window_open_disposition.h" | 18 #include "webkit/glue/window_open_disposition.h" |
| 19 | 19 |
| 20 class Browser; | 20 class Browser; |
| 21 class InstantController; | 21 class InstantController; |
| 22 class InstantTest; | 22 class InstantTest; |
| 23 class TabContents; | 23 class TabContents; |
| 24 | 24 |
| 25 namespace content { | |
| 26 class NotificationDetails; | |
| 27 class NotificationSource; | |
| 28 } | |
| 29 | |
| 30 namespace gfx { | 25 namespace gfx { |
| 31 class Rect; | 26 class Rect; |
| 32 } | 27 } |
| 33 | 28 |
| 34 namespace chrome { | 29 namespace chrome { |
| 35 | 30 |
| 36 class BrowserInstantController : public TabStripModelObserver, | 31 class BrowserInstantController : public TabStripModelObserver, |
| 37 public search::SearchModelObserver, | 32 public search::SearchModelObserver, |
| 38 public content::NotificationObserver { | 33 public PrefObserver { |
| 39 public: | 34 public: |
| 40 explicit BrowserInstantController(Browser* browser); | 35 explicit BrowserInstantController(Browser* browser); |
| 41 virtual ~BrowserInstantController(); | 36 virtual ~BrowserInstantController(); |
| 42 | 37 |
| 43 // Commits the current Instant, returning true on success. This is intended | 38 // Commits the current Instant, returning true on success. This is intended |
| 44 // for use from OpenCurrentURL. | 39 // for use from OpenCurrentURL. |
| 45 bool OpenInstant(WindowOpenDisposition disposition); | 40 bool OpenInstant(WindowOpenDisposition disposition); |
| 46 | 41 |
| 47 // Returns the InstantController or NULL if there is no InstantController for | 42 // Returns the InstantController or NULL if there is no InstantController for |
| 48 // this BrowserInstantController. | 43 // this BrowserInstantController. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 60 gfx::Rect GetInstantBounds(); | 55 gfx::Rect GetInstantBounds(); |
| 61 | 56 |
| 62 // Invoked by |instant_| to notify that the preview gained focus, usually due | 57 // Invoked by |instant_| to notify that the preview gained focus, usually due |
| 63 // to the user clicking on it. | 58 // to the user clicking on it. |
| 64 void InstantPreviewFocused(); | 59 void InstantPreviewFocused(); |
| 65 | 60 |
| 66 // Invoked by |instant_| to get the currently active tab, over which the | 61 // Invoked by |instant_| to get the currently active tab, over which the |
| 67 // preview would be shown. | 62 // preview would be shown. |
| 68 TabContents* GetActiveTabContents() const; | 63 TabContents* GetActiveTabContents() const; |
| 69 | 64 |
| 70 // Overridden from content::NotificationObserver: | 65 // Overridden from PrefObserver: |
| 71 virtual void Observe(int type, | 66 virtual void OnPreferenceChanged(PrefServiceBase* service, |
| 72 const content::NotificationSource& source, | 67 const std::string& pref_name) OVERRIDE; |
| 73 const content::NotificationDetails& details) OVERRIDE; | |
| 74 | 68 |
| 75 // Overridden from TabStripModelObserver: | 69 // Overridden from TabStripModelObserver: |
| 76 virtual void TabDeactivated(TabContents* contents) OVERRIDE; | 70 virtual void TabDeactivated(TabContents* contents) OVERRIDE; |
| 77 | 71 |
| 78 // Overridden from search::SearchModelObserver: | 72 // Overridden from search::SearchModelObserver: |
| 79 virtual void ModeChanged(const search::Mode& old_mode, | 73 virtual void ModeChanged(const search::Mode& old_mode, |
| 80 const search::Mode& new_mode) OVERRIDE; | 74 const search::Mode& new_mode) OVERRIDE; |
| 81 | 75 |
| 82 // If this browser should have Instant, a new InstantController created; | 76 // If this browser should have Instant, a new InstantController created; |
| 83 // otherwise any existing InstantController is destroyed. | 77 // otherwise any existing InstantController is destroyed. |
| 84 void ResetInstant(); | 78 void ResetInstant(); |
| 85 | 79 |
| 86 Browser* browser_; | 80 Browser* browser_; |
| 87 | 81 |
| 88 scoped_ptr<InstantController> instant_; | 82 scoped_ptr<InstantController> instant_; |
| 89 InstantUnloadHandler instant_unload_handler_; | 83 InstantUnloadHandler instant_unload_handler_; |
| 90 | 84 |
| 91 PrefChangeRegistrar profile_pref_registrar_; | 85 PrefChangeRegistrar profile_pref_registrar_; |
| 92 | 86 |
| 93 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); | 87 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); |
| 94 }; | 88 }; |
| 95 | 89 |
| 96 } // namespace chrome | 90 } // namespace chrome |
| 97 | 91 |
| 98 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ | 92 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ |
| OLD | NEW |