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

Side by Side Diff: chrome/browser/ui/gtk/unity_dock_service.cc

Issue 6903017: GTK: Add download notifications to the unity dock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/launcher/dock/; Created 9 years, 8 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
(Empty)
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 #include "chrome/browser/ui/gtk/unity_dock_service.h"
6
7 #include <dlfcn.h>
8
9 #include "base/environment.h"
10 #include "base/scoped_ptr.h"
11 #include "chrome/browser/shell_integration.h"
12
13 void UnityDockService::SetDownloadCount(int count) {
14 if (chrome_entry) {
15 entry_set_count(chrome_entry, count);
16 entry_set_count_visible(chrome_entry, count != 0);
17 }
18 }
19
20 void UnityDockService::SetProgressPercent(float percentage) {
21 if (chrome_entry) {
22 entry_set_progress(chrome_entry, percentage);
23 entry_set_progress_visible(chrome_entry,
24 percentage > 0.0 && percentage < 1.0);
25 }
26 }
27
28 UnityDockService::UnityDockService() {}
29
30 UnityDockService::~UnityDockService() {}
31
32 // static
33 DockService* UnityDockService::Build() {
34 UnityDockService* service = NULL;
35 void* unity_lib = dlopen("libunity.so.4", RTLD_LAZY);
36 if (unity_lib) {
Evan Martin 2011/04/26 00:33:52 Why not early return here rather than nesting so m
37 unity_launcher_entry_get_for_desktop_id_func entry_get_for_desktop_id =
38 reinterpret_cast<unity_launcher_entry_get_for_desktop_id_func>(
39 dlsym(unity_lib, "unity_launcher_entry_get_for_desktop_id"));
40
41 if (entry_get_for_desktop_id) {
42 scoped_ptr<base::Environment> env(base::Environment::Create());
43 std::string desktop_id = ShellIntegration::GetDesktopName(env.get());
44 UnityLauncherEntry* entry = entry_get_for_desktop_id(desktop_id.c_str());
45
46 unity_launcher_entry_set_count_func entry_set_count =
47 reinterpret_cast<unity_launcher_entry_set_count_func>(
48 dlsym(unity_lib, "unity_launcher_entry_set_count"));
49
50 unity_launcher_entry_set_count_visible_func entry_set_count_visible =
51 reinterpret_cast<unity_launcher_entry_set_count_visible_func>(
52 dlsym(unity_lib, "unity_launcher_entry_set_count_visible"));
53
54 unity_launcher_entry_set_progress_func entry_set_progress =
55 reinterpret_cast<unity_launcher_entry_set_progress_func>(
56 dlsym(unity_lib, "unity_launcher_entry_set_progress"));
57
58 unity_launcher_entry_set_progress_visible_func
59 entry_set_progress_visible =
60 reinterpret_cast<unity_launcher_entry_set_progress_visible_func>(
61 dlsym(unity_lib, "unity_launcher_entry_set_progress_visible"));
62
63 // Check every returned method because the API is unstable.
64 if (entry &&
65 entry_set_count &&
66 entry_set_count_visible &&
67 entry_set_progress &&
68 entry_set_progress_visible) {
69 service = new UnityDockService;
70 service->chrome_entry = entry;
71 service->entry_set_count = entry_set_count;
72 service->entry_set_count_visible = entry_set_count_visible;
73 service->entry_set_progress = entry_set_progress;
74 service->entry_set_progress_visible = entry_set_progress_visible;
75 }
76 }
77 }
78
79 return service;
80 }
81
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698