| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.h
" | 5 #include "chrome/browser/metro_viewer/chrome_metro_viewer_process_host_aurawin.h
" |
| 6 | 6 |
| 7 #include "ash/display/display_info.h" | 7 #include "ash/display/display_info.h" |
| 8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
| 9 #include "ash/host/ash_remote_window_tree_host_win.h" | 9 #include "ash/host/ash_remote_window_tree_host_win.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "ash/wm/window_positioner.h" | 11 #include "ash/wm/window_positioner.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/browser_process_platform_part_aurawin.h" | 16 #include "chrome/browser/browser_process_platform_part_aurawin.h" |
| 17 #include "chrome/browser/browser_shutdown.h" | 17 #include "chrome/browser/browser_shutdown.h" |
| 18 #include "chrome/browser/chrome_notification_types.h" | 18 #include "chrome/browser/chrome_notification_types.h" |
| 19 #include "chrome/browser/lifetime/application_lifetime.h" | 19 #include "chrome/browser/lifetime/application_lifetime.h" |
| 20 #include "chrome/browser/lifetime/browser_keep_alive.h" |
| 20 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
| 21 #include "chrome/browser/search_engines/template_url_service_factory.h" | 22 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 22 #include "chrome/browser/ui/ash/ash_init.h" | 23 #include "chrome/browser/ui/ash/ash_init.h" |
| 23 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_list.h" | 25 #include "chrome/browser/ui/browser_list.h" |
| 25 #include "chrome/browser/ui/browser_navigator.h" | 26 #include "chrome/browser/ui/browser_navigator.h" |
| 26 #include "chrome/browser/ui/browser_navigator_params.h" | 27 #include "chrome/browser/ui/browser_navigator_params.h" |
| 27 #include "chrome/browser/ui/browser_window.h" | 28 #include "chrome/browser/ui/browser_window.h" |
| 28 #include "chrome/browser/ui/host_desktop.h" | 29 #include "chrome/browser/ui/host_desktop.h" |
| 29 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 30 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 params.host_desktop_type = chrome::HOST_DESKTOP_TYPE_ASH; | 67 params.host_desktop_type = chrome::HOST_DESKTOP_TYPE_ASH; |
| 67 chrome::Navigate(¶ms); | 68 chrome::Navigate(¶ms); |
| 68 } | 69 } |
| 69 | 70 |
| 70 } // namespace | 71 } // namespace |
| 71 | 72 |
| 72 ChromeMetroViewerProcessHost::ChromeMetroViewerProcessHost() | 73 ChromeMetroViewerProcessHost::ChromeMetroViewerProcessHost() |
| 73 : MetroViewerProcessHost( | 74 : MetroViewerProcessHost( |
| 74 content::BrowserThread::GetMessageLoopProxyForThread( | 75 content::BrowserThread::GetMessageLoopProxyForThread( |
| 75 content::BrowserThread::IO)) { | 76 content::BrowserThread::IO)) { |
| 76 chrome::IncrementKeepAliveCount(); | 77 keep_alive_.reset(new browser_lifetime::ScopedKeepAlive); |
| 77 } | 78 } |
| 78 | 79 |
| 79 ChromeMetroViewerProcessHost::~ChromeMetroViewerProcessHost() { | 80 ChromeMetroViewerProcessHost::~ChromeMetroViewerProcessHost() { |
| 81 DCHECK(!keep_alive_); |
| 80 } | 82 } |
| 81 | 83 |
| 82 void ChromeMetroViewerProcessHost::OnChannelError() { | 84 void ChromeMetroViewerProcessHost::OnChannelError() { |
| 83 // TODO(cpu): At some point we only close the browser. Right now this | 85 // TODO(cpu): At some point we only close the browser. Right now this |
| 84 // is very convenient for developing. | 86 // is very convenient for developing. |
| 85 DVLOG(1) << "viewer channel error : Quitting browser"; | 87 DVLOG(1) << "viewer channel error : Quitting browser"; |
| 86 | 88 |
| 87 // Unset environment variable to let breakpad know that metro process wasn't | 89 // Unset environment variable to let breakpad know that metro process wasn't |
| 88 // connected. | 90 // connected. |
| 89 ::SetEnvironmentVariableA(env_vars::kMetroConnected, NULL); | 91 ::SetEnvironmentVariableA(env_vars::kMetroConnected, NULL); |
| 90 | 92 |
| 91 // It seems possible that channel is connected, but ASH desktop is not yet | 93 // It seems possible that channel is connected, but ASH desktop is not yet |
| 92 // created (instance is still NULL) and we receive channel error. | 94 // created (instance is still NULL) and we receive channel error. |
| 93 if (aura::RemoteWindowTreeHostWin::Instance()) { | 95 if (aura::RemoteWindowTreeHostWin::Instance()) { |
| 94 aura::RemoteWindowTreeHostWin::Instance()->Disconnected(); | 96 aura::RemoteWindowTreeHostWin::Instance()->Disconnected(); |
| 95 | 97 |
| 96 chrome::DecrementKeepAliveCount(); | 98 keep_alive_.reset(); |
| 97 | 99 |
| 98 // If browser is trying to quit, we shouldn't reenter the process. | 100 // If browser is trying to quit, we shouldn't reenter the process. |
| 99 // TODO(shrikant): In general there seem to be issues with how AttemptExit | 101 // TODO(shrikant): In general there seem to be issues with how AttemptExit |
| 100 // reentry works. In future release please clean up related code. | 102 // reentry works. In future release please clean up related code. |
| 101 if (!browser_shutdown::IsTryingToQuit()) { | 103 if (!browser_shutdown::IsTryingToQuit()) { |
| 102 CloseOpenAshBrowsers(); | 104 CloseOpenAshBrowsers(); |
| 103 chrome::CloseAsh(); | 105 chrome::CloseAsh(); |
| 104 } | 106 } |
| 105 // Tell the rest of Chrome about it. | 107 // Tell the rest of Chrome about it. |
| 106 content::NotificationService::current()->Notify( | 108 content::NotificationService::current()->Notify( |
| 107 chrome::NOTIFICATION_ASH_SESSION_ENDED, | 109 chrome::NOTIFICATION_ASH_SESSION_ENDED, |
| 108 content::NotificationService::AllSources(), | 110 content::NotificationService::AllSources(), |
| 109 content::NotificationService::NoDetails()); | 111 content::NotificationService::NoDetails()); |
| 110 return; | 112 return; |
| 111 } | 113 } |
| 112 | 114 |
| 113 chrome::DecrementKeepAliveCount(); | 115 keep_alive_.reset(); |
| 114 | 116 |
| 115 // This will delete the MetroViewerProcessHost object. Don't access member | 117 // This will delete the MetroViewerProcessHost object. Don't access member |
| 116 // variables/functions after this call. | 118 // variables/functions after this call. |
| 117 g_browser_process->platform_part()->OnMetroViewerProcessTerminated(); | 119 g_browser_process->platform_part()->OnMetroViewerProcessTerminated(); |
| 118 } | 120 } |
| 119 | 121 |
| 120 void ChromeMetroViewerProcessHost::OnChannelConnected(int32 /*peer_pid*/) { | 122 void ChromeMetroViewerProcessHost::OnChannelConnected(int32 /*peer_pid*/) { |
| 121 DVLOG(1) << "ChromeMetroViewerProcessHost::OnChannelConnected: "; | 123 DVLOG(1) << "ChromeMetroViewerProcessHost::OnChannelConnected: "; |
| 122 // Set environment variable to let breakpad know that metro process was | 124 // Set environment variable to let breakpad know that metro process was |
| 123 // connected. | 125 // connected. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 void ChromeMetroViewerProcessHost::OnWindowSizeChanged(uint32 width, | 172 void ChromeMetroViewerProcessHost::OnWindowSizeChanged(uint32 width, |
| 171 uint32 height) { | 173 uint32 height) { |
| 172 std::vector<ash::DisplayInfo> info_list; | 174 std::vector<ash::DisplayInfo> info_list; |
| 173 info_list.push_back(ash::DisplayInfo::CreateFromSpec( | 175 info_list.push_back(ash::DisplayInfo::CreateFromSpec( |
| 174 base::StringPrintf("%dx%d*%f", width, height, gfx::GetDPIScale()))); | 176 base::StringPrintf("%dx%d*%f", width, height, gfx::GetDPIScale()))); |
| 175 ash::Shell::GetInstance()->display_manager()->OnNativeDisplaysChanged( | 177 ash::Shell::GetInstance()->display_manager()->OnNativeDisplaysChanged( |
| 176 info_list); | 178 info_list); |
| 177 aura::RemoteWindowTreeHostWin::Instance()->HandleWindowSizeChanged(width, | 179 aura::RemoteWindowTreeHostWin::Instance()->HandleWindowSizeChanged(width, |
| 178 height); | 180 height); |
| 179 } | 181 } |
| OLD | NEW |