Skip to content

Commit

Permalink
win/aura: Remove some more non-aura code for Windows.
Browse files Browse the repository at this point in the history
This removes all the uses of USE_AURA ifdefs from the _win.cc files (and some
additional removal of dead code).

BUG=none
R=mkwst@chromium.org, sky@chromium.org, thestig@chromium.org

Review URL: https://codereview.chromium.org/909183002

Cr-Commit-Position: refs/heads/master@{#316231}
  • Loading branch information
sadrulhc committed Feb 13, 2015
1 parent c25e09c commit da8b9b7
Show file tree
Hide file tree
Showing 14 changed files with 8 additions and 181 deletions.
2 changes: 0 additions & 2 deletions chrome/browser/chrome_browser_main_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,7 @@ void ChromeBrowserMainPartsWin::ToolkitInitialized() {
ChromeBrowserMainParts::ToolkitInitialized();
gfx::PlatformFontWin::adjust_font_callback = &AdjustUIFont;
gfx::PlatformFontWin::get_minimum_font_size_callback = &GetMinimumFontSize;
#if defined(USE_AURA)
ui::CursorLoaderWin::SetCursorResourceModule(chrome::kBrowserResourcesDll);
#endif
}

void ChromeBrowserMainPartsWin::PreMainMessageLoopStart() {
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/lifetime/application_lifetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ void ActivateDesktopHelper(AshExecutionStatus ash_execution_status);
// Windows 7/8 specific: Like AttemptRestart but if chrome is running
// in desktop mode it starts in metro mode and vice-versa. The switching like
// the restarting is controlled by a preference.
void AttemptRestartWithModeSwitch();
void AttemptRestartToDesktopMode();
// Launches Chrome into Windows 8 metro mode on Windows 8. On Windows 7 it
// launches Chrome into Windows ASH.
Expand Down
44 changes: 6 additions & 38 deletions chrome/browser/lifetime/application_lifetime_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,33 @@
#include "chrome/browser/lifetime/application_lifetime.h"

#include "base/bind.h"
#include "base/environment.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "base/prefs/pref_service.h"
#include "base/win/metro.h"
#include "base/win/windows_version.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/first_run/upgrade_util.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/common/pref_names.h"
#include "ui/views/widget/widget.h"

#if defined(USE_AURA)
#include "base/environment.h"
#include "base/files/file_path.h"
#include "base/path_service.h"
#include "chrome/browser/metro_utils/metro_chrome_win.h"
#include "chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/pref_names.h"
#include "chrome/installer/util/util_constants.h"
#include "content/public/browser/web_contents.h"
#endif
#include "ui/views/widget/widget.h"

namespace chrome {

#if !defined(USE_AURA)
void HandleAppExitingForPlatform() {
views::Widget::CloseAllSecondaryWidgets();
}
#endif

// Following set of functions, which are used to switch chrome mode after
// restart are used for in places where either user explicitly wants to switch
// mode or some functionality is not available in either mode and we ask user
// to switch mode.
// Here mode refers to Windows 8 modes such as Metro (also called immersive)
// and desktop mode (Classic or traditional).

// Mode switch based on current mode which is devised from current process.
void AttemptRestartWithModeSwitch() {
#if defined(USE_AURA)
// This function should be called only from non aura code path.
// In aura/ash windows world browser process is always non metro.
NOTREACHED();
#else
// The kRestartSwitchMode preference does not exists for Windows 7 and older
// operating systems so there is no need for OS version check.
PrefService* prefs = g_browser_process->local_state();
if (base::win::IsMetroProcess()) {
prefs->SetString(prefs::kRelaunchMode,
upgrade_util::kRelaunchModeDesktop);
} else {
prefs->SetString(prefs::kRelaunchMode,
upgrade_util::kRelaunchModeMetro);
}
AttemptRestart();
#endif
}

#if defined(USE_AURA)
void ActivateDesktopHelper(AshExecutionStatus ash_execution_status) {
scoped_ptr<base::Environment> env(base::Environment::Create());
std::string version_str;
Expand Down Expand Up @@ -91,7 +60,6 @@ void ActivateDesktopHelper(AshExecutionStatus ash_execution_status) {
ChromeMetroViewerProcessHost::HandleActivateDesktop(
path, ash_execution_status == ASH_TERMINATE);
}
#endif

void AttemptRestartToDesktopMode() {
PrefService* prefs = g_browser_process->local_state();
Expand Down
7 changes: 0 additions & 7 deletions chrome/browser/metro_utils/metro_chrome_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,10 @@ bool ActivateMetroChrome() {
}

Win8Environment GetWin8Environment(HostDesktopType desktop) {
#if defined(USE_AURA) && defined(USE_ASH)
if (desktop == chrome::HOST_DESKTOP_TYPE_ASH)
return WIN_8_ENVIRONMENT_METRO_AURA;
else
return WIN_8_ENVIRONMENT_DESKTOP_AURA;
#else
if (base::win::IsProcessImmersive(::GetCurrentProcess()))
return WIN_8_ENVIRONMENT_METRO;
else
return WIN_8_ENVIRONMENT_DESKTOP;
#endif
}


Expand Down
2 changes: 0 additions & 2 deletions chrome/browser/metro_utils/metro_chrome_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ namespace chrome {
bool ActivateMetroChrome();

enum Win8Environment {
WIN_8_ENVIRONMENT_METRO,
WIN_8_ENVIRONMENT_DESKTOP,
WIN_8_ENVIRONMENT_METRO_AURA,
WIN_8_ENVIRONMENT_DESKTOP_AURA,
WIN_8_ENVIRONMENT_MAX
Expand Down
9 changes: 1 addition & 8 deletions chrome/browser/password_manager/password_manager_util_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "ui/base/l10n/l10n_util.h"

#if defined(USE_AURA)
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#endif
#include "ui/base/l10n/l10n_util.h"

namespace password_manager_util {
namespace {
Expand Down Expand Up @@ -248,11 +245,7 @@ bool AuthenticateUser(gfx::NativeWindow window) {

cui.cbSize = sizeof(CREDUI_INFO);
cui.hwndParent = NULL;
#if defined(USE_AURA)
cui.hwndParent = window->GetHost()->GetAcceleratedWidget();
#else
cui.hwndParent = window;
#endif

cui.pszMessageText = password_prompt.c_str();
cui.pszCaptionText = product_name.c_str();
Expand Down
23 changes: 0 additions & 23 deletions chrome/browser/platform_util_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -211,27 +211,4 @@ void OpenExternal(Profile* profile, const GURL& url) {
base::Bind(&OpenExternalOnFileThread, url));
}

#if !defined(USE_AURA)
gfx::NativeWindow GetTopLevel(gfx::NativeView view) {
return ::GetAncestor(view, GA_ROOT);
}

gfx::NativeView GetParent(gfx::NativeView view) {
return ::GetParent(view);
}

bool IsWindowActive(gfx::NativeWindow window) {
return ::GetForegroundWindow() == window;
}

void ActivateWindow(gfx::NativeWindow window) {
::SetForegroundWindow(window);
}

bool IsVisible(gfx::NativeView view) {
// MSVC complains if we don't include != 0.
return ::IsWindowVisible(view) != 0;
}
#endif

} // namespace platform_util
34 changes: 0 additions & 34 deletions chrome/browser/process_singleton_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,45 +186,11 @@ bool ProcessLaunchNotification(
// Move this function to a common place as the Windows 8 delegate_execute
// handler can possibly use this.
bool ShouldLaunchInWindows8ImmersiveMode(const base::FilePath& user_data_dir) {
#if defined(USE_AURA)
// Returning false from this function doesn't mean we don't launch immersive
// mode in Aura. This function is specifically called in case when we need
// to relaunch desktop launched chrome into immersive mode through 'relaunch'
// menu. In case of Aura, we will use delegate_execute to do the relaunch.
return false;
#else
if (base::win::GetVersion() < base::win::VERSION_WIN8)
return false;

if (base::win::IsProcessImmersive(base::GetCurrentProcessHandle()))
return false;

if (ShellIntegration::GetDefaultBrowser() != ShellIntegration::IS_DEFAULT)
return false;

base::IntegrityLevel integrity_level = base::INTEGRITY_UNKNOWN;
base::GetProcessIntegrityLevel(base::GetCurrentProcessHandle(),
&integrity_level);
if (integrity_level == base::HIGH_INTEGRITY)
return false;

base::FilePath default_user_data_dir;
if (!chrome::GetDefaultUserDataDirectory(&default_user_data_dir))
return false;

if (default_user_data_dir != user_data_dir)
return false;

base::win::RegKey reg_key;
DWORD reg_value = 0;
if (reg_key.Create(HKEY_CURRENT_USER, chrome::kMetroRegistryPath,
KEY_READ) == ERROR_SUCCESS &&
reg_key.ReadValueDW(chrome::kLaunchModeValue,
&reg_value) == ERROR_SUCCESS) {
return reg_value == 1;
}
return false;
#endif
}

} // namespace
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/pdf/pdf_unsupported_feature.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ bool PDFUnsupportedFeaturePromptClient::ShouldExpire(

void PDFUnsupportedFeaturePromptClient::Accept() {
if (base::win::IsMetroProcess()) {
chrome::AttemptRestartWithModeSwitch();
chrome::AttemptRestartToDesktopMode();
return;
}

Expand Down
6 changes: 0 additions & 6 deletions chrome/browser/ui/webui/help/version_updater_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,6 @@ gfx::AcceleratedWidget VersionUpdaterWin::GetElevationParent() {
EnumThreadWindows(GetCurrentThreadId(),
WindowEnumeration,
reinterpret_cast<LPARAM>(&window));
#if !defined(USE_AURA)
// If using Aura, we might not have a Visible window in this process. In
// theory Google update can cope with that.
DCHECK(window != NULL) << "Failed to find a valid window handle on thread: "
<< GetCurrentThreadId();
#endif
return window;
}

Expand Down
4 changes: 0 additions & 4 deletions components/crash/app/hard_error_handler_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,8 @@ bool HardErrorHandler(EXCEPTION_POINTERS* ex_info) {
EntryPointNotFoundHardError(ex_info->ExceptionRecord);
return true;
} else if (FacilityFromException(exception) == FACILITY_GRAPHICS_KERNEL) {
#if defined(USE_AURA)
RaiseHardErrorMsg(exception, std::string(), std::string());
return true;
#else
return false;
#endif
}
return false;
}
Expand Down
16 changes: 0 additions & 16 deletions content/shell/browser/shell_web_contents_view_delegate_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,23 +170,7 @@ void ShellWebContentsViewDelegate::ShowContextMenu(
L"Inspect...",
ShellContextMenuItemInspectId,
true);
#if defined(USE_AURA)
NOTIMPLEMENTED();
#else
gfx::Point screen_point(params.x, params.y);
POINT point = screen_point.ToPOINT();
ClientToScreen(web_contents_->GetNativeView(), &point);

int selection =
TrackPopupMenu(sub_menu,
TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD,
point.x, point.y,
0,
web_contents_->GetContentNativeView(),
NULL);

MenuItemSelected(selection);
#endif
DestroyMenu(menu);
}

Expand Down
9 changes: 0 additions & 9 deletions printing/printing_context_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@
#include "printing/printing_utils.h"
#include "printing/units.h"
#include "skia/ext/platform_device.h"

#if defined(USE_AURA)
#include "ui/aura/remote_window_tree_host_win.h"
#include "ui/aura/window.h"
#endif

namespace printing {

Expand Down Expand Up @@ -362,14 +359,8 @@ PrintingContext::Result PrintingContextWin::InitializeSettings(

HWND PrintingContextWin::GetRootWindow(gfx::NativeView view) {
HWND window = NULL;
#if defined(USE_AURA)
if (view)
window = view->GetHost()->GetAcceleratedWidget();
#else
if (view && IsWindow(view)) {
window = GetAncestor(view, GA_ROOTOWNER);
}
#endif
if (!window) {
// TODO(maruel): crbug.com/1214347 Get the right browser window instead.
return GetDesktopWindow();
Expand Down
30 changes: 0 additions & 30 deletions ui/gfx/path_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,4 @@ HRGN CreateHRGNFromSkPath(const SkPath& path) {
return CreateHRGNFromSkRegion(region);
}

// See path_aura.cc for Aura definition of these methods:
#if !defined(USE_AURA)

NativeRegion Path::CreateNativeRegion() const {
return CreateHRGNFromSkPath(*this);
}

// static
NativeRegion Path::IntersectRegions(NativeRegion r1, NativeRegion r2) {
HRGN dest = CreateRectRgn(0, 0, 1, 1);
CombineRgn(dest, r1, r2, RGN_AND);
return dest;
}

// static
NativeRegion Path::CombineRegions(NativeRegion r1, NativeRegion r2) {
HRGN dest = CreateRectRgn(0, 0, 1, 1);
CombineRgn(dest, r1, r2, RGN_OR);
return dest;
}

// static
NativeRegion Path::SubtractRegion(NativeRegion r1, NativeRegion r2) {
HRGN dest = CreateRectRgn(0, 0, 1, 1);
CombineRgn(dest, r1, r2, RGN_DIFF);
return dest;
}

#endif

} // namespace gfx

0 comments on commit da8b9b7

Please sign in to comment.