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

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: Rebase. 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(
dhollowa 2013/01/29 02:37:53 I believe this is ok, but please double-check with
samarth 2013/01/29 05:42:01 Ok, will do.
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();
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())->
dhollowa 2013/01/29 02:37:53 nit: This should fit on one line.
samarth 2013/01/29 05:42:01 Done.
91 set_delegate(this);
360 92
361 // Tab helpers used when committing a preview. 93 // Tab helpers used when committing a preview.
362 chrome::search::SearchTabHelper::CreateForWebContents(contents()); 94 chrome::search::SearchTabHelper::CreateForWebContents(contents());
363 HistoryTabHelper::CreateForWebContents(contents()); 95 HistoryTabHelper::CreateForWebContents(contents());
364 96
365 // Observers. 97 // Observers.
366 extensions::WebNavigationTabObserver::CreateForWebContents(contents()); 98 extensions::WebNavigationTabObserver::CreateForWebContents(contents());
367 99
368 // Favicons, required by the Task Manager. 100 // Favicons, required by the Task Manager.
369 FaviconTabHelper::CreateForWebContents(contents()); 101 FaviconTabHelper::CreateForWebContents(contents());
370 102
371 // And some flat-out paranoia. 103 // And some flat-out paranoia.
372 safe_browsing::SafeBrowsingTabObserver::CreateForWebContents(contents()); 104 safe_browsing::SafeBrowsingTabObserver::CreateForWebContents(contents());
373 105
374 #if defined(OS_MACOSX) 106 #if defined(OS_MACOSX)
375 // If |contents_| doesn't yet have a RWHV, SetTakesFocusOnlyOnMouseDown() will 107 // If |contents_| doesn't yet have a RWHV, SetTakesFocusOnlyOnMouseDown() will
376 // be called later, when NOTIFICATION_RENDER_VIEW_HOST_CHANGED is received. 108 // be called later, when NOTIFICATION_RENDER_VIEW_HOST_CHANGED is received.
377 if (content::RenderWidgetHostView* rwhv = 109 if (content::RenderWidgetHostView* rwhv =
378 contents_->GetRenderWidgetHostView()) 110 contents_->GetRenderWidgetHostView())
379 rwhv->SetTakesFocusOnlyOnMouseDown(true); 111 rwhv->SetTakesFocusOnlyOnMouseDown(true);
380 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 112 registrar_.Add(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
381 content::Source<content::NavigationController>( 113 content::Source<content::NavigationController>(
382 &contents_->GetController())); 114 &contents_->GetController()));
dhollowa 2013/01/29 02:37:53 nit: Indent
samarth 2013/01/29 05:42:01 Done.
383 #endif 115 #endif
384 } 116 }
385 117
386 void InstantLoader::CleanupPreviewContents() { 118 scoped_ptr<content::WebContents> InstantLoader::ReleaseContents() {
387 client_.SetContents(NULL);
388 contents_->RemoveUserData(&kUserDataKey);
389 contents_->SetDelegate(NULL); 119 contents_->SetDelegate(NULL);
390 120
391 // Undo tab helper work done in SetupPreviewContents(). 121 // Undo tab helper work done in SetupPreviewContents().
392 122
393 BlockedContentTabHelper::FromWebContents(contents())-> 123 BlockedContentTabHelper::FromWebContents(contents())->
394 SetAllContentsBlocked(false); 124 SetAllContentsBlocked(false);
395 TabSpecificContentSettings::FromWebContents(contents())-> 125 TabSpecificContentSettings::FromWebContents(contents())->
396 SetPopupsBlocked(false); 126 SetPopupsBlocked(false);
397 127
398 CoreTabHelper::FromWebContents(contents())->set_delegate(NULL); 128 CoreTabHelper::FromWebContents(contents())->set_delegate(NULL);
399 129
400 #if defined(OS_MACOSX) 130 #if defined(OS_MACOSX)
401 if (content::RenderWidgetHostView* rwhv = 131 if (content::RenderWidgetHostView* rwhv =
402 contents_->GetRenderWidgetHostView()) 132 contents_->GetRenderWidgetHostView())
403 rwhv->SetTakesFocusOnlyOnMouseDown(false); 133 rwhv->SetTakesFocusOnlyOnMouseDown(false);
404 registrar_.Remove(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 134 registrar_.Remove(this, content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
405 content::Source<content::NavigationController>( 135 content::Source<content::NavigationController>(
406 &contents_->GetController())); 136 &contents_->GetController()));
407 #endif 137 #endif
138
139 return contents_.Pass();
408 } 140 }
409 141
410 void InstantLoader::ReplacePreviewContents(content::WebContents* old_contents, 142 void InstantLoader::Observe(int type,
411 content::WebContents* new_contents) { 143 const content::NotificationSource& source,
144 const content::NotificationDetails& details) {
145 #if defined(OS_MACOSX)
146 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) {
147 if (content::RenderWidgetHostView* rwhv =
148 contents_->GetRenderWidgetHostView())
149 rwhv->SetTakesFocusOnlyOnMouseDown(true);
150 return;
151 }
152 NOTREACHED();
153 #endif
154 }
155
156 void InstantLoader::SwapTabContents(content::WebContents* old_contents,
157 content::WebContents* new_contents) {
412 DCHECK_EQ(old_contents, contents()); 158 DCHECK_EQ(old_contents, contents());
413 CleanupPreviewContents(); 159 // We release here without deleting since the caller has the responsibility
414 // We release here without deleting so that the caller still has the 160 // for deleting the old WebContents.
415 // responsibility for deleting the WebContents. 161 scoped_ptr<content::WebContents> released_contents =
416 ignore_result(contents_.release()); 162 delegate_->ReplaceAndReleaseContents(
417 contents_.reset(new_contents); 163 scoped_ptr<content::WebContents>(new_contents));
418 SetupPreviewContents(); 164 ignore_result(released_contents.release());
dhollowa 2013/01/29 02:37:53 I'm puzzled... is released_contents == old_content
samarth 2013/01/29 05:42:01 Yes. I could add another DCHECK if it would make
419 controller_->SwappedWebContents();
420 } 165 }
166
167 // Overridden from content::WebContentsDelegate:
168 bool InstantLoader::ShouldSuppressDialogs() {
169 // Any message shown during Instant cancels Instant, so we suppress them.
170 return true;
171 }
172
173 bool InstantLoader::ShouldFocusPageAfterCrash() {
174 return false;
175 }
176
177 void InstantLoader::LostCapture() {
178 delegate_->OnMouseUp();
179 }
180
181 void InstantLoader::WebContentsFocused(content::WebContents* contents) {
182 delegate_->OnFocus();
183 }
184
185 bool InstantLoader::CanDownload(content::RenderViewHost* /* render_view_host */,
dhollowa 2013/01/29 02:37:53 nit: No need for the commented params.
samarth 2013/01/29 05:42:01 Done.
186 int /* request_id */,
187 const std::string& /* request_method */) {
188 // Downloads are disabled.
189 return false;
190 }
191
192 void InstantLoader::HandleMouseDown() {
193 delegate_->OnMouseDown();
194 }
195
196 void InstantLoader::HandleMouseUp() {
197 delegate_->OnMouseUp();
198 }
199
200 void InstantLoader::HandlePointerActivate() {
201 delegate_->OnMouseDown();
202 }
203
204 void InstantLoader::HandleGestureEnd() {
205 delegate_->OnMouseUp();
206 }
207
208 void InstantLoader::DragEnded() {
209 // If the user drags, we won't get a mouse up (at least on Linux). Commit
210 // the Instant result when the drag ends, so that during the drag the page
211 // won't move around.
212 delegate_->OnMouseUp();
213 }
214
215 bool InstantLoader::OnGoToEntryOffset(int offset) {
216 return false;
217 }
218
219 content::WebContents* InstantLoader::OpenURLFromTab(
220 content::WebContents* source,
221 const content::OpenURLParams& params) {
222 if (delegate_->OnOpenURL())
223 return contents_->GetDelegate()->OpenURLFromTab(source, params);
224 return NULL;
225 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698