| 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/tab_contents/match_preview.h" | 5 #include "chrome/browser/tab_contents/match_preview.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "chrome/browser/tab_contents/navigation_controller.h" | 10 #include "chrome/browser/tab_contents/navigation_controller.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 url_ = url; | 160 url_ = url; |
| 161 | 161 |
| 162 if (url_.is_empty() || !url_.is_valid()) { | 162 if (url_.is_empty() || !url_.is_valid()) { |
| 163 DestroyPreviewContents(); | 163 DestroyPreviewContents(); |
| 164 return; | 164 return; |
| 165 } | 165 } |
| 166 | 166 |
| 167 if (!preview_contents_.get()) { | 167 if (!preview_contents_.get()) { |
| 168 preview_contents_.reset( | 168 preview_contents_.reset( |
| 169 new TabContents(host_->profile(), NULL, MSG_ROUTING_NONE, NULL)); | 169 new TabContents(host_->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL)); |
| 170 preview_contents_->set_delegate(delegate_.get()); | 170 preview_contents_->set_delegate(delegate_.get()); |
| 171 NotificationService::current()->Notify( | 171 NotificationService::current()->Notify( |
| 172 NotificationType::MATCH_PREVIEW_TAB_CONTENTS_CREATED, | 172 NotificationType::MATCH_PREVIEW_TAB_CONTENTS_CREATED, |
| 173 Source<TabContents>(host_), | 173 Source<TabContents>(host_), |
| 174 NotificationService::NoDetails()); | 174 NotificationService::NoDetails()); |
| 175 } | 175 } |
| 176 | 176 |
| 177 // TODO: figure out transition type. | 177 // TODO: figure out transition type. |
| 178 preview_contents_->controller().LoadURL(url, GURL(), | 178 preview_contents_->controller().LoadURL(url, GURL(), |
| 179 PageTransition::GENERATED); | 179 PageTransition::GENERATED); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void MatchPreview::DestroyPreviewContents() { | 182 void MatchPreview::DestroyPreviewContents() { |
| 183 url_ = GURL(); | 183 url_ = GURL(); |
| 184 preview_contents_.reset(NULL); | 184 preview_contents_.reset(NULL); |
| 185 } | 185 } |
| 186 | 186 |
| 187 void MatchPreview::CommitCurrentPreview() { | 187 void MatchPreview::CommitCurrentPreview() { |
| 188 DCHECK(preview_contents_.get()); | 188 DCHECK(preview_contents_.get()); |
| 189 if (host_->delegate()) | 189 if (host_->delegate()) |
| 190 host_->delegate()->CommitMatchPreview(host_); | 190 host_->delegate()->CommitMatchPreview(host_); |
| 191 } | 191 } |
| 192 | 192 |
| 193 TabContents* MatchPreview::ReleasePreviewContents() { | 193 TabContents* MatchPreview::ReleasePreviewContents() { |
| 194 url_ = GURL(); | 194 url_ = GURL(); |
| 195 return preview_contents_.release(); | 195 return preview_contents_.release(); |
| 196 } | 196 } |
| OLD | NEW |