diff options
-rw-r--r-- | app/os_exchange_data_provider_win.cc | 2 | ||||
-rw-r--r-- | base/scoped_bstr_win_unittest.cc | 54 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_uitest.cc | 21 | ||||
-rw-r--r-- | chrome/browser/views/select_profile_dialog.cc | 16 | ||||
-rw-r--r-- | chrome_frame/chrome_active_document.cc | 108 | ||||
-rw-r--r-- | chrome_frame/html_utils.cc | 28 | ||||
-rw-r--r-- | chrome_frame/html_utils.h | 6 | ||||
-rw-r--r-- | chrome_frame/urlmon_url_request.cc | 30 | ||||
-rw-r--r-- | gfx/icon_util.cc | 134 | ||||
-rw-r--r-- | gfx/icon_util.h | 20 | ||||
-rw-r--r-- | net/tools/dump_cache/cache_dumper.cc | 6 | ||||
-rw-r--r-- | sandbox/src/job_unittest.cc | 16 | ||||
-rw-r--r-- | sandbox/src/win_utils_unittest.cc | 2 |
13 files changed, 175 insertions, 268 deletions
diff --git a/app/os_exchange_data_provider_win.cc b/app/os_exchange_data_provider_win.cc index 9429b58..d0fb153 100644 --- a/app/os_exchange_data_provider_win.cc +++ b/app/os_exchange_data_provider_win.cc @@ -127,7 +127,7 @@ STDMETHODIMP FormatEtcEnumerator::Next( // This method copies count elements into |elements_array|. ULONG index = 0; while (cursor_ < contents_.size() && index < count) { - CloneFormatEtc(contents_.at(cursor_), &elements_array[index]); + CloneFormatEtc(contents_[cursor_], &elements_array[index]); ++cursor_; ++index; } diff --git a/base/scoped_bstr_win_unittest.cc b/base/scoped_bstr_win_unittest.cc index 276f13b..fbb327a 100644 --- a/base/scoped_bstr_win_unittest.cc +++ b/base/scoped_bstr_win_unittest.cc @@ -9,14 +9,14 @@ namespace { static const wchar_t kTestString1[] = L"123"; static const wchar_t kTestString2[] = L"456789"; -uint32 test1_len = arraysize(kTestString1) - 1; -uint32 test2_len = arraysize(kTestString2) - 1; +size_t test1_len = arraysize(kTestString1) - 1; +size_t test2_len = arraysize(kTestString2) - 1; void DumbBstrTests() { ScopedBstr b; EXPECT_TRUE(b == NULL); - EXPECT_TRUE(b.Length() == 0); - EXPECT_TRUE(b.ByteLength() == 0); + EXPECT_EQ(0, b.Length()); + EXPECT_EQ(0, b.ByteLength()); b.Reset(NULL); EXPECT_TRUE(b == NULL); EXPECT_TRUE(b.Release() == NULL); @@ -31,17 +31,17 @@ void GiveMeABstr(BSTR* ret) { void BasicBstrTests() { ScopedBstr b1(kTestString1); - EXPECT_TRUE(b1.Length() == test1_len); - EXPECT_TRUE(b1.ByteLength() == test1_len * sizeof(kTestString1[0])); + EXPECT_EQ(test1_len, b1.Length()); + EXPECT_EQ(test1_len * sizeof(kTestString1[0]), b1.ByteLength()); ScopedBstr b2; b1.Swap(b2); - EXPECT_TRUE(b2.Length() == test1_len); - EXPECT_TRUE(b1.Length() == 0); - EXPECT_TRUE(lstrcmpW(b2, kTestString1) == 0); + EXPECT_EQ(test1_len, b2.Length()); + EXPECT_EQ(0, b1.Length()); + EXPECT_EQ(0, lstrcmp(b2, kTestString1)); BSTR tmp = b2.Release(); EXPECT_TRUE(tmp != NULL); - EXPECT_TRUE(lstrcmpW(tmp, kTestString1) == 0); + EXPECT_EQ(0, lstrcmp(tmp, kTestString1)); EXPECT_TRUE(b2 == NULL); SysFreeString(tmp); @@ -49,18 +49,18 @@ void BasicBstrTests() { EXPECT_TRUE(b2 != NULL); b2.Reset(); EXPECT_TRUE(b2.AllocateBytes(100) != NULL); - EXPECT_TRUE(b2.ByteLength() == 100); - EXPECT_TRUE(b2.Length() == 100 / sizeof(kTestString1[0])); - lstrcpyW(static_cast<BSTR>(b2), kTestString1); - EXPECT_TRUE(lstrlen(b2) == static_cast<int>(test1_len)); - EXPECT_TRUE(b2.Length() == 100 / sizeof(kTestString1[0])); + EXPECT_EQ(100, b2.ByteLength()); + EXPECT_EQ(100 / sizeof(kTestString1[0]), b2.Length()); + lstrcpy(static_cast<BSTR>(b2), kTestString1); + EXPECT_EQ(test1_len, lstrlen(b2)); + EXPECT_EQ(100 / sizeof(kTestString1[0]), b2.Length()); b2.SetByteLen(lstrlen(b2) * sizeof(kTestString2[0])); - EXPECT_TRUE(lstrlen(b2) == static_cast<int>(b2.Length())); + EXPECT_EQ(b2.Length(), lstrlen(b2)); EXPECT_TRUE(b1.Allocate(kTestString2) != NULL); - EXPECT_TRUE(b1.Length() == test2_len); + EXPECT_EQ(test2_len, b1.Length()); b1.SetByteLen((test2_len - 1) * sizeof(kTestString2[0])); - EXPECT_TRUE(b1.Length() == test2_len - 1); + EXPECT_EQ(test2_len - 1, b1.Length()); } } // namespace @@ -76,18 +76,18 @@ TEST(ScopedBstrTest, ScopedBstr) { TEST(StackBstrTest, StackBstr) { ScopedBstr system_bstr(kSourceStr); StackBstrVar(kSourceStr, stack_bstr); - EXPECT_EQ(VarBstrCmp(system_bstr, stack_bstr, LOCALE_USER_DEFAULT, 0), - VARCMP_EQ); + EXPECT_EQ(VARCMP_EQ, + VarBstrCmp(system_bstr, stack_bstr, LOCALE_USER_DEFAULT, 0)); StackBstrVar(kSourceStrEmpty, empty); - uint32 l1 = SysStringLen(stack_bstr); - uint32 l2 = SysStringLen(StackBstr(kSourceStr)); - uint32 l3 = SysStringLen(system_bstr); - EXPECT_TRUE(l1 == l2); - EXPECT_TRUE(l2 == l3); - EXPECT_TRUE(SysStringLen(empty) == 0); + UINT l1 = SysStringLen(stack_bstr); + UINT l2 = SysStringLen(StackBstr(kSourceStr)); + UINT l3 = SysStringLen(system_bstr); + EXPECT_EQ(l1, l2); + EXPECT_EQ(l2, l3); + EXPECT_EQ(0, SysStringLen(empty)); const wchar_t one_more_test[] = L"this is my const string"; EXPECT_EQ(SysStringLen(StackBstr(one_more_test)), - lstrlenW(one_more_test)); + lstrlen(one_more_test)); } diff --git a/chrome/browser/extensions/extension_uitest.cc b/chrome/browser/extensions/extension_uitest.cc index 9adb732..b9554d0 100644 --- a/chrome/browser/extensions/extension_uitest.cc +++ b/chrome/browser/extensions/extension_uitest.cc @@ -155,15 +155,15 @@ TEST_F(ExtensionTestSimpleApiCall, FLAKY_RunTest) { reinterpret_cast<DictionaryValue*>(message_value.get()); std::string result; ASSERT_TRUE(message_dict->GetString(keys::kAutomationNameKey, &result)); - EXPECT_EQ(result, "tabs.remove"); + EXPECT_EQ("tabs.remove", result); - result = ""; + result.clear(); ASSERT_TRUE(message_dict->GetString(keys::kAutomationArgsKey, &result)); - EXPECT_NE(result, ""); + EXPECT_FALSE(result.empty()); - int callback_id = 0xBAADF00D; + int callback_id = 123456789; message_dict->GetInteger(keys::kAutomationRequestIdKey, &callback_id); - EXPECT_NE(callback_id, static_cast<int>(0xBAADF00D)); + EXPECT_NE(callback_id, 123456789); bool has_callback = true; EXPECT_TRUE(message_dict->GetBoolean(keys::kAutomationHasCallbackKey, @@ -212,7 +212,7 @@ public: &has_callback)); if (messages_received_ == 1) { - EXPECT_EQ(function_name, "tabs.getSelected"); + EXPECT_EQ("tabs.getSelected", function_name); EXPECT_GE(request_id, 0); EXPECT_TRUE(has_callback); @@ -241,7 +241,7 @@ public: keys::kAutomationOrigin, keys::kAutomationResponseTarget); } else if (messages_received_ == 2) { - EXPECT_EQ(function_name, "tabs.remove"); + EXPECT_EQ("tabs.remove", function_name); EXPECT_FALSE(has_callback); std::string args; @@ -383,7 +383,7 @@ void ExtensionTestBrowserEvents::HandleMessageFromChrome( namespace keys = extension_automation_constants; ASSERT_TRUE(tab_ != NULL); - ASSERT_TRUE(message.length() > 0); + ASSERT_FALSE(message.empty()); if (target == keys::kAutomationRequestTarget) { // This should be a request for the current window. We don't need to @@ -396,7 +396,7 @@ void ExtensionTestBrowserEvents::HandleMessageFromChrome( std::string name; ASSERT_TRUE(message_dict->GetString(keys::kAutomationNameKey, &name)); - ASSERT_STREQ(name.c_str(), "windows.getCurrent"); + ASSERT_EQ("windows.getCurrent", name); // Send an OpenChannelToExtension message to chrome. Note: the JSON // reader expects quoted property keys. See the comment in @@ -410,9 +410,8 @@ void ExtensionTestBrowserEvents::HandleMessageFromChrome( } else if (target == keys::kAutomationPortResponseTarget) { // This is a response to the open channel request. This means we know // that the port is ready to send us messages. Fire all the events now. - for (int i = 0; i < arraysize(events_); ++i) { + for (size_t i = 0; i < arraysize(events_); ++i) FireEvent(events_[i]); - } } else if (target == keys::kAutomationPortRequestTarget) { // This is the test extension calling us back. Make sure its telling // us that it received an event. We do this by checking to see if the diff --git a/chrome/browser/views/select_profile_dialog.cc b/chrome/browser/views/select_profile_dialog.cc index c92c2f8..f57fe6f 100644 --- a/chrome/browser/views/select_profile_dialog.cc +++ b/chrome/browser/views/select_profile_dialog.cc @@ -84,19 +84,11 @@ std::wstring SelectProfileDialog::GetWindowTitle() const { bool SelectProfileDialog::Accept() { size_t index = profile_combobox_->selected_item(); - if (index > profiles_.size()) { - NOTREACHED(); - return true; - } - - // If the user has selected <New Profile> from the drop down, then show the - // new profile dialog to the user. - if (index == profiles_.size()) { + DCHECK_LE(index, profiles_.size()); + if (index == profiles_.size()) NewProfileDialog::RunDialog(); - } else { - std::wstring profile_name = profiles_[index]; - UserDataManager::Get()->LaunchChromeForProfile(profile_name); - } + else + UserDataManager::Get()->LaunchChromeForProfile(profiles_[index]); return true; } diff --git a/chrome_frame/chrome_active_document.cc b/chrome_frame/chrome_active_document.cc index d9fa792..143a62b 100644 --- a/chrome_frame/chrome_active_document.cc +++ b/chrome_frame/chrome_active_document.cc @@ -120,9 +120,8 @@ HRESULT ChromeActiveDocument::FinalConstruct() { ChromeActiveDocument::~ChromeActiveDocument() { DLOG(INFO) << __FUNCTION__; - if (find_dialog_.IsWindow()) { + if (find_dialog_.IsWindow()) find_dialog_.DestroyWindow(); - } // ChromeFramePlugin BaseActiveX::Uninitialize(); @@ -140,9 +139,8 @@ STDMETHODIMP ChromeActiveDocument::DoVerb(LONG verb, // the user opens a new IE window with a URL that has us as the DocObject. // Here we refuse to be activated in-place and we will force IE to UIActivate // us. - if (OLEIVERB_INPLACEACTIVATE == verb) { + if (OLEIVERB_INPLACEACTIVATE == verb) return E_NOTIMPL; - } // Check if we should activate as a docobject or not // (client supports IOleDocumentSite) if (doc_site_) { @@ -150,15 +148,13 @@ STDMETHODIMP ChromeActiveDocument::DoVerb(LONG verb, case OLEIVERB_SHOW: { ScopedComPtr<IDocHostUIHandler> doc_host_handler; doc_host_handler.QueryFrom(doc_site_); - if (doc_host_handler.get()) { + if (doc_host_handler.get()) doc_host_handler->ShowUI(DOCHOSTUITYPE_BROWSE, this, this, NULL, NULL); - } } case OLEIVERB_OPEN: case OLEIVERB_UIACTIVATE: - if (!m_bUIActive) { + if (!m_bUIActive) return doc_site_->ActivateMe(NULL); - } break; } } @@ -208,9 +204,8 @@ STDMETHODIMP ChromeActiveDocument::Load(BOOL fully_avalable, IMoniker* moniker_name, LPBC bind_context, DWORD mode) { - if (NULL == moniker_name) { + if (NULL == moniker_name) return E_INVALIDARG; - } ScopedComPtr<IOleClientSite> client_site; if (bind_context) { @@ -272,9 +267,8 @@ STDMETHODIMP ChromeActiveDocument::Load(BOOL fully_avalable, return E_INVALIDARG; } - if (!is_chrome_protocol) { + if (!is_chrome_protocol) url_fetcher_.SetInfoForUrl(url, moniker_name, bind_context); - } THREAD_SAFE_UMA_HISTOGRAM_CUSTOM_COUNTS("ChromeFrame.FullTabLaunchType", is_chrome_protocol, 0, 1, 2); @@ -297,9 +291,8 @@ STDMETHODIMP ChromeActiveDocument::GetCurMoniker(IMoniker** moniker_name) { } STDMETHODIMP ChromeActiveDocument::GetClassID(CLSID* class_id) { - if (NULL == class_id) { + if (NULL == class_id) return E_POINTER; - } *class_id = GetObjectCLSID(); return S_OK; } @@ -316,9 +309,8 @@ STDMETHODIMP ChromeActiveDocument::QueryStatus(const GUID* cmd_group_guid, }; bool supported = (cmd_group_guid == NULL); - for (int i = 0; !supported && i < arraysize(supported_groups); ++i) { + for (int i = 0; !supported && i < arraysize(supported_groups); ++i) supported = (IsEqualGUID(*cmd_group_guid, *supported_groups[i]) != FALSE); - } if (!supported) { DLOG(INFO) << "unsupported command group: " @@ -330,9 +322,8 @@ STDMETHODIMP ChromeActiveDocument::QueryStatus(const GUID* cmd_group_guid, command_index++) { DLOG(INFO) << "Command id = " << commands[command_index].cmdID; if (enabled_commands_map_.find(commands[command_index].cmdID) != - enabled_commands_map_.end()) { + enabled_commands_map_.end()) commands[command_index].cmdf = OLECMDF_ENABLED; - } } return S_OK; } @@ -422,9 +413,8 @@ STDMETHODIMP ChromeActiveDocument::GetPositionCookie(DWORD* position_cookie) { } STDMETHODIMP ChromeActiveDocument::GetUrlForEvents(BSTR* url) { - if (NULL == url) { + if (NULL == url) return E_POINTER; - } *url = ::SysAllocString(url_); return S_OK; } @@ -481,21 +471,18 @@ HRESULT ChromeActiveDocument::IOleObject_SetClientSite( } ScopedComPtr<IDocHostUIHandler> doc_host_handler; - if (doc_site_) { + if (doc_site_) doc_host_handler.QueryFrom(doc_site_); - } - if (doc_host_handler.get()) { + if (doc_host_handler.get()) doc_host_handler->HideUI(); - } doc_site_.Release(); in_place_frame_.Release(); } - if (client_site != m_spClientSite) { + if (client_site != m_spClientSite) return BaseActiveX::IOleObject_SetClientSite(client_site); - } return S_OK; } @@ -505,9 +492,8 @@ HRESULT ChromeActiveDocument::ActiveXDocActivate(LONG verb) { m_bNegotiatedWnd = TRUE; if (!m_bInPlaceActive) { hr = m_spInPlaceSite->CanInPlaceActivate(); - if (FAILED(hr)) { + if (FAILED(hr)) return hr; - } m_spInPlaceSite->OnInPlaceActivate(); } m_bInPlaceActive = TRUE; @@ -543,17 +529,14 @@ HRESULT ChromeActiveDocument::ActiveXDocActivate(LONG verb) { if (!m_bUIActive) { m_bUIActive = TRUE; hr = m_spInPlaceSite->OnUIActivate(); - if (FAILED(hr)) { + if (FAILED(hr)) return hr; - } // set ourselves up in the host if (in_place_active_object) { - if (in_place_frame_) { + if (in_place_frame_) in_place_frame_->SetActiveObject(in_place_active_object, NULL); - } - if (in_place_ui_window) { + if (in_place_ui_window) in_place_ui_window->SetActiveObject(in_place_active_object, NULL); - } } } } @@ -575,9 +558,8 @@ void ChromeActiveDocument::OnNavigationStateChanged(int tab_handle, int flags, void ChromeActiveDocument::OnUpdateTargetUrl(int tab_handle, const std::wstring& new_target_url) { - if (in_place_frame_) { + if (in_place_frame_) in_place_frame_->SetStatusText(new_target_url.c_str()); - } } bool IsFindAccelerator(const MSG& msg) { @@ -688,9 +670,8 @@ void ChromeActiveDocument::UpdateNavigationState( StartsWith(static_cast<BSTR>(url_), kChromeAttachExternalTabPrefix, false); - if (new_navigation_info.url.is_valid()) { + if (new_navigation_info.url.is_valid()) url_.Allocate(UTF8ToWide(new_navigation_info.url.spec()).c_str()); - } if (is_internal_navigation) { ScopedComPtr<IDocObjectService> doc_object_svc; @@ -763,9 +744,8 @@ void ChromeActiveDocument::UpdateNavigationState( void ChromeActiveDocument::OnFindInPage() { TabProxy* tab = GetTabProxy(); if (tab) { - if (!find_dialog_.IsWindow()) { + if (!find_dialog_.IsWindow()) find_dialog_.Create(m_hWnd); - } find_dialog_.ShowWindow(SW_SHOW); } @@ -850,19 +830,12 @@ bool ChromeActiveDocument::PreProcessContextMenu(HMENU menu) { if (!browser_service || !travel_log) return true; - if (SUCCEEDED(travel_log->GetTravelEntry(browser_service, TLOG_BACK, NULL))) { - EnableMenuItem(menu, IDS_CONTENT_CONTEXT_BACK, MF_BYCOMMAND | MF_ENABLED); - } else { - EnableMenuItem(menu, IDS_CONTENT_CONTEXT_BACK, MF_BYCOMMAND | MFS_DISABLED); - } - - if (SUCCEEDED(travel_log->GetTravelEntry(browser_service, TLOG_FORE, NULL))) { - EnableMenuItem(menu, IDS_CONTENT_CONTEXT_FORWARD, - MF_BYCOMMAND | MF_ENABLED); - } else { - EnableMenuItem(menu, IDS_CONTENT_CONTEXT_FORWARD, - MF_BYCOMMAND | MFS_DISABLED); - } + EnableMenuItem(menu, IDS_CONTENT_CONTEXT_BACK, MF_BYCOMMAND | + (SUCCEEDED(travel_log->GetTravelEntry(browser_service, TLOG_BACK, NULL)) ? + MF_ENABLED : MF_DISABLED)); + EnableMenuItem(menu, IDS_CONTENT_CONTEXT_FORWARD, MF_BYCOMMAND | + (SUCCEEDED(travel_log->GetTravelEntry(browser_service, TLOG_FORE, NULL)) ? + MF_ENABLED : MF_DISABLED)); // Call base class (adds 'About' item) return BaseActiveX::PreProcessContextMenu(menu); @@ -893,16 +866,16 @@ HRESULT ChromeActiveDocument::IEExec(const GUID* cmd_group_guid, ScopedComPtr<IOleCommandTarget> frame_cmd_target; ScopedComPtr<IOleInPlaceSite> in_place_site(m_spInPlaceSite); - if (!in_place_site.get() && m_spClientSite != NULL) { + if (!in_place_site.get() && m_spClientSite != NULL) in_place_site.QueryFrom(m_spClientSite); - } if (in_place_site) hr = frame_cmd_target.QueryFrom(in_place_site); - if (frame_cmd_target) + if (frame_cmd_target) { hr = frame_cmd_target->Exec(cmd_group_guid, command_id, cmd_exec_opt, in_args, out_args); + } return hr; } @@ -1035,11 +1008,8 @@ bool ChromeActiveDocument::LaunchUrl(const std::wstring& url, automation_client_->SetUrlFetcher(&url_fetcher_); - if (InitializeAutomation(GetHostProcessName(false), L"", IsIEInPrivate(), - false)) - return true; - - return false; + return InitializeAutomation(GetHostProcessName(false), std::wstring(), + IsIEInPrivate(), false); } @@ -1186,8 +1156,8 @@ HRESULT ChromeActiveDocument::GetBrowserServiceAndTravelLog( if (travel_log) { hr = browser_service_local->GetTravelLog(travel_log); - DLOG_IF(INFO, !travel_log) << "browser_service->GetTravelLog failed: " - << hr; + DLOG_IF(INFO, !travel_log) << "browser_service->GetTravelLog failed: " << + hr; } if (browser_service) @@ -1203,9 +1173,8 @@ LRESULT ChromeActiveDocument::OnForward(WORD notify_code, WORD id, DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive()); DCHECK(web_browser2); - if (web_browser2) { + if (web_browser2) web_browser2->GoForward(); - } return 0; } @@ -1216,9 +1185,8 @@ LRESULT ChromeActiveDocument::OnBack(WORD notify_code, WORD id, DoQueryService(SID_SWebBrowserApp, m_spClientSite, web_browser2.Receive()); DCHECK(web_browser2); - if (web_browser2) { + if (web_browser2) web_browser2->GoBack(); - } return 0; } @@ -1242,11 +1210,9 @@ LRESULT ChromeActiveDocument::OnFirePrivacyChange(UINT message, WPARAM wparam, DCHECK(shell_browser.get() != NULL); ScopedComPtr<ITridentService2> trident_services; trident_services.QueryFrom(shell_browser); - if (trident_services) { + if (trident_services) trident_services->FirePrivacyImpactedStateChange(wparam); - } else { + else NOTREACHED() << "Failed to retrieve IWebBrowser2 interface."; - } return 0; } - diff --git a/chrome_frame/html_utils.cc b/chrome_frame/html_utils.cc index 8c8d6d3..3b71845 100644 --- a/chrome_frame/html_utils.cc +++ b/chrome_frame/html_utils.cc @@ -10,6 +10,7 @@ #include "base/string_util.h" #include "base/string_tokenizer.h" #include "chrome_frame/utils.h" +#include "net/base/net_util.h" const wchar_t kQuotes[] = L"\"'"; const char kXFrameOptionsHeader[] = "X-Frame-Options"; @@ -333,7 +334,7 @@ std::string GetDefaultUserAgentHeaderWithCFTag() { std::string GetDefaultUserAgent() { std::string ret; - DWORD size = MAX_PATH; // NOLINT + DWORD size = MAX_PATH; HRESULT hr = E_OUTOFMEMORY; for (int retries = 1; hr == E_OUTOFMEMORY && retries <= 10; ++retries) { hr = ::ObtainUserAgentString(0, WriteInto(&ret, size + 1), &size); @@ -341,8 +342,8 @@ std::string GetDefaultUserAgent() { size = MAX_PATH * retries; } else if (SUCCEEDED(hr)) { // Truncate the extra allocation. - DCHECK(size > 0); // NOLINT - ret.resize(size - 1); // NOLINT + DCHECK_GT(size, 0U); + ret.resize(size - 1); } } @@ -355,21 +356,16 @@ std::string GetDefaultUserAgent() { } bool HasFrameBustingHeader(const std::string& http_headers) { - net::HttpUtil::HeadersIterator it( - http_headers.begin(), http_headers.end(), "\r\n"); + // NOTE: We cannot use net::GetSpecificHeader() here since when there are + // multiple instances of a header that returns the first value seen, and we + // need to look at all instances. + net::HttpUtil::HeadersIterator it(http_headers.begin(), http_headers.end(), + "\r\n"); while (it.GetNext()) { - if (lstrcmpiA(it.name().c_str(), kXFrameOptionsHeader) == 0) { - std::string allow_all(kXFrameOptionsValueAllowAll); - if (it.values_end() - it.values_begin() != - static_cast<int>(allow_all.length()) || - !std::equal(it.values_begin(), it.values_end(), - allow_all.begin(), - CaseInsensitiveCompareASCII<const char>())) { - return true; - } - } + if (!lstrcmpiA(it.name().c_str(), kXFrameOptionsHeader) && + lstrcmpiA(it.values().c_str(), kXFrameOptionsValueAllowAll)) + return true; } - return false; } diff --git a/chrome_frame/html_utils.h b/chrome_frame/html_utils.h index daface10..21eb8cc 100644 --- a/chrome_frame/html_utils.h +++ b/chrome_frame/html_utils.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -140,7 +140,9 @@ std::string GetDefaultUserAgent(); const char* GetChromeFrameUserAgent(); // Returns true if there is a frame busting header (other than the do-nothing -// "X-Frame-Options: ALLOWALL") in the provided header block. +// "X-Frame-Options: ALLOWALL") in the provided header block. Note that there +// may be multiple X-Frame-Options values specified; if there is one anywhere in +// the list with a value other than ALLOWALL, this returns true. bool HasFrameBustingHeader(const std::string& http_headers); } // namespace http_utils diff --git a/chrome_frame/urlmon_url_request.cc b/chrome_frame/urlmon_url_request.cc index 922a951..73ea5c8 100644 --- a/chrome_frame/urlmon_url_request.cc +++ b/chrome_frame/urlmon_url_request.cc @@ -96,9 +96,8 @@ void UrlmonUrlRequest::Stop() { switch (state) { case Status::WORKING: status_.Cancel(); - if (binding_) { + if (binding_) binding_->Abort(); - } break; case Status::ABORTING: @@ -124,9 +123,8 @@ bool UrlmonUrlRequest::Read(int bytes_to_read) { return false; DCHECK((status_.get_state() != Status::DONE) == (binding_ != NULL)); - if (status_.get_state() == Status::ABORTING) { + if (status_.get_state() == Status::ABORTING) return true; - } // Send data if available. size_t bytes_copied = 0; @@ -233,15 +231,13 @@ size_t UrlmonUrlRequest::SendDataToDelegate(size_t bytes_to_read) { // while still using it. ScopedComPtr<IStream> pending(pending_data_); HRESULT hr = ReadStream(pending, bytes_to_read, &read_data); - if (read_data.empty()) { + if (read_data.empty()) pending_read_size_ = pending_data_read_save; - } // If we received S_FALSE it indicates that there is no more data in the // stream. Clear it to ensure that OnStopBinding correctly sends over the // response end notification to chrome. - if (hr == S_FALSE) { + if (hr == S_FALSE) pending_data_.Release(); - } } bytes_copied = read_data.length(); @@ -285,9 +281,8 @@ STDMETHODIMP UrlmonUrlRequest::OnProgress(ULONG progress, ULONG max_progress, ULONG status_code, LPCWSTR status_text) { DCHECK_EQ(thread_, PlatformThread::CurrentId()); - if (status_.get_state() != Status::WORKING) { + if (status_.get_state() != Status::WORKING) return S_OK; - } // Ignore any notifications received while we are in the pending state // waiting for the request to be initiated by Chrome. @@ -371,9 +366,8 @@ STDMETHODIMP UrlmonUrlRequest::OnStopBinding(HRESULT result, LPCWSTR error) { // Mark we a are done. status_.Done(); - if (result == INET_E_TERMINATED_BIND && terminate_requested()) { + if (result == INET_E_TERMINATED_BIND && terminate_requested()) terminate_bind_callback_->Run(moniker_, bind_context_); - } // We always return INET_E_TERMINATED_BIND from OnDataAvailable if (result == INET_E_TERMINATED_BIND) @@ -658,9 +652,8 @@ STDMETHODIMP UrlmonUrlRequest::OnResponse(DWORD dwResponseCode, STDMETHODIMP UrlmonUrlRequest::GetWindow(const GUID& guid_reason, HWND* parent_window) { - if (!parent_window) { + if (!parent_window) return E_INVALIDARG; - } #ifndef NDEBUG wchar_t guid[40] = {0}; @@ -797,9 +790,8 @@ HRESULT UrlmonUrlRequest::StartAsyncDownload() { hr = moniker_->BindToStorage(bind_context_, NULL, __uuidof(IStream), reinterpret_cast<void**>(stream.Receive())); - if (hr == S_OK) { + if (hr == S_OK) DCHECK(binding_ != NULL || status_.get_state() == Status::DONE); - } if (FAILED(hr)) { // TODO(joshia): Look into. This currently fails for: @@ -840,9 +832,8 @@ void UrlmonUrlRequest::ReleaseBindings() { // Do not release bind_context here! // We may get DownloadToHost request and therefore we want the bind_context // to be available. - if (bind_context_) { + if (bind_context_) ::RevokeBindStatusCallback(bind_context_, this); - } } net::Error UrlmonUrlRequest::HresultToNetError(HRESULT hr) { @@ -988,9 +979,8 @@ void UrlmonUrlRequestManager::ReadRequest(int request_id, int bytes_to_read) { DCHECK_EQ(0, calling_delegate_); scoped_refptr<UrlmonUrlRequest> request = LookupRequest(request_id); // if zero, it may just have had network error. - if (request) { + if (request) request->Read(bytes_to_read); - } } void UrlmonUrlRequestManager::DownloadRequestInHost(int request_id) { diff --git a/gfx/icon_util.cc b/gfx/icon_util.cc index 8ce2279..75435e0 100644 --- a/gfx/icon_util.cc +++ b/gfx/icon_util.cc @@ -41,9 +41,8 @@ HICON IconUtil::CreateHICONFromSkBitmap(const SkBitmap& bitmap) { SkAutoLockPixels bitmap_lock(bitmap); if ((bitmap.getConfig() != SkBitmap::kARGB_8888_Config) || (bitmap.width() <= 0) || (bitmap.height() <= 0) || - (bitmap.getPixels() == NULL)) { + (bitmap.getPixels() == NULL)) return NULL; - } // We start by creating a DIB which we'll use later on in order to create // the HICON. We use BITMAPV5HEADER since the bitmap we are about to convert @@ -105,9 +104,8 @@ SkBitmap* IconUtil::CreateSkBitmapFromHICON(HICON icon, const gfx::Size& s) { // We start with validating parameters. ICONINFO icon_info; if (!icon || !(::GetIconInfo(icon, &icon_info)) || - !icon_info.fIcon || s.IsEmpty()) { + !icon_info.fIcon || s.IsEmpty()) return NULL; - } // Allocating memory for the SkBitmap object. We are going to create an ARGB // bitmap so we should set the configuration appropriately. @@ -123,13 +121,9 @@ SkBitmap* IconUtil::CreateSkBitmapFromHICON(HICON icon, const gfx::Size& s) { BITMAPV5HEADER h; InitializeBitmapHeader(&h, s.width(), s.height()); HDC dc = ::GetDC(NULL); - unsigned int* bits; - HBITMAP dib = ::CreateDIBSection(dc, - reinterpret_cast<BITMAPINFO*>(&h), - DIB_RGB_COLORS, - reinterpret_cast<void**>(&bits), - NULL, - 0); + uint32* bits; + HBITMAP dib = ::CreateDIBSection(dc, reinterpret_cast<BITMAPINFO*>(&h), + DIB_RGB_COLORS, reinterpret_cast<void**>(&bits), NULL, 0); DCHECK(dib); HDC dib_dc = CreateCompatibleDC(dc); DCHECK(dib_dc); @@ -174,7 +168,7 @@ SkBitmap* IconUtil::CreateSkBitmapFromHICON(HICON icon, const gfx::Size& s) { // If the bitmap does not have an alpha channel, we need to build it using // the previously captured AND mask. Otherwise, we are done. if (!bitmap_has_alpha_channel) { - unsigned int* p = static_cast<unsigned int*>(bitmap->getPixels()); + uint32* p = static_cast<uint32*>(bitmap->getPixels()); for (size_t i = 0; i < num_pixels; ++p, ++i) { DCHECK_EQ((*p & 0xff000000), 0u); if (opaque[i]) @@ -199,36 +193,29 @@ bool IconUtil::CreateIconFileFromSkBitmap(const SkBitmap& bitmap, SkAutoLockPixels bitmap_lock(bitmap); if ((bitmap.getConfig() != SkBitmap::kARGB_8888_Config) || (bitmap.height() <= 0) || (bitmap.width() <= 0) || - (bitmap.getPixels() == NULL)) { + (bitmap.getPixels() == NULL)) return false; - } // We start by creating the file. - ScopedHandle icon_file(::CreateFile(icon_file_name.c_str(), - GENERIC_WRITE, - 0, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL)); - - if (icon_file.Get() == INVALID_HANDLE_VALUE) { + ScopedHandle icon_file(::CreateFile(icon_file_name.c_str(), GENERIC_WRITE, 0, + NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL)); + + if (icon_file.Get() == INVALID_HANDLE_VALUE) return false; - } // Creating a set of bitmaps corresponding to the icon images we'll end up // storing in the icon file. Each bitmap is created by resizing the given // bitmap to the desired size. std::vector<SkBitmap> bitmaps; CreateResizedBitmapSet(bitmap, &bitmaps); - int bitmap_count = static_cast<int>(bitmaps.size()); - DCHECK_GT(bitmap_count, 0); + DCHECK(!bitmaps.empty()); + size_t bitmap_count = bitmaps.size(); // Computing the total size of the buffer we need in order to store the // images in the desired icon format. - int buffer_size = ComputeIconFileBufferSize(bitmaps); + size_t buffer_size = ComputeIconFileBufferSize(bitmaps); unsigned char* buffer = new unsigned char[buffer_size]; - DCHECK_NE(buffer, static_cast<unsigned char*>(NULL)); + DCHECK(buffer != NULL); memset(buffer, 0, buffer_size); // Setting the information in the structures residing within the buffer. @@ -238,19 +225,15 @@ bool IconUtil::CreateIconFileFromSkBitmap(const SkBitmap& bitmap, ICONDIR* icon_dir = reinterpret_cast<ICONDIR*>(buffer); icon_dir->idType = kResourceTypeIcon; icon_dir->idCount = bitmap_count; - int icon_dir_count = bitmap_count - 1; - int offset = sizeof(ICONDIR) + (sizeof(ICONDIRENTRY) * icon_dir_count); - for (int i = 0; i < bitmap_count; i++) { + size_t icon_dir_count = bitmap_count - 1; // Note DCHECK(!bitmaps.empty())! + size_t offset = sizeof(ICONDIR) + (sizeof(ICONDIRENTRY) * icon_dir_count); + for (size_t i = 0; i < bitmap_count; i++) { ICONIMAGE* image = reinterpret_cast<ICONIMAGE*>(buffer + offset); DCHECK_LT(offset, buffer_size); - int icon_image_size = 0; - SetSingleIconImageInformation(bitmaps[i], - i, - icon_dir, - image, - offset, + size_t icon_image_size = 0; + SetSingleIconImageInformation(bitmaps[i], i, icon_dir, image, offset, &icon_image_size); - DCHECK_GT(icon_image_size, 0); + DCHECK_GT(icon_image_size, 0U); offset += icon_image_size; } DCHECK_EQ(offset, buffer_size); @@ -259,9 +242,8 @@ bool IconUtil::CreateIconFileFromSkBitmap(const SkBitmap& bitmap, DWORD bytes_written; bool delete_file = false; if (!WriteFile(icon_file.Get(), buffer, buffer_size, &bytes_written, NULL) || - static_cast<int>(bytes_written) != buffer_size) { + bytes_written != buffer_size) delete_file = true; - } ::CloseHandle(icon_file.Take()); delete [] buffer; @@ -273,15 +255,10 @@ bool IconUtil::CreateIconFileFromSkBitmap(const SkBitmap& bitmap, return !delete_file; } -int IconUtil::GetIconDimensionCount() { - return sizeof(icon_dimensions_) / sizeof(icon_dimensions_[0]); -} - bool IconUtil::PixelsHaveAlpha(const uint32* pixels, size_t num_pixels) { for (const uint32* end = pixels + num_pixels; pixels != end; ++pixels) { - if ((*pixels & 0xff000000) != 0) { + if ((*pixels & 0xff000000) != 0) return true; - } } return false; @@ -319,24 +296,20 @@ void IconUtil::InitializeBitmapHeader(BITMAPV5HEADER* header, int width, } void IconUtil::SetSingleIconImageInformation(const SkBitmap& bitmap, - int index, + size_t index, ICONDIR* icon_dir, ICONIMAGE* icon_image, - int image_offset, - int* image_byte_count) { - DCHECK_GE(index, 0); - DCHECK_NE(icon_dir, static_cast<ICONDIR*>(NULL)); - DCHECK_NE(icon_image, static_cast<ICONIMAGE*>(NULL)); - DCHECK_GT(image_offset, 0); - DCHECK_NE(image_byte_count, static_cast<int*>(NULL)); + size_t image_offset, + size_t* image_byte_count) { + DCHECK(icon_dir != NULL); + DCHECK(icon_image != NULL); + DCHECK_GT(image_offset, 0U); + DCHECK(image_byte_count != NULL); // We start by computing certain image values we'll use later on. - int xor_mask_size; - int and_mask_size; - int bytes_in_resource; + size_t xor_mask_size, bytes_in_resource; ComputeBitmapSizeComponents(bitmap, &xor_mask_size, - &and_mask_size, &bytes_in_resource); icon_dir->idEntries[index].bWidth = static_cast<BYTE>(bitmap.width()); @@ -378,12 +351,12 @@ void IconUtil::SetSingleIconImageInformation(const SkBitmap& bitmap, void IconUtil::CopySkBitmapBitsIntoIconBuffer(const SkBitmap& bitmap, unsigned char* buffer, - int buffer_size) { + size_t buffer_size) { SkAutoLockPixels bitmap_lock(bitmap); unsigned char* bitmap_ptr = static_cast<unsigned char*>(bitmap.getPixels()); - int bitmap_size = bitmap.height() * bitmap.width() * 4; + size_t bitmap_size = bitmap.height() * bitmap.width() * 4; DCHECK_EQ(buffer_size, bitmap_size); - for (int i = 0; i < bitmap_size; i += bitmap.width() * 4) { + for (size_t i = 0; i < bitmap_size; i += bitmap.width() * 4) { memcpy(buffer + bitmap_size - bitmap.width() * 4 - i, bitmap_ptr + i, bitmap.width() * 4); @@ -392,11 +365,11 @@ void IconUtil::CopySkBitmapBitsIntoIconBuffer(const SkBitmap& bitmap, void IconUtil::CreateResizedBitmapSet(const SkBitmap& bitmap_to_resize, std::vector<SkBitmap>* bitmaps) { - DCHECK_NE(bitmaps, static_cast<std::vector<SkBitmap>* >(NULL)); - DCHECK_EQ(static_cast<int>(bitmaps->size()), 0); + DCHECK(bitmaps != NULL); + DCHECK(bitmaps->empty()); bool inserted_original_bitmap = false; - for (int i = 0; i < GetIconDimensionCount(); i++) { + for (size_t i = 0; i < arraysize(icon_dimensions_); i++) { // If the dimensions of the bitmap we are resizing are the same as the // current dimensions, then we should insert the bitmap and not a resized // bitmap. If the bitmap's dimensions are smaller, we insert our bitmap @@ -421,31 +394,27 @@ void IconUtil::CreateResizedBitmapSet(const SkBitmap& bitmap_to_resize, icon_dimensions_[i], icon_dimensions_[i])); } - if (!inserted_original_bitmap) { + if (!inserted_original_bitmap) bitmaps->push_back(bitmap_to_resize); - } } -int IconUtil::ComputeIconFileBufferSize(const std::vector<SkBitmap>& set) { +size_t IconUtil::ComputeIconFileBufferSize(const std::vector<SkBitmap>& set) { + DCHECK(!set.empty()); + // We start by counting the bytes for the structures that don't depend on the // number of icon images. Note that sizeof(ICONDIR) already accounts for a // single ICONDIRENTRY structure, which is why we subtract one from the // number of bitmaps. - int total_buffer_size = 0; - total_buffer_size += sizeof(ICONDIR); - int bitmap_count = static_cast<int>(set.size()); + size_t total_buffer_size = sizeof(ICONDIR); + size_t bitmap_count = set.size(); total_buffer_size += sizeof(ICONDIRENTRY) * (bitmap_count - 1); - int dimension_count = GetIconDimensionCount(); - DCHECK_GE(bitmap_count, dimension_count); + DCHECK_GE(bitmap_count, arraysize(icon_dimensions_)); // Add the bitmap specific structure sizes. - for (int i = 0; i < bitmap_count; i++) { - int xor_mask_size; - int and_mask_size; - int bytes_in_resource; + for (size_t i = 0; i < bitmap_count; i++) { + size_t xor_mask_size, bytes_in_resource; ComputeBitmapSizeComponents(set[i], &xor_mask_size, - &and_mask_size, &bytes_in_resource); total_buffer_size += bytes_in_resource; } @@ -453,9 +422,8 @@ int IconUtil::ComputeIconFileBufferSize(const std::vector<SkBitmap>& set) { } void IconUtil::ComputeBitmapSizeComponents(const SkBitmap& bitmap, - int* xor_mask_size, - int* and_mask_size, - int* bytes_in_resource) { + size_t* xor_mask_size, + size_t* bytes_in_resource) { // The XOR mask size is easy to calculate since we only deal with 32bpp // images. *xor_mask_size = bitmap.width() * bitmap.height() * 4; @@ -481,9 +449,9 @@ void IconUtil::ComputeBitmapSizeComponents(const SkBitmap& bitmap, // number by the image height in order to get the total number of bytes for // the AND mask. Thus, for a 15X15 image, we need 15 * 4 which is 60 bytes // for the monochrome bitmap representing the AND mask. - int and_line_length = (bitmap.width() + 7) >> 3; + size_t and_line_length = (bitmap.width() + 7) >> 3; and_line_length = (and_line_length + 3) & ~3; - *and_mask_size = and_line_length * bitmap.height(); - int masks_size = *xor_mask_size + *and_mask_size; + size_t and_mask_size = and_line_length * bitmap.height(); + size_t masks_size = *xor_mask_size + and_mask_size; *bytes_in_resource = masks_size + sizeof(BITMAPINFOHEADER); } diff --git a/gfx/icon_util.h b/gfx/icon_util.h index 3e697e1..84ed12c 100644 --- a/gfx/icon_util.h +++ b/gfx/icon_util.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -125,9 +125,6 @@ class IconUtil { // The dimensions of the icon images we insert into the .ico file. static const int icon_dimensions_[]; - // Returns how many icon dimensions are defined. - static int GetIconDimensionCount(); - // Returns true if any pixel in the given pixels buffer has an non-zero alpha. static bool PixelsHaveAlpha(const uint32* pixels, size_t num_pixels); @@ -146,17 +143,17 @@ class IconUtil { // includes only the image data written into the memory pointed to by // |icon_image|. static void SetSingleIconImageInformation(const SkBitmap& bitmap, - int index, + size_t index, ICONDIR* icon_dir, ICONIMAGE* icon_image, - int image_offset, - int* image_byte_count); + size_t image_offset, + size_t* image_byte_count); // Copies the bits of an SkBitmap object into a buffer holding the bits of // the corresponding image for an icon within the .ico file. static void CopySkBitmapBitsIntoIconBuffer(const SkBitmap& bitmap, unsigned char* buffer, - int buffer_size); + size_t buffer_size); // Given a single bitmap, this function creates a set of bitmaps with // specific dimensions by resizing the given bitmap to the appropriate sizes. @@ -166,7 +163,7 @@ class IconUtil { // Given a set of bitmaps with varying dimensions, this function computes // the amount of memory needed in order to store the bitmaps as image icons // in a .ico file. - static int ComputeIconFileBufferSize(const std::vector<SkBitmap>& set); + static size_t ComputeIconFileBufferSize(const std::vector<SkBitmap>& set); // A helper function for computing various size components of a given bitmap. // The different sizes can be used within the various .ico file structures. @@ -184,9 +181,8 @@ class IconUtil { // and is not accounted for when computing the // different size components. static void ComputeBitmapSizeComponents(const SkBitmap& bitmap, - int* xor_mask_size, - int* and_mask_size, - int* bytes_in_resource); + size_t* xor_mask_size, + size_t* bytes_in_resource); // Prevent clients from instantiating objects of that class by declaring the // ctor/dtor as private. diff --git a/net/tools/dump_cache/cache_dumper.cc b/net/tools/dump_cache/cache_dumper.cc index a2e071a3..47602e6 100644 --- a/net/tools/dump_cache/cache_dumper.cc +++ b/net/tools/dump_cache/cache_dumper.cc @@ -89,10 +89,8 @@ bool DiskDumper::CreateEntry(const std::string& key, #ifdef WIN32_LARGE_FILENAME_SUPPORT entry_ = CreateFileW(file.c_str(), GENERIC_WRITE|GENERIC_READ, 0, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); - if (entry_ == INVALID_HANDLE_VALUE) { + if (entry_ == INVALID_HANDLE_VALUE) wprintf(L"CreateFileW (%s) failed: %d\n", file.c_str(), GetLastError()); - return false; - } return entry_ != INVALID_HANDLE_VALUE; #else entry_ = file_util::OpenFile(entry_path_, "w+"); @@ -147,7 +145,7 @@ bool DiskDumper::WriteEntry(disk_cache::Entry* entry, int index, int offset, std::string headers; const char *data; - int len; + size_t len; if (index == 0) { // Stream 0 is the headers. net::HttpResponseInfo response_info; bool truncated; diff --git a/sandbox/src/job_unittest.cc b/sandbox/src/job_unittest.cc index f7174e3..0f7010d 100644 --- a/sandbox/src/job_unittest.cc +++ b/sandbox/src/job_unittest.cc @@ -20,7 +20,7 @@ TEST(JobTest, TestCreation) { // check if the job exists. HANDLE job_handle = ::OpenJobObjectW(GENERIC_ALL, FALSE, L"my_test_job_name"); - ASSERT_NE(reinterpret_cast<HANDLE>(NULL), job_handle); + ASSERT_TRUE(job_handle != NULL); if (job_handle) CloseHandle(job_handle); @@ -28,7 +28,7 @@ TEST(JobTest, TestCreation) { // Check if the job is destroyed when the object goes out of scope. HANDLE job_handle = ::OpenJobObjectW(GENERIC_ALL, FALSE, L"my_test_job_name"); - ASSERT_EQ(reinterpret_cast<HANDLE>(NULL), job_handle); + ASSERT_TRUE(job_handle == NULL); ASSERT_EQ(ERROR_FILE_NOT_FOUND, ::GetLastError()); } @@ -42,14 +42,14 @@ TEST(JobTest, TestDetach) { ASSERT_EQ(ERROR_SUCCESS, job.Init(JOB_LOCKDOWN, L"my_test_job_name", 0)); job_handle = job.Detach(); - ASSERT_NE(reinterpret_cast<HANDLE>(NULL), job_handle); + ASSERT_TRUE(job_handle != NULL); } // Check to be sure that the job is still alive even after the object is gone // out of scope. HANDLE job_handle_dup = ::OpenJobObjectW(GENERIC_ALL, FALSE, L"my_test_job_name"); - ASSERT_NE(reinterpret_cast<HANDLE>(NULL), job_handle_dup); + ASSERT_TRUE(job_handle_dup != NULL); // Remove all references. if (job_handle_dup) @@ -60,7 +60,7 @@ TEST(JobTest, TestDetach) { // Check if the jbo is really dead. job_handle = ::OpenJobObjectW(GENERIC_ALL, FALSE, L"my_test_job_name"); - ASSERT_EQ(reinterpret_cast<HANDLE>(NULL), job_handle); + ASSERT_TRUE(job_handle == NULL); ASSERT_EQ(ERROR_FILE_NOT_FOUND, ::GetLastError()); } @@ -75,7 +75,7 @@ TEST(JobTest, TestExceptions) { JOB_OBJECT_UILIMIT_READCLIPBOARD)); job_handle = job.Detach(); - ASSERT_NE(reinterpret_cast<HANDLE>(NULL), job_handle); + ASSERT_TRUE(job_handle != NULL); JOBOBJECT_BASIC_UI_RESTRICTIONS jbur = {0}; DWORD size = sizeof(jbur); @@ -95,7 +95,7 @@ TEST(JobTest, TestExceptions) { ASSERT_EQ(ERROR_SUCCESS, job.Init(JOB_LOCKDOWN, L"my_test_job_name", 0)); job_handle = job.Detach(); - ASSERT_NE(reinterpret_cast<HANDLE>(NULL), job_handle); + ASSERT_TRUE(job_handle != NULL); JOBOBJECT_BASIC_UI_RESTRICTIONS jbur = {0}; DWORD size = sizeof(jbur); @@ -124,7 +124,7 @@ TEST(JobTest, NoInit) { Job job; ASSERT_EQ(ERROR_NO_DATA, job.UserHandleGrantAccess(NULL)); ASSERT_EQ(ERROR_NO_DATA, job.AssignProcessToJob(NULL)); - ASSERT_EQ(reinterpret_cast<HANDLE>(NULL), job.Detach()); + ASSERT_TRUE(job.Detach() == NULL); } // Tests the initialization of the job with different security level. diff --git a/sandbox/src/win_utils_unittest.cc b/sandbox/src/win_utils_unittest.cc index 27b49af..3afa78d 100644 --- a/sandbox/src/win_utils_unittest.cc +++ b/sandbox/src/win_utils_unittest.cc @@ -37,7 +37,7 @@ TEST(WinUtils, IsReparsePoint) { HANDLE dir = ::CreateFile(my_folder, FILE_ALL_ACCESS, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); - EXPECT_TRUE(INVALID_HANDLE_VALUE != dir); + EXPECT_NE(INVALID_HANDLE_VALUE, dir); std::wstring temp_dir_nt = std::wstring(L"\\??\\") + temp_directory; EXPECT_TRUE(SetReparsePoint(dir, temp_dir_nt.c_str())); |