Revert 250826 "Remove Profile dependency from apps::ShellWindow"

Speculative revert for failures:

http://build.chromium.org/p/chromium.win/builders/Win7%20Sync%20x64/builds/11201

> Remove Profile dependency from apps::ShellWindow
> 
> Part of the effort to remove src/chrome dependencies from src/{apps, extensions}
> 
> BUG=341690
> TBR=tapted@chromium.org,stevenjb@chromium.org
> 
> Review URL: https://codereview.chromium.org/157813007

TBR=rockot@chromium.org

Review URL: https://codereview.chromium.org/163913004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251094 0039d316-1c4b-4281-b951-d872f2087c98
parent b33a4837
...@@ -82,8 +82,8 @@ void AppLifetimeMonitor::OnShellWindowAdded(ShellWindow* shell_window) { ...@@ -82,8 +82,8 @@ void AppLifetimeMonitor::OnShellWindowAdded(ShellWindow* shell_window) {
return; return;
ShellWindowRegistry::ShellWindowList windows = ShellWindowRegistry::ShellWindowList windows =
ShellWindowRegistry::Get(shell_window->browser_context()) ShellWindowRegistry::Get(shell_window->profile())->
->GetShellWindowsForApp(shell_window->extension_id()); GetShellWindowsForApp(shell_window->extension_id());
if (windows.size() == 1) if (windows.size() == 1)
NotifyAppActivated(shell_window->extension_id()); NotifyAppActivated(shell_window->extension_id());
} }
...@@ -92,8 +92,8 @@ void AppLifetimeMonitor::OnShellWindowIconChanged(ShellWindow* shell_window) {} ...@@ -92,8 +92,8 @@ void AppLifetimeMonitor::OnShellWindowIconChanged(ShellWindow* shell_window) {}
void AppLifetimeMonitor::OnShellWindowRemoved(ShellWindow* shell_window) { void AppLifetimeMonitor::OnShellWindowRemoved(ShellWindow* shell_window) {
ShellWindowRegistry::ShellWindowList windows = ShellWindowRegistry::ShellWindowList windows =
ShellWindowRegistry::Get(shell_window->browser_context()) ShellWindowRegistry::Get(shell_window->profile())->
->GetShellWindowsForApp(shell_window->extension_id()); GetShellWindowsForApp(shell_window->extension_id());
if (windows.empty()) if (windows.empty())
NotifyAppDeactivated(shell_window->extension_id()); NotifyAppDeactivated(shell_window->extension_id());
} }
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include "apps/app_shim/app_shim_launch.h" #include "apps/app_shim/app_shim_launch.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
class Profile;
namespace apps { namespace apps {
// Registrar, and interface for services that can handle interactions with OSX // Registrar, and interface for services that can handle interactions with OSX
......
...@@ -230,16 +230,14 @@ void ExtensionAppShimHandler::QuitAppForWindow(ShellWindow* shell_window) { ...@@ -230,16 +230,14 @@ void ExtensionAppShimHandler::QuitAppForWindow(ShellWindow* shell_window) {
ExtensionAppShimHandler* handler = ExtensionAppShimHandler* handler =
g_browser_process->platform_part()->app_shim_host_manager()-> g_browser_process->platform_part()->app_shim_host_manager()->
extension_app_shim_handler(); extension_app_shim_handler();
Host* host = handler->FindHost( Host* host = handler->FindHost(shell_window->profile(),
Profile::FromBrowserContext(shell_window->browser_context()), shell_window->extension_id());
shell_window->extension_id());
if (host) { if (host) {
handler->OnShimQuit(host); handler->OnShimQuit(host);
} else { } else {
// App shims might be disabled or the shim is still starting up. // App shims might be disabled or the shim is still starting up.
ShellWindowRegistry::Get( ShellWindowRegistry::Get(shell_window->profile())->
Profile::FromBrowserContext(shell_window->browser_context())) CloseAllShellWindowsForApp(shell_window->extension_id());
->CloseAllShellWindowsForApp(shell_window->extension_id());
} }
} }
...@@ -247,8 +245,7 @@ void ExtensionAppShimHandler::HideAppForWindow(ShellWindow* shell_window) { ...@@ -247,8 +245,7 @@ void ExtensionAppShimHandler::HideAppForWindow(ShellWindow* shell_window) {
ExtensionAppShimHandler* handler = ExtensionAppShimHandler* handler =
g_browser_process->platform_part()->app_shim_host_manager()-> g_browser_process->platform_part()->app_shim_host_manager()->
extension_app_shim_handler(); extension_app_shim_handler();
Profile* profile = Profile* profile = shell_window->profile();
Profile::FromBrowserContext(shell_window->browser_context());
Host* host = handler->FindHost(profile, shell_window->extension_id()); Host* host = handler->FindHost(profile, shell_window->extension_id());
if (host) if (host)
host->OnAppHide(); host->OnAppHide();
...@@ -261,8 +258,7 @@ void ExtensionAppShimHandler::FocusAppForWindow(ShellWindow* shell_window) { ...@@ -261,8 +258,7 @@ void ExtensionAppShimHandler::FocusAppForWindow(ShellWindow* shell_window) {
ExtensionAppShimHandler* handler = ExtensionAppShimHandler* handler =
g_browser_process->platform_part()->app_shim_host_manager()-> g_browser_process->platform_part()->app_shim_host_manager()->
extension_app_shim_handler(); extension_app_shim_handler();
Profile* profile = Profile* profile = shell_window->profile();
Profile::FromBrowserContext(shell_window->browser_context());
const std::string& app_id = shell_window->extension_id(); const std::string& app_id = shell_window->extension_id();
Host* host = handler->FindHost(profile, app_id); Host* host = handler->FindHost(profile, app_id);
if (host) { if (host) {
...@@ -281,8 +277,7 @@ bool ExtensionAppShimHandler::RequestUserAttentionForWindow( ...@@ -281,8 +277,7 @@ bool ExtensionAppShimHandler::RequestUserAttentionForWindow(
ExtensionAppShimHandler* handler = ExtensionAppShimHandler* handler =
g_browser_process->platform_part()->app_shim_host_manager()-> g_browser_process->platform_part()->app_shim_host_manager()->
extension_app_shim_handler(); extension_app_shim_handler();
Profile* profile = Profile* profile = shell_window->profile();
Profile::FromBrowserContext(shell_window->browser_context());
Host* host = handler->FindHost(profile, shell_window->extension_id()); Host* host = handler->FindHost(profile, shell_window->extension_id());
if (host) { if (host) {
// Bring the window to the front without showing it. // Bring the window to the front without showing it.
......
...@@ -6,9 +6,9 @@ ...@@ -6,9 +6,9 @@
#include "apps/ui/native_app_window.h" #include "apps/ui/native_app_window.h"
#include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/app_window.h" #include "chrome/common/extensions/api/app_window.h"
#include "chrome/common/extensions/extension_messages.h" #include "chrome/common/extensions/extension_messages.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
...@@ -28,16 +28,15 @@ AppWindowContents::AppWindowContents(ShellWindow* host) ...@@ -28,16 +28,15 @@ AppWindowContents::AppWindowContents(ShellWindow* host)
AppWindowContents::~AppWindowContents() { AppWindowContents::~AppWindowContents() {
} }
void AppWindowContents::Initialize(content::BrowserContext* context, void AppWindowContents::Initialize(Profile* profile, const GURL& url) {
const GURL& url) {
url_ = url; url_ = url;
extension_function_dispatcher_.reset( extension_function_dispatcher_.reset(
new ExtensionFunctionDispatcher(context, this)); new ExtensionFunctionDispatcher(profile, this));
web_contents_.reset( web_contents_.reset(content::WebContents::Create(
content::WebContents::Create(content::WebContents::CreateParams( content::WebContents::CreateParams(
context, content::SiteInstance::CreateForURL(context, url_)))); profile, content::SiteInstance::CreateForURL(profile, url_))));
content::WebContentsObserver::Observe(web_contents_.get()); content::WebContentsObserver::Observe(web_contents_.get());
web_contents_->GetMutableRendererPrefs()-> web_contents_->GetMutableRendererPrefs()->
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
class GURL; class GURL;
namespace content { namespace content {
class BrowserContext; class RenderViewHost;
} }
namespace extensions { namespace extensions {
...@@ -38,8 +38,7 @@ class AppWindowContents : public ShellWindowContents, ...@@ -38,8 +38,7 @@ class AppWindowContents : public ShellWindowContents,
virtual ~AppWindowContents(); virtual ~AppWindowContents();
// ShellWindowContents // ShellWindowContents
virtual void Initialize(content::BrowserContext* context, virtual void Initialize(Profile* profile, const GURL& url) OVERRIDE;
const GURL& url) OVERRIDE;
virtual void LoadContents(int32 creator_process_id) OVERRIDE; virtual void LoadContents(int32 creator_process_id) OVERRIDE;
virtual void NativeWindowChanged(NativeAppWindow* native_app_window) OVERRIDE; virtual void NativeWindowChanged(NativeAppWindow* native_app_window) OVERRIDE;
virtual void NativeWindowClosed() OVERRIDE; virtual void NativeWindowClosed() OVERRIDE;
......
...@@ -82,10 +82,6 @@ BrowserContext* ShellExtensionsBrowserClient::GetOriginalContext( ...@@ -82,10 +82,6 @@ BrowserContext* ShellExtensionsBrowserClient::GetOriginalContext(
return context; return context;
} }
bool ShellExtensionsBrowserClient::IsGuestSession(BrowserContext* context) {
return false;
}
bool ShellExtensionsBrowserClient::IsExtensionIncognitoEnabled( bool ShellExtensionsBrowserClient::IsExtensionIncognitoEnabled(
const std::string& extension_id, const std::string& extension_id,
content::BrowserContext* context) const { content::BrowserContext* context) const {
......
...@@ -33,7 +33,6 @@ class ShellExtensionsBrowserClient : public ExtensionsBrowserClient { ...@@ -33,7 +33,6 @@ class ShellExtensionsBrowserClient : public ExtensionsBrowserClient {
content::BrowserContext* context) OVERRIDE; content::BrowserContext* context) OVERRIDE;
virtual content::BrowserContext* GetOriginalContext( virtual content::BrowserContext* GetOriginalContext(
content::BrowserContext* context) OVERRIDE; content::BrowserContext* context) OVERRIDE;
virtual bool IsGuestSession(content::BrowserContext* context) OVERRIDE;
virtual bool IsExtensionIncognitoEnabled( virtual bool IsExtensionIncognitoEnabled(
const std::string& extension_id, const std::string& extension_id,
content::BrowserContext* context) const OVERRIDE; content::BrowserContext* context) const OVERRIDE;
......
...@@ -15,11 +15,11 @@ ...@@ -15,11 +15,11 @@
#include "chrome/browser/extensions/extension_web_contents_observer.h" #include "chrome/browser/extensions/extension_web_contents_observer.h"
#include "chrome/browser/extensions/suggest_permission_util.h" #include "chrome/browser/extensions/suggest_permission_util.h"
#include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_messages.h" #include "chrome/common/extensions/extension_messages.h"
#include "chrome/common/extensions/manifest_handlers/icons_handler.h" #include "chrome/common/extensions/manifest_handlers/icons_handler.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h" #include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/invalidate_type.h" #include "content/public/browser/invalidate_type.h"
#include "content/public/browser/navigation_entry.h" #include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_details.h" #include "content/public/browser/notification_details.h"
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include "content/public/browser/web_contents_view.h" #include "content/public/browser/web_contents_view.h"
#include "content/public/common/media_stream_request.h" #include "content/public/common/media_stream_request.h"
#include "extensions/browser/extension_system.h" #include "extensions/browser/extension_system.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/process_manager.h" #include "extensions/browser/process_manager.h"
#include "extensions/browser/view_type_utils.h" #include "extensions/browser/view_type_utils.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
...@@ -44,7 +43,6 @@ ...@@ -44,7 +43,6 @@
#include "base/prefs/pref_service.h" #include "base/prefs/pref_service.h"
#endif #endif
using content::BrowserContext;
using content::ConsoleMessageLevel; using content::ConsoleMessageLevel;
using content::WebContents; using content::WebContents;
using extensions::APIPermission; using extensions::APIPermission;
...@@ -139,10 +137,10 @@ ShellWindow::CreateParams::~CreateParams() {} ...@@ -139,10 +137,10 @@ ShellWindow::CreateParams::~CreateParams() {}
ShellWindow::Delegate::~Delegate() {} ShellWindow::Delegate::~Delegate() {}
ShellWindow::ShellWindow(BrowserContext* context, ShellWindow::ShellWindow(Profile* profile,
Delegate* delegate, Delegate* delegate,
const extensions::Extension* extension) const extensions::Extension* extension)
: browser_context_(context), : profile_(profile),
extension_(extension), extension_(extension),
extension_id_(extension->id()), extension_id_(extension->id()),
window_type_(WINDOW_TYPE_DEFAULT), window_type_(WINDOW_TYPE_DEFAULT),
...@@ -152,9 +150,7 @@ ShellWindow::ShellWindow(BrowserContext* context, ...@@ -152,9 +150,7 @@ ShellWindow::ShellWindow(BrowserContext* context,
show_on_first_paint_(false), show_on_first_paint_(false),
first_paint_complete_(false), first_paint_complete_(false),
cached_always_on_top_(false) { cached_always_on_top_(false) {
extensions::ExtensionsBrowserClient* client = CHECK(!profile->IsGuestSession() || profile->IsOffTheRecord())
extensions::ExtensionsBrowserClient::Get();
CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord())
<< "Only off the record window may be opened in the guest mode."; << "Only off the record window may be opened in the guest mode.";
} }
...@@ -163,7 +159,7 @@ void ShellWindow::Init(const GURL& url, ...@@ -163,7 +159,7 @@ void ShellWindow::Init(const GURL& url,
const CreateParams& params) { const CreateParams& params) {
// Initialize the render interface and web contents // Initialize the render interface and web contents
shell_window_contents_.reset(shell_window_contents); shell_window_contents_.reset(shell_window_contents);
shell_window_contents_->Initialize(browser_context(), url); shell_window_contents_->Initialize(profile(), url);
WebContents* web_contents = shell_window_contents_->GetWebContents(); WebContents* web_contents = shell_window_contents_->GetWebContents();
if (CommandLine::ForCurrentProcess()->HasSwitch( if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableAppsShowOnFirstPaint)) { switches::kEnableAppsShowOnFirstPaint)) {
...@@ -211,12 +207,8 @@ void ShellWindow::Init(const GURL& url, ...@@ -211,12 +207,8 @@ void ShellWindow::Init(const GURL& url,
// about it in case it has any setup to do to make the renderer appear // about it in case it has any setup to do to make the renderer appear
// properly. In particular, on Windows, the view's clickthrough region needs // properly. In particular, on Windows, the view's clickthrough region needs
// to be set. // to be set.
extensions::ExtensionsBrowserClient* client = registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
extensions::ExtensionsBrowserClient::Get(); content::Source<Profile>(profile_->GetOriginalProfile()));
registrar_.Add(this,
chrome::NOTIFICATION_EXTENSION_UNLOADED,
content::Source<content::BrowserContext>(
client->GetOriginalContext(browser_context_)));
// Close when the browser process is exiting. // Close when the browser process is exiting.
registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING,
content::NotificationService::AllSources()); content::NotificationService::AllSources());
...@@ -237,7 +229,7 @@ void ShellWindow::Init(const GURL& url, ...@@ -237,7 +229,7 @@ void ShellWindow::Init(const GURL& url,
UpdateExtensionAppIcon(); UpdateExtensionAppIcon();
ShellWindowRegistry::Get(browser_context_)->AddShellWindow(this); ShellWindowRegistry::Get(profile_)->AddShellWindow(this);
} }
ShellWindow::~ShellWindow() { ShellWindow::~ShellWindow() {
...@@ -280,8 +272,8 @@ WebContents* ShellWindow::OpenURLFromTab(WebContents* source, ...@@ -280,8 +272,8 @@ WebContents* ShellWindow::OpenURLFromTab(WebContents* source,
return NULL; return NULL;
} }
WebContents* contents = WebContents* contents = delegate_->OpenURLFromTab(profile_, source,
delegate_->OpenURLFromTab(browser_context_, source, params); params);
if (!contents) { if (!contents) {
AddMessageToDevToolsConsole( AddMessageToDevToolsConsole(
content::CONSOLE_MESSAGE_LEVEL_ERROR, content::CONSOLE_MESSAGE_LEVEL_ERROR,
...@@ -299,13 +291,10 @@ void ShellWindow::AddNewContents(WebContents* source, ...@@ -299,13 +291,10 @@ void ShellWindow::AddNewContents(WebContents* source,
const gfx::Rect& initial_pos, const gfx::Rect& initial_pos,
bool user_gesture, bool user_gesture,
bool* was_blocked) { bool* was_blocked) {
DCHECK(new_contents->GetBrowserContext() == browser_context_); DCHECK(Profile::FromBrowserContext(new_contents->GetBrowserContext()) ==
delegate_->AddNewContents(browser_context_, profile_);
new_contents, delegate_->AddNewContents(profile_, new_contents, disposition,
disposition, initial_pos, user_gesture, was_blocked);
initial_pos,
user_gesture,
was_blocked);
} }
bool ShellWindow::PreHandleKeyboardEvent( bool ShellWindow::PreHandleKeyboardEvent(
...@@ -377,7 +366,7 @@ void ShellWindow::DidFirstVisuallyNonEmptyPaint(int32 page_id) { ...@@ -377,7 +366,7 @@ void ShellWindow::DidFirstVisuallyNonEmptyPaint(int32 page_id) {
} }
void ShellWindow::OnNativeClose() { void ShellWindow::OnNativeClose() {
ShellWindowRegistry::Get(browser_context_)->RemoveShellWindow(this); ShellWindowRegistry::Get(profile_)->RemoveShellWindow(this);
if (shell_window_contents_) { if (shell_window_contents_) {
WebContents* web_contents = shell_window_contents_->GetWebContents(); WebContents* web_contents = shell_window_contents_->GetWebContents();
WebContentsModalDialogManager::FromWebContents(web_contents)-> WebContentsModalDialogManager::FromWebContents(web_contents)->
...@@ -405,7 +394,7 @@ void ShellWindow::OnNativeWindowChanged() { ...@@ -405,7 +394,7 @@ void ShellWindow::OnNativeWindowChanged() {
} }
void ShellWindow::OnNativeWindowActivated() { void ShellWindow::OnNativeWindowActivated() {
ShellWindowRegistry::Get(browser_context_)->ShellWindowActivated(this); ShellWindowRegistry::Get(profile_)->ShellWindowActivated(this);
} }
content::WebContents* ShellWindow::web_contents() const { content::WebContents* ShellWindow::web_contents() const {
...@@ -499,16 +488,13 @@ void ShellWindow::UpdateAppIcon(const gfx::Image& image) { ...@@ -499,16 +488,13 @@ void ShellWindow::UpdateAppIcon(const gfx::Image& image) {
return; return;
app_icon_ = image; app_icon_ = image;
native_app_window_->UpdateWindowIcon(); native_app_window_->UpdateWindowIcon();
ShellWindowRegistry::Get(browser_context_)->ShellWindowIconChanged(this); ShellWindowRegistry::Get(profile_)->ShellWindowIconChanged(this);
} }
void ShellWindow::Fullscreen() { void ShellWindow::Fullscreen() {
#if !defined(OS_MACOSX) #if !defined(OS_MACOSX)
// Do not enter fullscreen mode if disallowed by pref. // Do not enter fullscreen mode if disallowed by pref.
PrefService* prefs = if (!profile()->GetPrefs()->GetBoolean(prefs::kAppFullscreenAllowed))
extensions::ExtensionsBrowserClient::Get()->GetPrefServiceForContext(
browser_context());
if (!prefs->GetBoolean(prefs::kAppFullscreenAllowed))
return; return;
#endif #endif
fullscreen_types_ |= FULLSCREEN_TYPE_WINDOW_API; fullscreen_types_ |= FULLSCREEN_TYPE_WINDOW_API;
...@@ -535,10 +521,7 @@ void ShellWindow::Restore() { ...@@ -535,10 +521,7 @@ void ShellWindow::Restore() {
void ShellWindow::OSFullscreen() { void ShellWindow::OSFullscreen() {
#if !defined(OS_MACOSX) #if !defined(OS_MACOSX)
// Do not enter fullscreen mode if disallowed by pref. // Do not enter fullscreen mode if disallowed by pref.
PrefService* prefs = if (!profile()->GetPrefs()->GetBoolean(prefs::kAppFullscreenAllowed))
extensions::ExtensionsBrowserClient::Get()->GetPrefServiceForContext(
browser_context());
if (!prefs->GetBoolean(prefs::kAppFullscreenAllowed))
return; return;
#endif #endif
fullscreen_types_ |= FULLSCREEN_TYPE_OS; fullscreen_types_ |= FULLSCREEN_TYPE_OS;
...@@ -684,13 +667,13 @@ void ShellWindow::UpdateExtensionAppIcon() { ...@@ -684,13 +667,13 @@ void ShellWindow::UpdateExtensionAppIcon() {
// Avoid using any previous app icons were being downloaded. // Avoid using any previous app icons were being downloaded.
image_loader_ptr_factory_.InvalidateWeakPtrs(); image_loader_ptr_factory_.InvalidateWeakPtrs();
app_icon_image_.reset( app_icon_image_.reset(new extensions::IconImage(
new extensions::IconImage(browser_context(), profile(),
extension(), extension(),
extensions::IconsInfo::GetIcons(extension()), extensions::IconsInfo::GetIcons(extension()),
delegate_->PreferredIconSize(), delegate_->PreferredIconSize(),
extensions::IconsInfo::GetDefaultAppIcon(), extensions::IconsInfo::GetDefaultAppIcon(),
this)); this));
// Triggers actual image loading with 1x resources. The 2x resource will // Triggers actual image loading with 1x resources. The 2x resource will
// be handled by IconImage class when requested. // be handled by IconImage class when requested.
...@@ -803,10 +786,8 @@ void ShellWindow::ToggleFullscreenModeForTab(content::WebContents* source, ...@@ -803,10 +786,8 @@ void ShellWindow::ToggleFullscreenModeForTab(content::WebContents* source,
// Do not enter fullscreen mode if disallowed by pref. // Do not enter fullscreen mode if disallowed by pref.
// TODO(bartfab): Add a test once it becomes possible to simulate a user // TODO(bartfab): Add a test once it becomes possible to simulate a user
// gesture. http://crbug.com/174178 // gesture. http://crbug.com/174178
PrefService* prefs = if (enter_fullscreen &&
extensions::ExtensionsBrowserClient::Get()->GetPrefServiceForContext( !profile()->GetPrefs()->GetBoolean(prefs::kAppFullscreenAllowed)) {
browser_context());
if (enter_fullscreen && !prefs->GetBoolean(prefs::kAppFullscreenAllowed)) {
return; return;
} }
#endif #endif
...@@ -882,8 +863,7 @@ void ShellWindow::SaveWindowPosition() { ...@@ -882,8 +863,7 @@ void ShellWindow::SaveWindowPosition() {
if (!native_app_window_) if (!native_app_window_)
return; return;
ShellWindowGeometryCache* cache = ShellWindowGeometryCache* cache = ShellWindowGeometryCache::Get(profile());
ShellWindowGeometryCache::Get(browser_context());
gfx::Rect bounds = native_app_window_->GetRestoredBounds(); gfx::Rect bounds = native_app_window_->GetRestoredBounds();
bounds.Inset(native_app_window_->GetFrameInsets()); bounds.Inset(native_app_window_->GetFrameInsets());
...@@ -939,8 +919,7 @@ ShellWindow::CreateParams ShellWindow::LoadDefaultsAndConstrain( ...@@ -939,8 +919,7 @@ ShellWindow::CreateParams ShellWindow::LoadDefaultsAndConstrain(
// Load cached state if it exists. // Load cached state if it exists.
if (!params.window_key.empty()) { if (!params.window_key.empty()) {
ShellWindowGeometryCache* cache = ShellWindowGeometryCache* cache = ShellWindowGeometryCache::Get(profile());
ShellWindowGeometryCache::Get(browser_context());
gfx::Rect cached_bounds; gfx::Rect cached_bounds;
gfx::Rect cached_screen_bounds; gfx::Rect cached_screen_bounds;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
class GURL; class GURL;
class Profile;
class SkRegion; class SkRegion;
namespace base { namespace base {
...@@ -28,7 +29,6 @@ class DictionaryValue; ...@@ -28,7 +29,6 @@ class DictionaryValue;
} }
namespace content { namespace content {
class BrowserContext;
class WebContents; class WebContents;
} }
...@@ -58,8 +58,7 @@ class ShellWindowContents { ...@@ -58,8 +58,7 @@ class ShellWindowContents {
virtual ~ShellWindowContents() {} virtual ~ShellWindowContents() {}
// Called to initialize the WebContents, before the app window is created. // Called to initialize the WebContents, before the app window is created.
virtual void Initialize(content::BrowserContext* context, virtual void Initialize(Profile* profile, const GURL& url) = 0;
const GURL& url) = 0;
// Called to load the contents, after the app window is created. // Called to load the contents, after the app window is created.
virtual void LoadContents(int32 creator_process_id) = 0; virtual void LoadContents(int32 creator_process_id) = 0;
...@@ -202,10 +201,10 @@ class ShellWindow : public content::NotificationObserver, ...@@ -202,10 +201,10 @@ class ShellWindow : public content::NotificationObserver,
// Link handling. // Link handling.
virtual content::WebContents* OpenURLFromTab( virtual content::WebContents* OpenURLFromTab(
content::BrowserContext* context, Profile* profile,
content::WebContents* source, content::WebContents* source,
const content::OpenURLParams& params) = 0; const content::OpenURLParams& params) = 0;
virtual void AddNewContents(content::BrowserContext* context, virtual void AddNewContents(Profile* profile,
content::WebContents* new_contents, content::WebContents* new_contents,
WindowOpenDisposition disposition, WindowOpenDisposition disposition,
const gfx::Rect& initial_pos, const gfx::Rect& initial_pos,
...@@ -240,7 +239,7 @@ class ShellWindow : public content::NotificationObserver, ...@@ -240,7 +239,7 @@ class ShellWindow : public content::NotificationObserver,
// with a non-standard render interface (e.g. v1 apps using Ash Panels). // with a non-standard render interface (e.g. v1 apps using Ash Panels).
// Normally ShellWindow::Create should be used. // Normally ShellWindow::Create should be used.
// The constructed shell window takes ownership of |delegate|. // The constructed shell window takes ownership of |delegate|.
ShellWindow(content::BrowserContext* context, ShellWindow(Profile* profile,
Delegate* delegate, Delegate* delegate,
const extensions::Extension* extension); const extensions::Extension* extension);
...@@ -261,7 +260,7 @@ class ShellWindow : public content::NotificationObserver, ...@@ -261,7 +260,7 @@ class ShellWindow : public content::NotificationObserver,
return (window_type_ == WINDOW_TYPE_PANEL || return (window_type_ == WINDOW_TYPE_PANEL ||
window_type_ == WINDOW_TYPE_V1_PANEL); window_type_ == WINDOW_TYPE_V1_PANEL);
} }
content::BrowserContext* browser_context() const { return browser_context_; } Profile* profile() const { return profile_; }
const gfx::Image& app_icon() const { return app_icon_; } const gfx::Image& app_icon() const { return app_icon_; }
const GURL& app_icon_url() const { return app_icon_url_; } const GURL& app_icon_url() const { return app_icon_url_; }
const gfx::Image& badge_icon() const { return badge_icon_; } const gfx::Image& badge_icon() const { return badge_icon_; }
...@@ -489,10 +488,7 @@ class ShellWindow : public content::NotificationObserver, ...@@ -489,10 +488,7 @@ class ShellWindow : public content::NotificationObserver,
virtual void OnExtensionIconImageChanged( virtual void OnExtensionIconImageChanged(
extensions::IconImage* image) OVERRIDE; extensions::IconImage* image) OVERRIDE;
// The browser context with which this window is associated. ShellWindow does Profile* profile_; // weak pointer - owned by ProfileManager.
// not own this object.
content::BrowserContext* browser_context_;
// weak pointer - owned by ExtensionService. // weak pointer - owned by ExtensionService.
const extensions::Extension* extension_; const extensions::Extension* extension_;
const std::string extension_id_; const std::string extension_id_;
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "chrome/browser/app_mode/app_mode_utils.h" #include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/devtools/devtools_window.h" #include "chrome/browser/devtools/devtools_window.h"
#include "chrome/browser/extensions/window_controller.h" #include "chrome/browser/extensions/window_controller.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/apps/chrome_shell_window_delegate.h" #include "chrome/browser/ui/apps/chrome_shell_window_delegate.h"
#include "chrome/common/extensions/api/app_window.h" #include "chrome/common/extensions/api/app_window.h"
#include "chrome/common/extensions/features/feature_channel.h" #include "chrome/common/extensions/features/feature_channel.h"
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sessions/session_tab_helper.h" #include "chrome/browser/sessions/session_tab_helper.h"
#include "chrome/common/extensions/extension_messages.h" #include "chrome/common/extensions/extension_messages.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/site_instance.h" #include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
...@@ -168,16 +167,15 @@ AshPanelContents::AshPanelContents(ShellWindow* host) ...@@ -168,16 +167,15 @@ AshPanelContents::AshPanelContents(ShellWindow* host)
AshPanelContents::~AshPanelContents() { AshPanelContents::~AshPanelContents() {
} }
void AshPanelContents::Initialize(content::BrowserContext* context, void AshPanelContents::Initialize(Profile* profile, const GURL& url) {
const GURL& url) {
url_ = url; url_ = url;
extension_function_dispatcher_.reset( extension_function_dispatcher_.reset(
new ExtensionFunctionDispatcher(context, this)); new ExtensionFunctionDispatcher(profile, this));
web_contents_.reset( web_contents_.reset(content::WebContents::Create(
content::WebContents::Create(content::WebContents::CreateParams( content::WebContents::CreateParams(
context, content::SiteInstance::CreateForURL(context, url_)))); profile, content::SiteInstance::CreateForURL(profile, url_))));
// Needed to give the web contents a Window ID. Extension APIs expect web // Needed to give the web contents a Window ID. Extension APIs expect web
// contents to have a Window ID. Also required for FaviconTabHelper to // contents to have a Window ID. Also required for FaviconTabHelper to
...@@ -197,8 +195,8 @@ void AshPanelContents::Initialize(content::BrowserContext* context, ...@@ -197,8 +195,8 @@ void AshPanelContents::Initialize(content::BrowserContext* context,
void AshPanelContents::LoadContents(int32 creator_process_id) { void AshPanelContents::LoadContents(int32 creator_process_id) {
// This must be created after the native window has been created. // This must be created after the native window has been created.
window_controller_.reset(new AshPanelWindowController( window_controller_.reset(
host_, Profile::FromBrowserContext(host_->browser_context()))); new AshPanelWindowController(host_, host_->profile()));
web_contents_->GetController().LoadURL( web_contents_->GetController().LoadURL(
url_, content::Referrer(), content::PAGE_TRANSITION_LINK, url_, content::Referrer(), content::PAGE_TRANSITION_LINK,
......
...@@ -39,8 +39,7 @@ class AshPanelContents : public apps::ShellWindowContents, ...@@ -39,8 +39,7 @@ class AshPanelContents : public apps::ShellWindowContents,
virtual ~AshPanelContents(); virtual ~AshPanelContents();
// apps::ShellWindowContents // apps::ShellWindowContents
virtual void Initialize(content::BrowserContext* context, virtual void Initialize(Profile* profile, const GURL& url) OVERRIDE;
const GURL& url) OVERRIDE;
virtual void LoadContents(int32 creator_process_id) OVERRIDE; virtual void LoadContents(int32 creator_process_id) OVERRIDE;
virtual void NativeWindowChanged(apps::NativeAppWindow* native_app_window) virtual void NativeWindowChanged(apps::NativeAppWindow* native_app_window)
OVERRIDE; OVERRIDE;
......
...@@ -81,11 +81,6 @@ content::BrowserContext* ChromeExtensionsBrowserClient::GetOriginalContext( ...@@ -81,11 +81,6 @@ content::BrowserContext* ChromeExtensionsBrowserClient::GetOriginalContext(
return static_cast<Profile*>(context)->GetOriginalProfile(); return static_cast<Profile*>(context)->GetOriginalProfile();
} }
bool ChromeExtensionsBrowserClient::IsGuestSession(
content::BrowserContext* context) {
return static_cast<Profile*>(context)->IsGuestSession();
}
bool ChromeExtensionsBrowserClient::IsExtensionIncognitoEnabled( bool ChromeExtensionsBrowserClient::IsExtensionIncognitoEnabled(
const std::string& extension_id, const std::string& extension_id,
content::BrowserContext* context) const { content::BrowserContext* context) const {
......
...@@ -44,7 +44,6 @@ class ChromeExtensionsBrowserClient : public ExtensionsBrowserClient { ...@@ -44,7 +44,6 @@ class ChromeExtensionsBrowserClient : public ExtensionsBrowserClient {
content::BrowserContext* context) OVERRIDE; content::BrowserContext* context) OVERRIDE;
virtual content::BrowserContext* GetOriginalContext( virtual content::BrowserContext* GetOriginalContext(
content::BrowserContext* context) OVERRIDE; content::BrowserContext* context) OVERRIDE;
virtual bool IsGuestSession(content::BrowserContext* context) OVERRIDE;
virtual bool IsExtensionIncognitoEnabled( virtual bool IsExtensionIncognitoEnabled(
const std::string& extension_id, const std::string& extension_id,
content::BrowserContext* context) const OVERRIDE; content::BrowserContext* context) const OVERRIDE;
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "chrome/browser/file_select_helper.h" #include "chrome/browser/file_select_helper.h"
#include "chrome/browser/media/media_capture_devices_dispatcher.h" #include "chrome/browser/media/media_capture_devices_dispatcher.h"
#include "chrome/browser/platform_util.h" #include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/shell_integration.h" #include "chrome/browser/shell_integration.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h" #include "chrome/browser/ui/browser_dialogs.h"
...@@ -17,7 +16,6 @@ ...@@ -17,7 +16,6 @@
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
#include "chrome/common/render_messages.h" #include "chrome/common/render_messages.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h" #include "content/public/browser/web_contents_view.h"
...@@ -41,7 +39,7 @@ bool disable_external_open_for_testing_ = false; ...@@ -41,7 +39,7 @@ bool disable_external_open_for_testing_ = false;
// Opens a URL with Chromium (not external browser) with the right profile. // Opens a URL with Chromium (not external browser) with the right profile.
content::WebContents* OpenURLFromTabInternal( content::WebContents* OpenURLFromTabInternal(
content::BrowserContext* context, Profile* profile,
content::WebContents* source, content::WebContents* source,
const content::OpenURLParams& params) { const content::OpenURLParams& params) {
// Force all links to open in a new tab, even if they were trying to open a // Force all links to open in a new tab, even if they were trying to open a
...@@ -51,7 +49,7 @@ content::WebContents* OpenURLFromTabInternal( ...@@ -51,7 +49,7 @@ content::WebContents* OpenURLFromTabInternal(
new_tab_params.disposition = params.disposition == NEW_BACKGROUND_TAB new_tab_params.disposition = params.disposition == NEW_BACKGROUND_TAB
? params.disposition ? params.disposition
: NEW_FOREGROUND_TAB; : NEW_FOREGROUND_TAB;
new_tab_params.initiating_profile = Profile::FromBrowserContext(context); new_tab_params.initiating_profile = profile;
chrome::Navigate(&new_tab_params); chrome::Navigate(&new_tab_params);
return new_tab_params.target_contents; return new_tab_params.target_contents;
...@@ -150,14 +148,14 @@ apps::NativeAppWindow* ChromeShellWindowDelegate::CreateNativeAppWindow( ...@@ -150,14 +148,14 @@ apps::NativeAppWindow* ChromeShellWindowDelegate::CreateNativeAppWindow(
} }
content::WebContents* ChromeShellWindowDelegate::OpenURLFromTab( content::WebContents* ChromeShellWindowDelegate::OpenURLFromTab(
content::BrowserContext* context, Profile* profile,
content::WebContents* source, content::WebContents* source,
const content::OpenURLParams& params) { const content::OpenURLParams& params) {
return OpenURLFromTabInternal(context, source, params); return OpenURLFromTabInternal(profile, source, params);
} }
void ChromeShellWindowDelegate::AddNewContents( void ChromeShellWindowDelegate::AddNewContents(
content::BrowserContext* context, Profile* profile,
content::WebContents* new_contents, content::WebContents* new_contents,
WindowOpenDisposition disposition, WindowOpenDisposition disposition,
const gfx::Rect& initial_pos, const gfx::Rect& initial_pos,
...@@ -170,7 +168,7 @@ void ChromeShellWindowDelegate::AddNewContents( ...@@ -170,7 +168,7 @@ void ChromeShellWindowDelegate::AddNewContents(
return; return;
} }
chrome::ScopedTabbedBrowserDisplayer displayer( chrome::ScopedTabbedBrowserDisplayer displayer(
Profile::FromBrowserContext(context), chrome::GetActiveDesktop()); profile, chrome::GetActiveDesktop());
// Force all links to open in a new tab, even if they were trying to open a // Force all links to open in a new tab, even if they were trying to open a
// new window. // new window.
disposition = disposition =
......
...@@ -7,15 +7,12 @@ ...@@ -7,15 +7,12 @@
#include "apps/shell_window.h" #include "apps/shell_window.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h" #include "content/public/browser/web_contents_delegate.h"
#include "ui/base/window_open_disposition.h" #include "ui/base/window_open_disposition.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
namespace content {
class BrowserContext;
}
class ShellWindowLinkDelegate : public content::WebContentsDelegate { class ShellWindowLinkDelegate : public content::WebContentsDelegate {
public: public:
ShellWindowLinkDelegate(); ShellWindowLinkDelegate();
...@@ -43,10 +40,10 @@ class ChromeShellWindowDelegate : public apps::ShellWindow::Delegate { ...@@ -43,10 +40,10 @@ class ChromeShellWindowDelegate : public apps::ShellWindow::Delegate {
apps::ShellWindow* window, apps::ShellWindow* window,
const apps::ShellWindow::CreateParams& params) OVERRIDE; const apps::ShellWindow::CreateParams& params) OVERRIDE;
virtual content::WebContents* OpenURLFromTab( virtual content::WebContents* OpenURLFromTab(
content::BrowserContext* context, Profile* profile,
content::WebContents* source, content::WebContents* source,
const content::OpenURLParams& params) OVERRIDE; const content::OpenURLParams& params) OVERRIDE;
virtual void AddNewContents(content::BrowserContext* context, virtual void AddNewContents(Profile* profile,
content::WebContents* new_contents, content::WebContents* new_contents,
WindowOpenDisposition disposition, WindowOpenDisposition disposition,
const gfx::Rect& initial_pos, const gfx::Rect& initial_pos,
......
...@@ -43,18 +43,14 @@ void MultiProfileShellWindowLauncherController::ActiveUserChanged( ...@@ -43,18 +43,14 @@ void MultiProfileShellWindowLauncherController::ActiveUserChanged(
for (ShellWindowList::iterator it = shell_window_list_.begin(); for (ShellWindowList::iterator it = shell_window_list_.begin();
it != shell_window_list_.end(); ++it) { it != shell_window_list_.end(); ++it) {
apps::ShellWindow* shell_window = *it; apps::ShellWindow* shell_window = *it;
Profile* profile = if (!multi_user_util::IsProfileFromActiveUser(shell_window->profile()) &&
Profile::FromBrowserContext(shell_window->browser_context());
if (!multi_user_util::IsProfileFromActiveUser(profile) &&
IsRegisteredApp(shell_window->GetNativeWindow())) IsRegisteredApp(shell_window->GetNativeWindow()))
UnregisterApp(shell_window->GetNativeWindow()); UnregisterApp(shell_window->GetNativeWindow());
} }
for (ShellWindowList::iterator it = shell_window_list_.begin(); for (ShellWindowList::iterator it = shell_window_list_.begin();
it != shell_window_list_.end(); ++it) { it != shell_window_list_.end(); ++it) {
apps::ShellWindow* shell_window = *it; apps::ShellWindow* shell_window = *it;
Profile* profile = if (multi_user_util::IsProfileFromActiveUser(shell_window->profile()) &&
Profile::FromBrowserContext(shell_window->browser_context());
if (multi_user_util::IsProfileFromActiveUser(profile) &&
!IsRegisteredApp(shell_window->GetNativeWindow())) !IsRegisteredApp(shell_window->GetNativeWindow()))
RegisterApp(*it); RegisterApp(*it);
} }
...@@ -73,9 +69,7 @@ void MultiProfileShellWindowLauncherController::OnShellWindowAdded( ...@@ -73,9 +69,7 @@ void MultiProfileShellWindowLauncherController::OnShellWindowAdded(
if (!ControlsWindow(shell_window->GetNativeWindow())) if (!ControlsWindow(shell_window->GetNativeWindow()))
return; return;
shell_window_list_.push_back(shell_window); shell_window_list_.push_back(shell_window);
Profile* profile = if (multi_user_util::IsProfileFromActiveUser(shell_window->profile()))
Profile::FromBrowserContext(shell_window->browser_context());
if (multi_user_util::IsProfileFromActiveUser(profile))
RegisterApp(shell_window); RegisterApp(shell_window);
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
class ExtensionKeybindingRegistryCocoa; class ExtensionKeybindingRegistryCocoa;
class Profile;
class NativeAppWindowCocoa; class NativeAppWindowCocoa;
@class ShellNSWindow; @class ShellNSWindow;
class SkRegion; class SkRegion;
......
...@@ -365,7 +365,7 @@ NativeAppWindowCocoa::NativeAppWindowCocoa( ...@@ -365,7 +365,7 @@ NativeAppWindowCocoa::NativeAppWindowCocoa(
UpdateWindowMinMaxSize(); UpdateWindowMinMaxSize();
extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryCocoa( extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryCocoa(
Profile::FromBrowserContext(shell_window_->browser_context()), shell_window_->profile(),
window, window,
extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY,
shell_window)); shell_window));
......
...@@ -30,11 +30,8 @@ class NativeAppWindowCocoaBrowserTest : public PlatformAppBrowserTest { ...@@ -30,11 +30,8 @@ class NativeAppWindowCocoaBrowserTest : public PlatformAppBrowserTest {
content::WindowedNotificationObserver app_loaded_observer( content::WindowedNotificationObserver app_loaded_observer(
content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
content::NotificationService::AllSources()); content::NotificationService::AllSources());
OpenApplication( OpenApplication(AppLaunchParams(
AppLaunchParams(profile(), profile(), app_, extensions::LAUNCH_CONTAINER_NONE, NEW_WINDOW));
app_,
extensions::LAUNCH_CONTAINER_NONE,
NEW_WINDOW));
app_loaded_observer.Wait(); app_loaded_observer.Wait();
} }
} }
......
...@@ -146,7 +146,7 @@ NativeAppWindowGtk::NativeAppWindowGtk(ShellWindow* shell_window, ...@@ -146,7 +146,7 @@ NativeAppWindowGtk::NativeAppWindowGtk(ShellWindow* shell_window,
// Add the keybinding registry. // Add the keybinding registry.
extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryGtk( extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryGtk(
Profile::FromBrowserContext(shell_window_->browser_context()), shell_window_->profile(),
window_, window_,
extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY,
shell_window_)); shell_window_));
...@@ -624,8 +624,7 @@ bool NativeAppWindowGtk::IsDetached() const { ...@@ -624,8 +624,7 @@ bool NativeAppWindowGtk::IsDetached() const {
} }
void NativeAppWindowGtk::UpdateWindowIcon() { void NativeAppWindowGtk::UpdateWindowIcon() {
Profile* profile = Profile* profile = shell_window_->profile();
Profile::FromBrowserContext(shell_window_->browser_context());
gfx::Image app_icon = shell_window_->app_icon(); gfx::Image app_icon = shell_window_->app_icon();
if (!app_icon.IsEmpty()) if (!app_icon.IsEmpty())
gtk_util::SetWindowIcon(window_, profile, app_icon.ToGdkPixbuf()); gtk_util::SetWindowIcon(window_, profile, app_icon.ToGdkPixbuf());
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "ui/gfx/x/x11_atom_cache.h" #include "ui/gfx/x/x11_atom_cache.h"
class ExtensionKeybindingRegistryGtk; class ExtensionKeybindingRegistryGtk;
class Profile;
namespace extensions { namespace extensions {
class Extension; class Extension;
......
...@@ -266,11 +266,12 @@ void NativeAppWindowViews::Init( ...@@ -266,11 +266,12 @@ void NativeAppWindowViews::Init(
} else { } else {
InitializeDefaultWindow(create_params); InitializeDefaultWindow(create_params);
} }
extension_keybinding_registry_.reset(new ExtensionKeybindingRegistryViews( extension_keybinding_registry_.reset(
Profile::FromBrowserContext(browser_context()), new ExtensionKeybindingRegistryViews(
window_->GetFocusManager(), profile(),
extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, window_->GetFocusManager(),
shell_window_)); extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY,
shell_window_));
OnViewWasResized(); OnViewWasResized();
window_->AddObserver(this); window_->AddObserver(this);
...@@ -361,15 +362,11 @@ void NativeAppWindowViews::InitializeDefaultWindow( ...@@ -361,15 +362,11 @@ void NativeAppWindowViews::InitializeDefaultWindow(
#if defined(OS_WIN) #if defined(OS_WIN)
base::string16 app_name_wide = base::UTF8ToWide(app_name); base::string16 app_name_wide = base::UTF8ToWide(app_name);
HWND hwnd = GetNativeAppWindowHWND(); HWND hwnd = GetNativeAppWindowHWND();
ui::win::SetAppIdForWindow( ui::win::SetAppIdForWindow(ShellIntegration::GetAppModelIdForProfile(
ShellIntegration::GetAppModelIdForProfile( app_name_wide, profile()->GetPath()), hwnd);
app_name_wide,
Profile::FromBrowserContext(browser_context())->GetPath()),
hwnd);
web_app::UpdateShortcutInfoAndIconForApp( web_app::UpdateShortcutInfoAndIconForApp(
*extension(), *extension(), profile(),
Profile::FromBrowserContext(browser_context()),
base::Bind(&NativeAppWindowViews::OnShortcutInfoLoaded, base::Bind(&NativeAppWindowViews::OnShortcutInfoLoaded,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
#endif #endif
......
...@@ -29,13 +29,13 @@ class ImmersiveFullscreenController; ...@@ -29,13 +29,13 @@ class ImmersiveFullscreenController;
#endif #endif
class ExtensionKeybindingRegistryViews; class ExtensionKeybindingRegistryViews;
class Profile;
namespace apps { namespace apps {
class ShellWindowFrameView; class ShellWindowFrameView;
} }
namespace content { namespace content {
class BrowserContext;
class RenderViewHost; class RenderViewHost;
class WebContents; class WebContents;
} }
...@@ -76,10 +76,7 @@ class NativeAppWindowViews : public apps::NativeAppWindow, ...@@ -76,10 +76,7 @@ class NativeAppWindowViews : public apps::NativeAppWindow,
virtual void Show() OVERRIDE; virtual void Show() OVERRIDE;
virtual void Activate() OVERRIDE; virtual void Activate() OVERRIDE;
content::BrowserContext* browser_context() { Profile* profile() { return shell_window_->profile(); }
return shell_window_->browser_context();
}
const extensions::Extension* extension() { const extensions::Extension* extension() {
return shell_window_->extension(); return shell_window_->extension();
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "chrome/browser/apps/per_app_settings_service.h" #include "chrome/browser/apps/per_app_settings_service.h"
#include "chrome/browser/apps/per_app_settings_service_factory.h" #include "chrome/browser/apps/per_app_settings_service_factory.h"
#include "chrome/browser/metro_utils/metro_chrome_win.h" #include "chrome/browser/metro_utils/metro_chrome_win.h"
#include "chrome/browser/profiles/profile.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "ui/aura/remote_root_window_host_win.h" #include "ui/aura/remote_root_window_host_win.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
...@@ -39,15 +40,15 @@ void NativeAppWindowViewsWin::OnBeforeWidgetInit( ...@@ -39,15 +40,15 @@ void NativeAppWindowViewsWin::OnBeforeWidgetInit(
// If an app has any existing windows, ensure new ones are created on the // If an app has any existing windows, ensure new ones are created on the
// same desktop. // same desktop.
apps::ShellWindow* any_existing_window = apps::ShellWindow* any_existing_window =
apps::ShellWindowRegistry::Get(browser_context()) apps::ShellWindowRegistry::Get(profile())->
->GetCurrentShellWindowForApp(extension()->id()); GetCurrentShellWindowForApp(extension()->id());
chrome::HostDesktopType desktop_type; chrome::HostDesktopType desktop_type;
if (any_existing_window) { if (any_existing_window) {
desktop_type = chrome::GetHostDesktopTypeForNativeWindow( desktop_type = chrome::GetHostDesktopTypeForNativeWindow(
any_existing_window->GetNativeWindow()); any_existing_window->GetNativeWindow());
} else { } else {
PerAppSettingsService* settings = PerAppSettingsService* settings =
PerAppSettingsServiceFactory::GetForBrowserContext(browser_context()); PerAppSettingsServiceFactory::GetForBrowserContext(profile());
if (settings->HasDesktopLastLaunchedFrom(extension()->id())) { if (settings->HasDesktopLastLaunchedFrom(extension()->id())) {
desktop_type = settings->GetDesktopLastLaunchedFrom(extension()->id()); desktop_type = settings->GetDesktopLastLaunchedFrom(extension()->id());
} else { } else {
......
...@@ -69,9 +69,6 @@ class ExtensionsBrowserClient { ...@@ -69,9 +69,6 @@ class ExtensionsBrowserClient {
virtual content::BrowserContext* GetOriginalContext( virtual content::BrowserContext* GetOriginalContext(
content::BrowserContext* context) = 0; content::BrowserContext* context) = 0;
// Returns true if |context| corresponds to a guest session.
virtual bool IsGuestSession(content::BrowserContext* context) = 0;
// Returns true if |extension_id| can run in an incognito window. // Returns true if |extension_id| can run in an incognito window.
virtual bool IsExtensionIncognitoEnabled( virtual bool IsExtensionIncognitoEnabled(
const std::string& extension_id, const std::string& extension_id,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment