summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chromeos/cros/login_library.cc5
-rw-r--r--chrome/browser/chromeos/cros/login_library.h3
-rw-r--r--chrome/browser/chromeos/cros/mock_login_library.h1
-rw-r--r--chrome/browser/chromeos/enterprise_extension_observer.cc65
-rw-r--r--chrome/browser/chromeos/enterprise_extension_observer.h45
-rw-r--r--chrome/browser/profile.cc4
-rw-r--r--chrome/browser/profile.h5
-rw-r--r--chrome/browser/profile_impl.cc7
-rw-r--r--chrome/browser/profile_impl.h4
-rw-r--r--chrome/browser/ui/browser_init.cc3
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/test/testing_profile.h2
12 files changed, 146 insertions, 0 deletions
diff --git a/chrome/browser/chromeos/cros/login_library.cc b/chrome/browser/chromeos/cros/login_library.cc
index 5af80e90..2f69b02 100644
--- a/chrome/browser/chromeos/cros/login_library.cc
+++ b/chrome/browser/chromeos/cros/login_library.cc
@@ -134,6 +134,10 @@ class LoginLibraryImpl : public LoginLibrary {
return chromeos::StopSession("");
}
+ bool RestartEntd() {
+ return chromeos::RestartEntd();
+ }
+
bool RestartJob(int pid, const std::string& command_line) {
return chromeos::RestartJob(pid, command_line.c_str());
}
@@ -257,6 +261,7 @@ class LoginLibraryStubImpl : public LoginLibrary {
const std::string& unique_id /* unused */) { return true; }
bool StopSession(const std::string& unique_id /* unused */) { return true; }
bool RestartJob(int pid, const std::string& command_line) { return true; }
+ bool RestartEntd() { return true; }
private:
static void DoStubCallback(Delegate* callback) {
diff --git a/chrome/browser/chromeos/cros/login_library.h b/chrome/browser/chromeos/cros/login_library.h
index fc9b11a..b9ba6e1 100644
--- a/chrome/browser/chromeos/cros/login_library.h
+++ b/chrome/browser/chromeos/cros/login_library.h
@@ -95,6 +95,9 @@ class LoginLibrary {
// indicated by |unique_id|.
virtual bool StopSession(const std::string& unique_id /* unused */) = 0;
+ // Restarts the Enterprise Daemon.
+ virtual bool RestartEntd() = 0;
+
// Restarts the job with specified command line string.
virtual bool RestartJob(int pid, const std::string& command_line) = 0;
diff --git a/chrome/browser/chromeos/cros/mock_login_library.h b/chrome/browser/chromeos/cros/mock_login_library.h
index 43a77b4..48d62c8 100644
--- a/chrome/browser/chromeos/cros/mock_login_library.h
+++ b/chrome/browser/chromeos/cros/mock_login_library.h
@@ -36,6 +36,7 @@ class MockLoginLibrary : public LoginLibrary {
Delegate*));
MOCK_METHOD2(StartSession, bool(const std::string&, const std::string&));
MOCK_METHOD1(StopSession, bool(const std::string&));
+ MOCK_METHOD0(RestartEntd, bool(void));
MOCK_METHOD2(RestartJob, bool(int, const std::string&));
};
diff --git a/chrome/browser/chromeos/enterprise_extension_observer.cc b/chrome/browser/chromeos/enterprise_extension_observer.cc
new file mode 100644
index 0000000..8e6c620
--- /dev/null
+++ b/chrome/browser/chromeos/enterprise_extension_observer.cc
@@ -0,0 +1,65 @@
+// 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.
+
+#include "chrome/browser/chromeos/enterprise_extension_observer.h"
+
+#include "base/file_util.h"
+#include "chrome/browser/browser_thread.h"
+#include "chrome/browser/chromeos/cros/cros_library.h"
+#include "chrome/browser/chromeos/cros/login_library.h"
+#include "chrome/browser/profile.h"
+
+namespace chromeos {
+
+EnterpriseExtensionObserver::EnterpriseExtensionObserver(Profile* profile)
+ : profile_(profile) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ registrar_.Add(this,
+ NotificationType::EXTENSION_INSTALLED,
+ Source<Profile>(profile_));
+}
+
+void EnterpriseExtensionObserver::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(type == NotificationType::EXTENSION_INSTALLED);
+ if (Source<Profile>(source).ptr() != profile_) {
+ return;
+ }
+ Extension* extension = Details<Extension>(details).ptr();
+ if (extension->location() != Extension::EXTERNAL_POLICY_DOWNLOAD) {
+ return;
+ }
+ BrowserThread::PostTask(
+ BrowserThread::FILE,
+ FROM_HERE,
+ NewRunnableFunction(
+ &EnterpriseExtensionObserver::CheckExtensionAndNotifyEntd,
+ extension->path()));
+}
+
+// static
+void EnterpriseExtensionObserver::CheckExtensionAndNotifyEntd(
+ const FilePath& path) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ if (file_util::PathExists(
+ path.Append(FILE_PATH_LITERAL("isa-cros-policy")))) {
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ NewRunnableFunction(&EnterpriseExtensionObserver::NotifyEntd));
+ }
+}
+
+// static
+void EnterpriseExtensionObserver::NotifyEntd() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (CrosLibrary::Get()->EnsureLoaded()) {
+ CrosLibrary::Get()->GetLoginLibrary()->RestartEntd();
+ return;
+ }
+}
+
+} // namespace chromeos
diff --git a/chrome/browser/chromeos/enterprise_extension_observer.h b/chrome/browser/chromeos/enterprise_extension_observer.h
new file mode 100644
index 0000000..3e5ed81
--- /dev/null
+++ b/chrome/browser/chromeos/enterprise_extension_observer.h
@@ -0,0 +1,45 @@
+// 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.
+
+#ifndef CHROME_BROWSER_CHROMEOS_ENTERPRISE_EXTENSION_OBSERVER_H_
+#define CHROME_BROWSER_CHROMEOS_ENTERPRISE_EXTENSION_OBSERVER_H_
+#pragma once
+
+#include "chrome/common/extensions/extension.h"
+#include "chrome/common/notification_details.h"
+#include "chrome/common/notification_observer.h"
+#include "chrome/common/notification_registrar.h"
+#include "chrome/common/notification_source.h"
+#include "chrome/common/notification_type.h"
+
+class FilePath;
+class Profile;
+
+namespace chromeos {
+
+// This observer listens for installed extensions and restarts the ChromeOS
+// Enterprise daemon if an Enterprise Extension gets installed.
+class EnterpriseExtensionObserver
+ : public NotificationObserver {
+ public:
+ explicit EnterpriseExtensionObserver(Profile* profile);
+ virtual ~EnterpriseExtensionObserver() {}
+
+ void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
+ private:
+ static void CheckExtensionAndNotifyEntd(const FilePath& path);
+ static void NotifyEntd();
+
+ Profile* profile_;
+ NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(EnterpriseExtensionObserver);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_ENTERPRISE_EXTENSION_OBSERVER_H_
diff --git a/chrome/browser/profile.cc b/chrome/browser/profile.cc
index c03483a..0a8e67c 100644
--- a/chrome/browser/profile.cc
+++ b/chrome/browser/profile.cc
@@ -546,6 +546,10 @@ class OffTheRecordProfileImpl : public Profile,
GetChromeOSProxyConfigServiceImpl() {
return profile_->GetChromeOSProxyConfigServiceImpl();
}
+
+ virtual void SetupChromeOSEnterpriseExtensionObserver() {
+ profile_->SetupChromeOSEnterpriseExtensionObserver();
+ }
#endif // defined(OS_CHROMEOS)
virtual void ExitedOffTheRecordMode() {
diff --git a/chrome/browser/profile.h b/chrome/browser/profile.h
index 5b5cdaf..b50c172 100644
--- a/chrome/browser/profile.h
+++ b/chrome/browser/profile.h
@@ -17,6 +17,7 @@ class Time;
#if defined(OS_CHROMEOS)
namespace chromeos {
+class EnterpriseExtensionObserver;
class ProxyConfigServiceImpl;
}
#endif
@@ -484,6 +485,10 @@ class Profile {
// Returns ChromeOS's ProxyConfigServiceImpl, creating if not yet created.
virtual chromeos::ProxyConfigServiceImpl*
GetChromeOSProxyConfigServiceImpl() = 0;
+
+ // Creates ChromeOS's EnterpriseExtensionListener.
+ virtual void SetupChromeOSEnterpriseExtensionObserver() = 0;
+
#endif // defined(OS_CHROMEOS)
// Returns the helper object that provides the proxy configuration service
diff --git a/chrome/browser/profile_impl.cc b/chrome/browser/profile_impl.cc
index 6e19ef4..392fdeb 100644
--- a/chrome/browser/profile_impl.cc
+++ b/chrome/browser/profile_impl.cc
@@ -105,6 +105,7 @@
#include "chrome/browser/keychain_mac.h"
#include "chrome/browser/password_manager/password_store_mac.h"
#elif defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/enterprise_extension_observer.h"
#include "chrome/browser/chromeos/proxy_config_service_impl.h"
#elif defined(OS_POSIX) && !defined(OS_CHROMEOS)
#include "base/nix/xdg_util.h"
@@ -1330,6 +1331,12 @@ chromeos::ProxyConfigServiceImpl*
}
return chromeos_proxy_config_service_impl_;
}
+
+void ProfileImpl::SetupChromeOSEnterpriseExtensionObserver() {
+ DCHECK(!chromeos_enterprise_extension_observer_.get());
+ chromeos_enterprise_extension_observer_.reset(
+ new chromeos::EnterpriseExtensionObserver(this));
+}
#endif // defined(OS_CHROMEOS)
PrefProxyConfigTracker* ProfileImpl::GetProxyConfigTracker() {
diff --git a/chrome/browser/profile_impl.h b/chrome/browser/profile_impl.h
index 83a4b93..9d484cd 100644
--- a/chrome/browser/profile_impl.h
+++ b/chrome/browser/profile_impl.h
@@ -128,6 +128,7 @@ class ProfileImpl : public Profile,
#if defined(OS_CHROMEOS)
virtual chromeos::ProxyConfigServiceImpl* GetChromeOSProxyConfigServiceImpl();
+ virtual void SetupChromeOSEnterpriseExtensionObserver();
#endif // defined(OS_CHROMEOS)
virtual PrefProxyConfigTracker* GetProxyConfigTracker();
@@ -281,6 +282,9 @@ class ProfileImpl : public Profile,
scoped_refptr<chromeos::ProxyConfigServiceImpl>
chromeos_proxy_config_service_impl_;
+
+ scoped_ptr<chromeos::EnterpriseExtensionObserver>
+ chromeos_enterprise_extension_observer_;
#endif
scoped_refptr<PrefProxyConfigTracker> pref_proxy_config_tracker_;
diff --git a/chrome/browser/ui/browser_init.cc b/chrome/browser/ui/browser_init.cc
index f7b8074..0ac4f04 100644
--- a/chrome/browser/ui/browser_init.cc
+++ b/chrome/browser/ui/browser_init.cc
@@ -85,6 +85,7 @@
#include "chrome/browser/chromeos/cros/mount_library.h"
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/customization_document.h"
+#include "chrome/browser/chromeos/enterprise_extension_observer.h"
#include "chrome/browser/chromeos/gview_request_interceptor.h"
#include "chrome/browser/chromeos/low_battery_observer.h"
#include "chrome/browser/chromeos/network_message_observer.h"
@@ -460,6 +461,8 @@ bool BrowserInit::LaunchBrowser(const CommandLine& command_line,
->AddNetworkManagerObserver(network_message_observer);
chromeos::CrosLibrary::Get()->GetNetworkLibrary()
->AddCellularDataPlanObserver(network_message_observer);
+
+ profile->SetupChromeOSEnterpriseExtensionObserver();
}
#endif
return true;
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index b3d8577..f43a532 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -486,6 +486,8 @@
'browser/chromeos/dom_ui/wrench_menu_ui.cc',
'browser/chromeos/dom_ui/wrench_menu_ui.h',
'browser/chromeos/drop_shadow_label.cc',
+ 'browser/chromeos/enterprise_extension_observer.cc',
+ 'browser/chromeos/enterprise_extension_observer.h',
'browser/chromeos/external_metrics.cc',
'browser/chromeos/external_metrics.h',
'browser/chromeos/external_protocol_dialog.cc',
diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h
index de7f32f..d08cafd 100644
--- a/chrome/test/testing_profile.h
+++ b/chrome/test/testing_profile.h
@@ -292,6 +292,8 @@ class TestingProfile : public Profile {
GetChromeOSProxyConfigServiceImpl() {
return NULL;
}
+ virtual void SetupChromeOSEnterpriseExtensionObserver() {
+ }
#endif // defined(OS_CHROMEOS)
virtual PrefProxyConfigTracker* GetProxyConfigTracker();