Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: chrome/browser/jumplist_win.cc

Issue 3823002: Move windows version-related stuff out of base/win_util and into base/win/win... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/jumplist_win.h" 5 #include "chrome/browser/jumplist_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shobjidl.h> 8 #include <shobjidl.h>
9 #include <propkey.h> 9 #include <propkey.h>
10 #include <propvarutil.h> 10 #include <propvarutil.h>
11 11
12 #include <string> 12 #include <string>
13 #include <vector> 13 #include <vector>
14 14
15 #include "app/l10n_util.h" 15 #include "app/l10n_util.h"
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/file_util.h" 18 #include "base/file_util.h"
19 #include "base/path_service.h" 19 #include "base/path_service.h"
20 #include "base/scoped_comptr_win.h" 20 #include "base/scoped_comptr_win.h"
21 #include "base/string_util.h" 21 #include "base/string_util.h"
22 #include "base/thread.h" 22 #include "base/thread.h"
23 #include "base/utf_string_conversions.h" 23 #include "base/utf_string_conversions.h"
24 #include "base/win_util.h" 24 #include "base/win/windows_version.h"
25 #include "chrome/browser/browser_thread.h" 25 #include "chrome/browser/browser_thread.h"
26 #include "chrome/browser/favicon_service.h" 26 #include "chrome/browser/favicon_service.h"
27 #include "chrome/browser/history/history.h" 27 #include "chrome/browser/history/history.h"
28 #include "chrome/browser/history/page_usage_data.h" 28 #include "chrome/browser/history/page_usage_data.h"
29 #include "chrome/browser/profile.h" 29 #include "chrome/browser/profile.h"
30 #include "chrome/browser/sessions/session_types.h" 30 #include "chrome/browser/sessions/session_types.h"
31 #include "chrome/browser/sessions/tab_restore_service.h" 31 #include "chrome/browser/sessions/tab_restore_service.h"
32 #include "chrome/browser/shell_integration.h" 32 #include "chrome/browser/shell_integration.h"
33 #include "chrome/common/chrome_constants.h" 33 #include "chrome/common/chrome_constants.h"
34 #include "chrome/common/chrome_switches.h" 34 #include "chrome/common/chrome_switches.h"
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 // the Chromium JumpList, such as: 383 // the Chromium JumpList, such as:
384 // * Creating an ICustomDestinationList instance; 384 // * Creating an ICustomDestinationList instance;
385 // * Updating the categories of the ICustomDestinationList instance, and; 385 // * Updating the categories of the ICustomDestinationList instance, and;
386 // * Sending it to Taskbar of Windows 7. 386 // * Sending it to Taskbar of Windows 7.
387 bool UpdateJumpList(const wchar_t* app_id, 387 bool UpdateJumpList(const wchar_t* app_id,
388 const ShellLinkItemList& most_visited_pages, 388 const ShellLinkItemList& most_visited_pages,
389 const ShellLinkItemList& recently_closed_pages) { 389 const ShellLinkItemList& recently_closed_pages) {
390 // JumpList is implemented only on Windows 7 or later. 390 // JumpList is implemented only on Windows 7 or later.
391 // So, we should return now when this function is called on earlier versions 391 // So, we should return now when this function is called on earlier versions
392 // of Windows. 392 // of Windows.
393 if (win_util::GetWinVersion() < win_util::WINVERSION_WIN7) 393 if (base::win::GetVersion() < base::win::VERSION_WIN7)
394 return true; 394 return true;
395 395
396 // Create an ICustomDestinationList object and attach it to our application. 396 // Create an ICustomDestinationList object and attach it to our application.
397 ScopedComPtr<ICustomDestinationList> destination_list; 397 ScopedComPtr<ICustomDestinationList> destination_list;
398 HRESULT result = destination_list.CreateInstance(CLSID_DestinationList, NULL, 398 HRESULT result = destination_list.CreateInstance(CLSID_DestinationList, NULL,
399 CLSCTX_INPROC_SERVER); 399 CLSCTX_INPROC_SERVER);
400 if (FAILED(result)) 400 if (FAILED(result))
401 return false; 401 return false;
402 402
403 // Set the App ID for this JumpList. 403 // Set the App ID for this JumpList.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 572
573 JumpList::JumpList() : profile_(NULL) { 573 JumpList::JumpList() : profile_(NULL) {
574 } 574 }
575 575
576 JumpList::~JumpList() { 576 JumpList::~JumpList() {
577 RemoveObserver(); 577 RemoveObserver();
578 } 578 }
579 579
580 // static 580 // static
581 bool JumpList::Enabled() { 581 bool JumpList::Enabled() {
582 return (win_util::GetWinVersion() >= win_util::WINVERSION_WIN7 && 582 return (base::win::GetVersion() >= base::win::VERSION_WIN7 &&
583 !CommandLine::ForCurrentProcess()->HasSwitch( 583 !CommandLine::ForCurrentProcess()->HasSwitch(
584 switches::kDisableCustomJumpList)); 584 switches::kDisableCustomJumpList));
585 } 585 }
586 586
587 bool JumpList::AddObserver(Profile* profile) { 587 bool JumpList::AddObserver(Profile* profile) {
588 // To update JumpList when a tab is added or removed, we add this object to 588 // To update JumpList when a tab is added or removed, we add this object to
589 // the observer list of the TabRestoreService class. 589 // the observer list of the TabRestoreService class.
590 // When we add this object to the observer list, we save the pointer to this 590 // When we add this object to the observer list, we save the pointer to this
591 // TabRestoreService object. This pointer is used when we remove this object 591 // TabRestoreService object. This pointer is used when we remove this object
592 // from the observer list. 592 // from the observer list.
593 if (win_util::GetWinVersion() < win_util::WINVERSION_WIN7 || !profile) 593 if (base::win::GetVersion() < base::win::VERSION_WIN7 || !profile)
594 return false; 594 return false;
595 595
596 TabRestoreService* tab_restore_service = profile->GetTabRestoreService(); 596 TabRestoreService* tab_restore_service = profile->GetTabRestoreService();
597 if (!tab_restore_service) 597 if (!tab_restore_service)
598 return false; 598 return false;
599 599
600 app_id_ = ShellIntegration::GetChromiumAppId(profile->GetPath()); 600 app_id_ = ShellIntegration::GetChromiumAppId(profile->GetPath());
601 icon_dir_ = profile->GetPath().Append(chrome::kJumpListIconDirname); 601 icon_dir_ = profile->GetPath().Append(chrome::kJumpListIconDirname);
602 profile_ = profile; 602 profile_ = profile;
603 tab_restore_service->AddObserver(this); 603 tab_restore_service->AddObserver(this);
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 // the file thread. 772 // the file thread.
773 BrowserThread::PostTask( 773 BrowserThread::PostTask(
774 BrowserThread::FILE, FROM_HERE, 774 BrowserThread::FILE, FROM_HERE,
775 new JumpListUpdateTask(app_id_.c_str(), icon_dir_, most_visited_pages_, 775 new JumpListUpdateTask(app_id_.c_str(), icon_dir_, most_visited_pages_,
776 recently_closed_pages_)); 776 recently_closed_pages_));
777 777
778 // Delete all items in these lists since we don't need these lists any longer. 778 // Delete all items in these lists since we don't need these lists any longer.
779 most_visited_pages_.clear(); 779 most_visited_pages_.clear();
780 recently_closed_pages_.clear(); 780 recently_closed_pages_.clear();
781 } 781 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698