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

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

Issue 11824050: InstantExtended: Committed NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 7 years, 10 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
OLDNEW
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 #include "chrome/browser/instant/instant_loader.h" 5 #include "chrome/browser/instant/instant_loader.h"
6 6
7 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 7 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
8 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" 8 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h"
9 #include "chrome/browser/favicon/favicon_tab_helper.h" 9 #include "chrome/browser/favicon/favicon_tab_helper.h"
10 #include "chrome/browser/history/history_tab_helper.h" 10 #include "chrome/browser/history/history_tab_helper.h"
11 #include "chrome/browser/instant/instant_controller.h"
12 #include "chrome/browser/safe_browsing/safe_browsing_tab_observer.h" 11 #include "chrome/browser/safe_browsing/safe_browsing_tab_observer.h"
12 #include "chrome/browser/tab_contents/tab_util.h"
13 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" 13 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
14 #include "chrome/browser/ui/search/search_tab_helper.h" 14 #include "chrome/browser/ui/search/search_tab_helper.h"
15 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" 15 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
16 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" 16 #include "content/public/browser/navigation_entry.h"
17 #include "content/public/browser/notification_source.h" 17 #include "content/public/browser/notification_source.h"
18 #include "content/public/browser/notification_types.h" 18 #include "content/public/browser/notification_types.h"
19 #include "content/public/browser/render_widget_host_view.h" 19 #include "content/public/browser/render_widget_host_view.h"
20 #include "content/public/browser/site_instance.h" 20 #include "content/public/browser/site_instance.h"
21 #include "content/public/browser/web_contents_delegate.h"
22 #include "content/public/browser/web_contents_view.h" 21 #include "content/public/browser/web_contents_view.h"
23 #include "ipc/ipc_message.h"
24 22
25 namespace { 23 namespace {
26 24
27 int kUserDataKey; 25 const int kStalePageTimeoutMS = 3 * 3600 * 1000; // 3 hours
28 26
29 class InstantLoaderUserData : public base::SupportsUserData::Data { 27 } // namespace
30 public:
31 explicit InstantLoaderUserData(InstantLoader* loader) : loader_(loader) {}
32 28
33 InstantLoader* loader() const { return loader_; } 29 InstantLoader::Delegate::~Delegate() {
34
35 private:
36 ~InstantLoaderUserData() {}
37
38 InstantLoader* const loader_;
39
40 DISALLOW_COPY_AND_ASSIGN(InstantLoaderUserData);
41 };
42
43 } 30 }
44 31
45 // WebContentsDelegateImpl ----------------------------------------------------- 32 InstantLoader::InstantLoader(Delegate* delegate)
46 33 : delegate_(delegate),
47 class InstantLoader::WebContentsDelegateImpl 34 contents_(NULL),
48 : public CoreTabHelperDelegate, 35 stale_page_timer_(false, false) {
49 public content::WebContentsDelegate {
50 public:
51 explicit WebContentsDelegateImpl(InstantLoader* loader);
52
53 private:
54 // Overridden from CoreTabHelperDelegate:
55 virtual void SwapTabContents(content::WebContents* old_contents,
56 content::WebContents* new_contents) OVERRIDE;
57
58 // Overridden from content::WebContentsDelegate:
59 virtual bool ShouldSuppressDialogs() OVERRIDE;
60 virtual bool ShouldFocusPageAfterCrash() OVERRIDE;
61 virtual void LostCapture() OVERRIDE;
62 virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE;
63 virtual bool CanDownload(content::RenderViewHost* render_view_host,
64 int request_id,
65 const std::string& request_method) OVERRIDE;
66 virtual void HandleMouseDown() OVERRIDE;
67 virtual void HandleMouseUp() OVERRIDE;
68 virtual void HandlePointerActivate() OVERRIDE;
69 virtual void HandleGestureEnd() OVERRIDE;
70 virtual void DragEnded() OVERRIDE;
71 virtual bool OnGoToEntryOffset(int offset) OVERRIDE;
72 virtual content::WebContents* OpenURLFromTab(
73 content::WebContents* source,
74 const content::OpenURLParams& params) OVERRIDE;
75
76 void MaybeCommitFromPointerRelease();
77
78 InstantLoader* const loader_;
79
80 DISALLOW_COPY_AND_ASSIGN(WebContentsDelegateImpl);
81 };
82
83 InstantLoader::WebContentsDelegateImpl::WebContentsDelegateImpl(
84 InstantLoader* loader)
85 : loader_(loader) {
86 }
87
88 void InstantLoader::WebContentsDelegateImpl::SwapTabContents(
89 content::WebContents* old_contents,
90 content::WebContents* new_contents) {
91 // If this is being called, something is swapping in to loader's |contents_|
92 // before we've added it to the tab strip.
93 loader_->ReplacePreviewContents(old_contents, new_contents);
94 }
95
96 bool InstantLoader::WebContentsDelegateImpl::ShouldSuppressDialogs() {
97 // Any message shown during Instant cancels Instant, so we suppress them.
98 return true;
99 }
100
101 bool InstantLoader::WebContentsDelegateImpl::ShouldFocusPageAfterCrash() {
102 return false;
103 }
104
105 void InstantLoader::WebContentsDelegateImpl::LostCapture() {
106 MaybeCommitFromPointerRelease();
107 }
108
109 void InstantLoader::WebContentsDelegateImpl::WebContentsFocused(
110 content::WebContents* /* contents */) {
111 // The preview is getting focus. Equivalent to it being clicked.
112 bool tmp = loader_->is_pointer_down_from_activate_;
113 loader_->is_pointer_down_from_activate_ = true;
114 loader_->controller_->InstantLoaderContentsFocused();
115 loader_->is_pointer_down_from_activate_ = tmp;
116 }
117
118 bool InstantLoader::WebContentsDelegateImpl::CanDownload(
119 content::RenderViewHost* /* render_view_host */,
120 int /* request_id */,
121 const std::string& /* request_method */) {
122 // Downloads are disabled.
123 return false;
124 }
125
126 void InstantLoader::WebContentsDelegateImpl::HandleMouseDown() {
127 loader_->is_pointer_down_from_activate_ = true;
128 }
129
130 void InstantLoader::WebContentsDelegateImpl::HandleMouseUp() {
131 MaybeCommitFromPointerRelease();
132 }
133
134 void InstantLoader::WebContentsDelegateImpl::HandlePointerActivate() {
135 loader_->is_pointer_down_from_activate_ = true;
136 }
137
138 void InstantLoader::WebContentsDelegateImpl::HandleGestureEnd() {
139 MaybeCommitFromPointerRelease();
140 }
141
142 void InstantLoader::WebContentsDelegateImpl::DragEnded() {
143 // If the user drags, we won't get a mouse up (at least on Linux). Commit the
144 // Instant result when the drag ends, so that during the drag the page won't
145 // move around.
146 MaybeCommitFromPointerRelease();
147 }
148
149 bool InstantLoader::WebContentsDelegateImpl::OnGoToEntryOffset(int offset) {
150 return false;
151 }
152
153 content::WebContents* InstantLoader::WebContentsDelegateImpl::OpenURLFromTab(
154 content::WebContents* source,
155 const content::OpenURLParams& params) {
156 content::WebContents* preview = loader_->contents_.get();
157 if (loader_->controller_->CommitIfPossible(INSTANT_COMMIT_NAVIGATED))
158 return preview->GetDelegate()->OpenURLFromTab(source, params);
159 return NULL;
160 }
161
162 void InstantLoader::WebContentsDelegateImpl::MaybeCommitFromPointerRelease() {
163 if (loader_->is_pointer_down_from_activate_) {
164 loader_->is_pointer_down_from_activate_ = false;
165 loader_->controller_->CommitIfPossible(INSTANT_COMMIT_FOCUS_LOST);
166 }
167 }
168
169 // InstantLoader ---------------------------------------------------------------
170
171 // static
172 InstantLoader* InstantLoader::FromWebContents(
173 const content::WebContents* web_contents) {
174 InstantLoaderUserData* data = static_cast<InstantLoaderUserData*>(
175 web_contents->GetUserData(&kUserDataKey));
176 return data ? data->loader() : NULL;
177 }
178
179 InstantLoader::InstantLoader(InstantController* controller,
180 const std::string& instant_url)
181 : client_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
182 controller_(controller),
183 delegate_(new WebContentsDelegateImpl(
184 ALLOW_THIS_IN_INITIALIZER_LIST(this))),
185 instant_url_(instant_url),
186 supports_instant_(false),
187 is_pointer_down_from_activate_(false) {
188 } 36 }
189 37
190 InstantLoader::~InstantLoader() { 38 InstantLoader::~InstantLoader() {
191 } 39 }
192 40
193 void InstantLoader::InitContents(const content::WebContents* active_tab) { 41 void InstantLoader::Load(const GURL& instant_url,
194 content::WebContents::CreateParams create_params( 42 Profile* profile,
195 active_tab->GetBrowserContext(), 43 const content::WebContents* active_tab,
196 active_tab->GetSiteInstance()->GetRelatedSiteInstance( 44 const base::Closure& on_stale_callback) {
197 GURL(instant_url_))); 45 content::WebContents::CreateParams create_params(profile);
198 if (active_tab) 46
47 if (active_tab) {
199 create_params.initial_size = active_tab->GetView()->GetContainerSize(); 48 create_params.initial_size = active_tab->GetView()->GetContainerSize();
200 contents_.reset(content::WebContents::CreateWithSessionStorage( 49 create_params.site_instance = active_tab->GetSiteInstance()->
201 create_params, 50 GetRelatedSiteInstance(instant_url);
202 active_tab->GetController().GetSessionStorageNamespaceMap())); 51 } else {
203 SetupPreviewContents(); 52 create_params.site_instance = content::SiteInstance::CreateForURL(
53 profile, instant_url);
54 }
55
56 SetContents(scoped_ptr<content::WebContents>(
57 content::WebContents::Create(create_params)));
204 58
205 // This HTTP header and value are set on loads that originate from Instant. 59 // This HTTP header and value are set on loads that originate from Instant.
206 const char kInstantHeader[] = "X-Purpose: Instant"; 60 const char kInstantHeader[] = "X-Purpose: Instant";
207 DVLOG(1) << "LoadURL: " << instant_url_; 61 DVLOG(1) << "LoadURL: " << instant_url.spec();
sreeram 2013/01/29 13:35:42 No need for the ".spec()". GURL provides an overlo
samarth 2013/01/31 16:24:57 Done.
208 contents_->GetController().LoadURL(GURL(instant_url_), content::Referrer(), 62 contents_->GetController().LoadURL(
63 instant_url, content::Referrer(),
209 content::PAGE_TRANSITION_GENERATED, kInstantHeader); 64 content::PAGE_TRANSITION_GENERATED, kInstantHeader);
210 contents_->WasHidden(); 65 contents_->WasHidden();
66
67 stale_page_timer_.Start(
68 FROM_HERE,
69 base::TimeDelta::FromMilliseconds(kStalePageTimeoutMS),
70 on_stale_callback);
211 } 71 }
212 72
213 content::WebContents* InstantLoader::ReleaseContents() { 73 void InstantLoader::SetContents(scoped_ptr<content::WebContents> new_contents) {
214 CleanupPreviewContents(); 74 contents_.reset(new_contents.release());
215 return contents_.release(); 75 contents_->SetDelegate(this);
216 }
217
218 void InstantLoader::DidNavigate(
219 const history::HistoryAddPageArgs& add_page_args) {
220 last_navigation_ = add_page_args;
221 }
222
223 bool InstantLoader::IsUsingLocalPreview() const {
224 return instant_url_ == InstantController::kLocalOmniboxPopupURL;
225 }
226
227 void InstantLoader::Update(const string16& text,
228 size_t selection_start,
229 size_t selection_end,
230 bool verbatim) {
231 last_navigation_ = history::HistoryAddPageArgs();
232 client_.Update(text, selection_start, selection_end, verbatim);
233 }
234
235 void InstantLoader::Submit(const string16& text) {
236 client_.Submit(text);
237 }
238
239 void InstantLoader::Cancel(const string16& text) {
240 client_.Cancel(text);
241 }
242
243 void InstantLoader::SetPopupBounds(const gfx::Rect& bounds) {
244 client_.SetPopupBounds(bounds);
245 }
246
247 void InstantLoader::SetMarginSize(int start, int end) {
248 client_.SetMarginSize(start, end);
249 }
250
251 void InstantLoader::SendAutocompleteResults(
252 const std::vector<InstantAutocompleteResult>& results) {
253 client_.SendAutocompleteResults(results);
254 }
255
256 void InstantLoader::UpOrDownKeyPressed(int count) {
257 client_.UpOrDownKeyPressed(count);
258 }
259
260 void InstantLoader::SearchModeChanged(const chrome::search::Mode& mode) {
261 client_.SearchModeChanged(mode);
262 }
263
264 void InstantLoader::SendThemeBackgroundInfo(
265 const ThemeBackgroundInfo& theme_info) {
266 client_.SendThemeBackgroundInfo(theme_info);
267 }
268
269 void InstantLoader::SendThemeAreaHeight(int height) {
270 client_.SendThemeAreaHeight(height);
271 }
272
273 void InstantLoader::SetDisplayInstantResults(bool display_instant_results) {
274 client_.SetDisplayInstantResults(display_instant_results);
275 }
276
277 void InstantLoader::KeyCaptureChanged(bool is_key_capture_enabled) {
278 client_.KeyCaptureChanged(is_key_capture_enabled);
279 }
280
281 void InstantLoader::SetSuggestions(
282 const std::vector<InstantSuggestion>& suggestions) {
283 InstantSupportDetermined(true);
284 controller_->SetSuggestions(contents(), suggestions);
285 }
286
287 void InstantLoader::InstantSupportDetermined(bool supports_instant) {
288 // If we had already determined that the page supports Instant, nothing to do.
289 if (supports_instant_)
290 return;
291
292 supports_instant_ = supports_instant;
293 controller_->InstantSupportDetermined(contents(), supports_instant);
294 }
295
296 void InstantLoader::ShowInstantPreview(InstantShownReason reason,
297 int height,
298 InstantSizeUnits units) {
299 InstantSupportDetermined(true);
300 controller_->ShowInstantPreview(reason, height, units);
301 }
302
303 void InstantLoader::StartCapturingKeyStrokes() {
304 InstantSupportDetermined(true);
305 controller_->StartCapturingKeyStrokes();
306 }
307
308 void InstantLoader::StopCapturingKeyStrokes() {
309 InstantSupportDetermined(true);
310 controller_->StopCapturingKeyStrokes();
311 }
312
313 void InstantLoader::RenderViewGone() {
314 controller_->InstantLoaderRenderViewGone();
315 }
316
317 void InstantLoader::AboutToNavigateMainFrame(const GURL& url) {
318 controller_->InstantLoaderAboutToNavigateMainFrame(url);
319 }
320
321 void InstantLoader::NavigateToURL(const GURL& url,
322 content::PageTransition transition) {
323 InstantSupportDetermined(true);
324 controller_->NavigateToURL(url, transition);
325 }
326
327 void InstantLoader::Observe(int type,
328 const content::NotificationSource& source,
329 const content::NotificationDetails& details) {
330 #if defined(OS_MACOSX)
331 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) {
332 if (content::RenderWidgetHostView* rwhv =
333 contents_->GetRenderWidgetHostView())
334 rwhv->SetTakesFocusOnlyOnMouseDown(true);
335 return;
336 }
337 NOTREACHED();
338 #endif
339 }
340
341 void InstantLoader::SetupPreviewContents() {
342 client_.SetContents(contents());
343 contents_->SetUserData(&kUserDataKey, new InstantLoaderUserData(this));
344 contents_->SetDelegate(delegate_.get());
345 76
346 // Set up various tab helpers. The rest will get attached when (if) the 77 // Set up various tab helpers. The rest will get attached when (if) the
347 // contents is added to the tab strip. 78 // contents is added to the tab strip.
348 79
349 // Tab helpers to control popups. 80 // Tab helpers to control popups.
350 BlockedContentTabHelper::CreateForWebContents(contents()); 81 BlockedContentTabHelper::CreateForWebContents(contents());
351 BlockedContentTabHelper::FromWebContents(contents())-> 82 BlockedContentTabHelper::FromWebContents(contents())->
352 SetAllContentsBlocked(true); 83 SetAllContentsBlocked(true);
353 TabSpecificContentSettings::CreateForWebContents(contents()); 84 TabSpecificContentSettings::CreateForWebContents(contents());
354 TabSpecificContentSettings::FromWebContents(contents())-> 85 TabSpecificContentSettings::FromWebContents(contents())->
355 SetPopupsBlocked(true); 86 SetPopupsBlocked(true);
356 87
357 // A tab helper to catch prerender content swapping shenanigans. 88 // A tab helper to catch prerender content swapping shenanigans.
358 CoreTabHelper::CreateForWebContents(contents()); 89 CoreTabHelper::CreateForWebContents(contents());
359 CoreTabHelper::FromWebContents(contents())->set_delegate(delegate_.get()); 90 CoreTabHelper::FromWebContents(contents())->set_delegate(this);
360 91
361 // Tab helpers used when committing a preview. 92 // Tab helpers used when committing a preview.
362 chrome::search::SearchTabHelper::CreateForWebContents(contents()); 93 chrome::search::SearchTabHelper::CreateForWebContents(contents());
363 HistoryTabHelper::CreateForWebContents(contents()); 94 HistoryTabHelper::CreateForWebContents(contents());
364 95
365 // Observers. 96 // Observers.
366 extensions::WebNavigationTabObserver::CreateForWebContents(contents()); 97 extensions::WebNavigationTabObserver::CreateForWebContents(contents());
367 98
368 // Favicons, required by the Task Manager. 99 // Favicons, required by the Task Manager.
369 FaviconTabHelper::CreateForWebContents(contents()); 100 FaviconTabHelper::CreateForWebContents(contents());
370 101
371 // And some flat-out paranoia. 102 // And some flat-out paranoia.
372 safe_browsing::SafeBrowsingTabObserver::CreateForWebContents(contents()); 103 safe_browsing::SafeBrowsingTabObserver::CreateForWebContents(contents());
373 104
374 #if defined(OS_MACOSX) 105 #if defined(OS_MACOSX)
375 // If |contents_| doesn't yet have a RWHV, SetTakesFocusOnlyOnMouseDown() will 106 // If |contents_| doesn't yet have a RWHV, SetTakesFocusOnlyOnMouseDown() will
376 // be called later, when NOTIFICATION_RENDER_VIEW_HOST_CHANGED is received. 107 // be called later, when NOTIFICATION_RENDER_VIEW_HOST_CHANGED is received.
377 if (content::RenderWidgetHostView* rwhv = 108 if (content::RenderWidgetHostView* rwhv =
378 contents_->GetRenderWidgetHostView()) 109 contents_->GetRenderWidgetHostView())
379 rwhv->SetTakesFocusOnlyOnMouseDown(true); 110 rwhv->SetTakesFocusOnlyOnMouseDown(true);
380 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 111 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
381 content::Source<content::NavigationController>( 112 content::Source<content::NavigationController>(
382 &contents_->GetController())); 113 &contents_->GetController()));
383 #endif 114 #endif
384 } 115 }
385 116
386 void InstantLoader::CleanupPreviewContents() { 117 scoped_ptr<content::WebContents> InstantLoader::ReleaseContents() {
387 client_.SetContents(NULL);
388 contents_->RemoveUserData(&kUserDataKey);
389 contents_->SetDelegate(NULL); 118 contents_->SetDelegate(NULL);
390 119
391 // Undo tab helper work done in SetupPreviewContents(). 120 // Undo tab helper work done in SetupPreviewContents().
sreeram 2013/01/29 13:35:42 SetupPreviewContents() -> SetContents().
samarth 2013/01/31 16:24:57 Done.
392 121
393 BlockedContentTabHelper::FromWebContents(contents())-> 122 BlockedContentTabHelper::FromWebContents(contents())->
394 SetAllContentsBlocked(false); 123 SetAllContentsBlocked(false);
395 TabSpecificContentSettings::FromWebContents(contents())-> 124 TabSpecificContentSettings::FromWebContents(contents())->
396 SetPopupsBlocked(false); 125 SetPopupsBlocked(false);
397 126
398 CoreTabHelper::FromWebContents(contents())->set_delegate(NULL); 127 CoreTabHelper::FromWebContents(contents())->set_delegate(NULL);
399 128
400 #if defined(OS_MACOSX) 129 #if defined(OS_MACOSX)
401 if (content::RenderWidgetHostView* rwhv = 130 if (content::RenderWidgetHostView* rwhv =
402 contents_->GetRenderWidgetHostView()) 131 contents_->GetRenderWidgetHostView())
403 rwhv->SetTakesFocusOnlyOnMouseDown(false); 132 rwhv->SetTakesFocusOnlyOnMouseDown(false);
404 registrar_.Remove(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 133 registrar_.Remove(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
405 content::Source<content::NavigationController>( 134 content::Source<content::NavigationController>(
406 &contents_->GetController())); 135 &contents_->GetController()));
407 #endif 136 #endif
137
138 return contents_.Pass();
408 } 139 }
409 140
410 void InstantLoader::ReplacePreviewContents(content::WebContents* old_contents, 141 void InstantLoader::Observe(int type,
411 content::WebContents* new_contents) { 142 const content::NotificationSource& source,
143 const content::NotificationDetails& details) {
sreeram 2013/01/29 13:35:42 Comment out source and details.
samarth 2013/01/31 16:24:57 Done.
144 #if defined(OS_MACOSX)
145 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) {
146 if (content::RenderWidgetHostView* rwhv =
147 contents_->GetRenderWidgetHostView())
148 rwhv->SetTakesFocusOnlyOnMouseDown(true);
149 return;
150 }
151 NOTREACHED();
152 #endif
153 }
154
155 void InstantLoader::SwapTabContents(content::WebContents* old_contents,
156 content::WebContents* new_contents) {
412 DCHECK_EQ(old_contents, contents()); 157 DCHECK_EQ(old_contents, contents());
413 CleanupPreviewContents(); 158 // We release here without deleting since the caller has the responsibility
414 // We release here without deleting so that the caller still has the 159 // for deleting the old WebContents.
415 // responsibility for deleting the WebContents. 160 scoped_ptr<content::WebContents> released_contents =
416 ignore_result(contents_.release()); 161 delegate_->SwapContents(scoped_ptr<content::WebContents>(new_contents));
417 contents_.reset(new_contents); 162 ignore_result(released_contents.release());
418 SetupPreviewContents();
419 controller_->SwappedWebContents();
420 } 163 }
164
165 // Overridden from content::WebContentsDelegate:
sreeram 2013/01/29 13:35:42 No need for this comment.
samarth 2013/01/31 16:24:57 Done.
166 bool InstantLoader::ShouldSuppressDialogs() {
167 // Any message shown during Instant cancels Instant, so we suppress them.
sreeram 2013/01/29 13:35:42 Any message -> Messages (to match the "them" and .
samarth 2013/01/31 16:24:57 Done.
168 return true;
169 }
170
171 bool InstantLoader::ShouldFocusPageAfterCrash() {
172 return false;
173 }
174
175 void InstantLoader::LostCapture() {
176 delegate_->OnMouseUp();
177 }
178
179 void InstantLoader::WebContentsFocused(content::WebContents* contents) {
sreeram 2013/01/29 13:35:42 /* contents */
samarth 2013/01/31 16:24:57 Done.
jam 2013/02/01 17:44:34 btw i just saw this. this isn't chrome style. plea
sreeram 2013/02/01 17:50:02 This style is in fact explicitly mentioned in the
180 delegate_->OnFocus();
181 }
182
183 bool InstantLoader::CanDownload(content::RenderViewHost*,
184 int,
185 const std::string&) {
sreeram 2013/01/29 13:35:42 Provide the names of the parameters, but comment t
samarth 2013/01/31 16:24:57 Done.
186 // Downloads are disabled.
187 return false;
188 }
189
190 void InstantLoader::HandleMouseDown() {
191 delegate_->OnMouseDown();
192 }
193
194 void InstantLoader::HandleMouseUp() {
195 delegate_->OnMouseUp();
196 }
197
198 void InstantLoader::HandlePointerActivate() {
199 delegate_->OnMouseDown();
200 }
201
202 void InstantLoader::HandleGestureEnd() {
203 delegate_->OnMouseUp();
204 }
205
206 void InstantLoader::DragEnded() {
207 // If the user drags, we won't get a mouse up (at least on Linux). Commit
208 // the Instant result when the drag ends, so that during the drag the page
209 // won't move around.
210 delegate_->OnMouseUp();
211 }
212
213 bool InstantLoader::OnGoToEntryOffset(int offset) {
sreeram 2013/01/29 13:35:42 /* offset */
samarth 2013/01/31 16:24:57 Done.
214 return false;
215 }
216
217 content::WebContents* InstantLoader::OpenURLFromTab(
218 content::WebContents* source,
219 const content::OpenURLParams& params) {
220 if (delegate_->OnOpenURL())
221 return contents_->GetDelegate()->OpenURLFromTab(source, params);
sreeram 2013/01/29 13:35:42 Isn't this an infinite recursion? contents_->GetDe
samarth 2013/01/31 16:24:57 See my comments in the header about this. (There
222 return NULL;
223 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698