OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 TabContentsWrapper* new_tc) OVERRIDE; | 227 TabContentsWrapper* new_tc) OVERRIDE; |
228 | 228 |
229 // TabContentsObserver: | 229 // TabContentsObserver: |
230 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 230 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
231 | 231 |
232 // DownloadTabHelperDelegate: | 232 // DownloadTabHelperDelegate: |
233 virtual bool CanDownload(int request_id) OVERRIDE; | 233 virtual bool CanDownload(int request_id) OVERRIDE; |
234 virtual void OnStartDownload(DownloadItem* download, | 234 virtual void OnStartDownload(DownloadItem* download, |
235 TabContentsWrapper* tab) OVERRIDE; | 235 TabContentsWrapper* tab) OVERRIDE; |
236 | 236 |
| 237 // Navigation interface to supoprt disposition. |
| 238 virtual void GoBack(WindowOpenDisposition disposition) OVERRIDE; |
| 239 virtual void GoForward(WindowOpenDisposition disposition) OVERRIDE; |
| 240 virtual bool NavigateToIndexWithDisposition( |
| 241 int index, WindowOpenDisposition disp) OVERRIDE; |
| 242 |
237 private: | 243 private: |
238 typedef std::vector<scoped_refptr<history::HistoryAddPageArgs> > | 244 typedef std::vector<scoped_refptr<history::HistoryAddPageArgs> > |
239 AddPageVector; | 245 AddPageVector; |
240 | 246 |
241 // Message from renderer indicating the page has suggestions. | 247 // Message from renderer indicating the page has suggestions. |
242 void OnSetSuggestions( | 248 void OnSetSuggestions( |
243 int32 page_id, | 249 int32 page_id, |
244 const std::vector<std::string>& suggestions, | 250 const std::vector<std::string>& suggestions, |
245 InstantCompleteBehavior behavior); | 251 InstantCompleteBehavior behavior); |
246 | 252 |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 bool InstantLoader::TabContentsDelegateImpl::CanDownload(int request_id) { | 590 bool InstantLoader::TabContentsDelegateImpl::CanDownload(int request_id) { |
585 // Downloads are disabled. | 591 // Downloads are disabled. |
586 return false; | 592 return false; |
587 } | 593 } |
588 | 594 |
589 void InstantLoader::TabContentsDelegateImpl::OnStartDownload( | 595 void InstantLoader::TabContentsDelegateImpl::OnStartDownload( |
590 DownloadItem* download, TabContentsWrapper* tab) { | 596 DownloadItem* download, TabContentsWrapper* tab) { |
591 // Downloads are disabled. | 597 // Downloads are disabled. |
592 } | 598 } |
593 | 599 |
| 600 void InstantLoader::TabContentsDelegateImpl::GoBack( |
| 601 WindowOpenDisposition disposition) { |
| 602 // Navigations are disabled. |
| 603 } |
| 604 |
| 605 void InstantLoader::TabContentsDelegateImpl::GoForward( |
| 606 WindowOpenDisposition disposition) { |
| 607 // Navigations are disabled. |
| 608 } |
| 609 |
| 610 bool InstantLoader::TabContentsDelegateImpl::NavigateToIndexWithDisposition( |
| 611 int index, WindowOpenDisposition disp) { |
| 612 // Navigations are disabled. |
| 613 return false; |
| 614 } |
| 615 |
| 616 |
594 void InstantLoader::TabContentsDelegateImpl::OnSetSuggestions( | 617 void InstantLoader::TabContentsDelegateImpl::OnSetSuggestions( |
595 int32 page_id, | 618 int32 page_id, |
596 const std::vector<std::string>& suggestions, | 619 const std::vector<std::string>& suggestions, |
597 InstantCompleteBehavior behavior) { | 620 InstantCompleteBehavior behavior) { |
598 TabContentsWrapper* source = loader_->preview_contents(); | 621 TabContentsWrapper* source = loader_->preview_contents(); |
599 if (!source->controller().GetActiveEntry() || | 622 if (!source->controller().GetActiveEntry() || |
600 page_id != source->controller().GetActiveEntry()->page_id()) | 623 page_id != source->controller().GetActiveEntry()->page_id()) |
601 return; | 624 return; |
602 | 625 |
603 if (suggestions.empty()) | 626 if (suggestions.empty()) |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 void InstantLoader::CreatePreviewContents(TabContentsWrapper* tab_contents) { | 1109 void InstantLoader::CreatePreviewContents(TabContentsWrapper* tab_contents) { |
1087 TabContents* new_contents = | 1110 TabContents* new_contents = |
1088 new TabContents( | 1111 new TabContents( |
1089 tab_contents->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); | 1112 tab_contents->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); |
1090 preview_contents_.reset(new TabContentsWrapper(new_contents)); | 1113 preview_contents_.reset(new TabContentsWrapper(new_contents)); |
1091 preview_tab_contents_delegate_.reset(new TabContentsDelegateImpl(this)); | 1114 preview_tab_contents_delegate_.reset(new TabContentsDelegateImpl(this)); |
1092 SetupPreviewContents(tab_contents); | 1115 SetupPreviewContents(tab_contents); |
1093 | 1116 |
1094 preview_contents_->tab_contents()->ShowContents(); | 1117 preview_contents_->tab_contents()->ShowContents(); |
1095 } | 1118 } |
OLD | NEW |