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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 host->Send(new ViewMsg_DetermineIfPageSupportsInstant( | 132 host->Send(new ViewMsg_DetermineIfPageSupportsInstant( |
133 host->routing_id(), text_, verbatim_, text_length, text_length)); | 133 host->routing_id(), text_, verbatim_, text_length, text_length)); |
134 break; | 134 break; |
135 } | 135 } |
136 default: | 136 default: |
137 NOTREACHED(); | 137 NOTREACHED(); |
138 break; | 138 break; |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 // If this is being called, something is swapping in to our preview_contents_ | |
143 // before we've added it to the tab strip. | |
144 void InstantLoader::SwapTabContents(TabContentsWrapper* old_tc, | |
145 TabContentsWrapper* new_tc) { | |
146 DCHECK(old_tc == preview_contents_); | |
147 // We release here without deleting so that the caller still has reponsibility | |
148 // for deleting the TabContentsWrapper. The (void) cast is so that we use the | |
149 // returned value. | |
150 TabContentsWrapper* tab_contents_wrapper = preview_contents_.release(); | |
sky
2011/05/19 19:53:55
ignore_result
dominich
2011/05/19 23:57:28
Done.
| |
151 (void) tab_contents_wrapper; | |
152 preview_contents_.reset(new_tc); | |
sky
2011/05/19 19:53:55
I'm not sure under when this might be invoked. Cou
dominich
2011/05/19 23:57:28
It's invoked if the InstantLoader is the delegate
| |
153 } | |
154 | |
142 // TabContentsDelegateImpl ----------------------------------------------------- | 155 // TabContentsDelegateImpl ----------------------------------------------------- |
143 | 156 |
144 class InstantLoader::TabContentsDelegateImpl | 157 class InstantLoader::TabContentsDelegateImpl |
145 : public TabContentsDelegate, | 158 : public TabContentsDelegate, |
146 public NotificationObserver, | 159 public NotificationObserver, |
147 public TabContentsObserver, | 160 public TabContentsObserver, |
148 public DownloadTabHelperDelegate { | 161 public DownloadTabHelperDelegate { |
149 public: | 162 public: |
150 explicit TabContentsDelegateImpl(InstantLoader* loader); | 163 explicit TabContentsDelegateImpl(InstantLoader* loader); |
151 | 164 |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
989 host->Send(new ViewMsg_SearchBoxResize( | 1002 host->Send(new ViewMsg_SearchBoxResize( |
990 host->routing_id(), GetOmniboxBoundsInTermsOfPreview())); | 1003 host->routing_id(), GetOmniboxBoundsInTermsOfPreview())); |
991 } | 1004 } |
992 } | 1005 } |
993 | 1006 |
994 void InstantLoader::CreatePreviewContents(TabContentsWrapper* tab_contents) { | 1007 void InstantLoader::CreatePreviewContents(TabContentsWrapper* tab_contents) { |
995 TabContents* new_contents = | 1008 TabContents* new_contents = |
996 new TabContents( | 1009 new TabContents( |
997 tab_contents->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); | 1010 tab_contents->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); |
998 preview_contents_.reset(new TabContentsWrapper(new_contents)); | 1011 preview_contents_.reset(new TabContentsWrapper(new_contents)); |
1012 preview_contents_->set_delegate(this); | |
999 preview_contents_->blocked_content_tab_helper()->SetAllContentsBlocked(true); | 1013 preview_contents_->blocked_content_tab_helper()->SetAllContentsBlocked(true); |
1000 // Propagate the max page id. That way if we end up merging the two | 1014 // Propagate the max page id. That way if we end up merging the two |
1001 // NavigationControllers (which happens if we commit) none of the page ids | 1015 // NavigationControllers (which happens if we commit) none of the page ids |
1002 // will overlap. | 1016 // will overlap. |
1003 int32 max_page_id = tab_contents->tab_contents()->GetMaxPageID(); | 1017 int32 max_page_id = tab_contents->tab_contents()->GetMaxPageID(); |
1004 if (max_page_id != -1) | 1018 if (max_page_id != -1) |
1005 preview_contents_->controller().set_max_restored_page_id(max_page_id + 1); | 1019 preview_contents_->controller().set_max_restored_page_id(max_page_id + 1); |
1006 | 1020 |
1007 preview_tab_contents_delegate_.reset(new TabContentsDelegateImpl(this)); | 1021 preview_tab_contents_delegate_.reset(new TabContentsDelegateImpl(this)); |
1008 new_contents->set_delegate(preview_tab_contents_delegate_.get()); | 1022 new_contents->set_delegate(preview_tab_contents_delegate_.get()); |
(...skipping 18 matching lines...) Expand all Loading... | |
1027 Source<NavigationController>(&preview_contents_->controller())); | 1041 Source<NavigationController>(&preview_contents_->controller())); |
1028 #endif | 1042 #endif |
1029 | 1043 |
1030 registrar_.Add( | 1044 registrar_.Add( |
1031 this, | 1045 this, |
1032 NotificationType::NAV_ENTRY_COMMITTED, | 1046 NotificationType::NAV_ENTRY_COMMITTED, |
1033 Source<NavigationController>(&preview_contents_->controller())); | 1047 Source<NavigationController>(&preview_contents_->controller())); |
1034 | 1048 |
1035 preview_contents_->tab_contents()->ShowContents(); | 1049 preview_contents_->tab_contents()->ShowContents(); |
1036 } | 1050 } |
OLD | NEW |