| 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/libgtk2ui/app_indicator_icon.h" | 5 #include "chrome/browser/ui/libgtk2ui/app_indicator_icon.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 #include <dlfcn.h> | 8 #include <dlfcn.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 base::FilePath new_file_path; | 137 base::FilePath new_file_path; |
| 138 | 138 |
| 139 // Create a new temporary directory for each image since using a single | 139 // Create a new temporary directory for each image since using a single |
| 140 // temporary directory seems to have issues when changing icons in quick | 140 // temporary directory seems to have issues when changing icons in quick |
| 141 // succession. | 141 // succession. |
| 142 if (!base::CreateNewTempDirectory(base::FilePath::StringType(), &temp_dir)) | 142 if (!base::CreateNewTempDirectory(base::FilePath::StringType(), &temp_dir)) |
| 143 return base::FilePath(); | 143 return base::FilePath(); |
| 144 new_file_path = | 144 new_file_path = |
| 145 temp_dir.Append(id + base::StringPrintf("_%d.png", icon_change_count)); | 145 temp_dir.Append(id + base::StringPrintf("_%d.png", icon_change_count)); |
| 146 int bytes_written = | 146 int bytes_written = |
| 147 file_util::WriteFile(new_file_path, | 147 base::WriteFile(new_file_path, |
| 148 png_data->front_as<char>(), | 148 png_data->front_as<char>(), png_data->size()); |
| 149 png_data->size()); | |
| 150 | 149 |
| 151 if (bytes_written != static_cast<int>(png_data->size())) | 150 if (bytes_written != static_cast<int>(png_data->size())) |
| 152 return base::FilePath(); | 151 return base::FilePath(); |
| 153 return new_file_path; | 152 return new_file_path; |
| 154 } | 153 } |
| 155 | 154 |
| 156 void DeleteTempImagePath(const base::FilePath& icon_file_path) { | 155 void DeleteTempImagePath(const base::FilePath& icon_file_path) { |
| 157 if (icon_file_path.empty()) | 156 if (icon_file_path.empty()) |
| 158 return; | 157 return; |
| 159 base::DeleteFile(icon_file_path, true); | 158 base::DeleteFile(icon_file_path, true); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 int id; | 362 int id; |
| 364 if (!GetMenuItemID(menu_item, &id)) | 363 if (!GetMenuItemID(menu_item, &id)) |
| 365 return; | 364 return; |
| 366 | 365 |
| 367 // The menu item can still be activated by hotkeys even if it is disabled. | 366 // The menu item can still be activated by hotkeys even if it is disabled. |
| 368 if (menu_model_->IsEnabledAt(id)) | 367 if (menu_model_->IsEnabledAt(id)) |
| 369 ExecuteCommand(model, id); | 368 ExecuteCommand(model, id); |
| 370 } | 369 } |
| 371 | 370 |
| 372 } // namespace libgtk2ui | 371 } // namespace libgtk2ui |
| OLD | NEW |