OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/libgtkui/app_indicator_icon.h" | 5 #include "chrome/browser/ui/libgtkui/app_indicator_icon.h" |
6 | 6 |
7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 187 |
188 EnsureMethodsLoaded(); | 188 EnsureMethodsLoaded(); |
189 tool_tip_ = base::UTF16ToUTF8(tool_tip); | 189 tool_tip_ = base::UTF16ToUTF8(tool_tip); |
190 SetImage(image); | 190 SetImage(image); |
191 } | 191 } |
192 AppIndicatorIcon::~AppIndicatorIcon() { | 192 AppIndicatorIcon::~AppIndicatorIcon() { |
193 if (icon_) { | 193 if (icon_) { |
194 app_indicator_set_status(icon_, APP_INDICATOR_STATUS_PASSIVE); | 194 app_indicator_set_status(icon_, APP_INDICATOR_STATUS_PASSIVE); |
195 g_object_unref(icon_); | 195 g_object_unref(icon_); |
196 content::BrowserThread::GetBlockingPool()->PostTask( | 196 content::BrowserThread::GetBlockingPool()->PostTask( |
197 FROM_HERE, | 197 FROM_HERE, base::BindOnce(&DeleteTempDirectory, temp_dir_)); |
198 base::Bind(&DeleteTempDirectory, temp_dir_)); | |
199 } | 198 } |
200 } | 199 } |
201 | 200 |
202 // static | 201 // static |
203 bool AppIndicatorIcon::CouldOpen() { | 202 bool AppIndicatorIcon::CouldOpen() { |
204 EnsureMethodsLoaded(); | 203 EnsureMethodsLoaded(); |
205 return g_opened; | 204 return g_opened; |
206 } | 205 } |
207 | 206 |
208 void AppIndicatorIcon::SetImage(const gfx::ImageSkia& image) { | 207 void AppIndicatorIcon::SetImage(const gfx::ImageSkia& image) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 params.icon_theme_path.c_str()); | 355 params.icon_theme_path.c_str()); |
357 app_indicator_set_status(icon_, APP_INDICATOR_STATUS_ACTIVE); | 356 app_indicator_set_status(icon_, APP_INDICATOR_STATUS_ACTIVE); |
358 SetMenu(); | 357 SetMenu(); |
359 } else { | 358 } else { |
360 app_indicator_set_icon_theme_path(icon_, params.icon_theme_path.c_str()); | 359 app_indicator_set_icon_theme_path(icon_, params.icon_theme_path.c_str()); |
361 app_indicator_set_icon_full(icon_, params.icon_name.c_str(), "icon"); | 360 app_indicator_set_icon_full(icon_, params.icon_name.c_str(), "icon"); |
362 } | 361 } |
363 | 362 |
364 if (temp_dir_ != params.parent_temp_dir) { | 363 if (temp_dir_ != params.parent_temp_dir) { |
365 content::BrowserThread::GetBlockingPool()->PostTask( | 364 content::BrowserThread::GetBlockingPool()->PostTask( |
366 FROM_HERE, | 365 FROM_HERE, base::BindOnce(&DeleteTempDirectory, temp_dir_)); |
367 base::Bind(&DeleteTempDirectory, temp_dir_)); | |
368 temp_dir_ = params.parent_temp_dir; | 366 temp_dir_ = params.parent_temp_dir; |
369 } | 367 } |
370 } | 368 } |
371 | 369 |
372 void AppIndicatorIcon::SetMenu() { | 370 void AppIndicatorIcon::SetMenu() { |
373 menu_.reset(new AppIndicatorIconMenu(menu_model_)); | 371 menu_.reset(new AppIndicatorIconMenu(menu_model_)); |
374 UpdateClickActionReplacementMenuItem(); | 372 UpdateClickActionReplacementMenuItem(); |
375 app_indicator_set_menu(icon_, menu_->GetGtkMenu()); | 373 app_indicator_set_menu(icon_, menu_->GetGtkMenu()); |
376 } | 374 } |
377 | 375 |
(...skipping 11 matching lines...) Expand all Loading... |
389 base::Bind(&AppIndicatorIcon::OnClickActionReplacementMenuItemActivated, | 387 base::Bind(&AppIndicatorIcon::OnClickActionReplacementMenuItemActivated, |
390 base::Unretained(this))); | 388 base::Unretained(this))); |
391 } | 389 } |
392 | 390 |
393 void AppIndicatorIcon::OnClickActionReplacementMenuItemActivated() { | 391 void AppIndicatorIcon::OnClickActionReplacementMenuItemActivated() { |
394 if (delegate()) | 392 if (delegate()) |
395 delegate()->OnClick(); | 393 delegate()->OnClick(); |
396 } | 394 } |
397 | 395 |
398 } // namespace libgtkui | 396 } // namespace libgtkui |
OLD | NEW |