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/instant/instant_loader.h" | 5 #include "chrome/browser/instant/instant_loader.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 264 TabContents* new_contents, | 264 TabContents* new_contents, |
| 265 WindowOpenDisposition disposition, | 265 WindowOpenDisposition disposition, |
| 266 const gfx::Rect& initial_pos, | 266 const gfx::Rect& initial_pos, |
| 267 bool user_gesture) {} | 267 bool user_gesture) {} |
| 268 virtual void ActivateContents(TabContents* contents) { | 268 virtual void ActivateContents(TabContents* contents) { |
| 269 } | 269 } |
| 270 virtual void DeactivateContents(TabContents* contents) {} | 270 virtual void DeactivateContents(TabContents* contents) {} |
| 271 virtual void LoadingStateChanged(TabContents* source) {} | 271 virtual void LoadingStateChanged(TabContents* source) {} |
| 272 virtual void CloseContents(TabContents* source) {} | 272 virtual void CloseContents(TabContents* source) {} |
| 273 virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {} | 273 virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {} |
| 274 virtual void DetachContents(TabContents* source) {} | |
| 275 virtual bool IsPopup(const TabContents* source) const { | |
| 276 return false; | |
| 277 } | |
| 278 virtual bool ShouldFocusConstrainedWindow() { | 274 virtual bool ShouldFocusConstrainedWindow() { |
| 279 // Return false so that constrained windows are not initially focused. If | 275 // Return false so that constrained windows are not initially focused. If |
| 280 // we did otherwise the preview would prematurely get committed when focus | 276 // we did otherwise the preview would prematurely get committed when focus |
| 281 // goes to the constrained window. | 277 // goes to the constrained window. |
| 282 return false; | 278 return false; |
| 283 } | 279 } |
| 284 virtual void WillShowConstrainedWindow(TabContents* source) { | 280 virtual void WillShowConstrainedWindow(TabContents* source) { |
| 285 if (!loader_->ready()) { | 281 if (!loader_->ready()) { |
| 286 // A constrained window shown for an auth may not paint. Show the preview | 282 // A constrained window shown for an auth may not paint. Show the preview |
| 287 // contents. | 283 // contents. |
| 288 DestroyPaintObserver(); | 284 DestroyPaintObserver(); |
| 289 loader_->ShowPreview(); | 285 loader_->ShowPreview(); |
| 290 } | 286 } |
| 291 } | 287 } |
| 292 virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {} | 288 virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {} |
| 293 virtual void URLStarredChanged(TabContents* source, bool starred) {} | 289 virtual void URLStarredChanged(TabContents* source, bool starred) {} |
| 294 virtual void UpdateTargetURL(TabContents* source, const GURL& url) {} | 290 virtual void UpdateTargetURL(TabContents* source, const GURL& url) {} |
| 295 virtual void ContentsMouseEvent( | |
| 296 TabContents* source, const gfx::Point& location, bool motion) {} | |
| 297 virtual void ContentsZoomChange(bool zoom_in) {} | |
| 298 virtual void OnContentSettingsChange(TabContents* source) {} | |
| 299 virtual bool IsApplication() const { return false; } | |
| 300 virtual void ConvertContentsToApplication(TabContents* source) {} | |
| 301 virtual bool CanReloadContents(TabContents* source) const { return true; } | |
| 302 virtual void ShowHtmlDialog(HtmlDialogUIDelegate* delegate, | |
| 303 gfx::NativeWindow parent_window) {} | |
| 304 virtual bool ShouldSuppressDialogs() { | 291 virtual bool ShouldSuppressDialogs() { |
| 305 // Any message shown during instant cancels instant, so we suppress them. | 292 // Any message shown during instant cancels instant, so we suppress them. |
| 306 return true; | 293 return true; |
| 307 } | 294 } |
| 308 virtual void BeforeUnloadFired(TabContents* tab, | 295 virtual void BeforeUnloadFired(TabContents* tab, |
| 309 bool proceed, | 296 bool proceed, |
| 310 bool* proceed_to_fire_unload) {} | 297 bool* proceed_to_fire_unload) {} |
| 311 virtual void ForwardMessageToExternalHost(const std::string& message, | |
| 312 const std::string& origin, | |
| 313 const std::string& target) {} | |
| 314 virtual bool IsExternalTabContainer() const { return false; } | |
| 315 virtual void SetFocusToLocationBar(bool select_all) {} | 298 virtual void SetFocusToLocationBar(bool select_all) {} |
| 316 virtual bool ShouldFocusPageAfterCrash() { return false; } | 299 virtual bool ShouldFocusPageAfterCrash() { return false; } |
| 317 virtual void RenderWidgetShowing() {} | |
| 318 virtual bool TakeFocus(bool reverse) { return false; } | |
| 319 virtual void LostCapture() { | 300 virtual void LostCapture() { |
| 320 CommitFromMouseReleaseIfNecessary(); | 301 CommitFromMouseReleaseIfNecessary(); |
| 321 } | 302 } |
| 322 virtual void SetTabContentBlocked(TabContents* contents, bool blocked) {} | |
| 323 virtual void TabContentsFocused(TabContents* tab_content) { | |
| 324 } | |
| 325 virtual int GetExtraRenderViewHeight() const { return 0; } | |
| 326 virtual bool CanDownload(int request_id) { return false; } | 303 virtual bool CanDownload(int request_id) { return false; } |
| 327 virtual void OnStartDownload(DownloadItem* download, TabContents* tab) {} | |
| 328 virtual bool HandleContextMenu(const ContextMenuParams& params) { | |
| 329 return false; | |
| 330 } | |
| 331 virtual bool ExecuteContextMenuCommand(int command) { | |
| 332 return false; | |
| 333 } | |
| 334 virtual void ConfirmAddSearchProvider(const TemplateURL* template_url, | |
| 335 Profile* profile) {} | |
| 336 virtual void ShowPageInfo(Profile* profile, | |
| 337 const GURL& url, | |
| 338 const NavigationEntry::SSLStatus& ssl, | |
| 339 bool show_history) {} | |
| 340 virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | |
| 341 bool* is_keyboard_shortcut) { | |
| 342 return false; | |
| 343 } | |
| 344 virtual void HandleMouseUp() { | 304 virtual void HandleMouseUp() { |
| 345 CommitFromMouseReleaseIfNecessary(); | 305 CommitFromMouseReleaseIfNecessary(); |
| 346 } | 306 } |
| 347 virtual void HandleMouseActivate() { | 307 virtual void HandleMouseActivate() { |
| 348 is_mouse_down_from_activate_ = true; | 308 is_mouse_down_from_activate_ = true; |
| 349 } | 309 } |
| 350 virtual void ShowRepostFormWarningDialog(TabContents* tab_contents) {} | |
| 351 virtual void ShowContentSettingsWindow(ContentSettingsType content_type) {} | |
| 352 virtual void ShowCollectedCookiesDialog(TabContents* tab_contents) {} | |
| 353 virtual bool OnGoToEntryOffset(int offset) { return false; } | 310 virtual bool OnGoToEntryOffset(int offset) { return false; } |
| 354 virtual bool ShouldAddNavigationToHistory( | 311 virtual bool ShouldAddNavigationToHistory( |
| 355 const history::HistoryAddPageArgs& add_page_args, | 312 const history::HistoryAddPageArgs& add_page_args, |
| 356 NavigationType::Type navigation_type) { | 313 NavigationType::Type navigation_type) { |
| 357 if (waiting_for_new_page_ && navigation_type == NavigationType::NEW_PAGE) | 314 if (waiting_for_new_page_ && navigation_type == NavigationType::NEW_PAGE) |
| 358 waiting_for_new_page_ = false; | 315 waiting_for_new_page_ = false; |
| 359 | 316 |
| 360 if (!waiting_for_new_page_) { | 317 if (!waiting_for_new_page_) { |
| 361 add_page_vector_.push_back( | 318 add_page_vector_.push_back( |
| 362 scoped_refptr<history::HistoryAddPageArgs>(add_page_args.Clone())); | 319 scoped_refptr<history::HistoryAddPageArgs>(add_page_args.Clone())); |
| 363 } | 320 } |
| 364 return false; | 321 return false; |
| 365 } | 322 } |
| 366 virtual void OnDidGetApplicationInfo(TabContents* tab_contents, | |
| 367 int32 page_id) {} | |
| 368 virtual gfx::NativeWindow GetFrameNativeWindow() { | |
| 369 return NULL; | |
| 370 } | |
| 371 virtual void TabContentsCreated(TabContents* new_contents) {} | |
| 372 virtual bool infobars_enabled() { return false; } | |
|
sky
2011/01/06 23:59:51
Sorry, I should have made that clearer. It's the r
| |
| 373 virtual bool ShouldEnablePreferredSizeNotifications() { return false; } | |
| 374 virtual void UpdatePreferredSize(const gfx::Size& pref_size) {} | |
| 375 virtual void ContentTypeChanged(TabContents* source) {} | |
| 376 | 323 |
| 377 virtual void OnSetSuggestions(int32 page_id, | 324 virtual void OnSetSuggestions(int32 page_id, |
| 378 const std::vector<std::string>& suggestions) { | 325 const std::vector<std::string>& suggestions) { |
| 379 TabContentsWrapper* source = loader_->preview_contents(); | 326 TabContentsWrapper* source = loader_->preview_contents(); |
| 380 if (!source->controller().GetActiveEntry() || | 327 if (!source->controller().GetActiveEntry() || |
| 381 page_id != source->controller().GetActiveEntry()->page_id()) | 328 page_id != source->controller().GetActiveEntry()->page_id()) |
| 382 return; | 329 return; |
| 383 | 330 |
| 384 // TODO: only allow for default search provider. | 331 // TODO: only allow for default search provider. |
| 385 // TODO(sky): Handle multiple suggestions. | 332 // TODO(sky): Handle multiple suggestions. |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 816 Source<NavigationController>(&preview_contents_->controller())); | 763 Source<NavigationController>(&preview_contents_->controller())); |
| 817 #endif | 764 #endif |
| 818 | 765 |
| 819 registrar_.Add( | 766 registrar_.Add( |
| 820 this, | 767 this, |
| 821 NotificationType::NAV_ENTRY_COMMITTED, | 768 NotificationType::NAV_ENTRY_COMMITTED, |
| 822 Source<NavigationController>(&preview_contents_->controller())); | 769 Source<NavigationController>(&preview_contents_->controller())); |
| 823 | 770 |
| 824 preview_contents_->tab_contents()->ShowContents(); | 771 preview_contents_->tab_contents()->ShowContents(); |
| 825 } | 772 } |
| OLD | NEW |