Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "chrome/browser/prerender/prerender_contents.h" | 5 #include "chrome/browser/prerender/prerender_contents.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/background_contents_service.h" | 8 #include "chrome/browser/background_contents_service.h" |
| 9 #include "chrome/browser/browsing_instance.h" | 9 #include "chrome/browser/browsing_instance.h" |
| 10 #include "chrome/browser/prerender/prerender_manager.h" | 10 #include "chrome/browser/prerender/prerender_manager.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 #include "gfx/rect.h" | 21 #include "gfx/rect.h" |
| 22 | 22 |
| 23 PrerenderContents::PrerenderContents(PrerenderManager* prerender_manager, | 23 PrerenderContents::PrerenderContents(PrerenderManager* prerender_manager, |
| 24 Profile* profile, | 24 Profile* profile, |
| 25 const GURL& url, | 25 const GURL& url, |
| 26 const std::vector<GURL>& alias_urls) | 26 const std::vector<GURL>& alias_urls) |
| 27 : prerender_manager_(prerender_manager), | 27 : prerender_manager_(prerender_manager), |
| 28 render_view_host_(NULL), | 28 render_view_host_(NULL), |
| 29 prerender_url_(url), | 29 prerender_url_(url), |
| 30 profile_(profile), | 30 profile_(profile), |
| 31 page_id_(0) { | 31 page_id_(0), |
| 32 has_stopped_loading_(false) { | |
| 32 DCHECK(prerender_manager != NULL); | 33 DCHECK(prerender_manager != NULL); |
| 33 AddAliasURL(prerender_url_); | 34 AddAliasURL(prerender_url_); |
| 34 for (std::vector<GURL>::const_iterator it = alias_urls.begin(); | 35 for (std::vector<GURL>::const_iterator it = alias_urls.begin(); |
| 35 it != alias_urls.end(); | 36 it != alias_urls.end(); |
| 36 ++it) { | 37 ++it) { |
| 37 AddAliasURL(*it); | 38 AddAliasURL(*it); |
| 38 } | 39 } |
| 39 } | 40 } |
| 40 | 41 |
| 41 void PrerenderContents::StartPrerendering() { | 42 void PrerenderContents::StartPrerendering() { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 } | 117 } |
| 117 | 118 |
| 118 void PrerenderContents::RunJavaScriptMessage( | 119 void PrerenderContents::RunJavaScriptMessage( |
| 119 const std::wstring& message, | 120 const std::wstring& message, |
| 120 const std::wstring& default_prompt, | 121 const std::wstring& default_prompt, |
| 121 const GURL& frame_url, | 122 const GURL& frame_url, |
| 122 const int flags, | 123 const int flags, |
| 123 IPC::Message* reply_msg, | 124 IPC::Message* reply_msg, |
| 124 bool* did_suppress_message) { | 125 bool* did_suppress_message) { |
| 125 *did_suppress_message = true; | 126 *did_suppress_message = true; |
| 127 // Cancel prerendering, since we do cannot deal with a pop up message. | |
| 128 prerender_manager_->RemoveEntry(this); | |
|
cbentzel
2011/01/26 19:38:36
Move this to a different CL.
tburkard
2011/01/26 20:05:50
Done.
| |
| 126 } | 129 } |
| 127 | 130 |
| 128 bool PrerenderContents::PreHandleKeyboardEvent( | 131 bool PrerenderContents::PreHandleKeyboardEvent( |
| 129 const NativeWebKeyboardEvent& event, | 132 const NativeWebKeyboardEvent& event, |
| 130 bool* is_keyboard_shortcut) { | 133 bool* is_keyboard_shortcut) { |
| 131 return false; | 134 return false; |
| 132 } | 135 } |
| 133 | 136 |
| 134 void PrerenderContents::Observe(NotificationType type, | 137 void PrerenderContents::Observe(NotificationType type, |
| 135 const NotificationSource& source, | 138 const NotificationSource& source, |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 } | 261 } |
| 259 | 262 |
| 260 void PrerenderContents::AddAliasURL(const GURL& url) { | 263 void PrerenderContents::AddAliasURL(const GURL& url) { |
| 261 alias_urls_.push_back(url); | 264 alias_urls_.push_back(url); |
| 262 } | 265 } |
| 263 | 266 |
| 264 bool PrerenderContents::MatchesURL(const GURL& url) const { | 267 bool PrerenderContents::MatchesURL(const GURL& url) const { |
| 265 return std::find(alias_urls_.begin(), alias_urls_.end(), url) | 268 return std::find(alias_urls_.begin(), alias_urls_.end(), url) |
| 266 != alias_urls_.end(); | 269 != alias_urls_.end(); |
| 267 } | 270 } |
| 271 | |
| 272 void PrerenderContents::DidStopLoading() { | |
|
cbentzel
2011/01/26 19:38:36
DCHECK(has_stopped_loading_) - can this ever be ca
tburkard
2011/01/26 20:05:50
Could happen multiple times.
In some pages, the lo
| |
| 273 has_stopped_loading_ = true; | |
| 274 } | |
| OLD | NEW |