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

Side by Side Diff: chrome/browser/ui/content_settings/content_setting_image_model_browsertest.cc

Issue 2561673003: Handle per-tab AUTOMATIC_DOWNLOADS setting in DownloadRequestLimiter. (Closed)
Patch Set: Address review comments. Created 3 years, 10 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/ui/content_settings/content_setting_image_model.h" 5 #include "chrome/browser/ui/content_settings/content_setting_image_model.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/download/download_request_limiter.h"
8 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" 12 #include "chrome/browser/ui/tabs/tab_strip_model.h"
11 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
12 14
13 using content::WebContents; 15 using content::WebContents;
14 16
15 typedef InProcessBrowserTest ContentSettingImageModelBrowserTest; 17 typedef InProcessBrowserTest ContentSettingImageModelBrowserTest;
16 18
17 // Tests that every model creates a valid bubble. 19 // Tests that every model creates a valid bubble.
18 IN_PROC_BROWSER_TEST_F(ContentSettingImageModelBrowserTest, CreateBubbleModel) { 20 IN_PROC_BROWSER_TEST_F(ContentSettingImageModelBrowserTest, CreateBubbleModel) {
19 WebContents* web_contents = 21 WebContents* web_contents =
20 browser()->tab_strip_model()->GetActiveWebContents(); 22 browser()->tab_strip_model()->GetActiveWebContents();
21 TabSpecificContentSettings* content_settings = 23 TabSpecificContentSettings* content_settings =
22 TabSpecificContentSettings::FromWebContents(web_contents); 24 TabSpecificContentSettings::FromWebContents(web_contents);
23 content_settings->BlockAllContentForTesting(); 25 content_settings->BlockAllContentForTesting();
26 // Automatic downloads are handled by DownloadRequestLimiter.
27 g_browser_process->download_request_limiter()
28 ->GetDownloadState(web_contents, web_contents, true)
29 ->SetDownloadStatusAndNotify(
30 DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED);
24 31
25 // Test that image models tied to a single content setting create bubbles tied 32 // Test that image models tied to a single content setting create bubbles tied
26 // to the same setting. 33 // to the same setting.
27 static const ContentSettingsType content_settings_to_test[] = { 34 static const ContentSettingsType content_settings_to_test[] = {
28 CONTENT_SETTINGS_TYPE_COOKIES, 35 CONTENT_SETTINGS_TYPE_COOKIES,
29 CONTENT_SETTINGS_TYPE_IMAGES, 36 CONTENT_SETTINGS_TYPE_IMAGES,
30 CONTENT_SETTINGS_TYPE_JAVASCRIPT, 37 CONTENT_SETTINGS_TYPE_JAVASCRIPT,
31 CONTENT_SETTINGS_TYPE_PLUGINS, 38 CONTENT_SETTINGS_TYPE_PLUGINS,
32 CONTENT_SETTINGS_TYPE_POPUPS, 39 CONTENT_SETTINGS_TYPE_POPUPS,
33 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, 40 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT,
34 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, 41 CONTENT_SETTINGS_TYPE_PPAPI_BROKER,
35 CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS,
36 CONTENT_SETTINGS_TYPE_GEOLOCATION, 42 CONTENT_SETTINGS_TYPE_GEOLOCATION,
37 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, 43 CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS,
38 CONTENT_SETTINGS_TYPE_MIDI_SYSEX, 44 CONTENT_SETTINGS_TYPE_MIDI_SYSEX,
39 }; 45 };
40 46
41 Profile* profile = browser()->profile(); 47 Profile* profile = browser()->profile();
42 for (ContentSettingsType type : content_settings_to_test) { 48 for (ContentSettingsType type : content_settings_to_test) {
43 std::unique_ptr<ContentSettingBubbleModel> bubble( 49 std::unique_ptr<ContentSettingBubbleModel> bubble(
44 ContentSettingSimpleImageModel::CreateForContentTypeForTesting(type) 50 ContentSettingSimpleImageModel::CreateForContentTypeForTesting(type)
45 ->CreateBubbleModel(nullptr, web_contents, profile)); 51 ->CreateBubbleModel(nullptr, web_contents, profile));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 EXPECT_FALSE(model->ShouldRunAnimation(web_contents)); 85 EXPECT_FALSE(model->ShouldRunAnimation(web_contents));
80 86
81 // The animation has run for the current WebContents, but not for any other. 87 // The animation has run for the current WebContents, but not for any other.
82 Profile* profile = browser()->profile(); 88 Profile* profile = browser()->profile();
83 WebContents::CreateParams create_params(profile); 89 WebContents::CreateParams create_params(profile);
84 WebContents* other_web_contents = WebContents::Create(create_params); 90 WebContents* other_web_contents = WebContents::Create(create_params);
85 browser()->tab_strip_model()->TabStripModel::AppendWebContents( 91 browser()->tab_strip_model()->TabStripModel::AppendWebContents(
86 other_web_contents, true); 92 other_web_contents, true);
87 EXPECT_TRUE(model->ShouldRunAnimation(other_web_contents)); 93 EXPECT_TRUE(model->ShouldRunAnimation(other_web_contents));
88 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698