#include "chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.h"
+#include "ash/display/display_info.h"
+#include "ash/display/display_manager.h"
#include "ash/shell.h"
+#include "ash/wm/window_positioner.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
+#include "base/strings/stringprintf.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_process_platform_part_aurawin.h"
+#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/page_navigator.h"
#include "content/public/browser/web_contents.h"
-#include "ui/aura/remote_root_window_host_win.h"
-#include "ui/surface/accelerated_surface_win.h"
+#include "ui/aura/remote_window_tree_host_win.h"
#include "url/gurl.h"
namespace {
void OpenURL(const GURL& url) {
chrome::NavigateParams params(
- ProfileManager::GetDefaultProfileOrOffTheRecord(),
+ ProfileManager::GetActiveUserProfile(),
GURL(url),
content::PAGE_TRANSITION_TYPED);
params.disposition = NEW_FOREGROUND_TAB;
void ChromeMetroViewerProcessHost::OnChannelError() {
// TODO(cpu): At some point we only close the browser. Right now this
// is very convenient for developing.
- DLOG(INFO) << "viewer channel error : Quitting browser";
+ DVLOG(1) << "viewer channel error : Quitting browser";
// Unset environment variable to let breakpad know that metro process wasn't
// connected.
::SetEnvironmentVariableA(env_vars::kMetroConnected, NULL);
- aura::RemoteRootWindowHostWin::Instance()->Disconnected();
+ aura::RemoteWindowTreeHostWin::Instance()->Disconnected();
g_browser_process->ReleaseModule();
- CloseOpenAshBrowsers();
- chrome::CloseAsh();
+
+ // If browser is trying to quit, we shouldn't reenter the process.
+ // TODO(shrikant): In general there seem to be issues with how AttemptExit
+ // reentry works. In future release please clean up related code.
+ if (!browser_shutdown::IsTryingToQuit()) {
+ CloseOpenAshBrowsers();
+ chrome::CloseAsh();
+ }
// Tell the rest of Chrome about it.
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_ASH_SESSION_ENDED,
}
void ChromeMetroViewerProcessHost::OnChannelConnected(int32 /*peer_pid*/) {
- DLOG(INFO) << "ChromeMetroViewerProcessHost::OnChannelConnected: ";
+ DVLOG(1) << "ChromeMetroViewerProcessHost::OnChannelConnected: ";
// Set environment variable to let breakpad know that metro process was
// connected.
::SetEnvironmentVariableA(env_vars::kMetroConnected, "1");
if (!content::GpuDataManager::GetInstance()->GpuAccessAllowed(NULL)) {
- DLOG(INFO) << "No GPU access, attempting to restart in Desktop\n";
+ DVLOG(1) << "No GPU access, attempting to restart in Desktop\n";
chrome::AttemptRestartToDesktopMode();
}
}
void ChromeMetroViewerProcessHost::OnSetTargetSurface(
gfx::NativeViewId target_surface) {
HWND hwnd = reinterpret_cast<HWND>(target_surface);
- // Tell our root window host that the viewer has connected.
- aura::RemoteRootWindowHostWin::Instance()->Connected(this, hwnd);
+ // Make hwnd available as early as possible for proper InputMethod
+ // initialization.
+ aura::RemoteWindowTreeHostWin::Instance()->SetRemoteWindowHandle(hwnd);
+
// Now start the Ash shell environment.
chrome::OpenAsh();
- ash::Shell::GetInstance()->CreateLauncher();
- ash::Shell::GetInstance()->ShowLauncher();
+ ash::Shell::GetInstance()->CreateShelf();
+ ash::Shell::GetInstance()->ShowShelf();
+
+ // Tell our root window host that the viewer has connected.
+ aura::RemoteWindowTreeHostWin::Instance()->Connected(this);
+
+ // On Windows 8 ASH we default to SHOW_STATE_MAXIMIZED for the browser
+ // window. This is to ensure that we honor metro app conventions by default.
+ ash::WindowPositioner::SetMaximizeFirstWindow(true);
// Tell the rest of Chrome that Ash is running.
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_ASH_SESSION_STARTED,
content::NotificationService::NoDetails());
}
-void ChromeMetroViewerProcessHost::OnOpenURL(const string16& url) {
+void ChromeMetroViewerProcessHost::OnOpenURL(const base::string16& url) {
OpenURL(GURL(url));
}
void ChromeMetroViewerProcessHost::OnHandleSearchRequest(
- const string16& search_string) {
+ const base::string16& search_string) {
GURL url(GetDefaultSearchURLForSearchTerms(
- ProfileManager::GetDefaultProfileOrOffTheRecord(), search_string));
+ ProfileManager::GetActiveUserProfile(), search_string));
if (url.is_valid())
OpenURL(url);
}
+
+void ChromeMetroViewerProcessHost::OnWindowSizeChanged(uint32 width,
+ uint32 height) {
+ std::vector<ash::internal::DisplayInfo> info_list;
+ info_list.push_back(ash::internal::DisplayInfo::CreateFromSpec(
+ base::StringPrintf("%dx%d", width, height)));
+ ash::Shell::GetInstance()->display_manager()->OnNativeDisplaysChanged(
+ info_list);
+ aura::RemoteWindowTreeHostWin::Instance()->HandleWindowSizeChanged(width,
+ height);
+}