Chromium Code Reviews| 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/tab_contents.h" | 5 #include "chrome/browser/tab_contents/tab_contents.h" |
| 6 | 6 |
| 7 #include "app/gfx/text_elider.h" | 7 #include "app/gfx/text_elider.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 | 179 |
| 180 BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { | 180 BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { |
| 181 // Note: erase is required to properly paint some widgets borders. This can | 181 // Note: erase is required to properly paint some widgets borders. This can |
| 182 // be seen with textfields. | 182 // be seen with textfields. |
| 183 InvalidateRect(hwnd, NULL, TRUE); | 183 InvalidateRect(hwnd, NULL, TRUE); |
| 184 return TRUE; | 184 return TRUE; |
| 185 } | 185 } |
| 186 #endif | 186 #endif |
| 187 | 187 |
| 188 ViewMsg_Navigate_Params::NavigationType GetNavigationType( | 188 ViewMsg_Navigate_Params::NavigationType GetNavigationType( |
| 189 Profile* profile, const NavigationEntry& entry, bool reload) { | 189 Profile* profile, const NavigationEntry& entry, |
| 190 if (reload) | 190 NavigationController::ReloadType reload_type) { |
| 191 return ViewMsg_Navigate_Params::RELOAD; | 191 switch (reload_type) { |
| 192 case NavigationController::RELOAD_VALIDATING_CACHE: | |
|
darin (slow to review)
2010/02/18 22:55:42
nit: maybe you should just stick with RELOAD / REL
| |
| 193 return ViewMsg_Navigate_Params::RELOAD; | |
| 194 case NavigationController::RELOAD_IGNORING_CACHE: | |
| 195 return ViewMsg_Navigate_Params::RELOAD_IGNORING_CACHE; | |
| 196 case NavigationController::NO_RELOAD: | |
| 197 break; // Fall through to rest of function. | |
| 198 } | |
| 192 | 199 |
| 193 if (entry.restore_type() == NavigationEntry::RESTORE_LAST_SESSION && | 200 if (entry.restore_type() == NavigationEntry::RESTORE_LAST_SESSION && |
| 194 profile->DidLastSessionExitCleanly()) | 201 profile->DidLastSessionExitCleanly()) |
| 195 return ViewMsg_Navigate_Params::RESTORE; | 202 return ViewMsg_Navigate_Params::RESTORE; |
| 196 | 203 |
| 197 return ViewMsg_Navigate_Params::NORMAL; | 204 return ViewMsg_Navigate_Params::NORMAL; |
| 198 } | 205 } |
| 199 | 206 |
| 200 void MakeNavigateParams(Profile* profile, const NavigationEntry& entry, | 207 void MakeNavigateParams(Profile* profile, const NavigationEntry& entry, |
| 201 bool reload, ViewMsg_Navigate_Params* params) { | 208 NavigationController::ReloadType reload_type, |
| 209 ViewMsg_Navigate_Params* params) { | |
| 202 params->page_id = entry.page_id(); | 210 params->page_id = entry.page_id(); |
| 203 params->url = entry.url(); | 211 params->url = entry.url(); |
| 204 params->referrer = entry.referrer(); | 212 params->referrer = entry.referrer(); |
| 205 params->transition = entry.transition_type(); | 213 params->transition = entry.transition_type(); |
| 206 params->state = entry.content_state(); | 214 params->state = entry.content_state(); |
| 207 params->navigation_type = GetNavigationType(profile, entry, reload); | 215 params->navigation_type = GetNavigationType(profile, entry, reload_type); |
| 208 params->request_time = base::Time::Now(); | 216 params->request_time = base::Time::Now(); |
| 209 } | 217 } |
| 210 | 218 |
| 211 } // namespace | 219 } // namespace |
| 212 | 220 |
| 213 // ----------------------------------------------------------------------------- | 221 // ----------------------------------------------------------------------------- |
| 214 | 222 |
| 215 // static | 223 // static |
| 216 int TabContents::find_request_id_counter_ = -1; | 224 int TabContents::find_request_id_counter_ = -1; |
| 217 | 225 |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 696 WasHidden(); | 704 WasHidden(); |
| 697 } | 705 } |
| 698 | 706 |
| 699 void TabContents::OpenURL(const GURL& url, const GURL& referrer, | 707 void TabContents::OpenURL(const GURL& url, const GURL& referrer, |
| 700 WindowOpenDisposition disposition, | 708 WindowOpenDisposition disposition, |
| 701 PageTransition::Type transition) { | 709 PageTransition::Type transition) { |
| 702 if (delegate_) | 710 if (delegate_) |
| 703 delegate_->OpenURLFromTab(this, url, referrer, disposition, transition); | 711 delegate_->OpenURLFromTab(this, url, referrer, disposition, transition); |
| 704 } | 712 } |
| 705 | 713 |
| 706 bool TabContents::NavigateToPendingEntry(bool reload) { | 714 bool TabContents::NavigateToPendingEntry( |
| 715 NavigationController::ReloadType reload_type) { | |
| 707 const NavigationEntry& entry = *controller_.pending_entry(); | 716 const NavigationEntry& entry = *controller_.pending_entry(); |
| 708 | 717 |
| 709 RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry); | 718 RenderViewHost* dest_render_view_host = render_manager_.Navigate(entry); |
| 710 if (!dest_render_view_host) | 719 if (!dest_render_view_host) |
| 711 return false; // Unable to create the desired render view host. | 720 return false; // Unable to create the desired render view host. |
| 712 | 721 |
| 713 // Tell DevTools agent that it is attached prior to the navigation. | 722 // Tell DevTools agent that it is attached prior to the navigation. |
| 714 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); | 723 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); |
| 715 if (devtools_manager) { // NULL in unit tests. | 724 if (devtools_manager) { // NULL in unit tests. |
| 716 devtools_manager->OnNavigatingToPendingEntry( | 725 devtools_manager->OnNavigatingToPendingEntry( |
| 717 render_view_host(), | 726 render_view_host(), |
| 718 dest_render_view_host, | 727 dest_render_view_host, |
| 719 controller_.pending_entry()->url()); | 728 controller_.pending_entry()->url()); |
| 720 } | 729 } |
| 721 | 730 |
| 722 // Used for page load time metrics. | 731 // Used for page load time metrics. |
| 723 current_load_start_ = base::TimeTicks::Now(); | 732 current_load_start_ = base::TimeTicks::Now(); |
| 724 | 733 |
| 725 // Navigate in the desired RenderViewHost. | 734 // Navigate in the desired RenderViewHost. |
| 726 ViewMsg_Navigate_Params navigate_params; | 735 ViewMsg_Navigate_Params navigate_params; |
| 727 MakeNavigateParams(profile(), entry, reload, &navigate_params); | 736 MakeNavigateParams(profile(), entry, reload_type, &navigate_params); |
| 728 dest_render_view_host->Navigate(navigate_params); | 737 dest_render_view_host->Navigate(navigate_params); |
| 729 | 738 |
| 730 if (entry.page_id() == -1) { | 739 if (entry.page_id() == -1) { |
| 731 // HACK!! This code suppresses javascript: URLs from being added to | 740 // HACK!! This code suppresses javascript: URLs from being added to |
| 732 // session history, which is what we want to do for javascript: URLs that | 741 // session history, which is what we want to do for javascript: URLs that |
| 733 // do not generate content. What we really need is a message from the | 742 // do not generate content. What we really need is a message from the |
| 734 // renderer telling us that a new page was not created. The same message | 743 // renderer telling us that a new page was not created. The same message |
| 735 // could be used for mailto: URLs and the like. | 744 // could be used for mailto: URLs and the like. |
| 736 if (entry.url().SchemeIs(chrome::kJavaScriptScheme)) | 745 if (entry.url().SchemeIs(chrome::kJavaScriptScheme)) |
| 737 return false; | 746 return false; |
| 738 } | 747 } |
| 739 | 748 |
| 740 // Clear any provisional password saves - this stops password infobars | 749 // Clear any provisional password saves - this stops password infobars |
| 741 // showing up on pages the user navigates to while the right page is | 750 // showing up on pages the user navigates to while the right page is |
| 742 // loading. | 751 // loading. |
| 743 GetPasswordManager()->ClearProvisionalSave(); | 752 GetPasswordManager()->ClearProvisionalSave(); |
| 744 | 753 |
| 745 if (reload && !profile()->IsOffTheRecord()) { | 754 if (reload_type != NavigationController::NO_RELOAD && |
| 755 !profile()->IsOffTheRecord()) { | |
| 746 FaviconService* favicon_service = | 756 FaviconService* favicon_service = |
| 747 profile()->GetFaviconService(Profile::IMPLICIT_ACCESS); | 757 profile()->GetFaviconService(Profile::IMPLICIT_ACCESS); |
| 748 if (favicon_service) | 758 if (favicon_service) |
| 749 favicon_service->SetFaviconOutOfDateForPage(entry.url()); | 759 favicon_service->SetFaviconOutOfDateForPage(entry.url()); |
| 750 } | 760 } |
| 751 | 761 |
| 752 return true; | 762 return true; |
| 753 } | 763 } |
| 754 | 764 |
| 755 void TabContents::Stop() { | 765 void TabContents::Stop() { |
| (...skipping 2093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2849 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, success, prompt); | 2859 render_view_host()->JavaScriptMessageBoxClosed(reply_msg, success, prompt); |
| 2850 } | 2860 } |
| 2851 | 2861 |
| 2852 void TabContents::SetSuppressMessageBoxes(bool suppress_message_boxes) { | 2862 void TabContents::SetSuppressMessageBoxes(bool suppress_message_boxes) { |
| 2853 set_suppress_javascript_messages(suppress_message_boxes); | 2863 set_suppress_javascript_messages(suppress_message_boxes); |
| 2854 } | 2864 } |
| 2855 | 2865 |
| 2856 void TabContents::set_encoding(const std::string& encoding) { | 2866 void TabContents::set_encoding(const std::string& encoding) { |
| 2857 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); | 2867 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); |
| 2858 } | 2868 } |
| OLD | NEW |