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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "chrome/browser/search/instant_service_observer.h"
13 #include "chrome/browser/ui/search/instant_controller.h"
14 #include "chrome/browser/ui/search/search_model_observer.h"
17 struct InstantSuggestion
;
24 class BrowserInstantController
: public SearchModelObserver
,
25 public InstantServiceObserver
{
27 explicit BrowserInstantController(Browser
* browser
);
28 virtual ~BrowserInstantController();
30 // Commits the current Instant, returning true on success. This is intended
31 // for use from OpenCurrentURL.
32 bool OpenInstant(WindowOpenDisposition disposition
, const GURL
& url
);
34 // Returns the Profile associated with the Browser that owns this object.
35 Profile
* profile() const;
37 // Returns the InstantController or NULL if there is no InstantController for
38 // this BrowserInstantController.
39 InstantController
* instant() { return &instant_
; }
41 // Invoked by |instant_| to get the currently active tab.
42 content::WebContents
* GetActiveWebContents() const;
44 // Invoked by |browser_| when the active tab changes.
45 void ActiveTabChanged();
47 // Invoked by |browser_| when the active tab is about to be deactivated.
48 void TabDeactivated(content::WebContents
* contents
);
51 // SearchModelObserver:
52 virtual void ModelChanged(const SearchModel::State
& old_state
,
53 const SearchModel::State
& new_state
) OVERRIDE
;
55 // InstantServiceObserver:
56 virtual void DefaultSearchProviderChanged() OVERRIDE
;
58 // Replaces the contents at tab |index| with |new_contents| and deletes the
60 void ReplaceWebContentsAt(int index
,
61 scoped_ptr
<content::WebContents
> new_contents
);
63 Browser
* const browser_
;
65 InstantController instant_
;
67 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController
);
70 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_