diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-28 18:34:56 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-28 18:34:56 +0000 |
commit | cafe4ad25440a7752f5a4d230adf29b16a4766b0 (patch) | |
tree | 125f3d638cbaf3a3db61c91904c0eddae1e8ad34 | |
parent | 96561cb87ad2679df630ddc0d1561949d78bbcff (diff) | |
download | chromium_src-cafe4ad25440a7752f5a4d230adf29b16a4766b0.zip chromium_src-cafe4ad25440a7752f5a4d230adf29b16a4766b0.tar.gz chromium_src-cafe4ad25440a7752f5a4d230adf29b16a4766b0.tar.bz2 |
Removal of Profile from content part 3.
BUG=76788
TEST=no change visible
Review URL: http://codereview.chromium.org/7522018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94511 0039d316-1c4b-4281-b951-d872f2087c98
51 files changed, 190 insertions, 121 deletions
diff --git a/chrome/browser/alternate_nav_url_fetcher.cc b/chrome/browser/alternate_nav_url_fetcher.cc index 815e0dc..6555261 100644 --- a/chrome/browser/alternate_nav_url_fetcher.cc +++ b/chrome/browser/alternate_nav_url_fetcher.cc @@ -61,7 +61,7 @@ void AlternateNavURLFetcher::Observe(int type, fetcher_.reset(new URLFetcher(GURL(alternate_nav_url_), URLFetcher::HEAD, this)); fetcher_->set_request_context( - controller_->profile()->GetRequestContext()); + controller_->browser_context()->GetRequestContext()); fetcher_->Start(); } break; diff --git a/chrome/browser/autocomplete/autocomplete_edit.cc b/chrome/browser/autocomplete/autocomplete_edit.cc index 8bee00e..2b0c3c0 100644 --- a/chrome/browser/autocomplete/autocomplete_edit.cc +++ b/chrome/browser/autocomplete/autocomplete_edit.cc @@ -236,7 +236,7 @@ void AutocompleteEditModel::OnChanged() { // Start Prerender of this page instead. CHECK(tab->tab_contents()); prerender::PrerenderManager* prerender_manager = - tab->tab_contents()->profile()->GetPrerenderManager(); + tab->profile()->GetPrerenderManager(); if (prerender_manager) { prerender_manager->AddPrerenderFromOmnibox( CurrentMatch().destination_url); diff --git a/chrome/browser/autocomplete_history_manager.cc b/chrome/browser/autocomplete_history_manager.cc index bf64c35..103bf3b 100644 --- a/chrome/browser/autocomplete_history_manager.cc +++ b/chrome/browser/autocomplete_history_manager.cc @@ -103,7 +103,7 @@ AutocompleteHistoryManager::AutocompleteHistoryManager( : TabContentsObserver(tab_contents), pending_query_handle_(0), query_id_(0) { - profile_ = tab_contents->profile(); + profile_ = Profile::FromBrowserContext(tab_contents->browser_context()); // May be NULL in unit tests. web_data_service_ = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS); autofill_enabled_.Init(prefs::kAutofillEnabled, profile_->GetPrefs(), NULL); diff --git a/chrome/browser/autofill/autofill_manager.cc b/chrome/browser/autofill/autofill_manager.cc index 255e427..a50d131c 100644 --- a/chrome/browser/autofill/autofill_manager.cc +++ b/chrome/browser/autofill/autofill_manager.cc @@ -403,7 +403,7 @@ void AutofillManager::OnFormSubmitted(const FormData& form) { if (!IsAutofillEnabled()) return; - if (tab_contents()->profile()->IsOffTheRecord()) + if (tab_contents()->browser_context()->IsOffTheRecord()) return; // Don't save data that was submitted through JavaScript. @@ -684,7 +684,7 @@ void AutofillManager::OnFillAutofillFormData(int query_id, void AutofillManager::OnShowAutofillDialog() { Browser* browser = BrowserList::GetLastActiveWithProfile( - tab_contents()->profile()); + Profile::FromBrowserContext(tab_contents()->browser_context())); if (browser) browser->ShowOptionsTab(chrome::kAutofillSubPage); } @@ -733,8 +733,9 @@ void AutofillManager::OnServerRequestError( } bool AutofillManager::IsAutofillEnabled() const { - return const_cast<AutofillManager*>(this)->tab_contents()->profile()-> - GetPrefs()->GetBoolean(prefs::kAutofillEnabled); + Profile* profile = Profile::FromBrowserContext( + const_cast<AutofillManager*>(this)->tab_contents()->browser_context()); + return profile->GetPrefs()->GetBoolean(prefs::kAutofillEnabled); } void AutofillManager::DeterminePossibleFieldTypesForUpload( diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 745928b..1e25d61 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -712,9 +712,10 @@ void AutomationProvider::OnSetPageFontSize(int tab_handle, NavigationController* tab = tab_tracker_->GetResource(tab_handle); DCHECK(tab != NULL); if (tab && tab->tab_contents()) { - DCHECK(tab->tab_contents()->profile() != NULL); - tab->tab_contents()->profile()->GetPrefs()->SetInteger( - prefs::kWebKitDefaultFontSize, font_size); + DCHECK(tab->tab_contents()->browser_context() != NULL); + Profile* profile = + Profile::FromBrowserContext(tab->tab_contents()->browser_context()); + profile->GetPrefs()->SetInteger(prefs::kWebKitDefaultFontSize, font_size); } } } diff --git a/chrome/browser/automation/automation_util.cc b/chrome/browser/automation/automation_util.cc index 1c605f3..189c90b 100644 --- a/chrome/browser/automation/automation_util.cc +++ b/chrome/browser/automation/automation_util.cc @@ -137,7 +137,7 @@ TabContents* GetTabContentsAt(int browser_index, int tab_index) { net::URLRequestContextGetter* GetRequestContext(TabContents* contents) { // Since we may be on the UI thread don't call GetURLRequestContext(). // Get the request context specific to the current TabContents and app. - return contents->profile()->GetRequestContextForRenderProcess( + return contents->browser_context()->GetRequestContextForRenderProcess( contents->render_view_host()->process()->id()); } diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 61b2de4..23d1030 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -704,8 +704,9 @@ void TestingAutomationProvider::GetRedirectsFrom(int tab_handle, LOG(ERROR) << "Can only handle one redirect query at once."; } else if (tab_tracker_->ContainsHandle(tab_handle)) { NavigationController* tab = tab_tracker_->GetResource(tab_handle); + Profile* profile = Profile::FromBrowserContext(tab->browser_context()); HistoryService* history_service = - tab->profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); + profile->GetHistoryService(Profile::EXPLICIT_ACCESS); DCHECK(history_service) << "Tab " << tab_handle << "'s profile " << "has no history service"; @@ -1344,7 +1345,7 @@ void TestingAutomationProvider::GetDownloadDirectory( int handle, FilePath* download_directory) { if (tab_tracker_->ContainsHandle(handle)) { NavigationController* tab = tab_tracker_->GetResource(handle); - DownloadManager* dlm = tab->profile()->GetDownloadManager(); + DownloadManager* dlm = tab->browser_context()->GetDownloadManager(); *download_directory = dlm->download_prefs()->download_path(); } } @@ -4297,7 +4298,8 @@ void TestingAutomationProvider::GetAutofillProfile( return; } - TabContents* tab_contents = browser->GetTabContentsAt(tab_index); + TabContentsWrapper* tab_contents = + browser->GetTabContentsWrapperAt(tab_index); if (tab_contents) { PersonalDataManager* pdm = tab_contents->profile()->GetOriginalProfile() ->GetPersonalDataManager(); @@ -4362,11 +4364,12 @@ void TestingAutomationProvider::FillAutofillProfile( return; } - TabContents* tab_contents = browser->GetTabContentsAt(tab_index); + TabContentsWrapper* tab_contents = + browser->GetTabContentsWrapperAt(tab_index); if (tab_contents) { - PersonalDataManager* pdm = tab_contents->profile() - ->GetPersonalDataManager(); + PersonalDataManager* pdm = + tab_contents->profile()->GetPersonalDataManager(); if (pdm) { if (profiles || cards) { // This observer will delete itself. diff --git a/chrome/browser/background/background_contents_service.cc b/chrome/browser/background/background_contents_service.cc index 065b892..9ec28ec 100644 --- a/chrome/browser/background/background_contents_service.cc +++ b/chrome/browser/background/background_contents_service.cc @@ -573,7 +573,7 @@ void BackgroundContentsService::AddTabContents( const gfx::Rect& initial_pos, bool user_gesture) { Browser* browser = BrowserList::GetLastActiveWithProfile( - new_contents->profile()); + Profile::FromBrowserContext(new_contents->browser_context())); if (!browser) return; browser->AddTabContents(new_contents, disposition, initial_pos, user_gesture); diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 04a3972..c7f5713 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -526,7 +526,8 @@ void ChromeContentBrowserClient::AllowCertificateError( return; } prerender::PrerenderManager* prerender_manager = - tab->profile()->GetPrerenderManager(); + Profile::FromBrowserContext(tab->browser_context())-> + GetPrerenderManager(); if (prerender_manager && prerender_manager->IsTabContentsPrerendering(tab)) { if (prerender_manager->prerender_tracker()->TryCancel( handler->render_process_host_id(), @@ -766,7 +767,9 @@ void ChromeContentBrowserClient::ClearCookies(RenderViewHost* rvh) { void ChromeContentBrowserClient::GetSaveDir(TabContents* tab_contents, FilePath* website_save_dir, FilePath* download_save_dir) { - PrefService* prefs = tab_contents->profile()->GetPrefs(); + Profile* profile = + Profile::FromBrowserContext(tab_contents->browser_context()); + PrefService* prefs = profile->GetPrefs(); // Check whether the preference has the preferred directory for saving file. // If not, initialize it with default directory. diff --git a/chrome/browser/chrome_quota_permission_context.cc b/chrome/browser/chrome_quota_permission_context.cc index cb46017..93efece 100644 --- a/chrome/browser/chrome_quota_permission_context.cc +++ b/chrome/browser/chrome_quota_permission_context.cc @@ -145,7 +145,7 @@ void ChromeQuotaPermissionContext::RequestQuotaPermission( wrapper->AddInfoBar(new RequestQuotaInfoBarDelegate( tab_contents, this, origin_url, requested_quota, - tab_contents->profile()->GetPrefs()->GetString(prefs::kAcceptLanguages), + wrapper->profile()->GetPrefs()->GetString(prefs::kAcceptLanguages), callback.release())); } diff --git a/chrome/browser/content_settings/tab_specific_content_settings.cc b/chrome/browser/content_settings/tab_specific_content_settings.cc index 4f6d303..3950da2 100644 --- a/chrome/browser/content_settings/tab_specific_content_settings.cc +++ b/chrome/browser/content_settings/tab_specific_content_settings.cc @@ -47,9 +47,10 @@ bool TabSpecificContentSettings::LocalSharedObjectsContainer::empty() const { TabSpecificContentSettings::TabSpecificContentSettings(TabContents* tab) : TabContentsObserver(tab), - allowed_local_shared_objects_(tab->profile()), - blocked_local_shared_objects_(tab->profile()), - geolocation_settings_state_(tab->profile()), + profile_(Profile::FromBrowserContext(tab->browser_context())), + allowed_local_shared_objects_(profile_), + blocked_local_shared_objects_(profile_), + geolocation_settings_state_(profile_), load_plugins_link_enabled_(true) { ClearBlockedContentSettingsExceptForCookies(); ClearCookieSpecificContentSettings(); @@ -57,7 +58,7 @@ TabSpecificContentSettings::TabSpecificContentSettings(TabContents* tab) registrar_.Add(this, chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED, Source<HostContentSettingsMap>( - tab->profile()->GetHostContentSettingsMap())); + profile_->GetHostContentSettingsMap())); } TabSpecificContentSettings::~TabSpecificContentSettings() { @@ -434,8 +435,9 @@ void TabSpecificContentSettings::DidNavigateMainFramePostCommit( void TabSpecificContentSettings::RenderViewCreated( RenderViewHost* render_view_host) { - HostContentSettingsMap* map = - tab_contents()->profile()->GetHostContentSettingsMap(); + Profile* profile = + Profile::FromBrowserContext(tab_contents()->browser_context()); + HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); render_view_host->Send(new ViewMsg_SetDefaultContentSettings( map->GetDefaultContentSettings())); } @@ -472,8 +474,9 @@ void TabSpecificContentSettings::Observe(int type, // The active NavigationEntry is the URL in the URL field of a tab. // Currently this should be matched by the |primary_pattern|. settings_details.ptr()->primary_pattern().Matches(entry_url)) { - HostContentSettingsMap* map = - tab_contents()->profile()->GetHostContentSettingsMap(); + Profile* profile = + Profile::FromBrowserContext(tab_contents()->browser_context()); + HostContentSettingsMap* map = profile->GetHostContentSettingsMap(); Send(new ViewMsg_SetDefaultContentSettings( map->GetDefaultContentSettings())); Send(new ViewMsg_SetContentSettingsForCurrentURL( diff --git a/chrome/browser/content_settings/tab_specific_content_settings.h b/chrome/browser/content_settings/tab_specific_content_settings.h index 1750211..448844d 100644 --- a/chrome/browser/content_settings/tab_specific_content_settings.h +++ b/chrome/browser/content_settings/tab_specific_content_settings.h @@ -265,6 +265,9 @@ class TabSpecificContentSettings : public TabContentsObserver, scoped_ptr<std::set<std::string> > blocked_resources_[CONTENT_SETTINGS_NUM_TYPES]; + // The profile of the tab. + Profile* profile_; + // Stores the blocked/allowed cookies. LocalSharedObjectsContainer allowed_local_shared_objects_; LocalSharedObjectsContainer blocked_local_shared_objects_; diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc index 367f7970..01de65a 100644 --- a/chrome/browser/debugger/devtools_window.cc +++ b/chrome/browser/debugger/devtools_window.cc @@ -379,8 +379,7 @@ void DevToolsWindow::AddDevToolsExtensionsToClient() { } ListValue results; const ExtensionService* extension_service = - tab_contents_->tab_contents()->profile()-> - GetOriginalProfile()->GetExtensionService(); + tab_contents_->profile()->GetOriginalProfile()->GetExtensionService(); if (!extension_service) return; diff --git a/chrome/browser/download/download_manager.cc b/chrome/browser/download/download_manager.cc index 0bf6266..89c4eca 100644 --- a/chrome/browser/download/download_manager.cc +++ b/chrome/browser/download/download_manager.cc @@ -998,7 +998,8 @@ void DownloadManager::DownloadUrlToFile(const GURL& url, g_browser_process->resource_dispatcher_host(), tab_contents->GetRenderProcessHost()->id(), tab_contents->render_view_host()->routing_id(), - &tab_contents->profile()->GetResourceContext())); + &tab_contents->browser_context()-> + GetResourceContext())); } void DownloadManager::AddObserver(Observer* observer) { diff --git a/chrome/browser/download/download_request_handle.cc b/chrome/browser/download/download_request_handle.cc index aaf66e9..987c5bb 100644 --- a/chrome/browser/download/download_request_handle.cc +++ b/chrome/browser/download/download_request_handle.cc @@ -61,11 +61,11 @@ DownloadManager* DownloadRequestHandle::GetDownloadManager() const { if (!contents) return NULL; - Profile* profile = contents->profile(); - if (!profile) + content::BrowserContext* browser_context = contents->browser_context(); + if (!browser_context) return NULL; - return profile->GetDownloadManager(); + return browser_context->GetDownloadManager(); } void DownloadRequestHandle::PauseRequest() const { diff --git a/chrome/browser/download/drag_download_file.cc b/chrome/browser/download/drag_download_file.cc index b29c165..ab80abe 100644 --- a/chrome/browser/download/drag_download_file.cc +++ b/chrome/browser/download/drag_download_file.cc @@ -117,7 +117,7 @@ void DragDownloadFile::InitiateDownload() { } #endif - download_manager_ = tab_contents_->profile()->GetDownloadManager(); + download_manager_ = tab_contents_->browser_context()->GetDownloadManager(); download_manager_observer_added_ = true; download_manager_->AddObserver(this); diff --git a/chrome/browser/download/save_package_file_picker.cc b/chrome/browser/download/save_package_file_picker.cc index c0169a3..03d9850 100644 --- a/chrome/browser/download/save_package_file_picker.cc +++ b/chrome/browser/download/save_package_file_picker.cc @@ -56,8 +56,8 @@ SavePackageFilePicker::SavePackageFilePicker( const FilePath& suggested_path, bool can_save_as_complete) : save_package_(save_package) { - DownloadPrefs* download_prefs = save_package->tab_contents()->profile()-> - GetDownloadManager()->download_prefs(); + DownloadPrefs* download_prefs = save_package->tab_contents()-> + browser_context()->GetDownloadManager()->download_prefs(); int file_type_index = SavePackageTypeToIndex( static_cast<SavePackage::SavePackageType>( download_prefs->save_file_type())); @@ -156,7 +156,9 @@ void SavePackageFilePicker::FileSelected(const FilePath& path, if (save_package_) { TabContents* tab_contents = save_package_->tab_contents(); SavePackage::SavePackageType save_type = kIndexToSaveType[index]; - PrefService* prefs = tab_contents->profile()->GetPrefs(); + Profile* profile = + Profile::FromBrowserContext(tab_contents->browser_context()); + PrefService* prefs = profile->GetPrefs(); prefs->SetInteger(prefs::kSaveFileType, save_type); StringPrefMember save_file_path; @@ -168,7 +170,7 @@ void SavePackageFilePicker::FileSelected(const FilePath& path, #endif // If user change the default saving directory, we will remember it just // like IE and FireFox. - if (!tab_contents->profile()->IsOffTheRecord() && + if (!tab_contents->browser_context()->IsOffTheRecord() && save_file_path.GetValue() != path_string) { save_file_path.SetValue(path_string); } diff --git a/chrome/browser/extensions/extension_browser_event_router.cc b/chrome/browser/extensions/extension_browser_event_router.cc index fb9f6ba..976c251 100644 --- a/chrome/browser/extensions/extension_browser_event_router.cc +++ b/chrome/browser/extensions/extension_browser_event_router.cc @@ -245,8 +245,8 @@ void ExtensionBrowserEventRouter::OnBrowserSetLastActive( void ExtensionBrowserEventRouter::TabCreatedAt(TabContents* contents, int index, bool active) { - DispatchEventWithTab(contents->profile(), "", events::kOnTabCreated, - contents, active); + Profile* profile = Profile::FromBrowserContext(contents->browser_context()); + DispatchEventWithTab(profile, "", events::kOnTabCreated, contents, active); RegisterForTabNotifications(contents); } @@ -476,7 +476,8 @@ void ExtensionBrowserEventRouter::DispatchTabUpdatedEvent( std::string json_args; base::JSONWriter::Write(&args, false, &json_args); - DispatchEvent(contents->profile(), events::kOnTabUpdated, json_args); + Profile* profile = Profile::FromBrowserContext(contents->browser_context()); + DispatchEvent(profile, events::kOnTabUpdated, json_args); } ExtensionBrowserEventRouter::TabEntry* ExtensionBrowserEventRouter::GetTabEntry( diff --git a/chrome/browser/extensions/extension_debugger_api.cc b/chrome/browser/extensions/extension_debugger_api.cc index 3a694cb..5afef7c 100644 --- a/chrome/browser/extensions/extension_debugger_api.cc +++ b/chrome/browser/extensions/extension_debugger_api.cc @@ -117,8 +117,10 @@ ExtensionDevToolsClientHost::ExtensionDevToolsClientHost( AttachedClientHosts::GetInstance()->Add(this); // Detach from debugger when extension unloads. + Profile* profile = + Profile::FromBrowserContext(tab_contents_->browser_context()); registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, - Source<Profile>(tab_contents_->profile())); + Source<Profile>(profile)); // Attach to debugger and tell it we are ready. DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( @@ -142,7 +144,8 @@ bool ExtensionDevToolsClientHost::MatchesContentsAndExtensionId( // DevToolsClientHost interface void ExtensionDevToolsClientHost::InspectedTabClosing() { // Tell extension that this client host has been detached. - Profile* profile = tab_contents_->profile(); + Profile* profile = + Profile::FromBrowserContext(tab_contents_->browser_context()); if (profile != NULL && profile->GetExtensionEventRouter()) { ListValue args; args.Append(Value::CreateIntegerValue(tab_id_)); @@ -205,7 +208,8 @@ void ExtensionDevToolsClientHost::Observe( void ExtensionDevToolsClientHost::OnDispatchOnInspectorFrontend( const std::string& data) { - Profile* profile = tab_contents_->profile(); + Profile* profile = + Profile::FromBrowserContext(tab_contents_->browser_context()); if (profile == NULL || !profile->GetExtensionEventRouter()) return; diff --git a/chrome/browser/extensions/extension_tab_helper.cc b/chrome/browser/extensions/extension_tab_helper.cc index 5495e6e..e3dc992 100644 --- a/chrome/browser/extensions/extension_tab_helper.cc +++ b/chrome/browser/extensions/extension_tab_helper.cc @@ -63,8 +63,9 @@ void ExtensionTabHelper::SetExtensionAppById( if (extension_app_id.empty()) return; - ExtensionService* extension_service = - tab_contents()->profile()->GetExtensionService(); + Profile* profile = + Profile::FromBrowserContext(tab_contents()->browser_context()); + ExtensionService* extension_service = profile->GetExtensionService(); if (!extension_service || !extension_service->is_ready()) return; @@ -87,7 +88,9 @@ void ExtensionTabHelper::DidNavigateMainFramePostCommit( if (details.is_in_page) return; - ExtensionService* service = tab_contents()->profile()->GetExtensionService(); + Profile* profile = + Profile::FromBrowserContext(tab_contents()->browser_context()); + ExtensionService* service = profile->GetExtensionService(); if (!service) return; diff --git a/chrome/browser/extensions/extension_tabs_module.cc b/chrome/browser/extensions/extension_tabs_module.cc index f7d2dea..b0472e1 100644 --- a/chrome/browser/extensions/extension_tabs_module.cc +++ b/chrome/browser/extensions/extension_tabs_module.cc @@ -201,7 +201,7 @@ DictionaryValue* ExtensionTabUtil::CreateTabValue(const TabContents* contents, tab_strip && tab_strip->IsTabPinned(tab_index)); result->SetString(keys::kTitleKey, contents->GetTitle()); result->SetBoolean(keys::kIncognitoKey, - contents->profile()->IsOffTheRecord()); + contents->browser_context()->IsOffTheRecord()); if (!is_loading) { NavigationEntry* entry = contents->controller().GetActiveEntry(); diff --git a/chrome/browser/extensions/extension_webnavigation_api.cc b/chrome/browser/extensions/extension_webnavigation_api.cc index 2ffb663..1736110 100644 --- a/chrome/browser/extensions/extension_webnavigation_api.cc +++ b/chrome/browser/extensions/extension_webnavigation_api.cc @@ -56,9 +56,10 @@ double MilliSecondsFromTime(const base::Time& time) { } // Dispatches events to the extension message service. -void DispatchEvent(Profile* profile, +void DispatchEvent(content::BrowserContext* browser_context, const char* event_name, const std::string& json_args) { + Profile* profile = Profile::FromBrowserContext(browser_context); if (profile && profile->GetExtensionEventRouter()) { profile->GetExtensionEventRouter()->DispatchEventToRenderers( event_name, json_args, profile, GURL()); @@ -81,7 +82,9 @@ void DispatchOnBeforeNavigate(TabContents* tab_contents, std::string json_args; base::JSONWriter::Write(&args, false, &json_args); - DispatchEvent(tab_contents->profile(), keys::kOnBeforeNavigate, json_args); + DispatchEvent(tab_contents->browser_context(), + keys::kOnBeforeNavigate, + json_args); } // Constructs and dispatches an onCommitted event. @@ -111,7 +114,7 @@ void DispatchOnCommitted(TabContents* tab_contents, std::string json_args; base::JSONWriter::Write(&args, false, &json_args); - DispatchEvent(tab_contents->profile(), keys::kOnCommitted, json_args); + DispatchEvent(tab_contents->browser_context(), keys::kOnCommitted, json_args); } // Constructs and dispatches an onDOMContentLoaded event. @@ -130,7 +133,9 @@ void DispatchOnDOMContentLoaded(TabContents* tab_contents, std::string json_args; base::JSONWriter::Write(&args, false, &json_args); - DispatchEvent(tab_contents->profile(), keys::kOnDOMContentLoaded, json_args); + DispatchEvent(tab_contents->browser_context(), + keys::kOnDOMContentLoaded, + json_args); } // Constructs and dispatches an onCompleted event. @@ -149,12 +154,12 @@ void DispatchOnCompleted(TabContents* tab_contents, std::string json_args; base::JSONWriter::Write(&args, false, &json_args); - DispatchEvent(tab_contents->profile(), keys::kOnCompleted, json_args); + DispatchEvent(tab_contents->browser_context(), keys::kOnCompleted, json_args); } // Constructs and dispatches an onBeforeRetarget event. void DispatchOnBeforeRetarget(TabContents* tab_contents, - Profile* profile, + content::BrowserContext* browser_context, int64 source_frame_id, bool source_frame_is_main_frame, TabContents* target_tab_contents, @@ -173,7 +178,7 @@ void DispatchOnBeforeRetarget(TabContents* tab_contents, std::string json_args; base::JSONWriter::Write(&args, false, &json_args); - DispatchEvent(profile, keys::kOnBeforeRetarget, json_args); + DispatchEvent(browser_context, keys::kOnBeforeRetarget, json_args); } // Constructs and dispatches an onErrorOccurred event. @@ -194,7 +199,9 @@ void DispatchOnErrorOccurred(TabContents* tab_contents, std::string json_args; base::JSONWriter::Write(&args, false, &json_args); - DispatchEvent(tab_contents->profile(), keys::kOnErrorOccurred, json_args); + DispatchEvent(tab_contents->browser_context(), + keys::kOnErrorOccurred, + json_args); } } // namespace @@ -389,7 +396,7 @@ void ExtensionWebNavigationEventRouter::Retargeting( } else { DispatchOnBeforeRetarget( details->source_tab_contents, - details->target_tab_contents->profile(), + details->target_tab_contents->browser_context(), details->source_frame_id, frame_navigation_state.IsMainFrame(details->source_frame_id), details->target_tab_contents, @@ -404,7 +411,7 @@ void ExtensionWebNavigationEventRouter::TabAdded(TabContents* tab_contents) { return; DispatchOnBeforeRetarget(iter->second.source_tab_contents, - iter->second.target_tab_contents->profile(), + iter->second.target_tab_contents->browser_context(), iter->second.source_frame_id, iter->second.source_frame_is_main_frame, iter->second.target_tab_contents, diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc index c10ad0d..a5e9140 100644 --- a/chrome/browser/extensions/extensions_ui.cc +++ b/chrome/browser/extensions/extensions_ui.cc @@ -778,15 +778,16 @@ ExtensionsDOMHandler::~ExtensionsDOMHandler() { // ExtensionsDOMHandler, public: ----------------------------------------------- ExtensionsUI::ExtensionsUI(TabContents* contents) : ChromeWebUI(contents) { - ExtensionService *exstension_service = + ExtensionService *extension_service = GetProfile()->GetOriginalProfile()->GetExtensionService(); - ExtensionsDOMHandler* handler = new ExtensionsDOMHandler(exstension_service); + ExtensionsDOMHandler* handler = new ExtensionsDOMHandler(extension_service); AddMessageHandler(handler); handler->Attach(this); // Set up the chrome://extensions/ source. - contents->profile()->GetChromeURLDataManager()->AddDataSource( + Profile* profile = Profile::FromBrowserContext(contents->browser_context()); + profile->GetChromeURLDataManager()->AddDataSource( CreateExtensionsUIHTMLSource()); } diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.cc b/chrome/browser/extensions/theme_installed_infobar_delegate.cc index 27e9c03..ed8462b 100644 --- a/chrome/browser/extensions/theme_installed_infobar_delegate.cc +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.cc @@ -26,7 +26,7 @@ ThemeInstalledInfoBarDelegate::ThemeInstalledInfoBarDelegate( const std::string& previous_theme_id, bool previous_using_native_theme) : ConfirmInfoBarDelegate(tab_contents), - profile_(tab_contents->profile()), + profile_(Profile::FromBrowserContext(tab_contents->browser_context())), theme_service_(ThemeServiceFactory::GetForProfile(profile_)), name_(new_theme->name()), theme_id_(new_theme->id()), diff --git a/chrome/browser/favicon/favicon_tab_helper.cc b/chrome/browser/favicon/favicon_tab_helper.cc index 11b756f..a7bf45d 100644 --- a/chrome/browser/favicon/favicon_tab_helper.cc +++ b/chrome/browser/favicon/favicon_tab_helper.cc @@ -21,11 +21,12 @@ #include "ui/gfx/image/image.h" FaviconTabHelper::FaviconTabHelper(TabContents* tab_contents) - : TabContentsObserver(tab_contents) { - favicon_handler_.reset(new FaviconHandler(tab_contents->profile(), this, + : TabContentsObserver(tab_contents), + profile_(Profile::FromBrowserContext(tab_contents->browser_context())) { + favicon_handler_.reset(new FaviconHandler(profile_, this, FaviconHandler::FAVICON)); if (chrome::kEnableTouchIcon) - touch_icon_handler_.reset(new FaviconHandler(tab_contents->profile(), this, + touch_icon_handler_.reset(new FaviconHandler(profile_, this, FaviconHandler::TOUCH)); } @@ -84,13 +85,13 @@ void FaviconTabHelper::SaveFavicon() { // Make sure the page is in history, otherwise adding the favicon does // nothing. - HistoryService* history = tab_contents()->profile()-> + HistoryService* history = profile_-> GetOriginalProfile()->GetHistoryService(Profile::IMPLICIT_ACCESS); if (!history) return; history->AddPageNoVisitForBookmark(entry->url()); - FaviconService* service = tab_contents()->profile()-> + FaviconService* service = profile_-> GetOriginalProfile()->GetFaviconService(Profile::IMPLICIT_ACCESS); if (!service) return; @@ -148,9 +149,9 @@ void FaviconTabHelper::NavigateToPendingEntry( const GURL& url, NavigationController::ReloadType reload_type) { if (reload_type != NavigationController::NO_RELOAD && - !tab_contents()->profile()->IsOffTheRecord()) { + !profile_->IsOffTheRecord()) { FaviconService* favicon_service = - tab_contents()->profile()->GetFaviconService(Profile::IMPLICIT_ACCESS); + profile_->GetFaviconService(Profile::IMPLICIT_ACCESS); if (favicon_service) favicon_service->SetFaviconOutOfDateForPage(url); } diff --git a/chrome/browser/favicon/favicon_tab_helper.h b/chrome/browser/favicon/favicon_tab_helper.h index e10005c..c236f75 100644 --- a/chrome/browser/favicon/favicon_tab_helper.h +++ b/chrome/browser/favicon/favicon_tab_helper.h @@ -92,6 +92,8 @@ class FaviconTabHelper : public TabContentsObserver, bool errored, const SkBitmap& image); + Profile* profile_; + scoped_ptr<FaviconHandler> favicon_handler_; // Handles downloading touchicons. It is NULL if diff --git a/chrome/browser/file_select_helper.cc b/chrome/browser/file_select_helper.cc index 4ca416e..ed5a194 100644 --- a/chrome/browser/file_select_helper.cc +++ b/chrome/browser/file_select_helper.cc @@ -317,8 +317,11 @@ bool FileSelectObserver::OnMessageReceived(const IPC::Message& message) { void FileSelectObserver::OnRunFileChooser( const ViewHostMsg_RunFileChooser_Params& params) { - if (!file_select_helper_.get()) - file_select_helper_.reset(new FileSelectHelper(tab_contents()->profile())); + if (!file_select_helper_.get()) { + Profile* profile = + Profile::FromBrowserContext(tab_contents()->browser_context()); + file_select_helper_.reset(new FileSelectHelper(profile)); + } file_select_helper_->RunFileChooser(tab_contents()->render_view_host(), tab_contents(), params); @@ -334,8 +337,11 @@ void FileSelectObserver::OnEnumerateDirectory(int request_id, return; } - if (!file_select_helper_.get()) - file_select_helper_.reset(new FileSelectHelper(tab_contents()->profile())); + if (!file_select_helper_.get()) { + Profile* profile = + Profile::FromBrowserContext(tab_contents()->browser_context()); + file_select_helper_.reset(new FileSelectHelper(profile)); + } file_select_helper_->EnumerateDirectory(request_id, tab_contents()->render_view_host(), path); diff --git a/chrome/browser/history/history_tab_helper.cc b/chrome/browser/history/history_tab_helper.cc index 442694d..71b6b02 100644 --- a/chrome/browser/history/history_tab_helper.cc +++ b/chrome/browser/history/history_tab_helper.cc @@ -143,18 +143,22 @@ void HistoryTabHelper::OnPageContents(const GURL& url, void HistoryTabHelper::OnThumbnail(const GURL& url, const ThumbnailScore& score, const SkBitmap& bitmap) { - if (tab_contents()->profile()->IsOffTheRecord()) + Profile* profile = + Profile::FromBrowserContext(tab_contents()->browser_context()); + if (profile->IsOffTheRecord()) return; // Tell History about this thumbnail - history::TopSites* ts = tab_contents()->profile()->GetTopSites(); + history::TopSites* ts = profile->GetTopSites(); if (ts) ts->SetPageThumbnail(url, bitmap, score); } HistoryService* HistoryTabHelper::GetHistoryService() { - if (tab_contents()->profile()->IsOffTheRecord()) + Profile* profile = + Profile::FromBrowserContext(tab_contents()->browser_context()); + if (profile->IsOffTheRecord()) return NULL; - return tab_contents()->profile()->GetHistoryService(Profile::IMPLICIT_ACCESS); + return profile->GetHistoryService(Profile::IMPLICIT_ACCESS); } diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc index 29dff9d..53dce9d 100644 --- a/chrome/browser/notifications/desktop_notification_service.cc +++ b/chrome/browser/notifications/desktop_notification_service.cc @@ -140,7 +140,7 @@ NotificationPermissionInfoBarDelegate::NotificationPermissionInfoBarDelegate( : ConfirmInfoBarDelegate(contents), origin_(origin), display_name_(display_name), - profile_(contents->profile()), + profile_(Profile::FromBrowserContext(contents->browser_context())), process_id_(process_id), route_id_(route_id), callback_context_(callback_context), diff --git a/chrome/browser/pdf_unsupported_feature.cc b/chrome/browser/pdf_unsupported_feature.cc index 8715fb8..9112765 100644 --- a/chrome/browser/pdf_unsupported_feature.cc +++ b/chrome/browser/pdf_unsupported_feature.cc @@ -86,7 +86,9 @@ InfoBarDelegate::Type } bool PDFEnableAdobeReaderInfoBarDelegate::Accept() { - tab_contents_->profile()->GetPrefs()->SetBoolean( + Profile* profile = + Profile::FromBrowserContext(tab_contents_->browser_context()); + profile->GetPrefs()->SetBoolean( prefs::kPluginsShowSetReaderDefaultInfobar, false); OnNo(); return true; @@ -115,7 +117,9 @@ void PDFEnableAdobeReaderInfoBarDelegate::OnYes() { PluginUpdater* plugin_updater = PluginUpdater::GetInstance(); plugin_updater->EnablePluginGroup(true, ASCIIToUTF16(webkit::npapi::PluginGroup::kAdobeReaderGroupName)); - plugin_updater->UpdatePreferences(tab_contents_->profile(), 0); + Profile* profile = + Profile::FromBrowserContext(tab_contents_->browser_context()); + plugin_updater->UpdatePreferences(profile, 0); } void PDFEnableAdobeReaderInfoBarDelegate::OnNo() { diff --git a/chrome/browser/plugin_observer.cc b/chrome/browser/plugin_observer.cc index 7983b9d2..f3b8a69 100644 --- a/chrome/browser/plugin_observer.cc +++ b/chrome/browser/plugin_observer.cc @@ -160,7 +160,9 @@ bool BlockedPluginInfoBarDelegate::Accept() { bool BlockedPluginInfoBarDelegate::Cancel() { UserMetrics::RecordAction( UserMetricsAction("BlockedPluginInfobar.AlwaysAllow")); - tab_contents_->profile()->GetHostContentSettingsMap()->AddExceptionForURL( + Profile* profile = + Profile::FromBrowserContext(tab_contents_->browser_context()); + profile->GetHostContentSettingsMap()->AddExceptionForURL( tab_contents_->GetURL(), tab_contents_->GetURL(), CONTENT_SETTINGS_TYPE_PLUGINS, diff --git a/chrome/browser/prerender/prerender_contents.cc b/chrome/browser/prerender/prerender_contents.cc index 1709e72..23be43d 100644 --- a/chrome/browser/prerender/prerender_contents.cc +++ b/chrome/browser/prerender/prerender_contents.cc @@ -16,6 +16,7 @@ #include "chrome/browser/prerender/prerender_manager.h" #include "chrome/browser/prerender/prerender_render_view_host_observer.h" #include "chrome/browser/prerender/prerender_tracker.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" diff --git a/chrome/browser/prerender/prerender_contents.h b/chrome/browser/prerender/prerender_contents.h index b72942d..48727ac 100644 --- a/chrome/browser/prerender/prerender_contents.h +++ b/chrome/browser/prerender/prerender_contents.h @@ -17,6 +17,7 @@ #include "content/browser/renderer_host/render_view_host_delegate.h" #include "content/common/notification_registrar.h" +class Profile; class RenderViewHost; class TabContents; class TabContentsWrapper; diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc index 39fee28..dd19f27 100644 --- a/chrome/browser/prerender/prerender_manager.cc +++ b/chrome/browser/prerender/prerender_manager.cc @@ -673,8 +673,9 @@ void PrerenderManager::RecordPerceivedPageLoadTime( base::TimeDelta perceived_page_load_time, TabContents* tab_contents) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - PrerenderManager* prerender_manager = - tab_contents->profile()->GetPrerenderManager(); + Profile* profile = + Profile::FromBrowserContext(tab_contents->browser_context()); + PrerenderManager* prerender_manager = profile->GetPrerenderManager(); if (!prerender_manager) return; if (!prerender_manager->is_enabled()) diff --git a/chrome/browser/prerender/prerender_observer.cc b/chrome/browser/prerender/prerender_observer.cc index af6ce6b..4b4c272 100644 --- a/chrome/browser/prerender/prerender_observer.cc +++ b/chrome/browser/prerender/prerender_observer.cc @@ -237,7 +237,9 @@ void PrerenderObserver::DidStopLoading() { } PrerenderManager* PrerenderObserver::MaybeGetPrerenderManager() { - return tab_contents()->profile()->GetPrerenderManager(); + Profile* profile = + Profile::FromBrowserContext(tab_contents()->browser_context()); + return profile->GetPrerenderManager(); } bool PrerenderObserver::MaybeUsePrerenderedPage(const GURL& url, diff --git a/chrome/browser/printing/print_preview_tab_controller.cc b/chrome/browser/printing/print_preview_tab_controller.cc index 724f266..7c68562 100644 --- a/chrome/browser/printing/print_preview_tab_controller.cc +++ b/chrome/browser/printing/print_preview_tab_controller.cc @@ -199,8 +199,9 @@ TabContents* PrintPreviewTabController::CreatePrintPreviewTab( tab->restore_tab_helper()->window_id().id()); if (!current_browser) { if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeFrame)) { - current_browser = Browser::CreateForType(Browser::TYPE_POPUP, - initiator_tab->profile()); + Profile* profile = + Profile::FromBrowserContext(initiator_tab->browser_context()); + current_browser = Browser::CreateForType(Browser::TYPE_POPUP, profile); if (!current_browser) { NOTREACHED() << "Failed to create popup browser window"; return NULL; diff --git a/chrome/browser/safe_browsing/browser_feature_extractor.cc b/chrome/browser/safe_browsing/browser_feature_extractor.cc index 3a65a01..4d8a48f 100644 --- a/chrome/browser/safe_browsing/browser_feature_extractor.cc +++ b/chrome/browser/safe_browsing/browser_feature_extractor.cc @@ -430,8 +430,9 @@ bool BrowserFeatureExtractor::GetPendingQuery( bool BrowserFeatureExtractor::GetHistoryService(HistoryService** history) { *history = NULL; - if (tab_ && tab_->profile()) { - *history = tab_->profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); + if (tab_ && tab_->browser_context()) { + Profile* profile = Profile::FromBrowserContext(tab_->browser_context()); + *history = profile->GetHistoryService(Profile::EXPLICIT_ACCESS); if (*history) { return true; } @@ -439,4 +440,5 @@ bool BrowserFeatureExtractor::GetHistoryService(HistoryService** history) { VLOG(2) << "Unable to query history. No history service available."; return false; } + }; // namespace safe_browsing diff --git a/chrome/browser/safe_browsing/client_side_detection_host.cc b/chrome/browser/safe_browsing/client_side_detection_host.cc index 2224d7c..d88f8ab 100644 --- a/chrome/browser/safe_browsing/client_side_detection_host.cc +++ b/chrome/browser/safe_browsing/client_side_detection_host.cc @@ -106,7 +106,7 @@ class ClientSideDetectionHost::ShouldClassifyUrlRequest } // Don't run the phishing classifier if the tab is incognito. - if (tab_contents_->profile()->IsOffTheRecord()) { + if (tab_contents_->browser_context()->IsOffTheRecord()) { VLOG(1) << "Skipping phishing classification for URL: " << params_.url << " because we're browsing incognito."; UMA_HISTOGRAM_ENUMERATION("SBClientPhishing.PreClassificationCheckFail", diff --git a/chrome/browser/safe_browsing/malware_details.cc b/chrome/browser/safe_browsing/malware_details.cc index decf24b..d8edb23 100644 --- a/chrome/browser/safe_browsing/malware_details.cc +++ b/chrome/browser/safe_browsing/malware_details.cc @@ -74,12 +74,13 @@ MalwareDetails::MalwareDetails( TabContents* tab_contents, const SafeBrowsingService::UnsafeResource& resource) : TabContentsObserver(tab_contents), - request_context_getter_(tab_contents->profile()->GetRequestContext()), + profile_(Profile::FromBrowserContext(tab_contents->browser_context())), + request_context_getter_(profile_->GetRequestContext()), sb_service_(sb_service), resource_(resource), cache_collector_(new MalwareDetailsCacheCollector), redirects_collector_( - new MalwareDetailsRedirectsCollector(tab_contents->profile())) { + new MalwareDetailsRedirectsCollector(profile_)) { StartCollection(); } diff --git a/chrome/browser/safe_browsing/malware_details.h b/chrome/browser/safe_browsing/malware_details.h index d4036c6..2f49df3 100644 --- a/chrome/browser/safe_browsing/malware_details.h +++ b/chrome/browser/safe_browsing/malware_details.h @@ -31,6 +31,7 @@ struct SafeBrowsingHostMsg_MalwareDOMDetails_Node; class MalwareDetailsCacheCollector; class MalwareDetailsRedirectsCollector; class MalwareDetailsFactory; +class Profile; namespace safe_browsing { // Maps a URL to its Resource. @@ -81,6 +82,8 @@ class MalwareDetails : public base::RefCountedThreadSafe<MalwareDetails>, virtual void AddDOMDetails( const std::vector<SafeBrowsingHostMsg_MalwareDOMDetails_Node>& params); + Profile* profile_; + // The report protocol buffer. scoped_ptr<safe_browsing::ClientMalwareReportRequest> report_; diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc index b0c4999..8ddc4ed 100644 --- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc +++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc @@ -161,7 +161,7 @@ SafeBrowsingBlockingPage::SafeBrowsingBlockingPage( } bool SafeBrowsingBlockingPage::CanShowMalwareDetailsOption() { - return (!tab()->profile()->IsOffTheRecord() && + return (!tab()->browser_context()->IsOffTheRecord() && tab()->GetURL().SchemeIs(chrome::kHttpScheme)); } @@ -364,8 +364,9 @@ void SafeBrowsingBlockingPage::PopulateMalwareStringDictionary( IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE, UTF8ToUTF16(privacy_link))); + Profile* profile = Profile::FromBrowserContext(tab()->browser_context()); const PrefService::Preference* pref = - tab()->profile()->GetPrefs()->FindPreference( + profile->GetPrefs()->FindPreference( prefs::kSafeBrowsingReportingEnabled); bool value; @@ -509,7 +510,8 @@ void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) { } void SafeBrowsingBlockingPage::SetReportingPreference(bool report) { - PrefService* pref = tab()->profile()->GetPrefs(); + Profile* profile = Profile::FromBrowserContext(tab()->browser_context()); + PrefService* pref = profile->GetPrefs(); pref->SetBoolean(prefs::kSafeBrowsingReportingEnabled, report); } @@ -626,9 +628,9 @@ void SafeBrowsingBlockingPage::FinishMalwareDetails(int64 delay_ms) { if (malware_details_ == NULL) return; // Not all interstitials have malware details (eg phishing). + Profile* profile = Profile::FromBrowserContext(tab()->browser_context()); const PrefService::Preference* pref = - tab()->profile()->GetPrefs()->FindPreference( - prefs::kSafeBrowsingReportingEnabled); + profile->GetPrefs()->FindPreference(prefs::kSafeBrowsingReportingEnabled); bool value; if (pref && pref->GetValue()->GetAsBoolean(&value) && value) { diff --git a/chrome/browser/sessions/session_types.cc b/chrome/browser/sessions/session_types.cc index 59ca5b9..7a61e4e 100644 --- a/chrome/browser/sessions/session_types.cc +++ b/chrome/browser/sessions/session_types.cc @@ -5,6 +5,7 @@ #include "chrome/browser/sessions/session_types.h" #include "base/string_util.h" +#include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "content/browser/tab_contents/navigation_controller.h" #include "content/browser/tab_contents/navigation_entry.h" diff --git a/chrome/browser/sidebar/sidebar_container.cc b/chrome/browser/sidebar/sidebar_container.cc index 4013537..f5e715c 100644 --- a/chrome/browser/sidebar/sidebar_container.cc +++ b/chrome/browser/sidebar/sidebar_container.cc @@ -31,7 +31,8 @@ SidebarContainer::SidebarContainer(TabContents* tab, use_default_icon_(true) { // Create TabContents for sidebar. sidebar_contents_.reset( - new TabContents(tab->profile(), NULL, MSG_ROUTING_NONE, NULL, NULL)); + new TabContents(Profile::FromBrowserContext(tab->browser_context()), + NULL, MSG_ROUTING_NONE, NULL, NULL)); sidebar_contents_->set_delegate(this); } @@ -124,8 +125,9 @@ void SidebarContainer::OnImageLoaded(SkBitmap* image, } const Extension* SidebarContainer::GetExtension() const { - ExtensionService* service = - sidebar_contents_->profile()->GetExtensionService(); + Profile* profile = + Profile::FromBrowserContext(sidebar_contents_->browser_context()); + ExtensionService* service = profile->GetExtensionService(); if (!service) return NULL; return service->GetExtensionById( diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc index 8479a5e..94f39fbe 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc @@ -160,7 +160,7 @@ TabContentsWrapper::TabContentsWrapper(TabContents* contents) } // Set-up the showing of the omnibox search infobar if applicable. - if (OmniboxSearchHint::IsEnabled(contents->profile())) + if (OmniboxSearchHint::IsEnabled(profile())) omnibox_search_hint_.reset(new OmniboxSearchHint(this)); registrar_.Add(this, chrome::NOTIFICATION_GOOGLE_URL_UPDATED, @@ -369,6 +369,10 @@ const TabContentsWrapper* TabContentsWrapper::GetCurrentWrapperForContents( return wrapper ? *wrapper : NULL; } +Profile* TabContentsWrapper::profile() const { + return Profile::FromBrowserContext(tab_contents()->browser_context()); +} + //////////////////////////////////////////////////////////////////////////////// // TabContentsWrapper implementation: diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h index e027200..1605755 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h @@ -117,7 +117,8 @@ class TabContentsWrapper : public TabContentsObserver, RenderViewHost* render_view_host() const { return tab_contents()->render_view_host(); } - Profile* profile() const { return tab_contents()->profile(); } + + Profile* profile() const; // Tab Helpers --------------------------------------------------------------- diff --git a/chrome/browser/ui/toolbar/toolbar_model.cc b/chrome/browser/ui/toolbar/toolbar_model.cc index 24a1330..f2c2dc45 100644 --- a/chrome/browser/ui/toolbar/toolbar_model.cc +++ b/chrome/browser/ui/toolbar/toolbar_model.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -40,8 +40,9 @@ std::wstring ToolbarModel::GetText() const { NavigationController* navigation_controller = GetNavigationController(); if (navigation_controller) { - languages = navigation_controller->profile()->GetPrefs()->GetString( - prefs::kAcceptLanguages); + Profile* profile = + Profile::FromBrowserContext(navigation_controller->browser_context()); + languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); NavigationEntry* entry = navigation_controller->GetActiveEntry(); if (!navigation_controller->tab_contents()->ShouldDisplayURL()) { // Explicitly hide the URL for this tab. diff --git a/content/browser/browser_context.h b/content/browser/browser_context.h index 2793aa7..b67142c 100644 --- a/content/browser/browser_context.h +++ b/content/browser/browser_context.h @@ -89,7 +89,7 @@ class BrowserContext { virtual GeolocationPermissionContext* GetGeolocationPermissionContext() = 0; // Returns true if the last time this context was open it was exited cleanly. - // This doesn't belong here; http://crbug.com/76788 + // This doesn't belong here; http://crbug.com/90737 virtual bool DidLastSessionExitCleanly() = 0; // Returns the WebKitContext assigned to this context. diff --git a/content/browser/download/save_package.cc b/content/browser/download/save_package.cc index e28da52..00cf6c6 100644 --- a/content/browser/download/save_package.cc +++ b/content/browser/download/save_package.cc @@ -256,19 +256,19 @@ bool SavePackage::Init() { wait_state_ = START_PROCESS; // Initialize the request context and resource dispatcher. - Profile* profile = tab_contents()->profile(); - if (!profile) { + content::BrowserContext* browser_context = tab_contents()->browser_context(); + if (!browser_context) { NOTREACHED(); return false; } // Create the fake DownloadItem and display the view. DownloadManager* download_manager = - tab_contents()->profile()->GetDownloadManager(); + tab_contents()->browser_context()->GetDownloadManager(); download_ = new DownloadItem(download_manager, saved_main_file_path_, page_url_, - profile->IsOffTheRecord()); + browser_context->IsOffTheRecord()); // Transfer the ownership to the download manager. We need the DownloadItem // to be alive as long as the Profile is alive. @@ -813,7 +813,8 @@ void SavePackage::SaveNextFile(bool process_all_remaining_items) { routing_id(), save_item->save_source(), save_item->full_path(), - tab_contents()->profile()->GetResourceContext(), + tab_contents()-> + browser_context()->GetResourceContext(), this); } while (process_all_remaining_items && waiting_item_queue_.size()); } diff --git a/content/browser/tab_contents/interstitial_page.cc b/content/browser/tab_contents/interstitial_page.cc index b711e4c..64950fc 100644 --- a/content/browser/tab_contents/interstitial_page.cc +++ b/content/browser/tab_contents/interstitial_page.cc @@ -408,7 +408,7 @@ RendererPreferences InterstitialPage::GetRendererPrefs( RenderViewHost* InterstitialPage::CreateRenderViewHost() { RenderViewHost* render_view_host = new RenderViewHost( - SiteInstance::CreateSiteInstance(tab()->profile()), + SiteInstance::CreateSiteInstance(tab()->browser_context()), this, MSG_ROUTING_NONE, kInvalidSessionStorageNamespaceId); return render_view_host; } diff --git a/content/browser/tab_contents/navigation_controller.h b/content/browser/tab_contents/navigation_controller.h index b2d254a..a01262d 100644 --- a/content/browser/tab_contents/navigation_controller.h +++ b/content/browser/tab_contents/navigation_controller.h @@ -14,7 +14,6 @@ #include "base/memory/linked_ptr.h" #include "base/time.h" #include "googleurl/src/gurl.h" -#include "chrome/browser/profiles/profile.h" #include "content/browser/ssl/ssl_manager.h" #include "content/common/navigation_types.h" #include "content/common/page_transition_types.h" @@ -61,12 +60,6 @@ class NavigationController { browser_context_ = browser_context; } - // Returns the profile. - // TEMPORARY; http://crbug.com/76788 - Profile* profile() const { - return Profile::FromBrowserContext(browser_context()); - } - // Initializes this NavigationController with the given saved navigations, // using selected_navigation as the currently loaded entry. Before this call // the controller should be unused (there should be no current entry). If diff --git a/content/browser/webui/web_ui.cc b/content/browser/webui/web_ui.cc index 37af425..f4a91ca 100644 --- a/content/browser/webui/web_ui.cc +++ b/content/browser/webui/web_ui.cc @@ -10,6 +10,7 @@ #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "base/values.h" +#include "chrome/browser/profiles/profile.h" #include "content/browser/child_process_security_policy.h" #include "content/browser/renderer_host/render_process_host.h" #include "content/browser/renderer_host/render_view_host.h" @@ -157,7 +158,7 @@ void WebUI::RegisterMessageCallback(const std::string &message, Profile* WebUI::GetProfile() const { DCHECK(tab_contents()); - return tab_contents()->profile(); + return Profile::FromBrowserContext(tab_contents()->browser_context()); } RenderViewHost* WebUI::GetRenderViewHost() const { |