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

[Web Intents] Fix crash when invoking intent in incognito mode.

BUG=117497
TEST=WebIntentPickerControllerIncognitoBrowserTest.*


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128153 0039d316-1c4b-4281-b951-d872f2087c98
parent c7b3ef4d
...@@ -123,6 +123,11 @@ void WebIntentPickerController::ShowDialog(Browser* browser, ...@@ -123,6 +123,11 @@ void WebIntentPickerController::ShowDialog(Browser* browser,
if (picker_shown_) if (picker_shown_)
return; return;
// TODO(binji): Figure out what to do when intents are invoked from incognito
// mode.
if (wrapper_->profile()->IsOffTheRecord())
return;
picker_model_->Clear(); picker_model_->Clear();
// If picker is non-NULL, it was set by a test. // If picker is non-NULL, it was set by a test.
......
...@@ -75,6 +75,7 @@ class WebIntentPickerController : public content::NotificationObserver, ...@@ -75,6 +75,7 @@ class WebIntentPickerController : public content::NotificationObserver,
private: private:
friend class WebIntentPickerControllerTest; friend class WebIntentPickerControllerTest;
friend class WebIntentPickerControllerBrowserTest; friend class WebIntentPickerControllerBrowserTest;
friend class WebIntentPickerControllerIncognitoBrowserTest;
friend class InvokingTabObserver; friend class InvokingTabObserver;
// Gets a notification when the return message is sent to the source tab, // Gets a notification when the return message is sent to the source tab,
......
...@@ -192,10 +192,10 @@ class WebIntentPickerControllerBrowserTest : public InProcessBrowserTest { ...@@ -192,10 +192,10 @@ class WebIntentPickerControllerBrowserTest : public InProcessBrowserTest {
new FakeURLFetcherFactory(default_url_fetcher_factory_.get())); new FakeURLFetcherFactory(default_url_fetcher_factory_.get()));
web_data_service_ = web_data_service_ =
browser()->profile()->GetWebDataService(Profile::EXPLICIT_ACCESS); GetBrowser()->profile()->GetWebDataService(Profile::EXPLICIT_ACCESS);
favicon_service_ = favicon_service_ =
browser()->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS); GetBrowser()->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS);
controller_ = browser()-> controller_ = GetBrowser()->
GetSelectedTabContentsWrapper()->web_intent_picker_controller(); GetSelectedTabContentsWrapper()->web_intent_picker_controller();
controller_->set_picker(&picker_); controller_->set_picker(&picker_);
...@@ -204,6 +204,8 @@ class WebIntentPickerControllerBrowserTest : public InProcessBrowserTest { ...@@ -204,6 +204,8 @@ class WebIntentPickerControllerBrowserTest : public InProcessBrowserTest {
CreateFakeIcon(); CreateFakeIcon();
} }
virtual Browser* GetBrowser() { return browser(); }
void AddWebIntentService(const string16& action, const GURL& service_url) { void AddWebIntentService(const string16& action, const GURL& service_url) {
webkit_glue::WebIntentServiceData service; webkit_glue::WebIntentServiceData service;
service.action = action; service.action = action;
...@@ -356,3 +358,28 @@ IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerBrowserTest, ...@@ -356,3 +358,28 @@ IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerBrowserTest,
ASSERT_EQ(2, browser()->tab_count()); ASSERT_EQ(2, browser()->tab_count());
EXPECT_EQ(original, browser()->GetSelectedWebContents()->GetURL()); EXPECT_EQ(original, browser()->GetSelectedWebContents()->GetURL());
} }
class WebIntentPickerControllerIncognitoBrowserTest :
public WebIntentPickerControllerBrowserTest {
public:
WebIntentPickerControllerIncognitoBrowserTest() {}
virtual void SetUpOnMainThread() OVERRIDE {
incognito_browser_ = CreateIncognitoBrowser();
WebIntentPickerControllerBrowserTest::SetUpOnMainThread();
}
virtual Browser* GetBrowser() OVERRIDE { return incognito_browser_; }
int pending_async_count() { return controller_->pending_async_count_; }
private:
Browser* incognito_browser_;
};
IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerIncognitoBrowserTest,
ShowDialogShouldntCrash) {
controller_->ShowDialog(GetBrowser(), kAction1, kType);
// This should do nothing for now.
EXPECT_EQ(0, pending_async_count());
}
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