Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: chrome/browser/tab_contents/interstitial_page.cc

Issue 56135: Adding unit tests for the SafeBrowsingBlockingPage class (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/interstitial_page.h" 5 #include "chrome/browser/tab_contents/interstitial_page.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/thread.h" 9 #include "base/thread.h"
10 #include "chrome/browser/browser.h" 10 #include "chrome/browser/browser.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 entry->set_page_type(NavigationEntry::INTERSTITIAL_PAGE); 167 entry->set_page_type(NavigationEntry::INTERSTITIAL_PAGE);
168 168
169 // Give sub-classes a chance to set some states on the navigation entry. 169 // Give sub-classes a chance to set some states on the navigation entry.
170 UpdateEntry(entry); 170 UpdateEntry(entry);
171 171
172 tab_->controller()->AddTransientEntry(entry); 172 tab_->controller()->AddTransientEntry(entry);
173 } 173 }
174 174
175 DCHECK(!render_view_host_); 175 DCHECK(!render_view_host_);
176 render_view_host_ = CreateRenderViewHost(); 176 render_view_host_ = CreateRenderViewHost();
177 CreateWebContentsView();
177 178
178 std::string data_url = "data:text/html;charset=utf-8," + 179 std::string data_url = "data:text/html;charset=utf-8," +
179 EscapePath(GetHTMLContents()); 180 EscapePath(GetHTMLContents());
180 render_view_host_->NavigateToURL(GURL(data_url)); 181 render_view_host_->NavigateToURL(GURL(data_url));
181 182
182 notification_registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED, 183 notification_registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED,
183 Source<TabContents>(tab_)); 184 Source<TabContents>(tab_));
184 notification_registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED, 185 notification_registrar_.Add(this, NotificationType::NAV_ENTRY_COMMITTED,
185 Source<NavigationController>(tab_->controller())); 186 Source<NavigationController>(tab_->controller()));
186 notification_registrar_.Add(this, NotificationType::NAV_ENTRY_PENDING, 187 notification_registrar_.Add(this, NotificationType::NAV_ENTRY_PENDING,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 break; 247 break;
247 default: 248 default:
248 NOTREACHED(); 249 NOTREACHED();
249 } 250 }
250 } 251 }
251 252
252 RenderViewHost* InterstitialPage::CreateRenderViewHost() { 253 RenderViewHost* InterstitialPage::CreateRenderViewHost() {
253 RenderViewHost* render_view_host = new RenderViewHost( 254 RenderViewHost* render_view_host = new RenderViewHost(
254 SiteInstance::CreateSiteInstance(tab()->profile()), 255 SiteInstance::CreateSiteInstance(tab()->profile()),
255 this, MSG_ROUTING_NONE, NULL); 256 this, MSG_ROUTING_NONE, NULL);
257 return render_view_host;
258 }
259
260 WebContentsView* InterstitialPage::CreateWebContentsView() {
256 WebContentsView* web_contents_view = tab()->view(); 261 WebContentsView* web_contents_view = tab()->view();
257 RenderWidgetHostView* view = 262 RenderWidgetHostView* view =
258 web_contents_view->CreateViewForWidget(render_view_host); 263 web_contents_view->CreateViewForWidget(render_view_host_);
259 render_view_host->set_view(view); 264 render_view_host_->set_view(view);
260 render_view_host->AllowDomAutomationBindings(); 265 render_view_host_->AllowDomAutomationBindings();
261 render_view_host->CreateRenderView(); 266 render_view_host_->CreateRenderView();
262 view->SetSize(web_contents_view->GetContainerSize()); 267 view->SetSize(web_contents_view->GetContainerSize());
263 // Don't show the interstitial until we have navigated to it. 268 // Don't show the interstitial until we have navigated to it.
264 view->Hide(); 269 view->Hide();
265 return render_view_host; 270 return web_contents_view;
266 } 271 }
267 272
268 void InterstitialPage::Proceed() { 273 void InterstitialPage::Proceed() {
269 if (action_taken_) { 274 if (action_taken_) {
270 NOTREACHED(); 275 NOTREACHED();
271 return; 276 return;
272 } 277 }
273 Disable(); 278 Disable();
274 action_taken_ = true; 279 action_taken_ = true;
275 280
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 void InterstitialPage::InterstitialPageRVHViewDelegate::HandleKeyboardEvent( 495 void InterstitialPage::InterstitialPageRVHViewDelegate::HandleKeyboardEvent(
491 const NativeWebKeyboardEvent& event) { 496 const NativeWebKeyboardEvent& event) {
492 if (interstitial_page_->tab() && interstitial_page_->tab()->GetViewDelegate()) 497 if (interstitial_page_->tab() && interstitial_page_->tab()->GetViewDelegate())
493 interstitial_page_->tab()->GetViewDelegate()->HandleKeyboardEvent(event); 498 interstitial_page_->tab()->GetViewDelegate()->HandleKeyboardEvent(event);
494 } 499 }
495 500
496 void InterstitialPage::InterstitialPageRVHViewDelegate::OnFindReply( 501 void InterstitialPage::InterstitialPageRVHViewDelegate::OnFindReply(
497 int request_id, int number_of_matches, const gfx::Rect& selection_rect, 502 int request_id, int number_of_matches, const gfx::Rect& selection_rect,
498 int active_match_ordinal, bool final_update) { 503 int active_match_ordinal, bool final_update) {
499 } 504 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/interstitial_page.h ('k') | chrome/browser/tab_contents/web_contents_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698