OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_INSTANT_INSTANT_LOADER_H_ | 5 #ifndef CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ |
6 #define CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ | 6 #define CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/string16.h" | 11 #include "base/string16.h" |
12 #include "base/timer.h" | 12 #include "base/timer.h" |
13 #include "chrome/browser/instant/instant_commit_type.h" | 13 #include "chrome/browser/instant/instant_commit_type.h" |
14 #include "chrome/browser/search_engines/template_url_id.h" | 14 #include "chrome/browser/search_engines/template_url_id.h" |
15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" | |
15 #include "chrome/common/instant_types.h" | 16 #include "chrome/common/instant_types.h" |
16 #include "content/common/notification_observer.h" | 17 #include "content/common/notification_observer.h" |
17 #include "content/common/notification_registrar.h" | 18 #include "content/common/notification_registrar.h" |
18 #include "content/common/page_transition_types.h" | 19 #include "content/common/page_transition_types.h" |
19 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
20 #include "ui/gfx/rect.h" | 21 #include "ui/gfx/rect.h" |
21 | 22 |
22 class InstantLoaderDelegate; | 23 class InstantLoaderDelegate; |
23 class InstantLoaderManagerTest; | 24 class InstantLoaderManagerTest; |
24 class TabContents; | 25 class TabContents; |
25 class TabContentsWrapper; | 26 class TabContentsWrapper; |
26 class TemplateURL; | 27 class TemplateURL; |
27 | 28 |
28 // InstantLoader does the loading of a particular URL for InstantController. | 29 // InstantLoader does the loading of a particular URL for InstantController. |
29 // InstantLoader notifies its delegate, which is typically InstantController, of | 30 // InstantLoader notifies its delegate, which is typically InstantController, of |
30 // all interesting events. | 31 // all interesting events. |
31 // | 32 // |
32 // InstantLoader is created with a TemplateURLID. If non-zero InstantLoader | 33 // InstantLoader is created with a TemplateURLID. If non-zero InstantLoader |
33 // first determines if the site actually supports instant. If it doesn't, the | 34 // first determines if the site actually supports instant. If it doesn't, the |
34 // delegate is notified by way of |InstantLoaderDoesntSupportInstant|. | 35 // delegate is notified by way of |InstantLoaderDoesntSupportInstant|. |
35 // | 36 // |
36 // If the TemplateURLID supplied to the constructor is zero, then the url is | 37 // If the TemplateURLID supplied to the constructor is zero, then the url is |
37 // loaded as is. | 38 // loaded as is. |
38 class InstantLoader : public NotificationObserver { | 39 class InstantLoader : public NotificationObserver, |
40 public TabContentsWrapperDelegate { | |
39 public: | 41 public: |
40 InstantLoader(InstantLoaderDelegate* delegate, TemplateURLID id); | 42 InstantLoader(InstantLoaderDelegate* delegate, TemplateURLID id); |
41 virtual ~InstantLoader(); | 43 virtual ~InstantLoader(); |
42 | 44 |
43 // Invoked to load a URL. |tab_contents| is the TabContents the preview is | 45 // Invoked to load a URL. |tab_contents| is the TabContents the preview is |
44 // going to be shown on top of and potentially replace. Returns true if the | 46 // going to be shown on top of and potentially replace. Returns true if the |
45 // arguments differ from the last call to |Update|. | 47 // arguments differ from the last call to |Update|. |
46 bool Update(TabContentsWrapper* tab_contents, | 48 bool Update(TabContentsWrapper* tab_contents, |
47 const TemplateURL* template_url, | 49 const TemplateURL* template_url, |
48 const GURL& url, | 50 const GURL& url, |
(...skipping 18 matching lines...) Expand all Loading... | |
67 | 69 |
68 // Calls through to method of same name on delegate. | 70 // Calls through to method of same name on delegate. |
69 bool ShouldCommitInstantOnMouseUp(); | 71 bool ShouldCommitInstantOnMouseUp(); |
70 void CommitInstantLoader(); | 72 void CommitInstantLoader(); |
71 | 73 |
72 // NotificationObserver: | 74 // NotificationObserver: |
73 virtual void Observe(NotificationType type, | 75 virtual void Observe(NotificationType type, |
74 const NotificationSource& source, | 76 const NotificationSource& source, |
75 const NotificationDetails& details) OVERRIDE; | 77 const NotificationDetails& details) OVERRIDE; |
76 | 78 |
79 // TabContentsWrapperDelegate implementation | |
80 virtual void SwapTabContents(TabContentsWrapper* old_tc, | |
81 TabContentsWrapper* new_tc); | |
sky
2011/05/19 19:53:55
OVERRIDE
dominich
2011/05/19 23:57:28
Done.
| |
82 | |
77 // The preview TabContents; may be null. | 83 // The preview TabContents; may be null. |
78 TabContentsWrapper* preview_contents() const { | 84 TabContentsWrapper* preview_contents() const { |
79 return preview_contents_.get(); | 85 return preview_contents_.get(); |
80 } | 86 } |
81 | 87 |
82 // Returns true if the preview TabContents is ready to be shown. | 88 // Returns true if the preview TabContents is ready to be shown. |
83 bool ready() const { return ready_; } | 89 bool ready() const { return ready_; } |
84 | 90 |
85 // Returns true if the current load returned a 200. | 91 // Returns true if the current load returned a 200. |
86 bool http_status_ok() const { return http_status_ok_; } | 92 bool http_status_ok() const { return http_status_ok_; } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 // Last value of verbatim passed to |Update|. | 210 // Last value of verbatim passed to |Update|. |
205 bool verbatim_; | 211 bool verbatim_; |
206 | 212 |
207 // True if the page needs to be reloaded. | 213 // True if the page needs to be reloaded. |
208 bool needs_reload_; | 214 bool needs_reload_; |
209 | 215 |
210 DISALLOW_COPY_AND_ASSIGN(InstantLoader); | 216 DISALLOW_COPY_AND_ASSIGN(InstantLoader); |
211 }; | 217 }; |
212 | 218 |
213 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ | 219 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ |
OLD | NEW |