Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: chrome/browser/instant/instant_loader.h

Issue 7034043: Prerender/Instant interopability. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup and consolidate code Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 {
sky 2011/05/20 15:57:36 Make TabContentsWrapperDelegate implement this. It
dominich 2011/05/20 16:39:53 Done.
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
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) OVERRIDE;
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 void PageDoesntSupportInstant(bool needs_reload); 149 void PageDoesntSupportInstant(bool needs_reload);
144 150
145 // Invokes |SetBoundsToPage(false)|. This is called from the timer. 151 // Invokes |SetBoundsToPage(false)|. This is called from the timer.
146 void ProcessBoundsChange(); 152 void ProcessBoundsChange();
147 153
148 // Notifes the page of the omnibox bounds. If |force_if_loading| is true the 154 // Notifes the page of the omnibox bounds. If |force_if_loading| is true the
149 // bounds are sent down even if we're waiting on the load, otherwise if we're 155 // bounds are sent down even if we're waiting on the load, otherwise if we're
150 // waiting on the load and |force_if_loading| is false this does nothing. 156 // waiting on the load and |force_if_loading| is false this does nothing.
151 void SendBoundsToPage(bool force_if_loading); 157 void SendBoundsToPage(bool force_if_loading);
152 158
159 // Called to set up the preview_contents_ when it is created or replaced.
sky 2011/05/20 15:57:36 preview_contents_ -> |tab_contents| But looking at
dominich 2011/05/20 16:39:53 The implementation should be using preview_content
sky 2011/05/20 18:54:19 My mistake. I was assuming tab_contents is the new
160 void SetupPreviewContents(TabContentsWrapper* tab_contents);
161
153 // Creates and sets the preview TabContentsWrapper. 162 // Creates and sets the preview TabContentsWrapper.
154 void CreatePreviewContents(TabContentsWrapper* tab_contents); 163 void CreatePreviewContents(TabContentsWrapper* tab_contents);
155 164
156 InstantLoaderDelegate* delegate_; 165 InstantLoaderDelegate* delegate_;
157 166
158 // If we're showing instant results this is the ID of the TemplateURL driving 167 // If we're showing instant results this is the ID of the TemplateURL driving
159 // the results. A value of 0 means there is no TemplateURL. 168 // the results. A value of 0 means there is no TemplateURL.
160 const TemplateURLID template_url_id_; 169 const TemplateURLID template_url_id_;
161 170
162 // The url we're displaying. 171 // The url we're displaying.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // Last value of verbatim passed to |Update|. 213 // Last value of verbatim passed to |Update|.
205 bool verbatim_; 214 bool verbatim_;
206 215
207 // True if the page needs to be reloaded. 216 // True if the page needs to be reloaded.
208 bool needs_reload_; 217 bool needs_reload_;
209 218
210 DISALLOW_COPY_AND_ASSIGN(InstantLoader); 219 DISALLOW_COPY_AND_ASSIGN(InstantLoader);
211 }; 220 };
212 221
213 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ 222 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/instant/instant_loader.cc » ('j') | chrome/browser/instant/instant_loader.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698