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

Side by Side Diff: chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc

Issue 13375017: Move the ViewType enum to extensions\common. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 8 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
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 <set> 5 #include <set>
6 #include <string> 6 #include <string>
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
11 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
12 #include "base/synchronization/waitable_event.h" 12 #include "base/synchronization/waitable_event.h"
13 #include "chrome/browser/content_settings/host_content_settings_map.h" 13 #include "chrome/browser/content_settings/host_content_settings_map.h"
14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 14 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
15 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" 15 #include "chrome/browser/geolocation/chrome_geolocation_permission_context.h"
16 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_facto ry.h" 16 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_facto ry.h"
17 #include "chrome/browser/geolocation/geolocation_permission_request_id.h" 17 #include "chrome/browser/geolocation/geolocation_permission_request_id.h"
18 #include "chrome/browser/infobars/confirm_infobar_delegate.h" 18 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
19 #include "chrome/browser/infobars/infobar.h" 19 #include "chrome/browser/infobars/infobar.h"
20 #include "chrome/browser/infobars/infobar_service.h" 20 #include "chrome/browser/infobars/infobar_service.h"
21 #include "chrome/browser/view_type_utils.h"
22 #include "chrome/common/chrome_notification_types.h" 21 #include "chrome/common/chrome_notification_types.h"
23 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 22 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
24 #include "chrome/test/base/testing_profile.h" 23 #include "chrome/test/base/testing_profile.h"
25 #include "content/public/browser/navigation_details.h" 24 #include "content/public/browser/navigation_details.h"
26 #include "content/public/browser/notification_registrar.h" 25 #include "content/public/browser/notification_registrar.h"
27 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
28 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
29 #include "content/public/test/mock_render_process_host.h" 28 #include "content/public/test/mock_render_process_host.h"
30 #include "content/public/test/test_browser_thread.h" 29 #include "content/public/test/test_browser_thread.h"
31 #include "content/public/test/test_renderer_host.h" 30 #include "content/public/test/test_renderer_host.h"
32 #include "content/public/test/web_contents_tester.h" 31 #include "content/public/test/web_contents_tester.h"
32 #include "extensions/browser/view_type_utils.h"
33 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
34 34
35 #if defined(OS_ANDROID) 35 #if defined(OS_ANDROID)
36 #include "base/prefs/pref_service.h" 36 #include "base/prefs/pref_service.h"
37 #include "chrome/browser/android/mock_google_location_settings_helper.h" 37 #include "chrome/browser/android/mock_google_location_settings_helper.h"
38 #include "chrome/common/pref_names.h" 38 #include "chrome/common/pref_names.h"
39 #endif 39 #endif
40 40
41 using content::MockRenderProcessHost; 41 using content::MockRenderProcessHost;
42 42
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 223
224 void GeolocationPermissionContextTests::AddNewTab(const GURL& url) { 224 void GeolocationPermissionContextTests::AddNewTab(const GURL& url) {
225 content::WebContents* new_tab = content::WebContents::Create( 225 content::WebContents* new_tab = content::WebContents::Create(
226 content::WebContents::CreateParams(profile())); 226 content::WebContents::CreateParams(profile()));
227 new_tab->GetController().LoadURL( 227 new_tab->GetController().LoadURL(
228 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); 228 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
229 content::RenderViewHostTester::For(new_tab->GetRenderViewHost())-> 229 content::RenderViewHostTester::For(new_tab->GetRenderViewHost())->
230 SendNavigate(extra_tabs_.size() + 1, url); 230 SendNavigate(extra_tabs_.size() + 1, url);
231 231
232 // Set up required helpers, and make this be as "tabby" as the code requires. 232 // Set up required helpers, and make this be as "tabby" as the code requires.
233 chrome::SetViewType(new_tab, chrome::VIEW_TYPE_TAB_CONTENTS); 233 extensions::SetViewType(new_tab, extensions::VIEW_TYPE_TAB_CONTENTS);
234 InfoBarService::CreateForWebContents(new_tab); 234 InfoBarService::CreateForWebContents(new_tab);
235 235
236 extra_tabs_.push_back(new_tab); 236 extra_tabs_.push_back(new_tab);
237 } 237 }
238 238
239 void GeolocationPermissionContextTests::CheckTabContentsState( 239 void GeolocationPermissionContextTests::CheckTabContentsState(
240 const GURL& requesting_frame, 240 const GURL& requesting_frame,
241 ContentSetting expected_content_setting) { 241 ContentSetting expected_content_setting) {
242 TabSpecificContentSettings* content_settings = 242 TabSpecificContentSettings* content_settings =
243 TabSpecificContentSettings::FromWebContents(web_contents()); 243 TabSpecificContentSettings::FromWebContents(web_contents());
244 const GeolocationSettingsState::StateMap& state_map = 244 const GeolocationSettingsState::StateMap& state_map =
245 content_settings->geolocation_settings_state().state_map(); 245 content_settings->geolocation_settings_state().state_map();
246 EXPECT_EQ(1U, state_map.count(requesting_frame.GetOrigin())); 246 EXPECT_EQ(1U, state_map.count(requesting_frame.GetOrigin()));
247 EXPECT_EQ(0U, state_map.count(requesting_frame)); 247 EXPECT_EQ(0U, state_map.count(requesting_frame));
248 GeolocationSettingsState::StateMap::const_iterator settings = 248 GeolocationSettingsState::StateMap::const_iterator settings =
249 state_map.find(requesting_frame.GetOrigin()); 249 state_map.find(requesting_frame.GetOrigin());
250 ASSERT_FALSE(settings == state_map.end()) 250 ASSERT_FALSE(settings == state_map.end())
251 << "geolocation state not found " << requesting_frame; 251 << "geolocation state not found " << requesting_frame;
252 EXPECT_EQ(expected_content_setting, settings->second); 252 EXPECT_EQ(expected_content_setting, settings->second);
253 } 253 }
254 254
255 void GeolocationPermissionContextTests::SetUp() { 255 void GeolocationPermissionContextTests::SetUp() {
256 db_thread_.Start(); 256 db_thread_.Start();
257 ChromeRenderViewHostTestHarness::SetUp(); 257 ChromeRenderViewHostTestHarness::SetUp();
258 258
259 // Set up required helpers, and make this be as "tabby" as the code requires. 259 // Set up required helpers, and make this be as "tabby" as the code requires.
260 chrome::SetViewType(web_contents(), chrome::VIEW_TYPE_TAB_CONTENTS); 260 extensions::SetViewType(web_contents(), extensions::VIEW_TYPE_TAB_CONTENTS);
261 InfoBarService::CreateForWebContents(web_contents()); 261 InfoBarService::CreateForWebContents(web_contents());
262 TabSpecificContentSettings::CreateForWebContents(web_contents()); 262 TabSpecificContentSettings::CreateForWebContents(web_contents());
263 #if defined(OS_ANDROID) 263 #if defined(OS_ANDROID)
264 MockGoogleLocationSettingsHelper::SetLocationStatus(true, true); 264 MockGoogleLocationSettingsHelper::SetLocationStatus(true, true);
265 #endif 265 #endif
266 geolocation_permission_context_ = 266 geolocation_permission_context_ =
267 ChromeGeolocationPermissionContextFactory::GetForProfile(profile()); 267 ChromeGeolocationPermissionContextFactory::GetForProfile(profile());
268 } 268 }
269 269
270 void GeolocationPermissionContextTests::TearDown() { 270 void GeolocationPermissionContextTests::TearDown() {
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 details.entry = web_contents()->GetController().GetLastCommittedEntry(); 700 details.entry = web_contents()->GetController().GetLastCommittedEntry();
701 EXPECT_FALSE(infobar_0->ShouldExpire(details)); 701 EXPECT_FALSE(infobar_0->ShouldExpire(details));
702 // Ensure the infobar will expire when we commit the pending navigation. 702 // Ensure the infobar will expire when we commit the pending navigation.
703 details.entry = web_contents()->GetController().GetActiveEntry(); 703 details.entry = web_contents()->GetController().GetActiveEntry();
704 EXPECT_TRUE(infobar_0->ShouldExpire(details)); 704 EXPECT_TRUE(infobar_0->ShouldExpire(details));
705 705
706 // Delete the tab contents. 706 // Delete the tab contents.
707 DeleteContents(); 707 DeleteContents();
708 delete infobar_0; 708 delete infobar_0;
709 } 709 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698