summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorbeaudoin@chromium.org <beaudoin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-21 14:43:51 +0000
committerbeaudoin@chromium.org <beaudoin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-21 14:43:51 +0000
commitf5d978cfcc87e29ac3284d9c518770d24c529699 (patch)
treef10f4a851d5a86499792ba525522456ce2da1b42 /content
parent4f27ff905f70604752d3365d813405a5122282de (diff)
downloadchromium_src-f5d978cfcc87e29ac3284d9c518770d24c529699.zip
chromium_src-f5d978cfcc87e29ac3284d9c518770d24c529699.tar.gz
chromium_src-f5d978cfcc87e29ac3284d9c518770d24c529699.tar.bz2
Ensures history tab displays a throbber when searching.
When performing a long running search in the history, turn on the tab thobber to indicate that an operation is in progress. BUG=14730 TEST=Ensure you have a large browsing history, go to chrome://history, search for something, notice the throbber come on. Review URL: http://codereview.chromium.org/7399007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93392 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/tab_contents/interstitial_page.cc2
-rw-r--r--content/browser/tab_contents/tab_contents.cc6
-rw-r--r--content/browser/tab_contents/tab_contents.h5
-rw-r--r--content/browser/tab_contents/tab_contents_delegate.h2
-rw-r--r--content/browser/tab_contents/tab_contents_observer.h2
-rw-r--r--content/browser/webui/generic_handler.cc29
-rw-r--r--content/browser/webui/generic_handler.h11
-rw-r--r--content/browser/webui/web_ui.cc13
-rw-r--r--content/browser/webui/web_ui.h8
9 files changed, 71 insertions, 7 deletions
diff --git a/content/browser/tab_contents/interstitial_page.cc b/content/browser/tab_contents/interstitial_page.cc
index 97357bb..6a28800 100644
--- a/content/browser/tab_contents/interstitial_page.cc
+++ b/content/browser/tab_contents/interstitial_page.cc
@@ -369,7 +369,7 @@ void InterstitialPage::DidNavigate(
// by the UI tests) expects to consider a navigation as complete. Without
// this, navigating in a UI test to a URL that triggers an interstitial would
// hang.
- tab_was_loading_ = tab_->is_loading();
+ tab_was_loading_ = tab_->IsLoading();
tab_->SetIsLoading(false, NULL);
}
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index 6034c9c..bbc1e7e 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -389,6 +389,10 @@ bool TabContents::ShouldDisplayURL() {
return true;
}
+bool TabContents::IsLoading() const {
+ return is_loading_ || (web_ui() && web_ui()->IsLoading());
+}
+
void TabContents::AddObserver(TabContentsObserver* observer) {
observers_.AddObserver(observer);
}
@@ -1773,7 +1777,7 @@ void TabContents::LoadStateChanged(const GURL& url,
content::GetContentClient()->browser()->GetAcceptLangs(this));
if (load_state_ == net::LOAD_STATE_READING_RESPONSE)
SetNotWaitingForResponse();
- if (is_loading())
+ if (IsLoading())
NotifyNavigationStateChanged(INVALIDATE_LOAD | INVALIDATE_TAB);
}
diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h
index 4671cca..5d60b26 100644
--- a/content/browser/tab_contents/tab_contents.h
+++ b/content/browser/tab_contents/tab_contents.h
@@ -164,8 +164,9 @@ class TabContents : public PageNavigator,
// the user is invited to type into it.
virtual bool ShouldDisplayURL();
- // Return whether this tab contents is loading a resource.
- bool is_loading() const { return is_loading_; }
+ // Return whether this tab contents is loading a resource, or whether its
+ // web_ui is.
+ bool IsLoading() const;
// Returns whether this tab contents is waiting for a first-response for the
// main resource of the page. This controls whether the throbber state is
diff --git a/content/browser/tab_contents/tab_contents_delegate.h b/content/browser/tab_contents/tab_contents_delegate.h
index cc6eb45..52bc318 100644
--- a/content/browser/tab_contents/tab_contents_delegate.h
+++ b/content/browser/tab_contents/tab_contents_delegate.h
@@ -90,7 +90,7 @@ class TabContentsDelegate {
// Notifies the delegate that this contents is starting or is done loading
// some resource. The delegate should use this notification to represent
- // loading feedback. See TabContents::is_loading()
+ // loading feedback. See TabContents::IsLoading()
virtual void LoadingStateChanged(TabContents* source);
// Notifies the delegate that the page has made some progress loading.
diff --git a/content/browser/tab_contents/tab_contents_observer.h b/content/browser/tab_contents/tab_contents_observer.h
index 3ddd0e4..1700cf4 100644
--- a/content/browser/tab_contents/tab_contents_observer.h
+++ b/content/browser/tab_contents/tab_contents_observer.h
@@ -67,7 +67,7 @@ class TabContentsObserver : public IPC::Channel::Listener,
// Notifies the delegate that this contents is starting or is done loading
// some resource. The delegate should use this notification to represent
- // loading feedback. See TabContents::is_loading()
+ // loading feedback. See TabContents::IsLoading()
virtual void LoadingStateChanged(TabContents* contents) { }
// Called to inform the delegate that the tab content's navigation state
// changed. The |changed_flags| indicates the parts of the navigation state
diff --git a/content/browser/webui/generic_handler.cc b/content/browser/webui/generic_handler.cc
index bad0584..bfc0940 100644
--- a/content/browser/webui/generic_handler.cc
+++ b/content/browser/webui/generic_handler.cc
@@ -8,9 +8,11 @@
#include "base/values.h"
#include "content/browser/disposition_utils.h"
#include "content/browser/tab_contents/tab_contents.h"
+#include "content/browser/tab_contents/tab_contents_delegate.h"
#include "googleurl/src/gurl.h"
-GenericHandler::GenericHandler() {
+GenericHandler::GenericHandler()
+ : is_loading_(false) {
}
GenericHandler::~GenericHandler() {
@@ -19,6 +21,12 @@ GenericHandler::~GenericHandler() {
void GenericHandler::RegisterMessages() {
web_ui_->RegisterMessageCallback("navigateToUrl",
NewCallback(this, &GenericHandler::HandleNavigateToUrl));
+ web_ui_->RegisterMessageCallback("setIsLoading",
+ NewCallback(this, &GenericHandler::HandleSetIsLoading));
+}
+
+bool GenericHandler::IsLoading() const {
+ return is_loading_;
}
void GenericHandler::HandleNavigateToUrl(const ListValue* args) {
@@ -52,3 +60,22 @@ void GenericHandler::HandleNavigateToUrl(const ListValue* args) {
// This may delete us!
}
+
+void GenericHandler::HandleSetIsLoading(const base::ListValue* args) {
+ CHECK(args->GetSize() == 1);
+ std::string is_loading;
+ CHECK(args->GetString(0, &is_loading));
+
+ SetIsLoading(is_loading == "true");
+}
+
+void GenericHandler::SetIsLoading(bool is_loading) {
+ DCHECK(web_ui_);
+
+ TabContents* contents = web_ui_->tab_contents();
+ bool was_loading = contents->IsLoading();
+
+ is_loading_ = is_loading;
+ if (was_loading != contents->IsLoading())
+ contents->delegate()->LoadingStateChanged(contents);
+}
diff --git a/content/browser/webui/generic_handler.h b/content/browser/webui/generic_handler.h
index c4ed317..4e668a5 100644
--- a/content/browser/webui/generic_handler.h
+++ b/content/browser/webui/generic_handler.h
@@ -20,10 +20,21 @@ class GenericHandler : public WebUIMessageHandler {
// WebUIMessageHandler implementation.
virtual void RegisterMessages();
+ virtual bool IsLoading() const OVERRIDE;
private:
void HandleNavigateToUrl(const base::ListValue* args);
+ // Javascript hook to indicate whether or not a long running operation is in
+ // progress.
+ void HandleSetIsLoading(const base::ListValue* args);
+
+ // Indicates whether or not this WebUI is performing a long running operation
+ // and that the throbber should reflect this.
+ void SetIsLoading(bool is_loading);
+
+ bool is_loading_;
+
DISALLOW_COPY_AND_ASSIGN(GenericHandler);
};
diff --git a/content/browser/webui/web_ui.cc b/content/browser/webui/web_ui.cc
index 4fed4da..37af425 100644
--- a/content/browser/webui/web_ui.cc
+++ b/content/browser/webui/web_ui.cc
@@ -165,6 +165,15 @@ RenderViewHost* WebUI::GetRenderViewHost() const {
return tab_contents()->render_view_host();
}
+bool WebUI::IsLoading() const {
+ std::vector<WebUIMessageHandler*>::const_iterator iter;
+ for (iter = handlers_.begin(); iter != handlers_.end(); ++iter) {
+ if ((*iter)->IsLoading())
+ return true;
+ }
+ return false;
+}
+
// WebUI, protected: ----------------------------------------------------------
void WebUI::AddMessageHandler(WebUIMessageHandler* handler) {
@@ -190,6 +199,10 @@ WebUIMessageHandler* WebUIMessageHandler::Attach(WebUI* web_ui) {
return this;
}
+bool WebUIMessageHandler::IsLoading() const {
+ return false;
+}
+
// WebUIMessageHandler, protected: ---------------------------------------------
void WebUIMessageHandler::SetURLAndTitle(DictionaryValue* dictionary,
diff --git a/content/browser/webui/web_ui.h b/content/browser/webui/web_ui.h
index 66ee230..d0462ac 100644
--- a/content/browser/webui/web_ui.h
+++ b/content/browser/webui/web_ui.h
@@ -149,6 +149,10 @@ class WebUI : public IPC::Channel::Listener {
TabContents* tab_contents() const { return tab_contents_; }
+ // Returns true to indicate that the WebUI is performing a long running
+ // operation and wants the tab throbber to run.
+ virtual bool IsLoading() const;
+
// An opaque identifier used to identify a WebUI. This can only be compared to
// kNoWebUI or other WebUI types. See GetWebUIType.
typedef void* TypeID;
@@ -210,6 +214,10 @@ class WebUIMessageHandler {
// is provided. Returns |this| for convenience.
virtual WebUIMessageHandler* Attach(WebUI* web_ui);
+ // Returns true to indicate that a long running operation is in progress and
+ // the tab throbber should be active.
+ virtual bool IsLoading() const;
+
protected:
// Adds "url" and "title" keys on incoming dictionary, setting title
// as the url as a fallback on empty title.