• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #ifndef CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_
7 
8 #include <string>
9 
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"
15 
16 class Browser;
17 struct InstantSuggestion;
18 class Profile;
19 
20 namespace content {
21 class WebContents;
22 }
23 
24 class BrowserInstantController : public SearchModelObserver,
25                                  public InstantServiceObserver {
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, const GURL& url);
33 
34   // Returns the Profile associated with the Browser that owns this object.
35   Profile* profile() const;
36 
37   // Returns the InstantController or NULL if there is no InstantController for
38   // this BrowserInstantController.
instant()39   InstantController* instant() { return &instant_; }
40 
41   // Invoked by |instant_| to get the currently active tab.
42   content::WebContents* GetActiveWebContents() const;
43 
44   // Invoked by |browser_| when the active tab changes.
45   void ActiveTabChanged();
46 
47   // Invoked by |browser_| when the active tab is about to be deactivated.
48   void TabDeactivated(content::WebContents* contents);
49 
50  private:
51   // SearchModelObserver:
52   virtual void ModelChanged(const SearchModel::State& old_state,
53                             const SearchModel::State& new_state) OVERRIDE;
54 
55   // InstantServiceObserver:
56   virtual void DefaultSearchProviderChanged() OVERRIDE;
57 
58   // Replaces the contents at tab |index| with |new_contents| and deletes the
59   // existing contents.
60   void ReplaceWebContentsAt(int index,
61                             scoped_ptr<content::WebContents> new_contents);
62 
63   Browser* const browser_;
64 
65   InstantController instant_;
66 
67   DISALLOW_COPY_AND_ASSIGN(BrowserInstantController);
68 };
69 
70 #endif  // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_
71