| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/file_util.h" | |
| 6 #include "base/path_service.h" | |
| 7 #include "base/string_util.h" | |
| 8 #include "chrome/browser/tab_contents/about_internets_status_view.h" | |
| 9 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | |
| 10 | |
| 11 AboutInternetsStatusView::AboutInternetsStatusView() | |
| 12 : StatusView(TAB_CONTENTS_ABOUT_INTERNETS_STATUS_VIEW) {} | |
| 13 | |
| 14 AboutInternetsStatusView::~AboutInternetsStatusView() { | |
| 15 if (process_handle_.IsValid()) | |
| 16 TerminateProcess(process_handle_.Get(), 0); | |
| 17 } | |
| 18 | |
| 19 const std::wstring AboutInternetsStatusView::GetDefaultTitle() const { | |
| 20 return L"Don't Clog the Tubes!"; | |
| 21 } | |
| 22 | |
| 23 const std::wstring& AboutInternetsStatusView::GetTitle() const { | |
| 24 return title_; | |
| 25 } | |
| 26 | |
| 27 void AboutInternetsStatusView::OnCreate(const CRect& rect) { | |
| 28 HWND contents_hwnd = GetContainerHWND(); | |
| 29 STARTUPINFO startup_info; | |
| 30 memset(&startup_info, 0, sizeof(startup_info)); | |
| 31 startup_info.cb = sizeof(startup_info); | |
| 32 PROCESS_INFORMATION process_info = {0}; | |
| 33 | |
| 34 std::wstring path; | |
| 35 PathService::Get(base::DIR_SYSTEM, &path); | |
| 36 file_util::AppendToPath(&path, L"sspipes.scr"); | |
| 37 std::wstring parameters; | |
| 38 parameters.append(path.c_str()); | |
| 39 // Append the handle of the HWND that we want to render the pipes into. | |
| 40 parameters.append(L" /p "); | |
| 41 parameters.append( | |
| 42 Int64ToWString(reinterpret_cast<int64>(contents_hwnd)).c_str()); | |
| 43 BOOL result = | |
| 44 CreateProcess(NULL, | |
| 45 const_cast<LPWSTR>(parameters.c_str()), | |
| 46 NULL, // LPSECURITY_ATTRIBUTES lpProcessAttributes | |
| 47 NULL, // LPSECURITY_ATTRIBUTES lpThreadAttributes | |
| 48 FALSE, // BOOL bInheritHandles | |
| 49 CREATE_DEFAULT_ERROR_MODE, // DWORD dwCreationFlags | |
| 50 NULL, // LPVOID lpEnvironment | |
| 51 NULL, // LPCTSTR lpCurrentDirectory | |
| 52 &startup_info, // LPstartup_info lpstartup_info | |
| 53 &process_info); // LPPROCESS_INFORMATION | |
| 54 // lpProcessInformation | |
| 55 | |
| 56 if (result) { | |
| 57 title_ = GetDefaultTitle(); | |
| 58 CloseHandle(process_info.hThread); | |
| 59 process_handle_.Set(process_info.hProcess); | |
| 60 } else { | |
| 61 title_ = L"The Tubes are Clogged!"; | |
| 62 } | |
| 63 } | |
| 64 | |
| 65 void AboutInternetsStatusView::OnSize(const CRect& rect) { | |
| 66 // We're required to implement this because it is abstract, but we don't | |
| 67 // actually have anything to do right here. | |
| 68 } | |
| 69 | |
| OLD | NEW |