OLD | NEW |
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" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 } | 177 } |
178 | 178 |
179 InstantLoader::InstantLoader(InstantController* controller, | 179 InstantLoader::InstantLoader(InstantController* controller, |
180 const std::string& instant_url) | 180 const std::string& instant_url) |
181 : client_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 181 : client_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
182 controller_(controller), | 182 controller_(controller), |
183 delegate_(new WebContentsDelegateImpl( | 183 delegate_(new WebContentsDelegateImpl( |
184 ALLOW_THIS_IN_INITIALIZER_LIST(this))), | 184 ALLOW_THIS_IN_INITIALIZER_LIST(this))), |
185 instant_url_(instant_url), | 185 instant_url_(instant_url), |
186 supports_instant_(false), | 186 supports_instant_(false), |
187 is_pointer_down_from_activate_(false) { | 187 is_pointer_down_from_activate_(false), |
| 188 is_in_fallback_mode_(false) { |
188 } | 189 } |
189 | 190 |
190 InstantLoader::~InstantLoader() { | 191 InstantLoader::~InstantLoader() { |
191 } | 192 } |
192 | 193 |
193 void InstantLoader::InitContents(const content::WebContents* active_tab) { | 194 void InstantLoader::InitContents(const content::WebContents* active_tab) { |
194 content::WebContents::CreateParams create_params( | 195 content::WebContents::CreateParams create_params( |
195 active_tab->GetBrowserContext(), | 196 active_tab->GetBrowserContext(), |
196 active_tab->GetSiteInstance()->GetRelatedSiteInstance( | 197 active_tab->GetSiteInstance()->GetRelatedSiteInstance( |
197 GURL(instant_url_))); | 198 GURL(instant_url_))); |
(...skipping 10 matching lines...) Expand all Loading... |
208 contents_->GetController().LoadURL(GURL(instant_url_), content::Referrer(), | 209 contents_->GetController().LoadURL(GURL(instant_url_), content::Referrer(), |
209 content::PAGE_TRANSITION_GENERATED, kInstantHeader); | 210 content::PAGE_TRANSITION_GENERATED, kInstantHeader); |
210 contents_->WasHidden(); | 211 contents_->WasHidden(); |
211 } | 212 } |
212 | 213 |
213 content::WebContents* InstantLoader::ReleaseContents() { | 214 content::WebContents* InstantLoader::ReleaseContents() { |
214 CleanupPreviewContents(); | 215 CleanupPreviewContents(); |
215 return contents_.release(); | 216 return contents_.release(); |
216 } | 217 } |
217 | 218 |
| 219 void InstantLoader::set_is_in_fallback_mode() { |
| 220 is_in_fallback_mode_ = true; |
| 221 } |
| 222 |
218 void InstantLoader::DidNavigate( | 223 void InstantLoader::DidNavigate( |
219 const history::HistoryAddPageArgs& add_page_args) { | 224 const history::HistoryAddPageArgs& add_page_args) { |
220 last_navigation_ = add_page_args; | 225 last_navigation_ = add_page_args; |
221 } | 226 } |
222 | 227 |
223 bool InstantLoader::IsUsingLocalPreview() const { | 228 bool InstantLoader::IsUsingLocalPreview() const { |
224 return instant_url_ == InstantController::kLocalOmniboxPopupURL; | 229 return instant_url_ == InstantController::kLocalOmniboxPopupURL; |
225 } | 230 } |
226 | 231 |
227 void InstantLoader::Update(const string16& text, | 232 void InstantLoader::Update(const string16& text, |
(...skipping 13 matching lines...) Expand all Loading... |
241 } | 246 } |
242 | 247 |
243 void InstantLoader::SetPopupBounds(const gfx::Rect& bounds) { | 248 void InstantLoader::SetPopupBounds(const gfx::Rect& bounds) { |
244 client_.SetPopupBounds(bounds); | 249 client_.SetPopupBounds(bounds); |
245 } | 250 } |
246 | 251 |
247 void InstantLoader::SetMarginSize(int start, int end) { | 252 void InstantLoader::SetMarginSize(int start, int end) { |
248 client_.SetMarginSize(start, end); | 253 client_.SetMarginSize(start, end); |
249 } | 254 } |
250 | 255 |
| 256 void InstantLoader::InitializeFonts() { |
| 257 client_.InitializeFonts(); |
| 258 } |
| 259 |
251 void InstantLoader::SendAutocompleteResults( | 260 void InstantLoader::SendAutocompleteResults( |
252 const std::vector<InstantAutocompleteResult>& results) { | 261 const std::vector<InstantAutocompleteResult>& results) { |
253 client_.SendAutocompleteResults(results); | 262 client_.SendAutocompleteResults(results); |
254 } | 263 } |
255 | 264 |
256 void InstantLoader::UpOrDownKeyPressed(int count) { | 265 void InstantLoader::UpOrDownKeyPressed(int count) { |
257 client_.UpOrDownKeyPressed(count); | 266 client_.UpOrDownKeyPressed(count); |
258 } | 267 } |
259 | 268 |
260 void InstantLoader::SearchModeChanged(const chrome::search::Mode& mode) { | 269 void InstantLoader::SearchModeChanged(const chrome::search::Mode& mode) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 void InstantLoader::AboutToNavigateMainFrame(const GURL& url) { | 326 void InstantLoader::AboutToNavigateMainFrame(const GURL& url) { |
318 controller_->InstantLoaderAboutToNavigateMainFrame(url); | 327 controller_->InstantLoaderAboutToNavigateMainFrame(url); |
319 } | 328 } |
320 | 329 |
321 void InstantLoader::NavigateToURL(const GURL& url, | 330 void InstantLoader::NavigateToURL(const GURL& url, |
322 content::PageTransition transition) { | 331 content::PageTransition transition) { |
323 InstantSupportDetermined(true); | 332 InstantSupportDetermined(true); |
324 controller_->NavigateToURL(url, transition); | 333 controller_->NavigateToURL(url, transition); |
325 } | 334 } |
326 | 335 |
| 336 void InstantLoader::RenderViewCreated(content::RenderViewHost* host) { |
| 337 if (!controller_->extended_enabled()) |
| 338 return; |
| 339 |
| 340 // Ensure the searchbox API has the correct initial state. |
| 341 SetDisplayInstantResults(controller_->instant_enabled()); |
| 342 SearchModeChanged(controller_->search_mode()); |
| 343 KeyCaptureChanged(controller_->omnibox_focus_state() == |
| 344 OMNIBOX_FOCUS_INVISIBLE); |
| 345 SetMarginSize(controller_->start_margin(), controller_->end_margin()); |
| 346 InitializeFonts(); |
| 347 } |
| 348 |
327 void InstantLoader::Observe(int type, | 349 void InstantLoader::Observe(int type, |
328 const content::NotificationSource& source, | 350 const content::NotificationSource& source, |
329 const content::NotificationDetails& details) { | 351 const content::NotificationDetails& details) { |
330 #if defined(OS_MACOSX) | 352 #if defined(OS_MACOSX) |
331 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) { | 353 if (type == content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED) { |
332 if (content::RenderWidgetHostView* rwhv = | 354 if (content::RenderWidgetHostView* rwhv = |
333 contents_->GetRenderWidgetHostView()) | 355 contents_->GetRenderWidgetHostView()) |
334 rwhv->SetTakesFocusOnlyOnMouseDown(true); | 356 rwhv->SetTakesFocusOnlyOnMouseDown(true); |
335 return; | 357 return; |
336 } | 358 } |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 content::WebContents* new_contents) { | 433 content::WebContents* new_contents) { |
412 DCHECK_EQ(old_contents, contents()); | 434 DCHECK_EQ(old_contents, contents()); |
413 CleanupPreviewContents(); | 435 CleanupPreviewContents(); |
414 // We release here without deleting so that the caller still has the | 436 // We release here without deleting so that the caller still has the |
415 // responsibility for deleting the WebContents. | 437 // responsibility for deleting the WebContents. |
416 ignore_result(contents_.release()); | 438 ignore_result(contents_.release()); |
417 contents_.reset(new_contents); | 439 contents_.reset(new_contents); |
418 SetupPreviewContents(); | 440 SetupPreviewContents(); |
419 controller_->SwappedWebContents(); | 441 controller_->SwappedWebContents(); |
420 } | 442 } |
OLD | NEW |