Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Unified Diff: chrome/browser/shell_integration_win.cc

Issue 10470002: Add ShellIntegration::ActivateMetroChrome, which launches Chrome in metro-mode on Windows 8. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: metro_exports -> metro Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/shell_integration.h ('k') | chrome/common/chrome_constants.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/shell_integration_win.cc
diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc
index 869b5b51311f5ff8019a259bc8d3301c07c44629..f4c8609f43ec88bc8c84e97eb715f7ec009cafb8 100644
--- a/chrome/browser/shell_integration_win.cc
+++ b/chrome/browser/shell_integration_win.cc
@@ -14,10 +14,12 @@
#include "base/file_util.h"
#include "base/message_loop.h"
#include "base/path_service.h"
+#include "base/scoped_native_library.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
+#include "base/win/metro.h"
#include "base/win/registry.h"
#include "base/win/scoped_co_mem.h"
#include "base/win/scoped_comptr.h"
@@ -387,6 +389,40 @@ void MigrateChromiumShortcutsCallback() {
}
}
+// Activates the application with the given AppUserModelId.
+bool ActivateApplication(const string16& app_id) {
+ // Not supported when running in metro mode.
+ // TODO(grt) This should perhaps check that this Chrome isn't in metro mode
+ // or, if it is, that |app_id| doesn't identify this Chrome.
+ if (base::win::GetMetroModule())
+ return false;
+
+ // Delegate to metro_driver, which has the brains to invoke the activation
+ // wizardry.
+ bool success = false;
+ const FilePath metro_driver_path(chrome::kMetroDriverDll);
+ base::ScopedNativeLibrary metro_driver(metro_driver_path);
+ if (!metro_driver.is_valid()) {
+ PLOG(ERROR) << "Failed to load metro_driver.";
+ } else {
+ base::win::ActivateApplicationFn activate_application =
+ reinterpret_cast<base::win::ActivateApplicationFn>(
+ metro_driver.GetFunctionPointer(base::win::kActivateApplication));
+ if (!activate_application) {
+ PLOG(ERROR) << "Failed to find activation method in metro_driver.";
+ } else {
+ HRESULT hr = activate_application(app_id.c_str());
+ if (FAILED(hr)) {
+ LOG(ERROR) << "Failed to activate " << app_id
+ << "; hr=0x" << std::hex << hr;
+ } else {
+ success = true;
+ }
+ }
+ }
+ return success;
+}
+
} // namespace
bool ShellIntegration::CanSetAsDefaultBrowser() {
@@ -537,3 +573,9 @@ void ShellIntegration::MigrateChromiumShortcuts() {
BrowserThread::FILE, FROM_HERE,
base::Bind(&MigrateChromiumShortcutsCallback));
}
+
+bool ShellIntegration::ActivateMetroChrome() {
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution();
+ const string16 app_id(dist->GetBrowserAppId());
+ return ActivateApplication(app_id);
+}
« no previous file with comments | « chrome/browser/shell_integration.h ('k') | chrome/common/chrome_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698