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

Side by Side Diff: chrome/app/metro_driver_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: Created 8 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "metro_driver_win.h" 5 #include "metro_driver_win.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "chrome/app/client_util.h" 9 #include "chrome/app/client_util.h"
10 #include "chrome/common/chrome_constants.h"
10 11
11 namespace { 12 namespace {
12 // The windows 8 metro driver dll name and entry point.
13 const wchar_t kMetroDriverDll[] = L"metro_driver.dll";
14 // This environment variable controls the loading of the metro driver DLL. 13 // This environment variable controls the loading of the metro driver DLL.
15 const char* kMetroModeEnvVar = "CHROME_METRO_DLL"; 14 const char* kMetroModeEnvVar = "CHROME_METRO_DLL";
16 15
17 typedef int (*InitMetro)(LPTHREAD_START_ROUTINE thread_proc, void* context); 16 typedef int (*InitMetro)(LPTHREAD_START_ROUTINE thread_proc, void* context);
18 17
19 struct Context { 18 struct Context {
20 MetroDriver::MainFn fn; 19 MetroDriver::MainFn fn;
21 HINSTANCE instance; 20 HINSTANCE instance;
22 }; 21 };
23 22
(...skipping 11 matching lines...) Expand all
35 return; 34 return;
36 // The metro activation always has the |ServerName| parameter. If we dont 35 // The metro activation always has the |ServerName| parameter. If we dont
37 // see it, we are being launched in desktop mode. 36 // see it, we are being launched in desktop mode.
38 if (!wcsstr(::GetCommandLineW(), L" -ServerName:DefaultBrowserServer")) { 37 if (!wcsstr(::GetCommandLineW(), L" -ServerName:DefaultBrowserServer")) {
39 ::SetEnvironmentVariableA(kMetroModeEnvVar, "0"); 38 ::SetEnvironmentVariableA(kMetroModeEnvVar, "0");
40 return; 39 return;
41 } 40 }
42 // We haven't tried to load the metro driver, this probably means we are the 41 // We haven't tried to load the metro driver, this probably means we are the
43 // browser. Find it or not we set the environment variable because we don't 42 // browser. Find it or not we set the environment variable because we don't
44 // want to keep trying in the child processes. 43 // want to keep trying in the child processes.
45 HMODULE metro_dll = ::LoadLibraryW(kMetroDriverDll); 44 HMODULE metro_dll = ::LoadLibraryW(chrome::kMetroDriverDll);
46 if (!metro_dll) { 45 if (!metro_dll) {
47 // It is not next to the build output, so this must be an actual deployment 46 // It is not next to the build output, so this must be an actual deployment
48 // and in that case we need the mainloader to find the current version 47 // and in that case we need the mainloader to find the current version
49 // directory. 48 // directory.
50 MainDllLoader* loader = MakeMainDllLoader(); 49 MainDllLoader* loader = MakeMainDllLoader();
51 std::wstring version = loader->GetVersion(); 50 std::wstring version = loader->GetVersion();
52 delete loader; 51 delete loader;
53 if (!version.empty()) { 52 if (!version.empty()) {
54 std::wstring exe_path(GetExecutablePath()); 53 std::wstring exe_path(GetExecutablePath());
55 exe_path.append(version).append(L"\\").append(kMetroDriverDll); 54 exe_path.append(version).append(L"\\").append(chrome::kMetroDriverDll);
56 metro_dll = ::LoadLibraryW(exe_path.c_str()); 55 metro_dll = ::LoadLibraryW(exe_path.c_str());
57 } 56 }
58 } 57 }
59 // We set the environment variable always, so we don't keep trying in 58 // We set the environment variable always, so we don't keep trying in
60 // the child processes. 59 // the child processes.
61 ::SetEnvironmentVariableA(kMetroModeEnvVar, metro_dll ? "1" : "0"); 60 ::SetEnvironmentVariableA(kMetroModeEnvVar, metro_dll ? "1" : "0");
62 if (!metro_dll) 61 if (!metro_dll)
63 return; 62 return;
64 init_metro_fn_ = ::GetProcAddress(metro_dll, "InitMetro"); 63 init_metro_fn_ = ::GetProcAddress(metro_dll, "InitMetro");
65 } 64 }
66 65
67 int MetroDriver::RunInMetro(HINSTANCE instance, MainFn main_fn) { 66 int MetroDriver::RunInMetro(HINSTANCE instance, MainFn main_fn) {
68 Context* context = new Context; 67 Context* context = new Context;
69 context->fn = main_fn; 68 context->fn = main_fn;
70 context->instance = instance; 69 context->instance = instance;
71 70
72 return reinterpret_cast<InitMetro>(init_metro_fn_)(&MainThread, context); 71 return reinterpret_cast<InitMetro>(init_metro_fn_)(&MainThread, context);
73 } 72 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/shell_integration.h » ('j') | chrome/browser/shell_integration_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698