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" |
14 #include "chrome/browser/ui/search/search_model_observer.h" | 15 #include "chrome/browser/ui/search/search_model_observer.h" |
15 | 16 |
16 class Browser; | 17 class Browser; |
17 struct InstantSuggestion; | 18 struct InstantSuggestion; |
18 class Profile; | 19 class Profile; |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 class WebContents; | 22 class WebContents; |
22 } | 23 } |
23 | 24 |
24 namespace gfx { | 25 namespace gfx { |
25 class Rect; | 26 class Rect; |
26 } | 27 } |
27 | 28 |
28 class BrowserInstantController : public SearchModelObserver, | 29 class BrowserInstantController : public SearchModelObserver, |
29 public InstantServiceObserver { | 30 public InstantServiceObserver { |
30 public: | 31 public: |
31 explicit BrowserInstantController(Browser* browser); | 32 explicit BrowserInstantController(Browser* browser); |
32 virtual ~BrowserInstantController(); | 33 virtual ~BrowserInstantController(); |
33 | 34 |
| 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 |
34 // Commits the current Instant, returning true on success. This is intended | 47 // Commits the current Instant, returning true on success. This is intended |
35 // for use from OpenCurrentURL. | 48 // for use from OpenCurrentURL. |
36 bool OpenInstant(WindowOpenDisposition disposition, const GURL& url); | 49 bool OpenInstant(WindowOpenDisposition disposition, const GURL& url); |
37 | 50 |
38 // Returns the Profile associated with the Browser that owns this object. | 51 // Returns the Profile associated with the Browser that owns this object. |
39 Profile* profile() const; | 52 Profile* profile() const; |
40 | 53 |
41 // Returns the InstantController or NULL if there is no InstantController for | 54 // Returns the InstantController or NULL if there is no InstantController for |
42 // this BrowserInstantController. | 55 // this BrowserInstantController. |
43 InstantController* instant() { return &instant_; } | 56 InstantController* instant() { return &instant_; } |
(...skipping 24 matching lines...) Expand all Loading... |
68 void ReloadTabsInInstantProcess(); | 81 void ReloadTabsInInstantProcess(); |
69 | 82 |
70 // Replaces the contents at tab |index| with |new_contents| and deletes the | 83 // Replaces the contents at tab |index| with |new_contents| and deletes the |
71 // existing contents. | 84 // existing contents. |
72 void ReplaceWebContentsAt(int index, | 85 void ReplaceWebContentsAt(int index, |
73 scoped_ptr<content::WebContents> new_contents); | 86 scoped_ptr<content::WebContents> new_contents); |
74 | 87 |
75 Browser* const browser_; | 88 Browser* const browser_; |
76 | 89 |
77 InstantController instant_; | 90 InstantController instant_; |
| 91 InstantUnloadHandler instant_unload_handler_; |
78 | 92 |
79 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); | 93 DISALLOW_COPY_AND_ASSIGN(BrowserInstantController); |
80 }; | 94 }; |
81 | 95 |
82 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ | 96 #endif // CHROME_BROWSER_UI_BROWSER_INSTANT_CONTROLLER_H_ |
OLD | NEW |