diff options
-rw-r--r-- | chrome/browser/external_tab_container_win.cc | 7 | ||||
-rw-r--r-- | chrome/browser/external_tab_container_win.h | 8 | ||||
-rw-r--r-- | chrome/browser/plugin_observer.cc | 29 | ||||
-rw-r--r-- | chrome/browser/plugin_observer.h | 1 | ||||
-rw-r--r-- | chrome/browser/prerender/prerender_tab_helper.cc | 53 | ||||
-rw-r--r-- | chrome/browser/prerender/prerender_tab_helper.h | 17 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 57 | ||||
-rw-r--r-- | chrome/browser/ui/browser.h | 14 | ||||
-rw-r--r-- | chrome/browser/ui/webui/html_dialog_tab_contents_delegate_unittest.cc | 2 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.cc | 7 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents.h | 1 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents_delegate.cc | 5 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents_delegate.h | 6 | ||||
-rw-r--r-- | content/browser/tab_contents/tab_contents_delegate_unittest.cc | 3 |
14 files changed, 133 insertions, 77 deletions
diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc index 00351e6..63349a9 100644 --- a/chrome/browser/external_tab_container_win.cc +++ b/chrome/browser/external_tab_container_win.cc @@ -538,7 +538,9 @@ bool ExternalTabContainer::IsPopup(const TabContents* source) const { } void ExternalTabContainer::UpdateTargetURL(TabContents* source, + int32 page_id, const GURL& url) { + Browser::UpdateTargetURLHelper(source, page_id, url); if (automation_) { std::wstring url_string = CA2W(url.spec().c_str()); automation_->Send( @@ -785,6 +787,11 @@ void ExternalTabContainer::FindReply(TabContents* tab, active_match_ordinal, final_update); } +void ExternalTabContainer::CrashedPlugin(TabContents* tab, + const FilePath& plugin_path) { + Browser::CrashedPluginHelper(tab, plugin_path); +} + bool ExternalTabContainer::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(ExternalTabContainer, message) diff --git a/chrome/browser/external_tab_container_win.h b/chrome/browser/external_tab_container_win.h index e87ca0e..0bdf7aa 100644 --- a/chrome/browser/external_tab_container_win.h +++ b/chrome/browser/external_tab_container_win.h @@ -136,7 +136,8 @@ class ExternalTabContainer : public TabContentsDelegate, virtual void CloseContents(TabContents* source); virtual void MoveContents(TabContents* source, const gfx::Rect& pos); virtual bool IsPopup(const TabContents* source) const; - virtual void UpdateTargetURL(TabContents* source, const GURL& url); + virtual void UpdateTargetURL(TabContents* source, int32 page_id, + const GURL& url); virtual void ContentsZoomChange(bool zoom_in); virtual gfx::NativeWindow GetFrameNativeWindow(); virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, @@ -182,6 +183,8 @@ class ExternalTabContainer : public TabContentsDelegate, const gfx::Rect& selection_rect, int active_match_ordinal, bool final_update); + virtual void CrashedPlugin(TabContents* tab, + const FilePath& plugin_path); void RegisterRenderViewHost(RenderViewHost* render_view_host); void UnregisterRenderViewHost(RenderViewHost* render_view_host); @@ -388,7 +391,8 @@ class TemporaryPopupExternalTabContainer : public ExternalTabContainer { NOTREACHED(); } - virtual void UpdateTargetURL(TabContents* source, const GURL& url) { + virtual void UpdateTargetURL(TabContents* source, int32 page_id, + const GURL& url) { NOTREACHED(); } diff --git a/chrome/browser/plugin_observer.cc b/chrome/browser/plugin_observer.cc index 44d414e..2364a52 100644 --- a/chrome/browser/plugin_observer.cc +++ b/chrome/browser/plugin_observer.cc @@ -10,7 +10,6 @@ #include "chrome/browser/infobars/infobar_tab_helper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" -#include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/render_messages.h" #include "chrome/common/url_constants.h" @@ -293,7 +292,6 @@ PluginObserver::~PluginObserver() { bool PluginObserver::OnMessageReceived(const IPC::Message& message) { IPC_BEGIN_MESSAGE_MAP(PluginObserver, message) - IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedOutdatedPlugin, OnBlockedOutdatedPlugin) IPC_MESSAGE_UNHANDLED(return false) @@ -302,33 +300,6 @@ bool PluginObserver::OnMessageReceived(const IPC::Message& message) { return true; } -void PluginObserver::OnCrashedPlugin(const FilePath& plugin_path) { - DCHECK(!plugin_path.value().empty()); - - string16 plugin_name = plugin_path.LossyDisplayName(); - webkit::WebPluginInfo plugin_info; - if (webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( - plugin_path, &plugin_info) && - !plugin_info.name.empty()) { - plugin_name = plugin_info.name; -#if defined(OS_MACOSX) - // Many plugins on the Mac have .plugin in the actual name, which looks - // terrible, so look for that and strip it off if present. - const std::string kPluginExtension = ".plugin"; - if (EndsWith(plugin_name, ASCIIToUTF16(kPluginExtension), true)) - plugin_name.erase(plugin_name.length() - kPluginExtension.length()); -#endif // OS_MACOSX - } - gfx::Image* icon = &ResourceBundle::GetSharedInstance().GetNativeImageNamed( - IDR_INFOBAR_PLUGIN_CRASHED); - tab_contents_->infobar_tab_helper()->AddInfoBar( - new SimpleAlertInfoBarDelegate( - tab_contents(), - icon, - l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT, plugin_name), - true)); -} - void PluginObserver::OnBlockedOutdatedPlugin(const string16& name, const GURL& update_url) { tab_contents_->infobar_tab_helper()->AddInfoBar(update_url.is_empty() ? diff --git a/chrome/browser/plugin_observer.h b/chrome/browser/plugin_observer.h index c9fed00..12f768c 100644 --- a/chrome/browser/plugin_observer.h +++ b/chrome/browser/plugin_observer.h @@ -23,7 +23,6 @@ class PluginObserver : public TabContentsObserver { virtual bool OnMessageReceived(const IPC::Message& message); private: - void OnCrashedPlugin(const FilePath& plugin_path); void OnBlockedOutdatedPlugin(const string16& name, const GURL& update_url); TabContentsWrapper* tab_contents_; diff --git a/chrome/browser/prerender/prerender_tab_helper.cc b/chrome/browser/prerender/prerender_tab_helper.cc index 0609502..67a963d 100644 --- a/chrome/browser/prerender/prerender_tab_helper.cc +++ b/chrome/browser/prerender/prerender_tab_helper.cc @@ -192,36 +192,7 @@ void PrerenderTabHelper::ProvisionalChangeToMainFrameUrl(const GURL& url, MaybeUsePrerenderedPage(url, has_opener_set); } -bool PrerenderTabHelper::OnMessageReceived(const IPC::Message& message) { - IPC_BEGIN_MESSAGE_MAP(PrerenderTabHelper, message) - IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartProvisionalLoadForFrame, - OnDidStartProvisionalLoadForFrame) - IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateTargetURL, OnMsgUpdateTargetURL) - IPC_END_MESSAGE_MAP() - return false; -} - -void PrerenderTabHelper::OnDidStartProvisionalLoadForFrame(int64 frame_id, - bool is_main_frame, - bool has_opener_set, - const GURL& url) { - if (is_main_frame) { - RecordPageviewEvent(PAGEVIEW_EVENT_LOAD_START); - if (IsTopSite(url)) - RecordPageviewEvent(PAGEVIEW_EVENT_TOP_SITE_LOAD_START); - - // Record the beginning of a new PPLT navigation. - pplt_load_start_ = base::TimeTicks::Now(); - - // Update hover stats. - for (int i = 0; i < kNumHoverThresholds; i++) - last_hovers_[i].RecordNavigation(url); - - MaybeLogCurrentHover(current_hover_url_ == url); - } -} - -void PrerenderTabHelper::OnMsgUpdateTargetURL(int32 page_id, const GURL& url) { +void PrerenderTabHelper::UpdateTargetURL(int32 page_id, const GURL& url) { for (int i = 0; i < kNumHoverThresholds; i++) last_hovers_[i].RecordHover(url); @@ -246,6 +217,28 @@ void PrerenderTabHelper::DidStopLoading() { pplt_load_start_ = base::TimeTicks(); } +void PrerenderTabHelper::DidStartProvisionalLoadForFrame( + int64 frame_id, + bool is_main_frame, + const GURL& validated_url, + bool is_error_page, + RenderViewHost* render_view_host) { + if (is_main_frame) { + RecordPageviewEvent(PAGEVIEW_EVENT_LOAD_START); + if (IsTopSite(validated_url)) + RecordPageviewEvent(PAGEVIEW_EVENT_TOP_SITE_LOAD_START); + + // Record the beginning of a new PPLT navigation. + pplt_load_start_ = base::TimeTicks::Now(); + + // Update hover stats. + for (int i = 0; i < kNumHoverThresholds; i++) + last_hovers_[i].RecordNavigation(validated_url); + + MaybeLogCurrentHover(current_hover_url_ == validated_url); + } +} + PrerenderManager* PrerenderTabHelper::MaybeGetPrerenderManager() const { Profile* profile = Profile::FromBrowserContext(tab_contents()->browser_context()); diff --git a/chrome/browser/prerender/prerender_tab_helper.h b/chrome/browser/prerender/prerender_tab_helper.h index 344cdfa..89f2b5b 100644 --- a/chrome/browser/prerender/prerender_tab_helper.h +++ b/chrome/browser/prerender/prerender_tab_helper.h @@ -27,24 +27,23 @@ class PrerenderTabHelper : public TabContentsObserver { // TabContentsObserver implementation. virtual void ProvisionalChangeToMainFrameUrl(const GURL& url, bool has_opener_set) OVERRIDE; - virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; virtual void DidStopLoading() OVERRIDE; + virtual void DidStartProvisionalLoadForFrame( + int64 frame_id, + bool is_main_frame, + const GURL& validated_url, + bool is_error_page, + RenderViewHost* render_view_host) OVERRIDE; // Called when this prerendered TabContents has just been swapped in. void PrerenderSwappedIn(); + void UpdateTargetURL(int32 page_id, const GURL& url); + private: // The data we store for a hover (time the hover occurred & URL). class HoverData; - // Message handler. - void OnDidStartProvisionalLoadForFrame(int64 frame_id, - bool main_frame, - bool has_opener_set, - const GURL& url); - - void OnMsgUpdateTargetURL(int32 page_id, const GURL& url); - // Retrieves the PrerenderManager, or NULL, if none was found. PrerenderManager* MaybeGetPrerenderManager() const; diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 280bd40..3a4e6c8 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -61,6 +61,7 @@ #include "chrome/browser/platform_util.h" #include "chrome/browser/prefs/incognito_mode_prefs.h" #include "chrome/browser/prefs/pref_service.h" +#include "chrome/browser/prerender/prerender_tab_helper.h" #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" #include "chrome/browser/printing/print_preview_tab_controller.h" #include "chrome/browser/printing/print_view_manager.h" @@ -141,6 +142,7 @@ #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" +#include "grit/theme_resources_standard.h" #include "net/base/cookie_monster.h" #include "net/base/net_util.h" #include "net/base/registry_controlled_domain.h" @@ -176,6 +178,8 @@ #include "chrome/browser/extensions/file_manager_util.h" #endif +#include "webkit/plugins/npapi/plugin_list.h" + using base::TimeDelta; /////////////////////////////////////////////////////////////////////////////// @@ -2548,6 +2552,50 @@ void Browser::FindReplyHelper(TabContents* tab, final_update); } +// static +void Browser::CrashedPluginHelper(TabContents* tab, + const FilePath& plugin_path) { + TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( + tab); + if (!tcw) + return; + + DCHECK(!plugin_path.value().empty()); + + string16 plugin_name = plugin_path.LossyDisplayName(); + webkit::WebPluginInfo plugin_info; + if (webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( + plugin_path, &plugin_info) && + !plugin_info.name.empty()) { + plugin_name = plugin_info.name; +#if defined(OS_MACOSX) + // Many plugins on the Mac have .plugin in the actual name, which looks + // terrible, so look for that and strip it off if present. + const std::string kPluginExtension = ".plugin"; + if (EndsWith(plugin_name, ASCIIToUTF16(kPluginExtension), true)) + plugin_name.erase(plugin_name.length() - kPluginExtension.length()); +#endif // OS_MACOSX + } + gfx::Image* icon = &ResourceBundle::GetSharedInstance().GetNativeImageNamed( + IDR_INFOBAR_PLUGIN_CRASHED); + tcw->infobar_tab_helper()->AddInfoBar( + new SimpleAlertInfoBarDelegate( + tab, + icon, + l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT, plugin_name), + true)); +} + +// static +void Browser::UpdateTargetURLHelper(TabContents* tab, int32 page_id, + const GURL& url) { + TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( + tab); + if (!tcw || !tcw->prerender_tab_helper()) + return; + tcw->prerender_tab_helper()->UpdateTargetURL(page_id, url); +} + void Browser::ExecuteCommandWithDisposition( int id, WindowOpenDisposition disposition) { // No commands are enabled if there is not yet any selected tab. @@ -3488,7 +3536,10 @@ void Browser::ContentsMouseEvent( } } -void Browser::UpdateTargetURL(TabContents* source, const GURL& url) { +void Browser::UpdateTargetURL(TabContents* source, int32 page_id, + const GURL& url) { + Browser::UpdateTargetURLHelper(source, page_id, url); + if (!GetStatusBubble()) return; @@ -3819,6 +3870,10 @@ void Browser::FindReply(TabContents* tab, active_match_ordinal, final_update); } +void Browser::CrashedPlugin(TabContents* tab, const FilePath& plugin_path) { + CrashedPluginHelper(tab, plugin_path); +} + void Browser::ExitTabbedFullscreenModeIfNecessary() { if (tab_caused_fullscreen_) ToggleFullscreenMode(); diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h index 3d14e8f..616c5a5 100644 --- a/chrome/browser/ui/browser.h +++ b/chrome/browser/ui/browser.h @@ -694,6 +694,14 @@ class Browser : public TabHandlerDelegate, int active_match_ordinal, bool final_update); + // Helper function to handle crashed plugin notifications. + static void CrashedPluginHelper(TabContents* tab, + const FilePath& plugin_path); + + // Helper function to handle url update notifications. + static void UpdateTargetURLHelper(TabContents* tab, int32 page_id, + const GURL& url); + // Calls ExecuteCommandWithDisposition with the given disposition. void ExecuteCommandWithDisposition(int id, WindowOpenDisposition); @@ -905,7 +913,8 @@ class Browser : public TabHandlerDelegate, virtual void DetachContents(TabContents* source) OVERRIDE; virtual bool IsPopupOrPanel(const TabContents* source) const OVERRIDE; virtual bool CanReloadContents(TabContents* source) const; - virtual void UpdateTargetURL(TabContents* source, const GURL& url) OVERRIDE; + virtual void UpdateTargetURL(TabContents* source, int32 page_id, + const GURL& url) OVERRIDE; virtual void ContentsMouseEvent( TabContents* source, const gfx::Point& location, bool motion) OVERRIDE; virtual void ContentsZoomChange(bool zoom_in) OVERRIDE; @@ -980,6 +989,9 @@ class Browser : public TabHandlerDelegate, int active_match_ordinal, bool final_update) OVERRIDE; + virtual void CrashedPlugin(TabContents* tab, + const FilePath& plugin_path) OVERRIDE; + // Overridden from TabContentsWrapperDelegate: virtual void OnDidGetApplicationInfo(TabContentsWrapper* source, int32 page_id) OVERRIDE; diff --git a/chrome/browser/ui/webui/html_dialog_tab_contents_delegate_unittest.cc b/chrome/browser/ui/webui/html_dialog_tab_contents_delegate_unittest.cc index f3eef16..845d52f 100644 --- a/chrome/browser/ui/webui/html_dialog_tab_contents_delegate_unittest.cc +++ b/chrome/browser/ui/webui/html_dialog_tab_contents_delegate_unittest.cc @@ -64,7 +64,7 @@ TEST_F(HtmlDialogTabContentsDelegateTest, DoNothingMethodsTest) { test_tab_contents_delegate_->ActivateContents(NULL); test_tab_contents_delegate_->LoadingStateChanged(NULL); test_tab_contents_delegate_->CloseContents(NULL); - test_tab_contents_delegate_->UpdateTargetURL(NULL, GURL()); + test_tab_contents_delegate_->UpdateTargetURL(NULL, 0, GURL()); test_tab_contents_delegate_->MoveContents(NULL, gfx::Rect()); EXPECT_EQ(0, browser()->tab_count()); EXPECT_EQ(1U, BrowserList::size()); diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index 2a78230..12e2039 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -307,6 +307,7 @@ bool TabContents::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ViewHostMsg_WebIntentDispatch, OnWebIntentDispatch) IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnFindReply) + IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP_EX() @@ -1146,6 +1147,10 @@ void TabContents::OnFindReply(int request_id, active_match_ordinal, final_update); } +void TabContents::OnCrashedPlugin(const FilePath& plugin_path) { + delegate()->CrashedPlugin(this, plugin_path); +} + // Notifies the RenderWidgetHost instance about the fact that the page is // loading, or done loading and calls the base implementation. void TabContents::SetIsLoading(bool is_loading, @@ -1606,7 +1611,7 @@ void TabContents::UpdateEncoding(RenderViewHost* render_view_host, void TabContents::UpdateTargetURL(int32 page_id, const GURL& url) { if (delegate()) - delegate()->UpdateTargetURL(this, url); + delegate()->UpdateTargetURL(this, page_id, url); } void TabContents::Close(RenderViewHost* rvh) { diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index 1e996c0..7b46ca6 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -580,6 +580,7 @@ class TabContents : public PageNavigator, void OnFindReply(int request_id, int number_of_matches, const gfx::Rect& selection_rect, int active_match_ordinal, bool final_update); + void OnCrashedPlugin(const FilePath& plugin_path); // Changes the IsLoading state and notifies delegate as needed // |details| is used to provide details on the load that just finished diff --git a/content/browser/tab_contents/tab_contents_delegate.cc b/content/browser/tab_contents/tab_contents_delegate.cc index 7247a7a..8663f91 100644 --- a/content/browser/tab_contents/tab_contents_delegate.cc +++ b/content/browser/tab_contents/tab_contents_delegate.cc @@ -79,6 +79,7 @@ void TabContentsDelegate::WillShowConstrainedWindow(TabContents* source) { } void TabContentsDelegate::UpdateTargetURL(TabContents* source, + int32 page_id, const GURL& url) { } @@ -324,6 +325,10 @@ void TabContentsDelegate::FindReply(TabContents* tab, bool final_update) { } +void TabContentsDelegate::CrashedPlugin(TabContents* tab, + const FilePath& plugin_path) { +} + TabContentsDelegate::~TabContentsDelegate() { while (!attached_contents_.empty()) { TabContents* tab_contents = *attached_contents_.begin(); diff --git a/content/browser/tab_contents/tab_contents_delegate.h b/content/browser/tab_contents/tab_contents_delegate.h index b1f0d52..d284110 100644 --- a/content/browser/tab_contents/tab_contents_delegate.h +++ b/content/browser/tab_contents/tab_contents_delegate.h @@ -132,7 +132,8 @@ class TabContentsDelegate { virtual void WillShowConstrainedWindow(TabContents* source); // Notification that the target URL has changed. - virtual void UpdateTargetURL(TabContents* source, const GURL& url); + virtual void UpdateTargetURL(TabContents* source, int32 page_id, + const GURL& url); // Notification that there was a mouse event, along with the absolute // coordinates of the mouse pointer and whether it was a normal motion event @@ -348,6 +349,9 @@ class TabContentsDelegate { int active_match_ordinal, bool final_update); + // Notification that a plugin has crashed. + virtual void CrashedPlugin(TabContents* tab, const FilePath& plugin_path); + protected: virtual ~TabContentsDelegate(); diff --git a/content/browser/tab_contents/tab_contents_delegate_unittest.cc b/content/browser/tab_contents/tab_contents_delegate_unittest.cc index 2181cad..f553f54 100644 --- a/content/browser/tab_contents/tab_contents_delegate_unittest.cc +++ b/content/browser/tab_contents/tab_contents_delegate_unittest.cc @@ -58,7 +58,8 @@ class MockTabContentsDelegate : public TabContentsDelegate { const gfx::Rect& pos) OVERRIDE { } - virtual void UpdateTargetURL(TabContents* source, const GURL& url) OVERRIDE {} + virtual void UpdateTargetURL(TabContents* source, int32 page_id, + const GURL& url) {} }; TEST(TabContentsDelegateTest, UnregisterInDestructor) { |