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

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

Issue 56020: Reverting 12673. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 9 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
« no previous file with comments | « chrome/browser/tab_contents/web_contents.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/web_contents.h" 5 #include "chrome/browser/tab_contents/web_contents.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/file_version_info.h" 9 #include "base/file_version_info.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 return title; 356 return title;
357 } 357 }
358 return TabContents::GetTitle(); 358 return TabContents::GetTitle();
359 } 359 }
360 360
361 SiteInstance* WebContents::GetSiteInstance() const { 361 SiteInstance* WebContents::GetSiteInstance() const {
362 return render_manager_.current_host()->site_instance(); 362 return render_manager_.current_host()->site_instance();
363 } 363 }
364 364
365 bool WebContents::ShouldDisplayURL() { 365 bool WebContents::ShouldDisplayURL() {
366 if (controller()->GetPendingEntry()) { 366 DOMUI* dom_ui = GetDOMUIForCurrentState();
367 // When there is a pending entry, that should determine whether the URL is 367 if (dom_ui)
368 // displayed (including getting the default behavior if the DOMUI doesn't 368 return !dom_ui->should_hide_url();
369 // specify).
370 if (render_manager_.pending_dom_ui())
371 return !render_manager_.pending_dom_ui()->should_hide_url();
372 return true;
373 }
374
375 if (render_manager_.dom_ui())
376 return !render_manager_.dom_ui()->should_hide_url();
377 return true; 369 return true;
378 } 370 }
379 371
380 bool WebContents::ShouldDisplayFavIcon() { 372 bool WebContents::ShouldDisplayFavIcon() {
381 if (controller()->GetPendingEntry()) { 373 DOMUI* dom_ui = GetDOMUIForCurrentState();
382 // See ShouldDisplayURL. 374 if (dom_ui)
383 if (render_manager_.pending_dom_ui()) 375 return !dom_ui->hide_favicon();
384 return !render_manager_.pending_dom_ui()->hide_favicon();
385 return true;
386 }
387
388 if (render_manager_.dom_ui())
389 return !render_manager_.dom_ui()->hide_favicon();
390 return true; 376 return true;
391 } 377 }
392 378
393 std::wstring WebContents::GetStatusText() const { 379 std::wstring WebContents::GetStatusText() const {
394 if (!is_loading() || load_state_ == net::LOAD_STATE_IDLE) 380 if (!is_loading() || load_state_ == net::LOAD_STATE_IDLE)
395 return std::wstring(); 381 return std::wstring();
396 382
397 switch (load_state_) { 383 switch (load_state_) {
398 case net::LOAD_STATE_WAITING_FOR_CACHE: 384 case net::LOAD_STATE_WAITING_FOR_CACHE:
399 return l10n_util::GetString(IDS_LOAD_STATE_WAITING_FOR_CACHE); 385 return l10n_util::GetString(IDS_LOAD_STATE_WAITING_FOR_CACHE);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 // TODO(pkasting): http://b/1239839 Right now we purposefully don't call 511 // TODO(pkasting): http://b/1239839 Right now we purposefully don't call
526 // our superclass HideContents(), because some callers want to be very picky 512 // our superclass HideContents(), because some callers want to be very picky
527 // about the order in which these get called. In addition to making the code 513 // about the order in which these get called. In addition to making the code
528 // here practically impossible to understand, this also means we end up 514 // here practically impossible to understand, this also means we end up
529 // calling TabContents::WasHidden() twice if callers call both versions of 515 // calling TabContents::WasHidden() twice if callers call both versions of
530 // HideContents() on a WebContents. 516 // HideContents() on a WebContents.
531 WasHidden(); 517 WasHidden();
532 } 518 }
533 519
534 bool WebContents::IsBookmarkBarAlwaysVisible() { 520 bool WebContents::IsBookmarkBarAlwaysVisible() {
535 // We want the bookmarks bar to go with the committed entry. This way, when 521 // See GetDOMUIForCurrentState() comment for more info. This case is very
536 // you're on the new tab page and navigate, the bookmarks bar doesn't 522 // similar, but for non-first loads, we want to use the committed entry. This
537 // disappear until the next load commits (the same time the page changes). 523 // is so the bookmarks bar disappears at the same time the page does.
538 if (!controller()->GetLastCommittedEntry()) { 524 if (controller()->GetLastCommittedEntry()) {
539 // However, when there is no committed entry (the first load of the tab), 525 // Not the first load, always use the committed DOM UI.
540 // then we fall back on the pending entry. This means that the bookmarks bar 526 if (render_manager_.dom_ui())
541 // will be visible before the new tab page load commits. 527 return render_manager_.dom_ui()->force_bookmark_bar_visible();
542 if (render_manager_.pending_dom_ui()) 528 return false; // Default.
543 return render_manager_.pending_dom_ui()->force_bookmark_bar_visible();
544 return false;
545 } 529 }
546 530
531 // When it's the first load, we know either the pending one or the committed
532 // one will have the DOM UI in it (see GetDOMUIForCurrentState), and only one
533 // of them will be valid, so we can just check both.
534 if (render_manager_.pending_dom_ui())
535 return render_manager_.pending_dom_ui()->force_bookmark_bar_visible();
547 if (render_manager_.dom_ui()) 536 if (render_manager_.dom_ui())
548 return render_manager_.dom_ui()->force_bookmark_bar_visible(); 537 return render_manager_.dom_ui()->force_bookmark_bar_visible();
549 return false; 538 return false; // Default.
550 } 539 }
551 540
552 void WebContents::SetDownloadShelfVisible(bool visible) { 541 void WebContents::SetDownloadShelfVisible(bool visible) {
553 TabContents::SetDownloadShelfVisible(visible); 542 TabContents::SetDownloadShelfVisible(visible);
554 if (visible) { 543 if (visible) {
555 // Always set this value as it reflects the last time the download shelf 544 // Always set this value as it reflects the last time the download shelf
556 // was made visible (even if it was already visible). 545 // was made visible (even if it was already visible).
557 last_download_shelf_show_ = TimeTicks::Now(); 546 last_download_shelf_show_ = TimeTicks::Now();
558 } 547 }
559 } 548 }
560 549
561 void WebContents::PopupNotificationVisibilityChanged(bool visible) { 550 void WebContents::PopupNotificationVisibilityChanged(bool visible) {
562 render_view_host()->PopupNotificationVisibilityChanged(visible); 551 render_view_host()->PopupNotificationVisibilityChanged(visible);
563 } 552 }
564 553
565 bool WebContents::FocusLocationBarByDefault() { 554 bool WebContents::FocusLocationBarByDefault() {
566 // Allow the DOM UI to override the default. We use the pending DOM UI since 555 DOMUI* dom_ui = GetDOMUIForCurrentState();
567 // that's what the user "just did" so should control what happens after they 556 if (dom_ui)
568 // did it. Using the committed one would mean when they navigate from a DOMUI 557 return dom_ui->focus_location_bar_by_default();
569 // to a regular page, the location bar would be focused.
570 if (render_manager_.pending_dom_ui())
571 return render_manager_.pending_dom_ui()->focus_location_bar_by_default();
572 return false; 558 return false;
573 } 559 }
574 560
575 // Stupid view pass-throughs 561 // Stupid view pass-throughs
576 void WebContents::CreateView() { 562 void WebContents::CreateView() {
577 view_->CreateView(); 563 view_->CreateView();
578 } 564 }
579 565
580 gfx::NativeView WebContents::GetNativeView() const { 566 gfx::NativeView WebContents::GetNativeView() const {
581 return view_->GetNativeView(); 567 return view_->GetNativeView();
(...skipping 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after
2011 // The favicon url isn't valid. This means there really isn't a favicon, 1997 // The favicon url isn't valid. This means there really isn't a favicon,
2012 // or the favicon url wasn't obtained before the load started. This assumes 1998 // or the favicon url wasn't obtained before the load started. This assumes
2013 // the later. 1999 // the later.
2014 // TODO(sky): Need a way to set the favicon that doesn't involve generating 2000 // TODO(sky): Need a way to set the favicon that doesn't involve generating
2015 // its url. 2001 // its url.
2016 new_url->SetFavIconURL(TemplateURL::GenerateFaviconURL(params.referrer)); 2002 new_url->SetFavIconURL(TemplateURL::GenerateFaviconURL(params.referrer));
2017 } 2003 }
2018 new_url->set_safe_for_autoreplace(true); 2004 new_url->set_safe_for_autoreplace(true);
2019 url_model->Add(new_url); 2005 url_model->Add(new_url);
2020 } 2006 }
2007
2008 DOMUI* WebContents::GetDOMUIForCurrentState() {
2009 // When there is a pending navigation entry, we want to use the pending DOMUI
2010 // that goes along with it to control the basic flags. For example, we want to
2011 // show the pending URL in the URL bar, so we want the display_url flag to
2012 // be from the pending entry.
2013 //
2014 // The confusion comes because there are multiple possibilities for the
2015 // initial load in a tab as a side effect of the way the RenderViewHostManager
2016 // works.
2017 //
2018 // - For the very first tab the load looks "normal". The new tab DOM UI is
2019 // the pending one, and we want it to apply here.
2020 //
2021 // - For subsequent new tabs, they'll get a new SiteInstance which will then
2022 // get switched to the one previously associated with the new tab pages.
2023 // This switching will cause the manager to commit the RVH/DOMUI. So we'll
2024 // have a committed DOM UI in this case.
2025 //
2026 // This condition handles all of these cases:
2027 //
2028 // - First load in first tab: no committed nav entry + pending nav entry +
2029 // pending dom ui:
2030 // -> Use pending DOM UI if any.
2031 //
2032 // - First load in second tab: no committed nav entry + pending nav entry +
2033 // no pending DOM UI:
2034 // -> Use the committed DOM UI if any.
2035 //
2036 // - Second navigation in any tab: committed nav entry + pending nav entry:
2037 // -> Use pending DOM UI if any.
2038 //
2039 // - Normal state with no load: committed nav entry + no pending nav entry:
2040 // -> Use committed DOM UI.
2041 if (controller()->GetPendingEntry() &&
2042 (controller()->GetLastCommittedEntry() ||
2043 render_manager_.pending_dom_ui()))
2044 return render_manager_.pending_dom_ui();
2045 return render_manager_.dom_ui();
2046 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/web_contents.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698