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