summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_main.cc15
-rw-r--r--chrome/browser/chromeos/login/existing_user_controller.cc2
-rw-r--r--chrome/browser/chromeos/login/login_browsertest.cc2
-rw-r--r--chrome/browser/chromeos/login/login_manager_view.cc2
-rw-r--r--chrome/browser/extensions/extension_browsertest.cc15
-rw-r--r--chrome/browser/profile.cc19
-rw-r--r--chrome/browser/profile_manager.cc41
-rw-r--r--chrome/browser/profile_manager.h5
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc2
-rw-r--r--chrome/browser/task_manager_resource_providers.cc2
-rw-r--r--chrome/browser/views/browser_actions_container.cc27
11 files changed, 77 insertions, 55 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index acc4525..6b7d540 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -1018,10 +1018,9 @@ int BrowserMain(const MainFunctionParams& parameters) {
// Profile creation ----------------------------------------------------------
#if defined(OS_CHROMEOS)
- // todo(davemoore) this is a hack to get the ProfileManager to register
- // for the user logged in notification before we send it. This needs to be
- // redone in a cleaner way.
- ProfileManager::GetDefaultProfile();
+ // This forces the ProfileManager to be created and register for the
+ // notification it needs to track the logged in user.
+ g_browser_process->profile_manager()->GetDefaultProfile();
if (parsed_command_line.HasSwitch(switches::kLoginUser)) {
std::string username =
@@ -1223,9 +1222,11 @@ int BrowserMain(const MainFunctionParams& parameters) {
metrics->StartExternalMetrics();
#endif
- // This will initialize bookmarks. Call it after bookmark import is done.
- // See issue 40144.
- profile->GetExtensionsService()->InitEventRouters();
+ if (profile->GetExtensionsService()) {
+ // This will initialize bookmarks. Call it after bookmark import is done.
+ // See issue 40144.
+ profile->GetExtensionsService()->InitEventRouters();
+ }
#if defined(OS_WIN)
// We check this here because if the profile is OTR (chromeos possibility)
diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc
index 61f7ebb..405c794 100644
--- a/chrome/browser/chromeos/login/existing_user_controller.cc
+++ b/chrome/browser/chromeos/login/existing_user_controller.cc
@@ -131,7 +131,7 @@ void ExistingUserController::Login(UserController* source,
selected_view_index_ = i - controllers_.begin();
authenticator_ = LoginUtils::Get()->CreateAuthenticator(this);
- Profile* profile = g_browser_process->profile_manager()->GetWizardProfile();
+ Profile* profile = g_browser_process->profile_manager()->GetDefaultProfile();
ChromeThread::PostTask(
ChromeThread::FILE, FROM_HERE,
NewRunnableMethod(authenticator_.get(),
diff --git a/chrome/browser/chromeos/login/login_browsertest.cc b/chrome/browser/chromeos/login/login_browsertest.cc
index 36e391f..da51a39 100644
--- a/chrome/browser/chromeos/login/login_browsertest.cc
+++ b/chrome/browser/chromeos/login/login_browsertest.cc
@@ -102,6 +102,8 @@ IN_PROC_BROWSER_TEST_F(LoginProfileTest, UserNotPassed) {
Profile* profile = browser()->profile();
EXPECT_EQ("Default", profile->GetPath().BaseName().value());
EXPECT_TRUE(profile->IsOffTheRecord());
+ // Ensure there's no extension service for this profile.
+ EXPECT_EQ(NULL, profile->GetExtensionsService());
}
} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/login_manager_view.cc b/chrome/browser/chromeos/login/login_manager_view.cc
index 3a2fe2c..b656542 100644
--- a/chrome/browser/chromeos/login/login_manager_view.cc
+++ b/chrome/browser/chromeos/login/login_manager_view.cc
@@ -288,7 +288,7 @@ void LoginManagerView::Login() {
username_field_->SetText(UTF8ToUTF16(username));
}
- Profile* profile = g_browser_process->profile_manager()->GetWizardProfile();
+ Profile* profile = g_browser_process->profile_manager()->GetDefaultProfile();
ChromeThread::PostTask(
ChromeThread::FILE, FROM_HERE,
NewRunnableMethod(authenticator_.get(),
diff --git a/chrome/browser/extensions/extension_browsertest.cc b/chrome/browser/extensions/extension_browsertest.cc
index 12c5833..ce0f37d 100644
--- a/chrome/browser/extensions/extension_browsertest.cc
+++ b/chrome/browser/extensions/extension_browsertest.cc
@@ -25,6 +25,10 @@
#include "chrome/common/notification_type.h"
#include "chrome/test/ui_test_utils.h"
+#if defined(OS_CHROMEOS)
+#include "chrome/common/chrome_switches.h"
+#endif
+
ExtensionBrowserTest::ExtensionBrowserTest()
: target_page_action_count_(-1),
target_visible_page_action_count_(-1) {
@@ -44,6 +48,17 @@ void ExtensionBrowserTest::SetUpCommandLine(CommandLine* command_line) {
// selectively enabling each of them, enable toolstrips for all extension
// tests.
command_line->AppendSwitch(switches::kEnableExtensionToolstrips);
+
+#if defined(OS_CHROMEOS)
+ // This makes sure that we create the Default profile first, with no
+ // ExtensionsService and then the real profile with one, as we do when
+ // running on chromeos.
+ command_line->AppendSwitchWithValue(
+ switches::kLoginUser, "TestUser@gmail.com");
+ command_line->AppendSwitchWithValue(switches::kLoginProfile, "user");
+ command_line->AppendSwitch(switches::kNoFirstRun);
+#endif
+
}
bool ExtensionBrowserTest::LoadExtensionImpl(const FilePath& path,
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index 1a01523..505a528 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -663,14 +663,6 @@ ProfileImpl::ProfileImpl(const FilePath& path)
TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this,
&ProfileImpl::EnsureSessionServiceCreated);
- if (CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableExtensionTimelineApi)) {
- extension_devtools_manager_ = new ExtensionDevToolsManager(this);
- }
-
- extension_process_manager_.reset(new ExtensionProcessManager(this));
- extension_message_service_ = new ExtensionMessageService(this);
-
PrefService* prefs = GetPrefs();
prefs->AddPrefObserver(prefs::kSpellCheckDictionary, this);
prefs->AddPrefObserver(prefs::kEnableSpellCheck, this);
@@ -736,6 +728,14 @@ void ProfileImpl::InitExtensions() {
return; // Already initialized.
const CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(
+ switches::kEnableExtensionTimelineApi)) {
+ extension_devtools_manager_ = new ExtensionDevToolsManager(this);
+ }
+
+ extension_process_manager_.reset(new ExtensionProcessManager(this));
+ extension_message_service_ = new ExtensionMessageService(this);
+
ExtensionErrorReporter::Init(true); // allow noisy errors.
FilePath script_dir; // Don't look for user scripts in any directory.
@@ -889,7 +889,8 @@ ProfileImpl::~ProfileImpl() {
// HistoryService first.
favicon_service_ = NULL;
- extension_message_service_->ProfileDestroyed();
+ if (extension_message_service_)
+ extension_message_service_->ProfileDestroyed();
if (extensions_service_)
extensions_service_->ProfileDestroyed();
diff --git a/chrome/browser/profile_manager.cc b/chrome/browser/profile_manager.cc
index 296ac4b..c755cfe 100644
--- a/chrome/browser/profile_manager.cc
+++ b/chrome/browser/profile_manager.cc
@@ -117,7 +117,7 @@ Profile* ProfileManager::GetDefaultProfile(const FilePath& user_data_dir) {
// If not logged in on cros, always return the incognito profile
default_profile_dir = default_profile_dir.Append(
FilePath::FromWStringHack(chrome::kNotSignedInProfile));
- Profile* profile = GetProfile(default_profile_dir);
+ Profile* profile;
// For cros, return the OTR profile so we never accidentally keep
// user data in an unencrypted profile. But doing this makes
@@ -125,9 +125,13 @@ Profile* ProfileManager::GetDefaultProfile(const FilePath& user_data_dir) {
// if the login-profile switch is passed so that we can test this.
// TODO(davemoore) Fix the tests so they allow OTR profiles.
if (!command_line.HasSwitch(switches::kTestType) ||
- command_line.HasSwitch(switches::kLoginProfile))
+ command_line.HasSwitch(switches::kLoginProfile)) {
+ // Don't init extensions for this profile
+ profile = GetProfile(default_profile_dir, false);
profile = profile->GetOffTheRecordProfile();
-
+ } else {
+ profile = GetProfile(default_profile_dir, true);
+ }
return profile;
}
#else
@@ -137,20 +141,6 @@ Profile* ProfileManager::GetDefaultProfile(const FilePath& user_data_dir) {
#endif
}
-#if defined(OS_CHROMEOS)
-Profile* ProfileManager::GetWizardProfile() {
- FilePath user_data_dir;
- PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
- FilePath default_profile_dir(user_data_dir);
- default_profile_dir = default_profile_dir.Append(
- FilePath::FromWStringHack(chrome::kNotSignedInProfile));
- ProfileManager* profile_manager = g_browser_process->profile_manager();
-
- // Don't init extensions for this profile
- return profile_manager->GetProfile(default_profile_dir, false);
-}
-#endif
-
Profile* ProfileManager::GetProfile(const FilePath& profile_dir) {
return GetProfile(profile_dir, true);
}
@@ -233,12 +223,17 @@ void ProfileManager::Observe(
const NotificationDetails& details) {
#if defined(OS_CHROMEOS)
if (type == NotificationType::LOGIN_USER_CHANGED) {
- CHECK(chromeos::CrosLibrary::Get()->EnsureLoaded());
- // If we don't have a mounted profile directory we're in trouble.
- // TODO(davemoore) Once we have better api this check should ensure that
- // our profile directory is the one that's mounted, and that it's mounted
- // as the current user.
- CHECK(chromeos::CrosLibrary::Get()->GetCryptohomeLibrary()->IsMounted());
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ if (!command_line.HasSwitch(switches::kTestType)) {
+ // This will fail when running on non cros os.
+ // TODO(davemoore) Need to mock this enough to enable testing.
+ CHECK(chromeos::CrosLibrary::Get()->EnsureLoaded());
+ // If we don't have a mounted profile directory we're in trouble.
+ // TODO(davemoore) Once we have better api this check should ensure that
+ // our profile directory is the one that's mounted, and that it's mounted
+ // as the current user.
+ CHECK(chromeos::CrosLibrary::Get()->GetCryptohomeLibrary()->IsMounted());
+ }
logged_in_ = true;
}
#endif
diff --git a/chrome/browser/profile_manager.h b/chrome/browser/profile_manager.h
index 711fcf1..41c2589 100644
--- a/chrome/browser/profile_manager.h
+++ b/chrome/browser/profile_manager.h
@@ -83,11 +83,6 @@ class ProfileManager : public NonThreadSafe,
// Same as instance method but provides the default user_data_dir as well.
static Profile* GetDefaultProfile();
-#if defined(OS_CHROMEOS)
- // Returns the default profile with extensions turned off
- static Profile* GetWizardProfile();
-#endif
-
// Returns a profile for a specific profile directory within the user data
// dir. This will return an existing profile it had already been created,
// otherwise it will create and manage it.
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index 4828840..19d0c0b 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -660,6 +660,8 @@ void BrowserRenderProcessHost::SendExtensionExtentsUpdate() {
}
ExtensionsService* service = profile()->GetExtensionsService();
+ if (!service)
+ return;
ViewMsg_ExtensionExtentsUpdated_Params params;
for (size_t i = 0; i < service->extensions()->size(); ++i) {
Extension* extension = service->extensions()->at(i);
diff --git a/chrome/browser/task_manager_resource_providers.cc b/chrome/browser/task_manager_resource_providers.cc
index f7cc5ab..bfe4ea0 100644
--- a/chrome/browser/task_manager_resource_providers.cc
+++ b/chrome/browser/task_manager_resource_providers.cc
@@ -587,6 +587,8 @@ void TaskManagerExtensionProcessResourceProvider::StartUpdating() {
it != profile_manager->end(); ++it) {
ExtensionProcessManager* process_manager =
(*it)->GetExtensionProcessManager();
+ if (!process_manager)
+ continue;
ExtensionProcessManager::const_iterator jt;
for (jt = process_manager->begin(); jt != process_manager->end(); ++jt)
AddToTaskManager(*jt);
diff --git a/chrome/browser/views/browser_actions_container.cc b/chrome/browser/views/browser_actions_container.cc
index 2103108..c99e867 100644
--- a/chrome/browser/views/browser_actions_container.cc
+++ b/chrome/browser/views/browser_actions_container.cc
@@ -373,9 +373,10 @@ BrowserActionsContainer::BrowserActionsContainer(
ALLOW_THIS_IN_INITIALIZER_LIST(show_menu_task_factory_(this)) {
SetID(VIEW_ID_BROWSER_ACTION_TOOLBAR);
- model_ = profile_->GetExtensionsService()->toolbar_model();
- model_->AddObserver(this);
-
+ if (profile_->GetExtensionsService()) {
+ model_ = profile_->GetExtensionsService()->toolbar_model();
+ model_->AddObserver(this);
+ }
resize_animation_.reset(new SlideAnimation(this));
resize_gripper_ = new views::ResizeGripper(this);
resize_gripper_->SetAccessibleName(
@@ -402,12 +403,14 @@ BrowserActionsContainer::BrowserActionsContainer(
profile_->GetPrefs()->GetInteger(prefs::kBrowserActionContainerWidth);
if (predefined_width != 0) {
int icon_width = (kButtonSize + kBrowserActionButtonPadding);
- model_->SetVisibleIconCount(
- (predefined_width - WidthOfNonIconArea()) / icon_width);
+ if (model_) {
+ model_->SetVisibleIconCount(
+ (predefined_width - WidthOfNonIconArea()) / icon_width);
+ }
}
}
- if (model_->extensions_initialized())
+ if (model_ && model_->extensions_initialized())
SetContainerWidth();
SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_EXTENSIONS));
@@ -486,6 +489,9 @@ void BrowserActionsContainer::SetDropIndicator(int x_pos) {
void BrowserActionsContainer::CreateBrowserActionViews() {
DCHECK(browser_action_views_.empty());
+ if (!model_)
+ return;
+
for (ExtensionList::iterator iter = model_->begin();
iter != model_->end(); ++iter) {
if (!ShouldDisplayBrowserAction(*iter))
@@ -783,6 +789,7 @@ int BrowserActionsContainer::OnPerformDrop(
// Make sure we have the same view as we started with.
DCHECK(browser_action_views_[data.index()]->button()->extension()->id() ==
data.id());
+ DCHECK(model_);
Extension* dragging =
browser_action_views_[data.index()]->button()->extension();
@@ -828,9 +835,11 @@ bool BrowserActionsContainer::GetAccessibleRole(
void BrowserActionsContainer::MoveBrowserAction(
const std::string& extension_id, size_t new_index) {
ExtensionsService* service = profile_->GetExtensionsService();
- Extension* extension = service->GetExtensionById(extension_id, false);
- model_->MoveBrowserAction(extension, new_index);
- SchedulePaint();
+ if (service) {
+ Extension* extension = service->GetExtensionById(extension_id, false);
+ model_->MoveBrowserAction(extension, new_index);
+ SchedulePaint();
+ }
}
void BrowserActionsContainer::RunMenu(View* source, const gfx::Point& pt) {