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