diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-25 18:04:59 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-25 18:04:59 +0000 |
commit | 6de74456d80f1f458509ec61c353b7ba2c728b84 (patch) | |
tree | 51912c23a1755d3aa8be422bfb7777fa7ef46860 | |
parent | 24d2b8f01cca7f68cdb526c03a15f75a7feec35b (diff) | |
download | chromium_src-6de74456d80f1f458509ec61c353b7ba2c728b84.zip chromium_src-6de74456d80f1f458509ec61c353b7ba2c728b84.tar.gz chromium_src-6de74456d80f1f458509ec61c353b7ba2c728b84.tar.bz2 |
Delete the ViewSourceTabContents.
This removes all the tab contents type stuff for view source mode. The
RenderViewHostManager now automatically switches RenderViews when we turn view
source mode on or off to get the desired effect.
I also moved some instances of hardcoded schemes into chrome_constants.h, and
renamed RendererCreated/Ready/Gone to RenderViewCreated/Ready/Gone to reflect
what they actually mean.
Review URL: http://codereview.chromium.org/28089
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10346 0039d316-1c4b-4281-b951-d872f2087c98
44 files changed, 176 insertions, 155 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc index 5b031f527..631aebd 100644 --- a/chrome/browser/autocomplete/autocomplete.cc +++ b/chrome/browser/autocomplete/autocomplete.cc @@ -20,6 +20,7 @@ #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" +#include "chrome/common/url_constants.h" #include "googleurl/src/gurl.h" #include "googleurl/src/url_canon_ip.h" #include "grit/generated_resources.h" @@ -118,8 +119,9 @@ AutocompleteInput::Type AutocompleteInput::Parse(const std::wstring& text, // reach the renderer or else the renderer handles internally without // reaching the URLRequest logic. We thus won't catch these above, but we // should still claim to handle them. - if ((parsed_scheme == L"view-source") || (parsed_scheme == L"javascript") || - (parsed_scheme == L"data")) + if (LowerCaseEqualsASCII(parsed_scheme, chrome::kViewSourceScheme) || + LowerCaseEqualsASCII(parsed_scheme, chrome::kJavaScriptScheme) || + LowerCaseEqualsASCII(parsed_scheme, chrome::kDataScheme)) return URL; // Finally, check and see if the user has explicitly opened this scheme as diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index c4bc67b..6866cf4 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -2032,6 +2032,9 @@ void Browser::UpdateCommandsForTabState() { WebContents* web_contents = current_tab->AsWebContents(); bool is_web_contents = web_contents != NULL; + // Current navigation entry, may be NULL. + NavigationEntry* active_entry = current_tab->controller()->GetActiveEntry(); + // Page-related commands // Only allow bookmarking for web content in normal windows. command_updater_.UpdateCommandEnabled(IDC_STAR, @@ -2039,8 +2042,7 @@ void Browser::UpdateCommandsForTabState() { window_->SetStarredState(is_web_contents && web_contents->is_starred()); // View-source should not be enabled if already in view-source mode. command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE, - is_web_contents && (current_tab->type() != TAB_CONTENTS_VIEW_SOURCE) && - current_tab->controller()->GetActiveEntry()); + is_web_contents && active_entry && !active_entry->IsViewSourceMode()); command_updater_.UpdateCommandEnabled(IDC_PRINT, is_web_contents); command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE, is_web_contents && SavePackage::IsSavableURL(current_tab->GetURL())); diff --git a/chrome/browser/browser.scons b/chrome/browser/browser.scons index 4ef5838..e0b346c 100644 --- a/chrome/browser/browser.scons +++ b/chrome/browser/browser.scons @@ -587,8 +587,6 @@ input_files = ChromeFileList([ 'tab_contents/tab_contents_type.h', 'tab_contents/tab_util.cc', 'tab_contents/tab_util.h', - 'tab_contents/view_source_contents.cc', - 'tab_contents/view_source_contents.h', 'tab_contents/web_contents.cc', 'tab_contents/web_contents.h', 'tab_contents/web_contents_view.cc', diff --git a/chrome/browser/browser.vcproj b/chrome/browser/browser.vcproj index e8ee21e..317ed07 100644 --- a/chrome/browser/browser.vcproj +++ b/chrome/browser/browser.vcproj @@ -2222,14 +2222,6 @@ > </File> <File - RelativePath=".\tab_contents\view_source_contents.cc" - > - </File> - <File - RelativePath=".\tab_contents\view_source_contents.h" - > - </File> - <File RelativePath=".\tab_contents\web_contents.cc" > </File> diff --git a/chrome/browser/history/history.cc b/chrome/browser/history/history.cc index 839e3d1..49707cf 100644 --- a/chrome/browser/history/history.cc +++ b/chrome/browser/history/history.cc @@ -44,6 +44,7 @@ #include "chrome/common/l10n_util.h" #include "chrome/common/notification_service.h" #include "chrome/common/thumbnail_score.h" +#include "chrome/common/url_constants.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" @@ -571,12 +572,12 @@ bool HistoryService::CanAddURL(const GURL& url) const { if (!url.is_valid()) return false; - if (url.SchemeIs("javascript") || - url.SchemeIs("chrome") || - url.SchemeIs("view-source")) + if (url.SchemeIs(chrome::kJavaScriptScheme) || + url.SchemeIs(chrome::kChromeUIScheme) || + url.SchemeIs(chrome::kViewSourceScheme)) return false; - if (url.SchemeIs("about")) { + if (url.SchemeIs(chrome::kAboutScheme)) { std::string path = url.path(); if (path.empty() || LowerCaseEqualsASCII(path, "blank")) return false; diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc index c251f8a..c448dbb 100644 --- a/chrome/browser/printing/print_view_manager.cc +++ b/chrome/browser/printing/print_view_manager.cc @@ -40,7 +40,7 @@ void PrintViewManager::Stop() { TerminatePrintJob(true); } -bool PrintViewManager::OnRendererGone(RenderViewHost* render_view_host) { +bool PrintViewManager::OnRenderViewGone(RenderViewHost* render_view_host) { if (!print_job_.get()) return true; diff --git a/chrome/browser/printing/print_view_manager.h b/chrome/browser/printing/print_view_manager.h index 1392ac57..698c714 100644 --- a/chrome/browser/printing/print_view_manager.h +++ b/chrome/browser/printing/print_view_manager.h @@ -36,7 +36,7 @@ class PrintViewManager : public NotificationObserver, // Terminates or cancels the print job if one was pending, depending on the // current state. Returns false if the renderer was not valuable. - bool OnRendererGone(RenderViewHost* render_view_host); + bool OnRenderViewGone(RenderViewHost* render_view_host); // Received a notification from the renderer that the number of printed page // has just been calculated.. diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 096930d..b1efc93 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -789,7 +789,7 @@ void BrowserRenderProcessHost::OnChannelError() { IDMap<IPC::Channel::Listener> local_listeners(listeners_); for (listeners_iterator i = local_listeners.begin(); i != local_listeners.end(); ++i) { - i->second->OnMessageReceived(ViewHostMsg_RendererGone(i->first)); + i->second->OnMessageReceived(ViewHostMsg_RenderViewGone(i->first)); } // at this point, this object should be deleted } diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 8770bcf..edff720 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -179,7 +179,7 @@ bool RenderViewHost::CreateRenderView() { routing_id(), enable_dom_ui_bindings_, enable_external_host_bindings_)); // Let our delegate know that we created a RenderView. - delegate_->RendererCreated(this); + delegate_->RenderViewCreated(this); return true; } @@ -671,8 +671,8 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_ShowView, OnMsgShowView) IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnMsgShowWidget) IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunModal, OnMsgRunModal) - IPC_MESSAGE_HANDLER(ViewHostMsg_RendererReady, OnMsgRendererReady) - IPC_MESSAGE_HANDLER(ViewHostMsg_RendererGone, OnMsgRendererGone) + IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnMsgRenderViewReady) + IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewGone, OnMsgRenderViewGone) IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_FrameNavigate, OnMsgNavigate(msg)) IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateState, OnMsgUpdateState) IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTitle, OnMsgUpdateTitle) @@ -818,12 +818,12 @@ void RenderViewHost::OnMsgRunModal(IPC::Message* reply_msg) { // an app-modal fashion. } -void RenderViewHost::OnMsgRendererReady() { +void RenderViewHost::OnMsgRenderViewReady() { WasResized(); - delegate_->RendererReady(this); + delegate_->RenderViewReady(this); } -void RenderViewHost::OnMsgRendererGone() { +void RenderViewHost::OnMsgRenderViewGone() { // Our base class RenderWidgetHouse needs to reset some stuff. RendererExited(); @@ -831,7 +831,7 @@ void RenderViewHost::OnMsgRendererGone() { // from a crashed renderer. renderer_initialized_ = false; - delegate_->RendererGone(this); + delegate_->RenderViewGone(this); OnDebugDisconnect(); } diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index 15d0c6f..2974db6 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -428,8 +428,8 @@ class RenderViewHost : public RenderWidgetHost { bool user_gesture); void OnMsgShowWidget(int route_id, const gfx::Rect& initial_pos); void OnMsgRunModal(IPC::Message* reply_msg); - void OnMsgRendererReady(); - void OnMsgRendererGone(); + void OnMsgRenderViewReady(); + void OnMsgRenderViewGone(); void OnMsgNavigate(const IPC::Message& msg); void OnMsgUpdateState(int32 page_id, const std::string& state); diff --git a/chrome/browser/renderer_host/render_view_host_delegate.h b/chrome/browser/renderer_host/render_view_host_delegate.h index 67ac07e..7c7fe4a 100644 --- a/chrome/browser/renderer_host/render_view_host_delegate.h +++ b/chrome/browser/renderer_host/render_view_host_delegate.h @@ -150,13 +150,13 @@ class RenderViewHostDelegate { // The RenderView is being constructed (message sent to the renderer process // to construct a RenderView). Now is a good time to send other setup events // to the RenderView. This precedes any other commands to the RenderView. - virtual void RendererCreated(RenderViewHost* render_view_host) { } + virtual void RenderViewCreated(RenderViewHost* render_view_host) { } // The RenderView has been constructed. - virtual void RendererReady(RenderViewHost* render_view_host) { } + virtual void RenderViewReady(RenderViewHost* render_view_host) { } // The RenderView died somehow (crashed or was killed by the user). - virtual void RendererGone(RenderViewHost* render_view_host) { } + virtual void RenderViewGone(RenderViewHost* render_view_host) { } // The RenderView was navigated to a different page. virtual void DidNavigate(RenderViewHost* render_view_host, diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc index 1f0ab85..b27f835 100644 --- a/chrome/browser/renderer_host/render_widget_host.cc +++ b/chrome/browser/renderer_host/render_widget_host.cc @@ -91,8 +91,8 @@ void RenderWidgetHost::Shutdown() { } IPC_DEFINE_MESSAGE_MAP(RenderWidgetHost) - IPC_MESSAGE_HANDLER(ViewHostMsg_RendererReady, OnMsgRendererReady) - IPC_MESSAGE_HANDLER(ViewHostMsg_RendererGone, OnMsgRendererGone) + IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnMsgRenderViewReady) + IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewGone, OnMsgRenderViewGone) IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnMsgClose) IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnMsgRequestMove) IPC_MESSAGE_HANDLER(ViewHostMsg_PaintRect, OnMsgPaintRect) @@ -321,8 +321,8 @@ void RenderWidgetHost::RendererExited() { is_hidden_ = false; if (view_) { - view_->RendererGone(); - view_ = NULL; // The View should be deleted by RendererGone. + view_->RenderViewGone(); + view_ = NULL; // The View should be deleted by RenderViewGone. } BackingStoreManager::RemoveBackingStore(this); @@ -376,11 +376,11 @@ void RenderWidgetHost::RendererIsResponsive() { } } -void RenderWidgetHost::OnMsgRendererReady() { +void RenderWidgetHost::OnMsgRenderViewReady() { WasResized(); } -void RenderWidgetHost::OnMsgRendererGone() { +void RenderWidgetHost::OnMsgRenderViewGone() { // TODO(evanm): This synchronously ends up calling "delete this". // Is that really what we want in response to this message? I'm matching // previous behavior of the code here. diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h index 8c8f007..df0c417 100644 --- a/chrome/browser/renderer_host/render_widget_host.h +++ b/chrome/browser/renderer_host/render_widget_host.h @@ -247,8 +247,8 @@ class RenderWidgetHost : public IPC::Channel::Listener { void RendererIsResponsive(); // IPC message handlers - void OnMsgRendererReady(); - void OnMsgRendererGone(); + void OnMsgRenderViewReady(); + void OnMsgRenderViewGone(); void OnMsgClose(); void OnMsgRequestMove(const gfx::Rect& pos); void OnMsgPaintRect(const ViewHostMsg_PaintRect_Params& params); diff --git a/chrome/browser/renderer_host/render_widget_host_view.h b/chrome/browser/renderer_host/render_widget_host_view.h index b451fd3..7b00158 100644 --- a/chrome/browser/renderer_host/render_widget_host_view.h +++ b/chrome/browser/renderer_host/render_widget_host_view.h @@ -100,7 +100,7 @@ class RenderWidgetHostView { const gfx::Rect& rect, int dx, int dy) = 0; // Notifies the View that the renderer has ceased to exist. - virtual void RendererGone() = 0; + virtual void RenderViewGone() = 0; // Tells the View to destroy itself. virtual void Destroy() = 0; diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc index c955abc..1151152 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc @@ -261,7 +261,7 @@ void RenderWidgetHostViewGtk::DidScrollRect(const gfx::Rect& rect, int dx, Paint(rect); } -void RenderWidgetHostViewGtk::RendererGone() { +void RenderWidgetHostViewGtk::RenderViewGone() { NOTIMPLEMENTED(); } diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.h b/chrome/browser/renderer_host/render_widget_host_view_gtk.h index d839f06..9d342ff 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.h +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.h @@ -44,7 +44,7 @@ class RenderWidgetHostViewGtk : public RenderWidgetHostView { void DidPaintRect(const gfx::Rect& rect); void DidScrollRect( const gfx::Rect& rect, int dx, int dy); - void RendererGone(); + void RenderViewGone(); void Destroy(); void SetTooltipText(const std::wstring& tooltip_text); // --------------------------------------------------------------------------- diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.h b/chrome/browser/renderer_host/render_widget_host_view_mac.h index a9221c9..13d4fb6 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.h +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.h @@ -75,7 +75,7 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { virtual void IMEUpdateStatus(int control, const gfx::Rect& caret_rect); virtual void DidPaintRect(const gfx::Rect& rect); virtual void DidScrollRect(const gfx::Rect& rect, int dx, int dy); - virtual void RendererGone(); + virtual void RenderViewGone(); virtual void Destroy(); virtual void SetTooltipText(const std::wstring& tooltip_text); diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm index afc0f25..24a68ac 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm +++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm @@ -181,7 +181,7 @@ void RenderWidgetHostViewMac::DidScrollRect( [cocoa_view_ setNeedsDisplayInRect:[cocoa_view_ RectToNSRect:dirty_rect]]; } -void RenderWidgetHostViewMac::RendererGone() { +void RenderWidgetHostViewMac::RenderViewGone() { // TODO(darin): keep this around, and draw sad-tab into it. UpdateCursorIfOverSelf(); Destroy(); diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc index b9fe070..6369485 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc @@ -400,7 +400,7 @@ void RenderWidgetHostViewWin::DidScrollRect( Redraw(gfx::Rect(invalid_rect)); } -void RenderWidgetHostViewWin::RendererGone() { +void RenderWidgetHostViewWin::RenderViewGone() { // TODO(darin): keep this around, and draw sad-tab into it. UpdateCursorIfOverSelf(); DestroyWindow(); diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.h b/chrome/browser/renderer_host/render_widget_host_view_win.h index 02887c5..dad1b5d 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.h +++ b/chrome/browser/renderer_host/render_widget_host_view_win.h @@ -134,7 +134,7 @@ class RenderWidgetHostViewWin : virtual void IMEUpdateStatus(int control, const gfx::Rect& caret_rect); virtual void DidPaintRect(const gfx::Rect& rect); virtual void DidScrollRect(const gfx::Rect& rect, int dx, int dy); - virtual void RendererGone(); + virtual void RenderViewGone(); virtual void Destroy(); virtual void SetTooltipText(const std::wstring& tooltip_text); diff --git a/chrome/browser/renderer_host/renderer_security_policy.cc b/chrome/browser/renderer_host/renderer_security_policy.cc index 3350f59..71a71ec 100644 --- a/chrome/browser/renderer_host/renderer_security_policy.cc +++ b/chrome/browser/renderer_host/renderer_security_policy.cc @@ -6,6 +6,7 @@ #include "base/logging.h" #include "base/string_util.h" +#include "chrome/common/url_constants.h" #ifdef CHROME_PERSONALIZATION #include "chrome/personalization/personalization.h" #endif @@ -85,9 +86,9 @@ RendererSecurityPolicy::RendererSecurityPolicy() { RegisterWebSafeScheme("chrome-extension"); // We know about the following psuedo schemes and treat them specially. - RegisterPseudoScheme("about"); - RegisterPseudoScheme("javascript"); - RegisterPseudoScheme("view-source"); + RegisterPseudoScheme(chrome::kAboutScheme); + RegisterPseudoScheme(chrome::kJavaScriptScheme); + RegisterPseudoScheme(chrome::kViewSourceScheme); } // static diff --git a/chrome/browser/renderer_host/test_render_view_host.h b/chrome/browser/renderer_host/test_render_view_host.h index 380222a..b6d011e 100644 --- a/chrome/browser/renderer_host/test_render_view_host.h +++ b/chrome/browser/renderer_host/test_render_view_host.h @@ -64,7 +64,7 @@ class TestRenderWidgetHostView : public RenderWidgetHostView { virtual void IMEUpdateStatus(int control, const gfx::Rect& caret_rect) {} virtual void DidPaintRect(const gfx::Rect& rect) {} virtual void DidScrollRect(const gfx::Rect& rect, int dx, int dy) {} - virtual void RendererGone() {} + virtual void RenderViewGone() {} virtual void Destroy() {} virtual void PrepareToDestroy() {} virtual void SetTooltipText(const std::wstring& tooltip_text) {} diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc index cb9fe98..4511447 100644 --- a/chrome/browser/tab_contents/interstitial_page.cc +++ b/chrome/browser/tab_contents/interstitial_page.cc @@ -371,7 +371,7 @@ void InterstitialPage::DidNavigate( #endif } -void InterstitialPage::RendererGone(RenderViewHost* render_view_host) { +void InterstitialPage::RenderViewGone(RenderViewHost* render_view_host) { // Our renderer died. This should not happen in normal cases. // Just dismiss the interstitial. DontProceed(); diff --git a/chrome/browser/tab_contents/interstitial_page.h b/chrome/browser/tab_contents/interstitial_page.h index f6fe1ee..d05d0aa 100644 --- a/chrome/browser/tab_contents/interstitial_page.h +++ b/chrome/browser/tab_contents/interstitial_page.h @@ -86,7 +86,7 @@ class InterstitialPage : public NotificationObserver, } virtual void DidNavigate(RenderViewHost* render_view_host, const ViewHostMsg_FrameNavigate_Params& params); - virtual void RendererGone(RenderViewHost* render_view_host); + virtual void RenderViewGone(RenderViewHost* render_view_host); virtual void DomOperationResponse(const std::string& json_string, int automation_id); virtual void UpdateTitle(RenderViewHost* render_view_host, diff --git a/chrome/browser/tab_contents/navigation_controller.cc b/chrome/browser/tab_contents/navigation_controller.cc index 91d0d84..def6c34 100644 --- a/chrome/browser/tab_contents/navigation_controller.cc +++ b/chrome/browser/tab_contents/navigation_controller.cc @@ -17,6 +17,7 @@ #include "chrome/common/notification_service.h" #include "chrome/common/render_messages.h" #include "chrome/common/resource_bundle.h" +#include "chrome/common/url_constants.h" #include "webkit/glue/webkit_glue.h" #if defined(OS_WIN) @@ -55,7 +56,7 @@ void SetContentStateIfEmpty(NavigationEntry* entry) { entry->tab_type() == TAB_CONTENTS_NEW_TAB_UI || entry->tab_type() == TAB_CONTENTS_ABOUT_UI || entry->tab_type() == TAB_CONTENTS_HTML_DIALOG || - entry->tab_type() == TAB_CONTENTS_VIEW_SOURCE)) { + entry->IsViewSourceMode())) { entry->set_content_state( webkit_glue::CreateHistoryStateForURL(entry->url())); } @@ -467,6 +468,11 @@ NavigationEntry* NavigationController::CreateNavigationEntry( else type = TabContents::TypeForURL(&real_url); + if (url.SchemeIs(chrome::kViewSourceScheme)) { + // Load the inner URL instead, setting the original URL as the "display". + real_url = GURL(url.path()); + } + NavigationEntry* entry = new NavigationEntry(type, NULL, -1, real_url, referrer, std::wstring(), transition); diff --git a/chrome/browser/tab_contents/navigation_controller.h b/chrome/browser/tab_contents/navigation_controller.h index a7518c3..00b6b0f 100644 --- a/chrome/browser/tab_contents/navigation_controller.h +++ b/chrome/browser/tab_contents/navigation_controller.h @@ -160,7 +160,6 @@ class NavigationController { // // If you are trying to get the current state of the NavigationController, // this is the method you will typically want to call. - // NavigationEntry* GetActiveEntry() const; // Returns the index from which we would go back/forward or reload. This is diff --git a/chrome/browser/tab_contents/navigation_entry.cc b/chrome/browser/tab_contents/navigation_entry.cc index bf0951c..e243f8a 100644 --- a/chrome/browser/tab_contents/navigation_entry.cc +++ b/chrome/browser/tab_contents/navigation_entry.cc @@ -4,6 +4,7 @@ #include "chrome/browser/tab_contents/navigation_entry.h" +#include "chrome/common/url_constants.h" #include "chrome/common/resource_bundle.h" // Use this to get a new unique ID for a NavigationEntry during construction. @@ -62,3 +63,7 @@ const std::wstring& NavigationEntry::GetTitleForDisplay() { return display_url_as_string_; return title_; } + +bool NavigationEntry::IsViewSourceMode() const { + return display_url_.SchemeIs(chrome::kViewSourceScheme); +} diff --git a/chrome/browser/tab_contents/navigation_entry.h b/chrome/browser/tab_contents/navigation_entry.h index 377e8df..20d3fd4 100644 --- a/chrome/browser/tab_contents/navigation_entry.h +++ b/chrome/browser/tab_contents/navigation_entry.h @@ -309,6 +309,16 @@ class NavigationEntry { return ssl_; } + // Page-related helpers ------------------------------------------------------ + + // Returns the title to be displayed on the tab. This could be the title of + // the page if it is available or the URL. + const std::wstring& GetTitleForDisplay(); + + // Returns true if the current tab is in view source mode. This will be false + // if there is no navigation. + bool IsViewSourceMode() const; + // Tracking stuff ------------------------------------------------------------ // The transition type indicates what the user did to move to this page from @@ -359,10 +369,6 @@ class NavigationEntry { return restored_; } - // Returns the title to be displayed on the tab. This could be the title of - // the page if it is available or the URL. - const std::wstring& GetTitleForDisplay(); - private: // WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING // Session/Tab restore save portions of this class so that it can be recreated diff --git a/chrome/browser/tab_contents/render_view_context_menu_controller.cc b/chrome/browser/tab_contents/render_view_context_menu_controller.cc index 8882628..df373e4 100644 --- a/chrome/browser/tab_contents/render_view_context_menu_controller.cc +++ b/chrome/browser/tab_contents/render_view_context_menu_controller.cc @@ -24,6 +24,7 @@ #include "chrome/common/l10n_util.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" +#include "chrome/common/url_constants.h" #include "grit/generated_resources.h" #include "net/base/escape.h" #include "net/base/net_util.h" @@ -519,17 +520,17 @@ bool RenderViewContextMenuController::IsDevCommandEnabled(int id) const { return false; // Don't inspect view source. - if (source_web_contents_->type() == TAB_CONTENTS_VIEW_SOURCE) + if (active_entry->IsViewSourceMode()) return false; // Don't inspect inspector, new tab UI, etc. - if (active_entry->url().SchemeIs("chrome")) + if (active_entry->url().SchemeIs(chrome::kChromeUIScheme)) return false; // Don't inspect about:network, about:memory, etc. // However, we do want to inspect about:blank, which is often // used by ordinary web pages. - if (active_entry->display_url().SchemeIs("about") && + if (active_entry->display_url().SchemeIs(chrome::kAboutScheme) && !LowerCaseEqualsASCII(active_entry->display_url().path(), "blank")) return false; diff --git a/chrome/browser/tab_contents/render_view_host_manager.cc b/chrome/browser/tab_contents/render_view_host_manager.cc index d315eac..b1062bc 100644 --- a/chrome/browser/tab_contents/render_view_host_manager.cc +++ b/chrome/browser/tab_contents/render_view_host_manager.cc @@ -267,6 +267,21 @@ bool RenderViewHostManager::ShouldTransitionCrossSite() { return !CommandLine::ForCurrentProcess()->HasSwitch(switches::kProcessPerTab); } +bool RenderViewHostManager::ShouldSwapRenderViewsForNavigation( + const NavigationEntry* cur_entry, + const NavigationEntry* new_entry) const { + if (!cur_entry || !new_entry) + return false; + + // We can't switch a RenderView between view source and non-view source mode + // without screwing up the session history sometimes (when navigating between + // "view-source:http://foo.com/" and "http://foo.com/", WebKit doesn't treat + // it as a new navigation). So require a view switch. + if (cur_entry->IsViewSourceMode() != new_entry->IsViewSourceMode()) + return true; + return false; +} + SiteInstance* RenderViewHostManager::GetSiteInstanceForEntry( const NavigationEntry& entry, SiteInstance* curr_instance) { @@ -413,12 +428,12 @@ void RenderViewHostManager::SwapToRenderView( (*new_render_view_host) = NULL; // If the view is gone, then this RenderViewHost died while it was hidden. - // We ignored the RendererGone call at the time, so we should send it now + // We ignored the RenderViewGone call at the time, so we should send it now // to make sure the sad tab shows up, etc. if (render_view_host_->view()) render_view_host_->view()->Show(); else - delegate_->RendererGoneFromRenderManager(render_view_host_); + delegate_->RenderViewGoneFromRenderManager(render_view_host_); // Make sure the size is up to date. (Fix for bug 1079768.) delegate_->UpdateRenderViewSizeForRenderManager(); @@ -463,7 +478,9 @@ RenderViewHost* RenderViewHostManager::UpdateRendererStateNavigate( if (ShouldTransitionCrossSite()) new_instance = GetSiteInstanceForEntry(entry, curr_instance); - if (new_instance != curr_instance) { + if (new_instance != curr_instance || ShouldSwapRenderViewsForNavigation( + delegate_->GetLastCommittedNavigationEntryForRenderManager(), + &entry)) { // New SiteInstance. DCHECK(!cross_navigation_pending_); diff --git a/chrome/browser/tab_contents/render_view_host_manager.h b/chrome/browser/tab_contents/render_view_host_manager.h index 268b298..160ecff 100644 --- a/chrome/browser/tab_contents/render_view_host_manager.h +++ b/chrome/browser/tab_contents/render_view_host_manager.h @@ -42,11 +42,16 @@ class RenderViewHostManager : public NotificationObserver { bool proceed, bool* proceed_to_fire_unload) = 0; virtual void DidStartLoadingFromRenderManager( RenderViewHost* render_view_host, int32 page_id) = 0; - virtual void RendererGoneFromRenderManager( + virtual void RenderViewGoneFromRenderManager( RenderViewHost* render_view_host) = 0; virtual void UpdateRenderViewSizeForRenderManager() = 0; virtual void NotifySwappedFromRenderManager() = 0; virtual NavigationController* GetControllerForRenderManager() = 0; + + // Returns the navigation entry of the current navigation, or NULL if there + // is none. + virtual NavigationEntry* + GetLastCommittedNavigationEntryForRenderManager() = 0; }; // The factory is optional. It is used by unit tests to supply custom render @@ -167,6 +172,13 @@ class RenderViewHostManager : public NotificationObserver { // switch. Can be overridden in unit tests. bool ShouldTransitionCrossSite(); + // Returns true if the two navigation entries are incompatible in some way + // other than site instances. This will cause us to swap RenderViewHosts even + // if the site instances are the same. Either of the entries may be NULL. + bool ShouldSwapRenderViewsForNavigation( + const NavigationEntry* cur_entry, + const NavigationEntry* new_entry) const; + // Returns an appropriate SiteInstance object for the given NavigationEntry, // possibly reusing the current SiteInstance. // Never called if --process-per-tab is used. @@ -200,7 +212,9 @@ class RenderViewHostManager : public NotificationObserver { // Our delegate, not owned by us. Guaranteed non-NULL. Delegate* delegate_; - // Whether a cross-site request is pending (in the new process model). + // Whether a navigation requiring different RenderView's is pending. This is + // either cross-site request is (in the new process model), or when required + // for the view type (like view source versus not). bool cross_navigation_pending_; // Allows tests to create their own render view host types. diff --git a/chrome/browser/tab_contents/tab_contents_factory.cc b/chrome/browser/tab_contents/tab_contents_factory.cc index 9a5063f..045a01c 100644 --- a/chrome/browser/tab_contents/tab_contents_factory.cc +++ b/chrome/browser/tab_contents/tab_contents_factory.cc @@ -11,7 +11,6 @@ #include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/browser/debugger/debugger_contents.h" #include "chrome/browser/tab_contents/tab_contents_factory.h" -#include "chrome/browser/tab_contents/view_source_contents.h" #include "chrome/browser/tab_contents/web_contents.h" #include "net/base/net_util.h" @@ -58,9 +57,6 @@ TabContents* TabContents::CreateWithType(TabContentsType type, case TAB_CONTENTS_NATIVE_UI: contents = new NativeUIContents(profile); break; - case TAB_CONTENTS_VIEW_SOURCE: - contents = new ViewSourceContents(profile, instance); - break; case TAB_CONTENTS_ABOUT_UI: contents = new BrowserAboutHandler(profile, instance, NULL); break; @@ -119,11 +115,6 @@ TabContentsType TabContents::TypeForURL(GURL* url) { if (url->SchemeIs(DOMUIContents::GetScheme().c_str())) return TAB_CONTENTS_DOM_UI; - if (url->SchemeIs("view-source")) { - // Load the inner URL instead, but render it using a ViewSourceContents. - *url = GURL(url->path()); - return TAB_CONTENTS_VIEW_SOURCE; - } #elif defined(OS_POSIX) NOTIMPLEMENTED(); #endif diff --git a/chrome/browser/tab_contents/tab_contents_type.h b/chrome/browser/tab_contents/tab_contents_type.h index 87cd6452..53e79b0 100644 --- a/chrome/browser/tab_contents/tab_contents_type.h +++ b/chrome/browser/tab_contents/tab_contents_type.h @@ -16,7 +16,6 @@ enum TabContentsType { TAB_CONTENTS_CHROME_VIEW_CONTENTS, TAB_CONTENTS_NEW_TAB_UI, TAB_CONTENTS_NATIVE_UI, - TAB_CONTENTS_VIEW_SOURCE, TAB_CONTENTS_HTML_DIALOG, TAB_CONTENTS_ABOUT_UI, TAB_CONTENTS_DEBUGGER, diff --git a/chrome/browser/tab_contents/view_source_contents.cc b/chrome/browser/tab_contents/view_source_contents.cc deleted file mode 100644 index be95c5b..0000000 --- a/chrome/browser/tab_contents/view_source_contents.cc +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/tab_contents/view_source_contents.h" - -#include "chrome/browser/renderer_host/render_view_host.h" -#include "chrome/browser/tab_contents/navigation_entry.h" -#include "chrome/common/render_messages.h" - -ViewSourceContents::ViewSourceContents(Profile* profile, SiteInstance* instance) - : WebContents(profile, instance, NULL, MSG_ROUTING_NONE, NULL) { - set_type(TAB_CONTENTS_VIEW_SOURCE); -} - -void ViewSourceContents::RendererCreated(RenderViewHost* host) { - // Make sure the renderer is in view source mode. - host->Send(new ViewMsg_EnableViewSourceMode(host->routing_id())); -} - diff --git a/chrome/browser/tab_contents/view_source_contents.h b/chrome/browser/tab_contents/view_source_contents.h deleted file mode 100644 index f09f14b..0000000 --- a/chrome/browser/tab_contents/view_source_contents.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_TAB_CONTENTS_VIEW_SOURCE_CONTENTS_H_ -#define CHROME_BROWSER_TAB_CONTENTS_VIEW_SOURCE_CONTENTS_H_ - -#include "chrome/browser/tab_contents/web_contents.h" - -// We use this class to implement view-source: URLs. -class ViewSourceContents : public WebContents { - public: - ViewSourceContents(Profile* profile, SiteInstance* instance); - - protected: - // RenderViewHostDelegate overrides: - virtual void RendererCreated(RenderViewHost* host); - - // WebContents overrides: - // We override updating history with a no-op so these pages - // are not saved to history. - virtual void UpdateHistoryForNavigation(const GURL& url, - const ViewHostMsg_FrameNavigate_Params& params) { } -}; - -#endif // CHROME_BROWSER_TAB_CONTENTS_VIEW_SOURCE_CONTENTS_H_ - diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc index ecf33c9..11665cc 100644 --- a/chrome/browser/tab_contents/web_contents.cc +++ b/chrome/browser/tab_contents/web_contents.cc @@ -36,6 +36,7 @@ #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "chrome/common/render_messages.h" +#include "chrome/common/url_constants.h" #include "grit/locale_settings.h" #include "net/base/mime_util.h" #include "net/base/net_errors.h" @@ -391,7 +392,7 @@ bool WebContents::NavigateToPendingEntry(bool reload) { // do not generate content. What we really need is a message from the // renderer telling us that a new page was not created. The same message // could be used for mailto: URLs and the like. - if (entry->url().SchemeIs("javascript")) + if (entry->url().SchemeIs(chrome::kJavaScriptScheme)) return false; } @@ -672,7 +673,21 @@ Profile* WebContents::GetProfile() const { return profile(); } -void WebContents::RendererReady(RenderViewHost* rvh) { +void WebContents::RenderViewCreated(RenderViewHost* render_view_host) { + if (!controller()) + return; + NavigationEntry* entry = controller()->GetActiveEntry(); + if (!entry) + return; + + if (entry->IsViewSourceMode()) { + // Put the renderer in view source mode. + render_view_host->Send( + new ViewMsg_EnableViewSourceMode(render_view_host->routing_id())); + } +} + +void WebContents::RenderViewReady(RenderViewHost* rvh) { if (rvh != render_view_host()) { // Don't notify the world, since this came from a renderer in the // background. @@ -683,9 +698,9 @@ void WebContents::RendererReady(RenderViewHost* rvh) { SetIsCrashed(false); } -void WebContents::RendererGone(RenderViewHost* rvh) { +void WebContents::RenderViewGone(RenderViewHost* rvh) { // Ask the print preview if this renderer was valuable. - if (!printing_.OnRendererGone(rvh)) + if (!printing_.OnRenderViewGone(rvh)) return; if (rvh != render_view_host()) { // The pending page's RenderViewHost is gone. @@ -1456,6 +1471,13 @@ void WebContents::UpdateRenderViewSizeForRenderManager() { view_->SizeContents(view_->GetContainerSize()); } +NavigationEntry* +WebContents::GetLastCommittedNavigationEntryForRenderManager() { + if (!controller()) + return NULL; + return controller()->GetLastCommittedEntry(); +} + bool WebContents::CreateRenderViewForRenderManager( RenderViewHost* render_view_host) { RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(render_view_host); diff --git a/chrome/browser/tab_contents/web_contents.h b/chrome/browser/tab_contents/web_contents.h index 08ac907..3974a78 100644 --- a/chrome/browser/tab_contents/web_contents.h +++ b/chrome/browser/tab_contents/web_contents.h @@ -107,6 +107,8 @@ class WebContents : public TabContents, return view_.get(); } + // Page state getters & setters ---------------------------------------------- + bool is_starred() const { return is_starred_; } const std::wstring& encoding() const { return encoding_; } @@ -282,8 +284,9 @@ class WebContents : public TabContents, virtual RenderViewHostDelegate::Save* GetSaveDelegate() const; virtual Profile* GetProfile() const; virtual WebContents* GetAsWebContents() { return this; } - virtual void RendererReady(RenderViewHost* render_view_host); - virtual void RendererGone(RenderViewHost* render_view_host); + virtual void RenderViewCreated(RenderViewHost* render_view_host); + virtual void RenderViewReady(RenderViewHost* render_view_host); + virtual void RenderViewGone(RenderViewHost* render_view_host); virtual void DidNavigate(RenderViewHost* render_view_host, const ViewHostMsg_FrameNavigate_Params& params); virtual void UpdateState(RenderViewHost* render_view_host, @@ -405,8 +408,9 @@ class WebContents : public TabContents, RenderViewHost* render_view_host, int32 page_id) { DidStartLoading(render_view_host, page_id); } - virtual void RendererGoneFromRenderManager(RenderViewHost* render_view_host) { - RendererGone(render_view_host); + virtual void RenderViewGoneFromRenderManager( + RenderViewHost* render_view_host) { + RenderViewGone(render_view_host); } virtual void UpdateRenderViewSizeForRenderManager(); virtual void NotifySwappedFromRenderManager() { @@ -415,6 +419,7 @@ class WebContents : public TabContents, virtual NavigationController* GetControllerForRenderManager() { return controller(); } + virtual NavigationEntry* GetLastCommittedNavigationEntryForRenderManager(); // Initializes the given renderer if necessary and creates the view ID // corresponding to this view host. If this method is not called and the diff --git a/chrome/browser/tab_contents/web_contents_unittest.cc b/chrome/browser/tab_contents/web_contents_unittest.cc index 60f795e..9e595af0 100644 --- a/chrome/browser/tab_contents/web_contents_unittest.cc +++ b/chrome/browser/tab_contents/web_contents_unittest.cc @@ -125,8 +125,8 @@ class TestInterstitialPage : public InterstitialPage { DidNavigate(render_view_host(), params); } - void TestRendererGone() { - RendererGone(render_view_host()); + void TestRenderViewGone() { + RenderViewGone(render_view_host()); } bool is_showing() const { @@ -1032,7 +1032,7 @@ TEST_F(WebContentsTest, InterstitialCrasher) { TestInterstitialPageStateGuard state_guard(interstitial); interstitial->Show(); // Simulate a renderer crash before the interstitial is shown. - interstitial->TestRendererGone(); + interstitial->TestRenderViewGone(); // The interstitial should have been dismissed. EXPECT_TRUE(deleted); EXPECT_EQ(TestInterstitialPage::CANCELED, state); @@ -1043,7 +1043,7 @@ TEST_F(WebContentsTest, InterstitialCrasher) { interstitial->Show(); interstitial->TestDidNavigate(1, url); // Simulate a renderer crash. - interstitial->TestRendererGone(); + interstitial->TestRenderViewGone(); // The interstitial should have been dismissed. EXPECT_TRUE(deleted); EXPECT_EQ(TestInterstitialPage::CANCELED, state); diff --git a/chrome/chrome.xcodeproj/project.pbxproj b/chrome/chrome.xcodeproj/project.pbxproj index 1edaef7..171a28c 100644 --- a/chrome/chrome.xcodeproj/project.pbxproj +++ b/chrome/chrome.xcodeproj/project.pbxproj @@ -328,6 +328,8 @@ A7A20BF20F3A16DC00F62B4D /* render_widget.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D640CD50EAE868600EBCFC0 /* render_widget.cc */; }; A7A20E650F3A1E1C00F62B4D /* render_view.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D640CD30EAE868600EBCFC0 /* render_view.cc */; }; A7A214A00F3B91B100F62B4D /* resource_message_filter.cc in Sources */ = {isa = PBXBuildFile; fileRef = A7A211730F3A248300F62B4D /* resource_message_filter.cc */; }; + A7A400540F54B6CB00F9E371 /* url_constants.cc in Sources */ = {isa = PBXBuildFile; fileRef = A7A400520F54B6CB00F9E371 /* url_constants.cc */; }; + A7A400550F54B6CB00F9E371 /* url_constants.cc in Sources */ = {isa = PBXBuildFile; fileRef = A7A400520F54B6CB00F9E371 /* url_constants.cc */; }; A7C612990F30D63D008CEE5D /* render_process_host.cc in Sources */ = {isa = PBXBuildFile; fileRef = B5D16EC10F2144D500861FAC /* render_process_host.cc */; }; A7C613C10F30D7E4008CEE5D /* mock_render_process_host.cc in Sources */ = {isa = PBXBuildFile; fileRef = A7C613BF0F30D7E4008CEE5D /* mock_render_process_host.cc */; }; A7C6146F0F30DA1D008CEE5D /* ipc_test_sink.cc in Sources */ = {isa = PBXBuildFile; fileRef = A7C6146D0F30DA1D008CEE5D /* ipc_test_sink.cc */; }; @@ -2525,6 +2527,8 @@ A7A211740F3A248300F62B4D /* resource_message_filter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = resource_message_filter.h; path = renderer_host/resource_message_filter.h; sourceTree = "<group>"; }; A7A211830F3A254F00F62B4D /* resource_request_details.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = resource_request_details.h; path = renderer_host/resource_request_details.h; sourceTree = "<group>"; }; A7A212AF0F3A698200F62B4D /* repost_form_warning.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = repost_form_warning.h; path = tab_contents/repost_form_warning.h; sourceTree = "<group>"; }; + A7A400520F54B6CB00F9E371 /* url_constants.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = url_constants.cc; sourceTree = "<group>"; }; + A7A400530F54B6CB00F9E371 /* url_constants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = url_constants.h; sourceTree = "<group>"; }; A7C613B80F30D779008CEE5D /* security_style.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = security_style.h; path = tab_contents/security_style.h; sourceTree = "<group>"; }; A7C613BF0F30D7E4008CEE5D /* mock_render_process_host.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mock_render_process_host.cc; path = renderer_host/mock_render_process_host.cc; sourceTree = "<group>"; }; A7C613C00F30D7E4008CEE5D /* mock_render_process_host.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mock_render_process_host.h; path = renderer_host/mock_render_process_host.h; sourceTree = "<group>"; }; @@ -2634,8 +2638,6 @@ B6CCB9E90F1EC32700106F0D /* tab_contents_type.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tab_contents_type.h; path = tab_contents/tab_contents_type.h; sourceTree = "<group>"; }; B6CCB9EA0F1EC32700106F0D /* tab_util.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = tab_util.cc; path = tab_contents/tab_util.cc; sourceTree = "<group>"; }; B6CCB9EB0F1EC32700106F0D /* tab_util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tab_util.h; path = tab_contents/tab_util.h; sourceTree = "<group>"; }; - B6CCB9EC0F1EC32700106F0D /* view_source_contents.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = view_source_contents.cc; path = tab_contents/view_source_contents.cc; sourceTree = "<group>"; }; - B6CCB9ED0F1EC32700106F0D /* view_source_contents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = view_source_contents.h; path = tab_contents/view_source_contents.h; sourceTree = "<group>"; }; B6CCB9EE0F1EC32700106F0D /* view_source_uitest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = view_source_uitest.cc; path = tab_contents/view_source_uitest.cc; sourceTree = "<group>"; }; B6CCB9EF0F1EC32700106F0D /* web_contents.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = web_contents.cc; path = tab_contents/web_contents.cc; sourceTree = "<group>"; }; B6CCB9F00F1EC32700106F0D /* web_contents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = web_contents.h; path = tab_contents/web_contents.h; sourceTree = "<group>"; }; @@ -3857,6 +3859,8 @@ E45076E40F153AB6003BE099 /* unzip.cc */, E45076E30F153AB6003BE099 /* unzip.h */, E45076E80F153B06003BE099 /* unzip_unittest.cc */, + A7A400520F54B6CB00F9E371 /* url_constants.cc */, + A7A400530F54B6CB00F9E371 /* url_constants.h */, 4D7BFC0D0E9D4C9F009A6919 /* visitedlink_common.cc */, 4D7BFC0E0E9D4C9F009A6919 /* visitedlink_common.h */, 4D7BFC0F0E9D4C9F009A6919 /* win_safe_util.cc */, @@ -4218,8 +4222,6 @@ B6CCB9EA0F1EC32700106F0D /* tab_util.cc */, B6CCB9EB0F1EC32700106F0D /* tab_util.h */, 56E1D7DF17D327BFCB0B895D /* test_web_contents.cc */, - B6CCB9EC0F1EC32700106F0D /* view_source_contents.cc */, - B6CCB9ED0F1EC32700106F0D /* view_source_contents.h */, B6CCB9EE0F1EC32700106F0D /* view_source_uitest.cc */, B6CCB9EF0F1EC32700106F0D /* web_contents.cc */, B6CCB9F00F1EC32700106F0D /* web_contents.h */, @@ -5751,6 +5753,7 @@ B502DA280F098056005BE90C /* visit_database_unittest.cc in Sources */, 4D7BFB420E9D4C35009A6919 /* visit_tracker_unittest.cc in Sources */, E46C4B4C0F21098F00B393B8 /* worker_thread_ticker_unittest.cc in Sources */, + A7A400540F54B6CB00F9E371 /* url_constants.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -5806,6 +5809,7 @@ E45076AB0F153629003BE099 /* time_format.cc in Sources */, 8385551004565907D74AD2E0 /* transport_dib_mac.cc in Sources */, E45076E50F153AB6003BE099 /* unzip.cc in Sources */, + A7A400550F54B6CB00F9E371 /* url_constants.cc in Sources */, 406DFE278638D6132B21B2C9 /* url_pattern.cc in Sources */, E46C4B3F0F21095400B393B8 /* url_request_intercept_job.cc in Sources */, 49C8AD19AA0094034F59B6F0 /* user_script.cc in Sources */, diff --git a/chrome/common/chrome_constants.cc b/chrome/common/chrome_constants.cc index 9432915..56c9735 100644 --- a/chrome/common/chrome_constants.cc +++ b/chrome/common/chrome_constants.cc @@ -9,6 +9,7 @@ #define FPL FILE_PATH_LITERAL namespace chrome { + // The following should not be used for UI strings; they are meant // for system strings only. UI changes should be made in the GRD. const wchar_t kBrowserProcessExecutableName[] = L"chrome.exe"; @@ -60,5 +61,5 @@ const bool kRecordModeEnabled = true; #else const bool kRecordModeEnabled = false; #endif -} +} // namespace chrome diff --git a/chrome/common/chrome_constants.h b/chrome/common/chrome_constants.h index 0ddf579..681f6f4 100644 --- a/chrome/common/chrome_constants.h +++ b/chrome/common/chrome_constants.h @@ -4,8 +4,8 @@ // A handful of resource-like constants related to the Chrome application. -#ifndef CHROME_COMMON_CHROME_CONSTANTS_H__ -#define CHROME_COMMON_CHROME_CONSTANTS_H__ +#ifndef CHROME_COMMON_CHROME_CONSTANTS_H_ +#define CHROME_COMMON_CHROME_CONSTANTS_H_ #include "base/file_path.h" @@ -45,7 +45,8 @@ extern const int kStatsMaxThreads; extern const int kStatsMaxCounters; extern const bool kRecordModeEnabled; -} -#endif // CHROME_COMMON_CHROME_CONSTANTS_H__ +} // namespace chrome + +#endif // CHROME_COMMON_CHROME_CONSTANTS_H_ diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 46be905..27a49a0 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -252,9 +252,9 @@ IPC_BEGIN_MESSAGES(View) int, /* tools msg type */ std::wstring /* body */) - // RenderViewHostDelegate::RendererCreated method sends this message to a new - // renderer to notify it that it will host developer tools UI and should set - // up all neccessary bindings and create ToolsClient instance that will + // RenderViewHostDelegate::RendererViewCreated method sends this message to a + // new renderer to notify it that it will host developer tools UI and should + // set up all neccessary bindings and create ToolsClient instance that will // handle communication with inspected page ToolsAgent. IPC_MESSAGE_ROUTED0(ViewMsg_SetUpToolsClient) @@ -588,11 +588,11 @@ IPC_BEGIN_MESSAGES(ViewHost) // Indicates the renderer is ready in response to a ViewMsg_New or // a ViewMsg_CreatingNew_ACK. - IPC_MESSAGE_ROUTED0(ViewHostMsg_RendererReady) + IPC_MESSAGE_ROUTED0(ViewHostMsg_RenderViewReady) // Indicates the renderer process is gone. This actually is sent by the // browser process to itself, but keeps the interface cleaner. - IPC_MESSAGE_ROUTED0(ViewHostMsg_RendererGone) + IPC_MESSAGE_ROUTED0(ViewHostMsg_RenderViewGone) // Sent by the renderer process to request that the browser close the view. // This corresponds to the window.close() API, and the browser may ignore diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 22286f5..978be7b 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -23,6 +23,7 @@ #include "chrome/common/render_messages.h" #include "chrome/common/resource_bundle.h" #include "chrome/common/thumbnail_score.h" +#include "chrome/common/url_constants.h" #include "chrome/renderer/about_handler.h" #include "chrome/renderer/debug_message_handler.h" #include "chrome/renderer/localized_error.h" @@ -1551,7 +1552,7 @@ WindowOpenDisposition RenderView::DispositionForNavigationAction( // to, for example, opening a new window). // But we sometimes navigate to about:blank to clear a tab, and we want to // still allow that. - if (disposition == CURRENT_TAB && !(url.SchemeIs("about"))) { + if (disposition == CURRENT_TAB && !(url.SchemeIs(chrome::kAboutScheme))) { // GetExtraData is NULL when we did not issue the request ourselves (see // OnNavigate), and so such a request may correspond to a link-click, // script, or drag-n-drop initiated navigation. @@ -1560,7 +1561,7 @@ WindowOpenDisposition RenderView::DispositionForNavigationAction( // punt them up to the browser to handle. if (enable_dom_ui_bindings_ || frame->GetInViewSourceMode() || - url.SchemeIs("view-source")) { + url.SchemeIs(chrome::kViewSourceScheme)) { OpenURL(webview, url, GURL(), disposition); return IGNORE_ACTION; // Suppress the load here. } else if (url.SchemeIs(kBackForwardNavigationScheme)) { @@ -2069,7 +2070,7 @@ void RenderView::OnGetApplicationInfo(int page_id) { // to decode arbitrary data URLs in the browser process. See // http://b/issue?id=1162972 for (size_t i = 0; i < app_info.icons.size(); ++i) { - if (app_info.icons[i].url.SchemeIs("data")) { + if (app_info.icons[i].url.SchemeIs(chrome::kDataScheme)) { app_info.icons.erase(app_info.icons.begin() + i); --i; } diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc index c6993c1..f6b3572 100644 --- a/chrome/renderer/render_widget.cc +++ b/chrome/renderer/render_widget.cc @@ -102,7 +102,7 @@ void RenderWidget::CompleteInit(gfx::NativeViewId parent_hwnd) { host_window_ = parent_hwnd; - Send(new ViewHostMsg_RendererReady(routing_id_)); + Send(new ViewHostMsg_RenderViewReady(routing_id_)); } IPC_DEFINE_MESSAGE_MAP(RenderWidget) |