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

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

Issue 5073002: Modifies the Instant loader to listen for RENDER_VIEW_HOST_CHANGED notificati... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/instant/instant_loader.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/scoped_ptr.h" 10 #include "base/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/common/notification_observer.h"
16 #include "chrome/common/notification_registrar.h"
15 #include "chrome/common/page_transition_types.h" 17 #include "chrome/common/page_transition_types.h"
16 #include "gfx/rect.h" 18 #include "gfx/rect.h"
17 #include "googleurl/src/gurl.h" 19 #include "googleurl/src/gurl.h"
18 20
19 class InstantLoaderDelegate; 21 class InstantLoaderDelegate;
20 class InstantLoaderManagerTest; 22 class InstantLoaderManagerTest;
21 class TabContents; 23 class TabContents;
22 class TemplateURL; 24 class TemplateURL;
23 25
24 // InstantLoader does the loading of a particular URL for InstantController. 26 // InstantLoader does the loading of a particular URL for InstantController.
25 // InstantLoader notifies its delegate, which is typically InstantController, of 27 // InstantLoader notifies its delegate, which is typically InstantController, of
26 // all interesting events. 28 // all interesting events.
27 // 29 //
28 // InstantLoader is created with a TemplateURLID. If non-zero InstantLoader 30 // InstantLoader is created with a TemplateURLID. If non-zero InstantLoader
29 // first determines if the site actually supports instant. If it doesn't, the 31 // first determines if the site actually supports instant. If it doesn't, the
30 // delegate is notified by way of |InstantLoaderDoesntSupportInstant|. 32 // delegate is notified by way of |InstantLoaderDoesntSupportInstant|.
31 // 33 //
32 // If the TemplateURLID supplied to the constructor is zero, then the url is 34 // If the TemplateURLID supplied to the constructor is zero, then the url is
33 // loaded as is. 35 // loaded as is.
34 class InstantLoader { 36 class InstantLoader : public NotificationObserver {
35 public: 37 public:
36 InstantLoader(InstantLoaderDelegate* delegate, TemplateURLID id); 38 InstantLoader(InstantLoaderDelegate* delegate, TemplateURLID id);
37 ~InstantLoader(); 39 virtual ~InstantLoader();
38 40
39 // Invoked to load a URL. |tab_contents| is the TabContents the preview is 41 // Invoked to load a URL. |tab_contents| is the TabContents the preview is
40 // going to be shown on top of and potentially replace. 42 // going to be shown on top of and potentially replace.
41 void Update(TabContents* tab_contents, 43 void Update(TabContents* tab_contents,
42 const TemplateURL* template_url, 44 const TemplateURL* template_url,
43 const GURL& url, 45 const GURL& url,
44 PageTransition::Type transition_type, 46 PageTransition::Type transition_type,
45 const string16& user_text, 47 const string16& user_text,
46 string16* suggested_text); 48 string16* suggested_text);
47 49
(...skipping 12 matching lines...) Expand all
60 TabContents* ReleasePreviewContents(InstantCommitType type); 62 TabContents* ReleasePreviewContents(InstantCommitType type);
61 63
62 // Calls through to method of same name on delegate. 64 // Calls through to method of same name on delegate.
63 bool ShouldCommitInstantOnMouseUp(); 65 bool ShouldCommitInstantOnMouseUp();
64 void CommitInstantLoader(); 66 void CommitInstantLoader();
65 67
66 // Resets the template_url_id_ to zero and shows this loader. This is only 68 // Resets the template_url_id_ to zero and shows this loader. This is only
67 // intended to be invoked from InstantLoaderDoesntSupportInstant. 69 // intended to be invoked from InstantLoaderDoesntSupportInstant.
68 void ClearTemplateURLID(); 70 void ClearTemplateURLID();
69 71
72 virtual void Observe(NotificationType type,
73 const NotificationSource& source,
74 const NotificationDetails& details);
75
70 // The preview TabContents; may be null. 76 // The preview TabContents; may be null.
71 TabContents* preview_contents() const { return preview_contents_.get(); } 77 TabContents* preview_contents() const { return preview_contents_.get(); }
72 78
73 // Returns true if the preview TabContents is ready to be shown. 79 // Returns true if the preview TabContents is ready to be shown.
74 bool ready() const { return ready_; } 80 bool ready() const { return ready_; }
75 81
76 const GURL& url() const { return url_; } 82 const GURL& url() const { return url_; }
77 83
78 // Are we showing instant results? 84 // Are we showing instant results?
79 bool is_showing_instant() const { return template_url_id_ != 0; } 85 bool is_showing_instant() const { return template_url_id_ != 0; }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 gfx::Rect last_omnibox_bounds_; 163 gfx::Rect last_omnibox_bounds_;
158 164
159 scoped_ptr<FrameLoadObserver> frame_load_observer_; 165 scoped_ptr<FrameLoadObserver> frame_load_observer_;
160 166
161 // Transition type of the match last passed to Update. 167 // Transition type of the match last passed to Update.
162 PageTransition::Type last_transition_type_; 168 PageTransition::Type last_transition_type_;
163 169
164 // Timer used to update the bounds of the omnibox. 170 // Timer used to update the bounds of the omnibox.
165 base::OneShotTimer<InstantLoader> update_bounds_timer_; 171 base::OneShotTimer<InstantLoader> update_bounds_timer_;
166 172
173 // Used to get notifications about renderers coming and going.
174 NotificationRegistrar registrar_;
175
167 DISALLOW_COPY_AND_ASSIGN(InstantLoader); 176 DISALLOW_COPY_AND_ASSIGN(InstantLoader);
168 }; 177 };
169 178
170 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_ 179 #endif // CHROME_BROWSER_INSTANT_INSTANT_LOADER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/instant/instant_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698