Chromium Code Reviews| 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/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "base/environment.h" | |
| 8 #include "base/logging.h" | 9 #include "base/logging.h" |
| 9 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/strings/string_number_conversions.h" | |
| 10 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/browser_process_platform_part_aurawin.h" | 14 #include "chrome/browser/browser_process_platform_part_aurawin.h" |
| 12 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 16 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/browser/search_engines/util.h" | 17 #include "chrome/browser/search_engines/util.h" |
| 15 #include "chrome/browser/ui/ash/ash_init.h" | 18 #include "chrome/browser/ui/ash/ash_init.h" |
| 16 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
| 18 #include "chrome/browser/ui/browser_list.h" | 21 #include "chrome/browser/ui/browser_list.h" |
| 19 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
| 20 #include "chrome/browser/ui/host_desktop.h" | 23 #include "chrome/browser/ui/host_desktop.h" |
| 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 24 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 25 #include "chrome/common/env_vars.h" | |
| 22 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
| 24 #include "content/public/browser/page_navigator.h" | 28 #include "content/public/browser/page_navigator.h" |
| 25 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
| 26 #include "ui/aura/remote_root_window_host_win.h" | 30 #include "ui/aura/remote_root_window_host_win.h" |
| 27 #include "ui/surface/accelerated_surface_win.h" | 31 #include "ui/surface/accelerated_surface_win.h" |
| 28 #include "url/gurl.h" | 32 #include "url/gurl.h" |
| 29 | 33 |
| 30 namespace { | 34 namespace { |
| 31 | 35 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 60 : MetroViewerProcessHost( | 64 : MetroViewerProcessHost( |
| 61 content::BrowserThread::GetMessageLoopProxyForThread( | 65 content::BrowserThread::GetMessageLoopProxyForThread( |
| 62 content::BrowserThread::IO)) { | 66 content::BrowserThread::IO)) { |
| 63 g_browser_process->AddRefModule(); | 67 g_browser_process->AddRefModule(); |
| 64 } | 68 } |
| 65 | 69 |
| 66 void ChromeMetroViewerProcessHost::OnChannelError() { | 70 void ChromeMetroViewerProcessHost::OnChannelError() { |
| 67 // TODO(cpu): At some point we only close the browser. Right now this | 71 // TODO(cpu): At some point we only close the browser. Right now this |
| 68 // is very convenient for developing. | 72 // is very convenient for developing. |
| 69 DLOG(INFO) << "viewer channel error : Quitting browser"; | 73 DLOG(INFO) << "viewer channel error : Quitting browser"; |
| 74 | |
| 75 // Set environment variable to let breakpad know that metro process wasn't | |
| 76 // connected. | |
| 77 scoped_ptr<base::Environment> env(base::Environment::Create()); | |
|
cpu_(ooo_6.6-7.5)
2013/08/27 17:40:37
don't use this method, just call the windows api d
Shrikant Kelkar
2013/08/27 22:29:30
Done.
| |
| 78 env->UnSetVar(env_vars::kMetroConnected); | |
| 79 | |
| 70 aura::RemoteRootWindowHostWin::Instance()->Disconnected(); | 80 aura::RemoteRootWindowHostWin::Instance()->Disconnected(); |
| 71 g_browser_process->ReleaseModule(); | 81 g_browser_process->ReleaseModule(); |
| 72 CloseOpenAshBrowsers(); | 82 CloseOpenAshBrowsers(); |
| 73 chrome::CloseAsh(); | 83 chrome::CloseAsh(); |
| 74 // Tell the rest of Chrome about it. | 84 // Tell the rest of Chrome about it. |
| 75 content::NotificationService::current()->Notify( | 85 content::NotificationService::current()->Notify( |
| 76 chrome::NOTIFICATION_ASH_SESSION_ENDED, | 86 chrome::NOTIFICATION_ASH_SESSION_ENDED, |
| 77 content::NotificationService::AllSources(), | 87 content::NotificationService::AllSources(), |
| 78 content::NotificationService::NoDetails()); | 88 content::NotificationService::NoDetails()); |
| 79 | 89 |
| 80 // This will delete the MetroViewerProcessHost object. Don't access member | 90 // This will delete the MetroViewerProcessHost object. Don't access member |
| 81 // variables/functions after this call. | 91 // variables/functions after this call. |
| 82 g_browser_process->platform_part()->OnMetroViewerProcessTerminated(); | 92 g_browser_process->platform_part()->OnMetroViewerProcessTerminated(); |
| 83 } | 93 } |
| 84 | 94 |
| 95 void ChromeMetroViewerProcessHost::OnChannelConnected(int32 /*peer_pid*/) { | |
| 96 DLOG(INFO) << "ChromeMetroViewerProcessHost::OnChannelConnected: "; | |
| 97 // Set environment variable to let breakpad know that metro process was | |
| 98 // connected. | |
| 99 scoped_ptr<base::Environment> env(base::Environment::Create()); | |
| 100 env->SetVar(env_vars::kMetroConnected, "1"); | |
| 101 } | |
| 102 | |
| 85 void ChromeMetroViewerProcessHost::OnSetTargetSurface( | 103 void ChromeMetroViewerProcessHost::OnSetTargetSurface( |
| 86 gfx::NativeViewId target_surface) { | 104 gfx::NativeViewId target_surface) { |
| 87 DLOG(INFO) << __FUNCTION__ << ", target_surface = " << target_surface; | 105 DLOG(INFO) << __FUNCTION__ << ", target_surface = " << target_surface; |
| 88 HWND hwnd = reinterpret_cast<HWND>(target_surface); | 106 HWND hwnd = reinterpret_cast<HWND>(target_surface); |
| 89 chrome::OpenAsh(); | 107 chrome::OpenAsh(); |
| 90 scoped_refptr<AcceleratedPresenter> any_window = | 108 scoped_refptr<AcceleratedPresenter> any_window = |
| 91 AcceleratedPresenter::GetForWindow(NULL); | 109 AcceleratedPresenter::GetForWindow(NULL); |
| 92 any_window->SetNewTargetWindow(hwnd); | 110 any_window->SetNewTargetWindow(hwnd); |
| 93 aura::RemoteRootWindowHostWin::Instance()->Connected(this); | 111 aura::RemoteRootWindowHostWin::Instance()->Connected(this); |
| 94 ash::Shell::GetInstance()->CreateLauncher(); | 112 ash::Shell::GetInstance()->CreateLauncher(); |
| 95 ash::Shell::GetInstance()->ShowLauncher(); | 113 ash::Shell::GetInstance()->ShowLauncher(); |
| 96 // Tell the rest of Chrome that Ash is running. | 114 // Tell the rest of Chrome that Ash is running. |
| 97 content::NotificationService::current()->Notify( | 115 content::NotificationService::current()->Notify( |
| 98 chrome::NOTIFICATION_ASH_SESSION_STARTED, | 116 chrome::NOTIFICATION_ASH_SESSION_STARTED, |
| 99 content::NotificationService::AllSources(), | 117 content::NotificationService::AllSources(), |
| 100 content::NotificationService::NoDetails()); | 118 content::NotificationService::NoDetails()); |
| 101 } | 119 } |
| 102 | 120 |
| 103 void ChromeMetroViewerProcessHost::OnOpenURL(const string16& url) { | 121 void ChromeMetroViewerProcessHost::OnOpenURL(const string16& url) { |
| 104 OpenURL(GURL(url)); | 122 OpenURL(GURL(url)); |
| 105 } | 123 } |
| 106 | 124 |
| 107 void ChromeMetroViewerProcessHost::OnHandleSearchRequest( | 125 void ChromeMetroViewerProcessHost::OnHandleSearchRequest( |
| 108 const string16& search_string) { | 126 const string16& search_string) { |
| 109 GURL url(GetDefaultSearchURLForSearchTerms( | 127 GURL url(GetDefaultSearchURLForSearchTerms( |
| 110 ProfileManager::GetDefaultProfileOrOffTheRecord(), search_string)); | 128 ProfileManager::GetDefaultProfileOrOffTheRecord(), search_string)); |
| 111 if (url.is_valid()) | 129 if (url.is_valid()) |
| 112 OpenURL(url); | 130 OpenURL(url); |
| 113 } | 131 } |
| OLD | NEW |