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

Side by Side Diff: base/win/metro.cc

Issue 10910311: If desktop chrome is launched via the New Window/the recently opened url shortcuts on the chrome sh… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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
« no previous file with comments | « base/win/metro.h ('k') | chrome/browser/process_singleton_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/win/metro.h" 5 #include "base/win/metro.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/win/scoped_comptr.h" 9 #include "base/win/scoped_comptr.h"
10 #include "base/win/windows_version.h" 10 #include "base/win/windows_version.h"
(...skipping 23 matching lines...) Expand all
34 DCHECK(metro_module != kUninitialized); 34 DCHECK(metro_module != kUninitialized);
35 return metro_module; 35 return metro_module;
36 } 36 }
37 37
38 bool IsMetroProcess() { 38 bool IsMetroProcess() {
39 enum ImmersiveState { 39 enum ImmersiveState {
40 kImmersiveUnknown, 40 kImmersiveUnknown,
41 kImmersiveTrue, 41 kImmersiveTrue,
42 kImmersiveFalse 42 kImmersiveFalse
43 }; 43 };
44 typedef BOOL (WINAPI* IsImmersiveProcessFunc)(HANDLE process);
45
46 // The immersive state of a process can never change. 44 // The immersive state of a process can never change.
47 // Look it up once and cache it here. 45 // Look it up once and cache it here.
48 static ImmersiveState state = kImmersiveUnknown; 46 static ImmersiveState state = kImmersiveUnknown;
49 47
50 if (state == kImmersiveUnknown) { 48 if (state == kImmersiveUnknown) {
51 // The lookup hasn't been done yet. Note that the code below here is 49 if (IsProcessImmersive(::GetCurrentProcess())) {
52 // idempotent, so it doesn't matter if it races to assignment on multiple 50 state = kImmersiveTrue;
53 // threads.
54 HMODULE user32 = ::GetModuleHandleA("user32.dll");
55 DCHECK(user32 != NULL);
56
57 IsImmersiveProcessFunc is_immersive_process =
58 reinterpret_cast<IsImmersiveProcessFunc>(
59 ::GetProcAddress(user32, "IsImmersiveProcess"));
60
61 if (is_immersive_process != NULL) {
62 if (is_immersive_process(::GetCurrentProcess())) {
63 state = kImmersiveTrue;
64 } else {
65 state = kImmersiveFalse;
66 }
67 } else { 51 } else {
68 // No "IsImmersiveProcess" export on user32.dll, so this is pre-Windows8
69 // and therefore not immersive.
70 state = kImmersiveFalse; 52 state = kImmersiveFalse;
71 } 53 }
72 } 54 }
73 DCHECK_NE(kImmersiveUnknown, state); 55 DCHECK_NE(kImmersiveUnknown, state);
56 return state == kImmersiveTrue;
57 }
74 58
75 return state == kImmersiveTrue; 59 bool IsProcessImmersive(HANDLE process) {
60 typedef BOOL (WINAPI* IsImmersiveProcessFunc)(HANDLE process);
61 HMODULE user32 = ::GetModuleHandleA("user32.dll");
62 DCHECK(user32 != NULL);
63
64 IsImmersiveProcessFunc is_immersive_process =
65 reinterpret_cast<IsImmersiveProcessFunc>(
66 ::GetProcAddress(user32, "IsImmersiveProcess"));
67
68 if (is_immersive_process)
69 return is_immersive_process(process) ? true: false;
70 return false;
76 } 71 }
77 72
78 bool IsTsfAwareRequired() { 73 bool IsTsfAwareRequired() {
79 // Although this function is equal to IsMetroProcess at this moment, 74 // Although this function is equal to IsMetroProcess at this moment,
80 // Chrome for Win7 and Vista may support TSF in the future. 75 // Chrome for Win7 and Vista may support TSF in the future.
81 return g_should_tsf_aware_required || IsMetroProcess(); 76 return g_should_tsf_aware_required || IsMetroProcess();
82 } 77 }
83 78
84 void SetForceToUseTsf() { 79 void SetForceToUseTsf() {
85 g_should_tsf_aware_required = true; 80 g_should_tsf_aware_required = true;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 reinterpret_cast<GetInitialSearchString>( 180 reinterpret_cast<GetInitialSearchString>(
186 ::GetProcAddress(metro, "GetInitialSearchString")); 181 ::GetProcAddress(metro, "GetInitialSearchString"));
187 DCHECK(initial_search_string); 182 DCHECK(initial_search_string);
188 *params = initial_search_string(); 183 *params = initial_search_string();
189 } 184 }
190 return launch_type; 185 return launch_type;
191 } 186 }
192 187
193 } // namespace win 188 } // namespace win
194 } // namespace base 189 } // namespace base
OLDNEW
« no previous file with comments | « base/win/metro.h ('k') | chrome/browser/process_singleton_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698