Commit ca8d144f authored by binji@chromium.org's avatar binji@chromium.org

[Web Intents] Display throbber when loading inline disposition.

BUG=112615
TEST=none
TBR=sail@chromium.org
TBR=estade@chromium.org

Review URL: http://codereview.chromium.org/9959130

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132490 0039d316-1c4b-4281-b951-d872f2087c98
parent 98566d7a
...@@ -162,7 +162,8 @@ void WebIntentPickerCocoa::OnInlineDisposition(WebIntentPickerModel* model, ...@@ -162,7 +162,8 @@ void WebIntentPickerCocoa::OnInlineDisposition(WebIntentPickerModel* model,
content::WebContents* web_contents = content::WebContents::Create( content::WebContents* web_contents = content::WebContents::Create(
browser_->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); browser_->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL);
inline_disposition_tab_contents_.reset(new TabContentsWrapper(web_contents)); inline_disposition_tab_contents_.reset(new TabContentsWrapper(web_contents));
inline_disposition_delegate_.reset(new WebIntentInlineDispositionDelegate); inline_disposition_delegate_.reset(
new WebIntentInlineDispositionDelegate(this));
web_contents->SetDelegate(inline_disposition_delegate_.get()); web_contents->SetDelegate(inline_disposition_delegate_.get());
// Must call this immediately after WebContents creation to avoid race // Must call this immediately after WebContents creation to avoid race
......
...@@ -192,7 +192,8 @@ void WebIntentPickerGtk::OnInlineDisposition(WebIntentPickerModel* model, ...@@ -192,7 +192,8 @@ void WebIntentPickerGtk::OnInlineDisposition(WebIntentPickerModel* model,
content::WebContents* web_contents = content::WebContents::Create( content::WebContents* web_contents = content::WebContents::Create(
browser_->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); browser_->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL);
inline_disposition_tab_contents_.reset(new TabContentsWrapper(web_contents)); inline_disposition_tab_contents_.reset(new TabContentsWrapper(web_contents));
inline_disposition_delegate_.reset(new WebIntentInlineDispositionDelegate); inline_disposition_delegate_.reset(
new WebIntentInlineDispositionDelegate(this));
web_contents->SetDelegate(inline_disposition_delegate_.get()); web_contents->SetDelegate(inline_disposition_delegate_.get());
// Must call this immediately after WebContents creation to avoid race // Must call this immediately after WebContents creation to avoid race
......
...@@ -5,10 +5,13 @@ ...@@ -5,10 +5,13 @@
#include "chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h" #include "chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h"
#include "base/logging.h" #include "base/logging.h"
#include "chrome/browser/ui/intents/web_intent_picker.h"
#include "content/public/browser/navigation_controller.h" #include "content/public/browser/navigation_controller.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
WebIntentInlineDispositionDelegate::WebIntentInlineDispositionDelegate() { WebIntentInlineDispositionDelegate::WebIntentInlineDispositionDelegate(
WebIntentPicker* picker)
: picker_(picker) {
} }
WebIntentInlineDispositionDelegate::~WebIntentInlineDispositionDelegate() { WebIntentInlineDispositionDelegate::~WebIntentInlineDispositionDelegate() {
...@@ -38,3 +41,10 @@ content::WebContents* WebIntentInlineDispositionDelegate::OpenURLFromTab( ...@@ -38,3 +41,10 @@ content::WebContents* WebIntentInlineDispositionDelegate::OpenURLFromTab(
return source; return source;
} }
void WebIntentInlineDispositionDelegate::LoadingStateChanged(
content::WebContents* source) {
if (!source->IsLoading())
picker_->OnInlineDispositionWebContentsLoaded(source);
}
...@@ -9,11 +9,15 @@ ...@@ -9,11 +9,15 @@
#include "base/compiler_specific.h" #include "base/compiler_specific.h"
#include "content/public/browser/web_contents_delegate.h" #include "content/public/browser/web_contents_delegate.h"
class WebIntentPicker;
// This class is the policy delegate for the rendered page in the intents // This class is the policy delegate for the rendered page in the intents
// inline disposition bubble. // inline disposition bubble.
class WebIntentInlineDispositionDelegate : public content::WebContentsDelegate { class WebIntentInlineDispositionDelegate : public content::WebContentsDelegate {
public: public:
WebIntentInlineDispositionDelegate(); // |picker| is notified when the web contents loading state changes. Must not
// be NULL.
explicit WebIntentInlineDispositionDelegate(WebIntentPicker* picker);
virtual ~WebIntentInlineDispositionDelegate(); virtual ~WebIntentInlineDispositionDelegate();
// WebContentsDelegate implementation. // WebContentsDelegate implementation.
...@@ -25,6 +29,11 @@ class WebIntentInlineDispositionDelegate : public content::WebContentsDelegate { ...@@ -25,6 +29,11 @@ class WebIntentInlineDispositionDelegate : public content::WebContentsDelegate {
virtual content::WebContents* OpenURLFromTab( virtual content::WebContents* OpenURLFromTab(
content::WebContents* source, content::WebContents* source,
const content::OpenURLParams& params) OVERRIDE; const content::OpenURLParams& params) OVERRIDE;
virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE;
private:
// Picker to notify when loading state changes. Weak pointer.
WebIntentPicker* picker_;
}; };
#endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_INLINE_DISPOSITION_DELEGATE_H_ #endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_INLINE_DISPOSITION_DELEGATE_H_
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h" #include "chrome/browser/ui/intents/web_intent_inline_disposition_delegate.h"
#include "chrome/browser/ui/intents/web_intent_picker.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/test/base/browser_with_test_window_test.h" #include "chrome/test/base/browser_with_test_window_test.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
...@@ -12,6 +13,12 @@ ...@@ -12,6 +13,12 @@
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
class WebIntentPickerMock : public WebIntentPicker {
public:
virtual void Close() OVERRIDE {}
virtual void SetActionString(const string16& action) OVERRIDE {}
};
class WebIntentInlineDispositionBrowserTest class WebIntentInlineDispositionBrowserTest
: public BrowserWithTestWindowTest { : public BrowserWithTestWindowTest {
public: public:
...@@ -21,7 +28,7 @@ class WebIntentInlineDispositionBrowserTest ...@@ -21,7 +28,7 @@ class WebIntentInlineDispositionBrowserTest
content::WebContents* contents = content::WebContents::Create( content::WebContents* contents = content::WebContents::Create(
browser()->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL); browser()->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL);
wrapper_.reset(new TabContentsWrapper(contents)); wrapper_.reset(new TabContentsWrapper(contents));
delegate_.reset(new WebIntentInlineDispositionDelegate); delegate_.reset(new WebIntentInlineDispositionDelegate(&mock_));
contents->SetDelegate(delegate_.get()); contents->SetDelegate(delegate_.get());
} }
...@@ -29,6 +36,7 @@ class WebIntentInlineDispositionBrowserTest ...@@ -29,6 +36,7 @@ class WebIntentInlineDispositionBrowserTest
TestingProfile profile_; TestingProfile profile_;
scoped_ptr<TabContentsWrapper> wrapper_; scoped_ptr<TabContentsWrapper> wrapper_;
scoped_ptr<WebIntentInlineDispositionDelegate> delegate_; scoped_ptr<WebIntentInlineDispositionDelegate> delegate_;
WebIntentPickerMock mock_;
}; };
// Verifies delegate's OpenURLFromTab works. This allows navigation inside // Verifies delegate's OpenURLFromTab works. This allows navigation inside
......
...@@ -49,6 +49,10 @@ class WebIntentPicker { ...@@ -49,6 +49,10 @@ class WebIntentPicker {
// activities. // activities.
virtual void OnPendingAsyncCompleted() {} virtual void OnPendingAsyncCompleted() {}
// Called when the inline disposition's web contents have been loaded.
virtual void OnInlineDispositionWebContentsLoaded(
content::WebContents* web_contents) {}
// Get the default size of the inline disposition tab container. // Get the default size of the inline disposition tab container.
static gfx::Size GetDefaultInlineDispositionSize( static gfx::Size GetDefaultInlineDispositionSize(
content::WebContents* web_contents); content::WebContents* web_contents);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment