OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "chrome/browser/search/instant_service_observer.h" | 12 #include "chrome/browser/search/instant_service_observer.h" |
13 #include "chrome/browser/ui/search/instant_controller.h" | 13 #include "chrome/browser/ui/search/instant_controller.h" |
14 #include "chrome/browser/ui/search/instant_unload_handler.h" | |
15 #include "chrome/browser/ui/search/search_model_observer.h" | 14 #include "chrome/browser/ui/search/search_model_observer.h" |
16 | 15 |
17 class Browser; | 16 class Browser; |
18 struct InstantSuggestion; | 17 struct InstantSuggestion; |
19 class Profile; | 18 class Profile; |
20 | 19 |
21 namespace content { | 20 namespace content { |
22 class WebContents; | 21 class WebContents; |
23 } | 22 } |
24 | 23 |
25 namespace gfx { | 24 namespace gfx { |
26 class Rect; | 25 class Rect; |
27 } | 26 } |
28 | 27 |
29 class BrowserInstantController : public SearchModelObserver, | 28 class BrowserInstantController : public SearchModelObserver, |
30 public InstantServiceObserver { | 29 public InstantServiceObserver { |
31 public: | 30 public: |
32 explicit BrowserInstantController(Browser* browser); | 31 explicit BrowserInstantController(Browser* browser); |
33 virtual ~BrowserInstantController(); | 32 virtual ~BrowserInstantController(); |
34 | 33 |
35 // If |url| is the new tab page URL, set |target_contents| to the preloaded | |
36 // NTP contents from InstantController. If |source_contents| is not NULL, we | |
37 // replace it with the new |target_contents| in the tabstrip and delete | |
38 // |source_contents|. Otherwise, the caller owns |target_contents| and is | |
39 // responsible for inserting it into the tabstrip. | |
40 // | |
41 // Returns true if and only if we update |target_contents|. | |
42 bool MaybeSwapInInstantNTPContents( | |
43 const GURL& url, | |
44 content::WebContents* source_contents, | |
45 content::WebContents** target_contents); | |
46 | |
47 // Commits the current Instant, returning true on success. This is intended | 34 // Commits the current Instant, returning true on success. This is intended |
48 // for use from OpenCurrentURL. | 35 // for use from OpenCurrentURL. |
49 bool OpenInstant(WindowOpenDisposition disposition, const GURL& url); | 36 bool OpenInstant(WindowOpenDisposition disposition, const GURL& url); |
50 | 37 |
51 // Returns the Profile associated with the Browser that owns this object. | 38 // Returns the Profile associated with the Browser that owns this object. |
52 Profile* profile() const; | 39 Profile* profile() const; |
53 | 40 |
54 // Returns the InstantController or NULL if there is no InstantController for | 41 // Returns the InstantController or NULL if there is no InstantController for |
55 // this BrowserInstantController. | 42 // this BrowserInstantController. |
56 InstantController* instant() { return &instant_; } | 43 InstantController* instant() { return &instant_; } |
(...skipping 24 matching lines...) Expand all Loading... |
81 void ReloadTabsInInstantProcess(); | 68 void ReloadTabsInInstantProcess(); |
82 | 69 |
83 // Replaces the contents at tab |index| with |new_contents| and deletes the | 70 // Replaces the contents at tab |index| with |new_contents| and deletes the |
84 // existing contents. | 71 // existing contents. |
85 void ReplaceWebContentsAt(int index, | 72 void ReplaceWebContentsAt(int index, |
86 scoped_ptr<content::WebContents> new_contents); | 73 scoped_ptr<content::WebContents> new_contents); |
87 | 74 |
88 Browser* const browser_; | 75 Browser* const browser_; |
89 | 76 |
90 InstantController instant_; | 77 InstantController instant_; |
91 InstantUnloadHandler instant_unload_handler_; | |
92 | 78 |
93 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); | 79 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); |
94 }; | 80 }; |
95 | 81 |
96 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ | 82 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ |
OLD | NEW |