[email protected] | 3dd0e20 | 2011-07-18 21:45:52 | [diff] [blame^] | 1 | // Copyright (c) 2011 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 | #ifndef CHROME_BROWSER_MAC_DOCK_H_ |
| 6 | #define CHROME_BROWSER_MAC_DOCK_H_ |
| 7 | #pragma once |
| 8 | |
| 9 | #if defined(__OBJC__) |
| 10 | @class NSString; |
| 11 | #else |
| 12 | class NSString; |
| 13 | #endif |
| 14 | |
| 15 | namespace dock { |
| 16 | |
| 17 | // Adds an icon to the Dock pointing to |installed_path| if one is not already |
| 18 | // present. |dmg_app_path| is the path to the install source. Its tile will be |
| 19 | // removed if present. If any changes are made to the Dock's configuration, |
| 20 | // the Dock process is restarted so that the changes become visible in the UI. |
| 21 | // |
| 22 | // Various heuristics are used to determine where to place the new icon |
| 23 | // relative to other items already present in the Dock: |
| 24 | // - If installed_path is already in the Dock, no new tiles for this path |
| 25 | // will be added. |
| 26 | // - If dmg_app_path is present in the Dock, it will be removed. If |
| 27 | // installed_path is not already present, the new tile referencing |
| 28 | // installed_path will be placed where the dmg_app_path tile was. This |
| 29 | // keeps the tile where a user expects it if they dragged the application |
| 30 | // icon from a disk image into the Dock and then clicked on the new icon |
| 31 | // in the Dock. |
| 32 | // - The new tile will precede any application with the same name already |
| 33 | // in the Dock. |
| 34 | // - In an official build, a new tile for Google Chrome will be placed |
| 35 | // immediately before the first existing tile for Google Chrome Canary, |
| 36 | // and a new tile for Google Chrome Canary will be placed immediately after |
| 37 | // the last existing tile for Google Chrome. |
| 38 | // - The new tile will be placed immediately after the last tile for another |
| 39 | // browser application already in the Dock. |
| 40 | // - The new tile will be placed last in the Dock. |
| 41 | // For the purposes of these comparisons, applications are identified by the |
| 42 | // last component in their path. For example, any application named Safari.app |
| 43 | // will be treated as a browser. If the user renames an application on disk, |
| 44 | // it will alter the result. Looking up the bundle ID could be slightly more |
| 45 | // robust in the presence of such alterations, but it's not thought to be a |
| 46 | // large enough problem to warrant such lookups. |
| 47 | // |
| 48 | // The changes made to the Dock's configuration are the minimal changes |
| 49 | // necessary to cause the desired behavior. Although it's possible to set |
| 50 | // additional properties on the dock tile added to the Dock's plist, this |
| 51 | // is not done. Upon relaunch, Dock.app will determine the correct values for |
| 52 | // the properties it requires and add them to its configuration. |
| 53 | void AddIcon(NSString* installed_path, NSString* dmg_app_path); |
| 54 | |
| 55 | } // namespace dock |
| 56 | |
| 57 | #endif // CHROME_BROWSER_MAC_DOCK_H_ |