Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)); | 91 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)); |
| 92 model->OnCustomLinkClicked(); | 92 model->OnCustomLinkClicked(); |
| 93 | 93 |
| 94 content::TestNavigationObserver observer( | 94 content::TestNavigationObserver observer( |
| 95 browser()->tab_strip_model()->GetActiveWebContents()); | 95 browser()->tab_strip_model()->GetActiveWebContents()); |
| 96 observer.Wait(); | 96 observer.Wait(); |
| 97 | 97 |
| 98 EXPECT_FALSE(GetActiveTabSpecificContentSettings()->IsContentBlocked( | 98 EXPECT_FALSE(GetActiveTabSpecificContentSettings()->IsContentBlocked( |
| 99 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)); | 99 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)); |
| 100 } | 100 } |
| 101 | |
| 102 class ContentSettingBubbleModelMediaStreamTest : public InProcessBrowserTest { | |
| 103 public: | |
| 104 scoped_ptr<ContentSettingBubbleModel> GetNewBubbleInTheFirstTab() { | |
|
msw
2015/08/05 17:05:38
nit: rename this CreateBubble(), or better yet com
msramek
2015/08/05 17:39:28
Yep, that sounds good.
| |
| 105 return make_scoped_ptr( | |
| 106 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | |
| 107 browser()->content_setting_bubble_model_delegate(), | |
| 108 GetFirstTab(), | |
| 109 browser()->profile(), | |
| 110 CONTENT_SETTINGS_TYPE_MEDIASTREAM)); | |
| 111 } | |
| 112 | |
| 113 void SetAccessedDevices( | |
| 114 TabSpecificContentSettings::MicrophoneCameraState state) { | |
| 115 TabSpecificContentSettings::FromWebContents(GetFirstTab())-> | |
| 116 OnMediaStreamPermissionSet( | |
| 117 GetFirstTab()->GetLastCommittedURL(), | |
| 118 state, device_name_, device_name_, device_name_, device_name_); | |
| 119 } | |
| 120 | |
| 121 void WaitForNavigation() { | |
| 122 content::TestNavigationObserver observer( | |
| 123 browser()->tab_strip_model()->GetActiveWebContents()); | |
|
msw
2015/08/05 17:05:38
nit: use GetFirstTab() here?
msramek
2015/08/05 17:39:28
No actually. The bubble itself is invoked for the
msw
2015/08/05 17:47:20
Acknowledged.
| |
| 124 observer.Wait(); | |
| 125 } | |
| 126 | |
| 127 private: | |
| 128 content::WebContents* GetFirstTab() { | |
| 129 return browser()->tab_strip_model()->GetWebContentsAt(0); | |
| 130 } | |
| 131 | |
| 132 std::string device_name_ = "is not important for this test"; | |
|
msw
2015/08/05 17:05:38
nit: can you remove this and just pass std::string
msramek
2015/08/05 17:39:28
Done.
| |
| 133 }; | |
| 134 | |
| 135 // Tests that clicking on the management link in the media bubble opens | |
| 136 // the correct section of the settings UI. | |
| 137 IN_PROC_BROWSER_TEST_F(ContentSettingBubbleModelMediaStreamTest, ManageLink) { | |
| 138 // The microphone bubble links to microphone exceptions. | |
| 139 SetAccessedDevices(TabSpecificContentSettings::MICROPHONE_ACCESSED); | |
| 140 scoped_ptr<ContentSettingBubbleModel> bubble = GetNewBubbleInTheFirstTab(); | |
| 141 bubble->OnManageLinkClicked(); | |
| 142 WaitForNavigation(); | |
| 143 EXPECT_EQ(GURL("chrome://settings/contentExceptions#media-stream-mic"), | |
| 144 browser()->tab_strip_model()-> | |
| 145 GetActiveWebContents()->GetLastCommittedURL()); | |
| 146 | |
| 147 // The camera bubble links to camera exceptions. | |
| 148 SetAccessedDevices(TabSpecificContentSettings::CAMERA_ACCESSED); | |
| 149 bubble = GetNewBubbleInTheFirstTab(); | |
| 150 bubble->OnManageLinkClicked(); | |
| 151 WaitForNavigation(); | |
| 152 EXPECT_EQ(GURL("chrome://settings/contentExceptions#media-stream-camera"), | |
| 153 browser()->tab_strip_model()-> | |
| 154 GetActiveWebContents()->GetLastCommittedURL()); | |
| 155 | |
| 156 // The bubble for both media devices links to the the first section of the | |
| 157 // default media content settings, which is the microphone section. | |
| 158 SetAccessedDevices(TabSpecificContentSettings::MICROPHONE_ACCESSED | | |
| 159 TabSpecificContentSettings::CAMERA_ACCESSED); | |
| 160 bubble = GetNewBubbleInTheFirstTab(); | |
| 161 bubble->OnManageLinkClicked(); | |
| 162 WaitForNavigation(); | |
| 163 EXPECT_EQ(GURL("chrome://settings/content#media-stream-mic"), | |
| 164 browser()->tab_strip_model()-> | |
| 165 GetActiveWebContents()->GetLastCommittedURL()); | |
| 166 } | |
| OLD | NEW |