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