diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-27 19:29:56 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-27 19:29:56 +0000 |
commit | 74d32ec47f9098ae52997b159cf05342020d72a9 (patch) | |
tree | 1a2b178feceea57e0e15250cc7c5fc44114fe436 /chrome | |
parent | 331bf1416770ae1a2b3649369b596f6f5511bd72 (diff) | |
download | chromium_src-74d32ec47f9098ae52997b159cf05342020d72a9.zip chromium_src-74d32ec47f9098ae52997b159cf05342020d72a9.tar.gz chromium_src-74d32ec47f9098ae52997b159cf05342020d72a9.tar.bz2 |
Revert 94332 - Removal of Profile from content part 2.
BUG=76788
TEST=no change visible
Review URL: http://codereview.chromium.org/7480028
TBR=avi@chromium.org
Review URL: http://codereview.chromium.org/7492051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94335 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
18 files changed, 47 insertions, 74 deletions
diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc index 367f7970..eda78d8 100644 --- a/chrome/browser/debugger/devtools_window.cc +++ b/chrome/browser/debugger/devtools_window.cc @@ -566,8 +566,7 @@ DevToolsWindow* DevToolsWindow::ToggleDevToolsWindow( bool do_open = force_open; if (!window) { - Profile* profile = Profile::FromBrowserContext( - inspected_rvh->process()->browser_context()); + Profile* profile = inspected_rvh->process()->profile(); bool docked = profile->GetPrefs()->GetBoolean(prefs::kDevToolsOpenDocked); window = new DevToolsWindow(profile, inspected_rvh, docked, false); manager->RegisterDevToolsClientHostFor(inspected_rvh, window); diff --git a/chrome/browser/extensions/extension_event_router.cc b/chrome/browser/extensions/extension_event_router.cc index 7a9cb340..44561ce 100644 --- a/chrome/browser/extensions/extension_event_router.cc +++ b/chrome/browser/extensions/extension_event_router.cc @@ -202,7 +202,7 @@ void ExtensionEventRouter::DispatchEventImpl( // Is this event from a different profile than the renderer (ie, an // incognito tab event sent to a normal process, or vice versa). bool cross_incognito = restrict_to_profile && - listener->process->browser_context() != restrict_to_profile; + listener->process->profile() != restrict_to_profile; const Extension* extension = service->GetExtensionById( listener->extension_id, false); // Send the event with different arguments to extensions that can't diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc index f90868a..15529b2 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.cc +++ b/chrome/browser/extensions/extension_function_dispatcher.cc @@ -498,8 +498,7 @@ Browser* ExtensionFunctionDispatcher::GetCurrentBrowser( // profile. Note that the profile may already be incognito, in which case // we will search the incognito version only, regardless of the value of // |include_incognito|. - Profile* profile = Profile::FromBrowserContext( - render_view_host->process()->browser_context()); + Profile* profile = render_view_host->process()->profile(); browser = BrowserList::FindTabbedBrowser(profile, include_incognito); // NOTE(rafaelw): This can return NULL in some circumstances. In particular, diff --git a/chrome/browser/extensions/extension_message_handler.cc b/chrome/browser/extensions/extension_message_handler.cc index 8895530..7595082 100644 --- a/chrome/browser/extensions/extension_message_handler.cc +++ b/chrome/browser/extensions/extension_message_handler.cc @@ -37,8 +37,7 @@ void ExtensionMessageHandler::RenderViewHostInitialized() { void ExtensionMessageHandler::OnPostMessage(int port_id, const std::string& message) { - Profile* profile = Profile::FromBrowserContext( - render_view_host()->process()->browser_context()); + Profile* profile = render_view_host()->process()->profile(); if (profile->GetExtensionMessageService()) { profile->GetExtensionMessageService()->PostMessageFromRenderer( port_id, message); diff --git a/chrome/browser/extensions/extension_message_service.cc b/chrome/browser/extensions/extension_message_service.cc index 58400e5..0dd960d 100644 --- a/chrome/browser/extensions/extension_message_service.cc +++ b/chrome/browser/extensions/extension_message_service.cc @@ -143,13 +143,12 @@ void ExtensionMessageService::OpenChannelToExtension( RenderProcessHost* source = RenderProcessHost::FromID(source_process_id); if (!source) return; - Profile* profile = Profile::FromBrowserContext(source->browser_context()); // Note: we use the source's profile here. If the source is an incognito // process, we will use the incognito EPM to find the right extension process, // which depends on whether the extension uses spanning or split mode. MessagePort receiver( - profile->GetExtensionProcessManager()->GetExtensionProcess( + source->profile()->GetExtensionProcessManager()->GetExtensionProcess( target_extension_id), MSG_ROUTING_CONTROL); TabContents* source_contents = tab_util::GetTabContentsByID( @@ -174,11 +173,10 @@ void ExtensionMessageService::OpenChannelToTab( RenderProcessHost* source = RenderProcessHost::FromID(source_process_id); if (!source) return; - Profile* profile = Profile::FromBrowserContext(source->browser_context()); TabContentsWrapper* contents = NULL; MessagePort receiver; - if (ExtensionTabUtil::GetTabById(tab_id, profile, true, + if (ExtensionTabUtil::GetTabById(tab_id, source->profile(), true, NULL, NULL, &contents, NULL)) { receiver.sender = contents->render_view_host(); receiver.routing_id = contents->render_view_host()->routing_id(); diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc index 9dc02d4..1944478 100644 --- a/chrome/browser/extensions/extension_process_manager.cc +++ b/chrome/browser/extensions/extension_process_manager.cc @@ -132,9 +132,8 @@ ExtensionHost* ExtensionProcessManager::CreateViewHost( const GURL& url, Browser* browser, ViewType::Type view_type) { // A NULL browser may only be given for pop-up views. DCHECK(browser || (!browser && view_type == ViewType::EXTENSION_POPUP)); - Profile* profile = - Profile::FromBrowserContext(browsing_instance_->browser_context()); - ExtensionService* service = profile->GetExtensionService(); + ExtensionService* service = + browsing_instance_->profile()->GetExtensionService(); if (service) { const Extension* extension = service->GetExtensionByURL(url); if (extension) @@ -199,9 +198,8 @@ void ExtensionProcessManager::OpenOptionsPage(const Extension* extension, // Force the options page to open in non-OTR window, because it won't be // able to save settings from OTR. if (!browser || browser->profile()->IsOffTheRecord()) { - Profile* profile = - Profile::FromBrowserContext(browsing_instance_->browser_context()); - browser = Browser::GetOrCreateTabbedBrowser(profile->GetOriginalProfile()); + browser = Browser::GetOrCreateTabbedBrowser( + browsing_instance_->profile()->GetOriginalProfile()); } browser->OpenURL(extension->options_url(), GURL(), SINGLETON_TAB, @@ -264,9 +262,8 @@ const Extension* ExtensionProcessManager::GetExtensionForSiteInstance( if (it != extension_ids_.end()) { // Look up the extension by ID, including disabled extensions in case // this gets called while an old process is still around. - Profile* profile = - Profile::FromBrowserContext(browsing_instance_->browser_context()); - ExtensionService* service = profile->GetExtensionService(); + ExtensionService* service = + browsing_instance_->profile()->GetExtensionService(); return service->GetExtensionById(it->second, false); } @@ -345,7 +342,7 @@ void ExtensionProcessManager::Observe(int type, void ExtensionProcessManager::OnExtensionHostCreated(ExtensionHost* host, bool is_background) { - DCHECK_EQ(browsing_instance_->browser_context(), host->profile()); + DCHECK_EQ(browsing_instance_->profile(), host->profile()); all_hosts_.insert(host); if (is_background) @@ -445,9 +442,8 @@ const Extension* IncognitoExtensionProcessManager::GetExtensionForSiteInstance( const Extension* IncognitoExtensionProcessManager::GetExtensionOrAppByURL( const GURL& url) { - Profile* profile = - Profile::FromBrowserContext(browsing_instance_->browser_context()); - ExtensionService* service = profile->GetExtensionService(); + ExtensionService* service = + browsing_instance_->profile()->GetExtensionService(); if (!service) return NULL; return (url.SchemeIs(chrome::kExtensionScheme)) ? @@ -456,9 +452,8 @@ const Extension* IncognitoExtensionProcessManager::GetExtensionOrAppByURL( bool IncognitoExtensionProcessManager::IsIncognitoEnabled( const Extension* extension) { - Profile* profile = - Profile::FromBrowserContext(browsing_instance_->browser_context()); - ExtensionService* service = profile->GetExtensionService(); + ExtensionService* service = + browsing_instance_->profile()->GetExtensionService(); return service && service->IsIncognitoEnabled(extension->id()); } @@ -472,13 +467,12 @@ void IncognitoExtensionProcessManager::Observe( // incognito window. Watch for new browsers and create the hosts if // it matches our profile. Browser* browser = Source<Browser>(source).ptr(); - if (browser->profile() == browsing_instance_->browser_context()) { + if (browser->profile() == browsing_instance_->profile()) { // On Chrome OS, a login screen is implemented as a browser. // This browser has no extension service. In this case, // service will be NULL. - Profile* profile = - Profile::FromBrowserContext(browsing_instance_->browser_context()); - ExtensionService* service = profile->GetExtensionService(); + ExtensionService* service = + browsing_instance_->profile()->GetExtensionService(); if (service && service->is_ready()) CreateBackgroundHosts(this, service->extensions()); } diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index ffb87e06..72667a1 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -1363,9 +1363,8 @@ void ExtensionService::NotifyExtensionLoaded(const Extension* extension) { for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); !i.IsAtEnd(); i.Advance()) { RenderProcessHost* host = i.GetCurrentValue(); - Profile* host_profile = - Profile::FromBrowserContext(host->browser_context()); - if (host_profile->GetOriginalProfile() == profile_->GetOriginalProfile()) { + if (host->profile()->GetOriginalProfile() == + profile_->GetOriginalProfile()) { host->Send( new ExtensionMsg_Loaded(ExtensionMsg_Loaded_Params( extension, extension->GetActivePermissions()))); @@ -1461,10 +1460,10 @@ void ExtensionService::NotifyExtensionUnloaded( for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); !i.IsAtEnd(); i.Advance()) { RenderProcessHost* host = i.GetCurrentValue(); - Profile* host_profile = - Profile::FromBrowserContext(host->browser_context()); - if (host_profile->GetOriginalProfile() == profile_->GetOriginalProfile()) + if (host->profile()->GetOriginalProfile() == + profile_->GetOriginalProfile()) { host->Send(new ExtensionMsg_Unloaded(extension->id())); + } } profile_->UnregisterExtensionWithRequestContexts(extension->id(), reason); diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc index c10ad0d..8eb68c8 100644 --- a/chrome/browser/extensions/extensions_ui.cc +++ b/chrome/browser/extensions/extensions_ui.cc @@ -757,9 +757,8 @@ void ExtensionsDOMHandler::GetActivePagesForExtensionProcess( continue; } - result->push_back( - ExtensionPage(url, process->id(), host->routing_id(), - process->browser_context()->IsOffTheRecord())); + result->push_back(ExtensionPage(url, process->id(), host->routing_id(), + process->profile()->IsOffTheRecord())); } } diff --git a/chrome/browser/extensions/user_script_master.cc b/chrome/browser/extensions/user_script_master.cc index 8267b78..758700c 100644 --- a/chrome/browser/extensions/user_script_master.cc +++ b/chrome/browser/extensions/user_script_master.cc @@ -363,9 +363,8 @@ void UserScriptMaster::StartLoad() { void UserScriptMaster::SendUpdate(RenderProcessHost* process, base::SharedMemory* shared_memory) { - Profile* profile = Profile::FromBrowserContext(process->browser_context()); // Make sure we only send user scripts to processes in our profile. - if (!profile_->IsSameProfile(profile)) + if (!profile_->IsSameProfile(process->profile())) return; // If the process is being started asynchronously, early return. We'll end up diff --git a/chrome/browser/memory_details.cc b/chrome/browser/memory_details.cc index 7649775..8d26788 100644 --- a/chrome/browser/memory_details.cc +++ b/chrome/browser/memory_details.cc @@ -135,8 +135,7 @@ void MemoryDetails::CollectChildInfoOnUIThread() { continue; } process.type = ChildProcessInfo::RENDER_PROCESS; - Profile* profile = - Profile::FromBrowserContext(render_process_host->browser_context()); + Profile* profile = render_process_host->profile(); ExtensionService* extension_service = profile->GetExtensionService(); // The RenderProcessHost may host multiple TabContents. Any diff --git a/chrome/browser/spellcheck_host_impl.cc b/chrome/browser/spellcheck_host_impl.cc index f490e0d..e0f9fd2 100644 --- a/chrome/browser/spellcheck_host_impl.cc +++ b/chrome/browser/spellcheck_host_impl.cc @@ -143,8 +143,7 @@ void SpellCheckHostImpl::UnsetObserver() { void SpellCheckHostImpl::InitForRenderer(RenderProcessHost* process) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - Profile* profile = Profile::FromBrowserContext(process->browser_context()); - PrefService* prefs = profile->GetPrefs(); + PrefService* prefs = process->profile()->GetPrefs(); IPC::PlatformFileForTransit file; if (GetDictionaryFile() != base::kInvalidPlatformFileValue) { diff --git a/chrome/browser/spellcheck_message_filter.cc b/chrome/browser/spellcheck_message_filter.cc index 483d560..54de49e 100644 --- a/chrome/browser/spellcheck_message_filter.cc +++ b/chrome/browser/spellcheck_message_filter.cc @@ -94,7 +94,7 @@ void SpellCheckMessageFilter::OnSpellCheckerRequestDictionary() { RenderProcessHost* host = RenderProcessHost::FromID(render_process_id_); if (!host) return; // Teardown. - Profile* profile = Profile::FromBrowserContext(host->browser_context()); + Profile* profile = host->profile(); // The renderer has requested that we initialize its spellchecker. This should // generally only be called once per session, as after the first call, all // future renderers will be passed the initialization information on startup @@ -117,8 +117,7 @@ void SpellCheckMessageFilter::OnNotifyChecked(const string16& word, if (!host) return; // Teardown. // Delegates to SpellCheckHost which tracks the stats of our spellchecker. - Profile* profile = Profile::FromBrowserContext(host->browser_context()); - SpellCheckHost* spellcheck_host = profile->GetSpellCheckHost(); + SpellCheckHost* spellcheck_host = host->profile()->GetSpellCheckHost(); if (spellcheck_host && spellcheck_host->GetMetrics()) spellcheck_host->GetMetrics()->RecordCheckedWordStats(word, misspelled); } diff --git a/chrome/browser/tab_contents/background_contents.cc b/chrome/browser/tab_contents/background_contents.cc index 0c78a80..66c20a9 100644 --- a/chrome/browser/tab_contents/background_contents.cc +++ b/chrome/browser/tab_contents/background_contents.cc @@ -52,8 +52,7 @@ BackgroundContents::BackgroundContents() BackgroundContents::~BackgroundContents() { if (!render_view_host_) // Will be null for unit tests. return; - Profile* profile = Profile::FromBrowserContext( - render_view_host_->process()->browser_context()); + Profile* profile = render_view_host_->process()->profile(); NotificationService::current()->Notify( chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, Source<Profile>(profile), @@ -93,8 +92,7 @@ void BackgroundContents::DidNavigate( // extent a background page will be opened but will remain at about:blank. url_ = params.url; - Profile* profile = Profile::FromBrowserContext( - render_view_host->process()->browser_context()); + Profile* profile = render_view_host->process()->profile(); NotificationService::current()->Notify( chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, Source<Profile>(profile), @@ -149,8 +147,7 @@ gfx::NativeWindow BackgroundContents::GetDialogRootWindow() { } void BackgroundContents::Close(RenderViewHost* render_view_host) { - Profile* profile = Profile::FromBrowserContext( - render_view_host->process()->browser_context()); + Profile* profile = render_view_host->process()->profile(); NotificationService::current()->Notify( chrome::NOTIFICATION_BACKGROUND_CONTENTS_CLOSED, Source<Profile>(profile), @@ -161,8 +158,7 @@ void BackgroundContents::Close(RenderViewHost* render_view_host) { void BackgroundContents::RenderViewGone(RenderViewHost* rvh, base::TerminationStatus status, int error_code) { - Profile* profile = - Profile::FromBrowserContext(rvh->process()->browser_context()); + Profile* profile = rvh->process()->profile(); NotificationService::current()->Notify( chrome::NOTIFICATION_BACKGROUND_CONTENTS_TERMINATED, Source<Profile>(profile), @@ -186,8 +182,7 @@ RendererPreferences BackgroundContents::GetRendererPrefs( WebPreferences BackgroundContents::GetWebkitPrefs() { // TODO(rafaelw): Consider enabling the webkit_prefs.dom_paste_enabled for // apps. - Profile* profile = Profile::FromBrowserContext( - render_view_host_->process()->browser_context()); + Profile* profile = render_view_host_->process()->profile(); return RenderViewHostDelegateHelper::GetWebkitPrefs(profile, false); // is_web_ui } @@ -195,13 +190,12 @@ WebPreferences BackgroundContents::GetWebkitPrefs() { void BackgroundContents::CreateNewWindow( int route_id, const ViewHostMsg_CreateWindow_Params& params) { - Profile* profile = Profile::FromBrowserContext( - render_view_host_->process()->browser_context()); delegate_view_helper_.CreateNewWindow( route_id, - profile, + render_view_host_->process()->profile(), render_view_host_->site_instance(), - ChromeWebUIFactory::GetInstance()->GetWebUIType(profile, url_), + ChromeWebUIFactory::GetInstance()->GetWebUIType( + render_view_host_->process()->profile(), url_), this, params.window_container_type, params.frame_name); diff --git a/chrome/browser/ui/cocoa/extensions/extension_popup_controller.mm b/chrome/browser/ui/cocoa/extensions/extension_popup_controller.mm index d5e22c3..85bee4f 100644 --- a/chrome/browser/ui/cocoa/extensions/extension_popup_controller.mm +++ b/chrome/browser/ui/cocoa/extensions/extension_popup_controller.mm @@ -133,7 +133,7 @@ class DevtoolsNotificationBridge : public NotificationObserver { registrar_.reset(new NotificationRegistrar); registrar_->Add(notificationBridge_.get(), content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING, - Source<content::BrowserContext>(host->profile())); + Source<Profile>(host->profile())); registrar_->Add(notificationBridge_.get(), chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, Source<Profile>(host->profile())); diff --git a/chrome/browser/ui/gtk/extensions/extension_popup_gtk.cc b/chrome/browser/ui/gtk/extensions/extension_popup_gtk.cc index 84393dd..ac258d7 100644 --- a/chrome/browser/ui/gtk/extensions/extension_popup_gtk.cc +++ b/chrome/browser/ui/gtk/extensions/extension_popup_gtk.cc @@ -100,7 +100,7 @@ void ExtensionPopupGtk::ShowPopup() { DevToolsWindow::OpenDevToolsWindow(host_->render_view_host()); // Listen for the the devtools window closing. registrar_.Add(this, content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING, - Source<content::BrowserContext>(host_->profile())); + Source<Profile>(host_->profile())); } // Only one instance should be showing at a time. Get rid of the old one, if diff --git a/chrome/browser/ui/views/extensions/extension_popup.cc b/chrome/browser/ui/views/extensions/extension_popup.cc index 4a2eec9..9d1a5ad 100644 --- a/chrome/browser/ui/views/extensions/extension_popup.cc +++ b/chrome/browser/ui/views/extensions/extension_popup.cc @@ -129,7 +129,7 @@ void ExtensionPopup::Observe(int type, if (inspect_with_devtools_) { // Listen for the the devtools window closing. registrar_.Add(this, content::NOTIFICATION_DEVTOOLS_WINDOW_CLOSING, - Source<content::BrowserContext>(extension_host_->profile())); + Source<Profile>(extension_host_->profile())); DevToolsWindow::ToggleDevToolsWindow( extension_host_->render_view_host(), DEVTOOLS_TOGGLE_ACTION_SHOW_CONSOLE); diff --git a/chrome/browser/visitedlink/visitedlink_event_listener.cc b/chrome/browser/visitedlink/visitedlink_event_listener.cc index 13461d4..cadfedb 100644 --- a/chrome/browser/visitedlink/visitedlink_event_listener.cc +++ b/chrome/browser/visitedlink/visitedlink_event_listener.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 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. @@ -122,8 +122,7 @@ void VisitedLinkEventListener::NewTable(base::SharedMemory* table_memory) { for (Updaters::iterator i = updaters_.begin(); i != updaters_.end(); ++i) { // Make sure to not send to incognito renderers. RenderProcessHost* process = RenderProcessHost::FromID(i->first); - Profile* profile = Profile::FromBrowserContext(process->browser_context()); - VisitedLinkMaster* master = profile->GetVisitedLinkMaster(); + VisitedLinkMaster* master = process->profile()->GetVisitedLinkMaster(); if (master && master->shared_memory() == table_memory) i->second->SendVisitedLinkTable(table_memory); } @@ -170,9 +169,7 @@ void VisitedLinkEventListener::Observe(int type, // Initialize support for visited links. Send the renderer process its // initial set of visited links. - Profile* profile = - Profile::FromBrowserContext(process->browser_context()); - VisitedLinkMaster* master = profile->GetVisitedLinkMaster(); + VisitedLinkMaster* master = process->profile()->GetVisitedLinkMaster(); if (!master) return; diff --git a/chrome/browser/visitedlink/visitedlink_unittest.cc b/chrome/browser/visitedlink/visitedlink_unittest.cc index 3af5113..86362a1 100644 --- a/chrome/browser/visitedlink/visitedlink_unittest.cc +++ b/chrome/browser/visitedlink/visitedlink_unittest.cc @@ -524,8 +524,7 @@ class VisitRelayingRenderProcessHost : public BrowserRenderProcessHost { virtual bool Send(IPC::Message* msg) { VisitCountingProfile* counting_profile = - static_cast<VisitCountingProfile*>( - Profile::FromBrowserContext(browser_context())); + static_cast<VisitCountingProfile*>(profile()); if (msg->type() == ViewMsg_VisitedLink_Add::ID) { void* iter = NULL; |