Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(785)

Side by Side Diff: chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc

Issue 9805005: [Web Intents] Fix crash when invoking intent in incognito mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/intents/web_intent_picker_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 virtual void SetUpOnMainThread() OVERRIDE { 186 virtual void SetUpOnMainThread() OVERRIDE {
187 // The FakeURLFetcherFactory will return a NULL URLFetcher if a request is 187 // The FakeURLFetcherFactory will return a NULL URLFetcher if a request is
188 // created for a URL it doesn't know and there is no default factory. 188 // created for a URL it doesn't know and there is no default factory.
189 // Instead, use this dummy factory to infinitely delay the request. 189 // Instead, use this dummy factory to infinitely delay the request.
190 default_url_fetcher_factory_.reset(new DummyURLFetcherFactory); 190 default_url_fetcher_factory_.reset(new DummyURLFetcherFactory);
191 fake_url_fetcher_factory_.reset( 191 fake_url_fetcher_factory_.reset(
192 new FakeURLFetcherFactory(default_url_fetcher_factory_.get())); 192 new FakeURLFetcherFactory(default_url_fetcher_factory_.get()));
193 193
194 web_data_service_ = 194 web_data_service_ =
195 browser()->profile()->GetWebDataService(Profile::EXPLICIT_ACCESS); 195 GetBrowser()->profile()->GetWebDataService(Profile::EXPLICIT_ACCESS);
196 favicon_service_ = 196 favicon_service_ =
197 browser()->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS); 197 GetBrowser()->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS);
198 controller_ = browser()-> 198 controller_ = GetBrowser()->
199 GetSelectedTabContentsWrapper()->web_intent_picker_controller(); 199 GetSelectedTabContentsWrapper()->web_intent_picker_controller();
200 200
201 controller_->set_picker(&picker_); 201 controller_->set_picker(&picker_);
202 controller_->set_model_observer(&picker_); 202 controller_->set_model_observer(&picker_);
203 203
204 CreateFakeIcon(); 204 CreateFakeIcon();
205 } 205 }
206 206
207 virtual Browser* GetBrowser() { return browser(); }
208
207 void AddWebIntentService(const string16& action, const GURL& service_url) { 209 void AddWebIntentService(const string16& action, const GURL& service_url) {
208 webkit_glue::WebIntentServiceData service; 210 webkit_glue::WebIntentServiceData service;
209 service.action = action; 211 service.action = action;
210 service.type = kType; 212 service.type = kType;
211 service.service_url = service_url; 213 service.service_url = service_url;
212 web_data_service_->AddWebIntentService(service); 214 web_data_service_->AddWebIntentService(service);
213 } 215 }
214 216
215 void AddCWSExtensionServiceEmpty(const string16& action) { 217 void AddCWSExtensionServiceEmpty(const string16& action) {
216 GURL cws_query_url = CWSIntentsRegistry::BuildQueryURL(action, kType); 218 GURL cws_query_url = CWSIntentsRegistry::BuildQueryURL(action, kType);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 ASSERT_EQ(3, browser()->tab_count()); 351 ASSERT_EQ(3, browser()->tab_count());
350 EXPECT_EQ(GURL(kServiceURL1), 352 EXPECT_EQ(GURL(kServiceURL1),
351 browser()->GetSelectedWebContents()->GetURL()); 353 browser()->GetSelectedWebContents()->GetURL());
352 354
353 EXPECT_TRUE(dispatcher.dispatched_); 355 EXPECT_TRUE(dispatcher.dispatched_);
354 356
355 OnSendReturnMessage(webkit_glue::WEB_INTENT_REPLY_SUCCESS); 357 OnSendReturnMessage(webkit_glue::WEB_INTENT_REPLY_SUCCESS);
356 ASSERT_EQ(2, browser()->tab_count()); 358 ASSERT_EQ(2, browser()->tab_count());
357 EXPECT_EQ(original, browser()->GetSelectedWebContents()->GetURL()); 359 EXPECT_EQ(original, browser()->GetSelectedWebContents()->GetURL());
358 } 360 }
361
362 class WebIntentPickerControllerIncognitoBrowserTest :
363 public WebIntentPickerControllerBrowserTest {
364 public:
365 WebIntentPickerControllerIncognitoBrowserTest() {}
366
367 virtual void SetUpOnMainThread() OVERRIDE {
368 incognito_browser_ = CreateIncognitoBrowser();
369 WebIntentPickerControllerBrowserTest::SetUpOnMainThread();
370 }
371
372 virtual Browser* GetBrowser() OVERRIDE { return incognito_browser_; }
373
374 int pending_async_count() { return controller_->pending_async_count_; }
375
376 private:
377 Browser* incognito_browser_;
378 };
379
380 IN_PROC_BROWSER_TEST_F(WebIntentPickerControllerIncognitoBrowserTest,
381 ShowDialogShouldntCrash) {
382 controller_->ShowDialog(GetBrowser(), kAction1, kType);
383 // This should do nothing for now.
384 EXPECT_EQ(0, pending_async_count());
385 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/intents/web_intent_picker_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698