| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/importer/importer.h" | 5 #include "chrome/browser/importer/importer.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/gfx/image_operations.h" | |
| 12 #include "base/gfx/png_encoder.h" | 11 #include "base/gfx/png_encoder.h" |
| 13 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_model.h" | 13 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 15 #include "chrome/browser/browser.h" | 14 #include "chrome/browser/browser.h" |
| 16 #include "chrome/browser/browser_list.h" | 15 #include "chrome/browser/browser_list.h" |
| 17 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/first_run.h" | 17 #include "chrome/browser/first_run.h" |
| 19 #include "chrome/browser/importer/firefox2_importer.h" | 18 #include "chrome/browser/importer/firefox2_importer.h" |
| 20 #include "chrome/browser/importer/firefox3_importer.h" | 19 #include "chrome/browser/importer/firefox3_importer.h" |
| 21 #include "chrome/browser/importer/firefox_importer_utils.h" | 20 #include "chrome/browser/importer/firefox_importer_utils.h" |
| 22 #include "chrome/browser/importer/firefox_profile_lock.h" | 21 #include "chrome/browser/importer/firefox_profile_lock.h" |
| 23 #include "chrome/browser/importer/ie_importer.h" | 22 #include "chrome/browser/importer/ie_importer.h" |
| 24 #include "chrome/browser/importer/toolbar_importer.h" | 23 #include "chrome/browser/importer/toolbar_importer.h" |
| 25 #include "chrome/browser/template_url_model.h" | 24 #include "chrome/browser/template_url_model.h" |
| 26 #include "chrome/browser/shell_integration.h" | 25 #include "chrome/browser/shell_integration.h" |
| 27 #include "chrome/browser/webdata/web_data_service.h" | 26 #include "chrome/browser/webdata/web_data_service.h" |
| 28 #include "chrome/common/gfx/favicon_size.h" | 27 #include "chrome/common/gfx/favicon_size.h" |
| 29 #include "chrome/common/l10n_util.h" | 28 #include "chrome/common/l10n_util.h" |
| 30 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 31 #include "chrome/common/pref_service.h" | 30 #include "chrome/common/pref_service.h" |
| 32 #include "chrome/common/win_util.h" | 31 #include "chrome/common/win_util.h" |
| 33 #include "chrome/views/window.h" | 32 #include "chrome/views/window.h" |
| 33 #include "skia/ext/image_operations.h" |
| 34 #include "webkit/glue/image_decoder.h" | 34 #include "webkit/glue/image_decoder.h" |
| 35 | 35 |
| 36 #include "generated_resources.h" | 36 #include "generated_resources.h" |
| 37 | 37 |
| 38 // ProfileWriter. | 38 // ProfileWriter. |
| 39 | 39 |
| 40 bool ProfileWriter::BookmarkModelIsLoaded() const { | 40 bool ProfileWriter::BookmarkModelIsLoaded() const { |
| 41 return profile_->GetBookmarkModel()->IsLoaded(); | 41 return profile_->GetBookmarkModel()->IsLoaded(); |
| 42 } | 42 } |
| 43 | 43 |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 webkit_glue::ImageDecoder decoder(gfx::Size(kFavIconSize, kFavIconSize)); | 377 webkit_glue::ImageDecoder decoder(gfx::Size(kFavIconSize, kFavIconSize)); |
| 378 SkBitmap decoded = decoder.Decode(src_data, src_len); | 378 SkBitmap decoded = decoder.Decode(src_data, src_len); |
| 379 if (decoded.empty()) | 379 if (decoded.empty()) |
| 380 return false; // Unable to decode. | 380 return false; // Unable to decode. |
| 381 | 381 |
| 382 if (decoded.width() != kFavIconSize || decoded.height() != kFavIconSize) { | 382 if (decoded.width() != kFavIconSize || decoded.height() != kFavIconSize) { |
| 383 // The bitmap is not the correct size, re-sample. | 383 // The bitmap is not the correct size, re-sample. |
| 384 int new_width = decoded.width(); | 384 int new_width = decoded.width(); |
| 385 int new_height = decoded.height(); | 385 int new_height = decoded.height(); |
| 386 calc_favicon_target_size(&new_width, &new_height); | 386 calc_favicon_target_size(&new_width, &new_height); |
| 387 decoded = gfx::ImageOperations::Resize( | 387 decoded = skia::ImageOperations::Resize( |
| 388 decoded, gfx::ImageOperations::RESIZE_LANCZOS3, | 388 decoded, skia::ImageOperations::RESIZE_LANCZOS3, |
| 389 gfx::Size(new_width, new_height)); | 389 gfx::Size(new_width, new_height)); |
| 390 } | 390 } |
| 391 | 391 |
| 392 // Encode our bitmap as a PNG. | 392 // Encode our bitmap as a PNG. |
| 393 SkAutoLockPixels decoded_lock(decoded); | 393 SkAutoLockPixels decoded_lock(decoded); |
| 394 PNGEncoder::Encode(reinterpret_cast<unsigned char*>(decoded.getPixels()), | 394 PNGEncoder::Encode(reinterpret_cast<unsigned char*>(decoded.getPixels()), |
| 395 PNGEncoder::FORMAT_BGRA, decoded.width(), | 395 PNGEncoder::FORMAT_BGRA, decoded.width(), |
| 396 decoded.height(), decoded.width() * 4, false, png_data); | 396 decoded.height(), decoded.width() * 4, false, png_data); |
| 397 return true; | 397 return true; |
| 398 } | 398 } |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 ProfileInfo* google_toolbar = new ProfileInfo(); | 709 ProfileInfo* google_toolbar = new ProfileInfo(); |
| 710 google_toolbar->browser_type = GOOGLE_TOOLBAR5; | 710 google_toolbar->browser_type = GOOGLE_TOOLBAR5; |
| 711 google_toolbar->description = l10n_util::GetString( | 711 google_toolbar->description = l10n_util::GetString( |
| 712 IDS_IMPORT_FROM_GOOGLE_TOOLBAR); | 712 IDS_IMPORT_FROM_GOOGLE_TOOLBAR); |
| 713 google_toolbar->source_path.clear(); | 713 google_toolbar->source_path.clear(); |
| 714 google_toolbar->app_path.clear(); | 714 google_toolbar->app_path.clear(); |
| 715 google_toolbar->services_supported = FAVORITES; | 715 google_toolbar->services_supported = FAVORITES; |
| 716 source_profiles_.push_back(google_toolbar); | 716 source_profiles_.push_back(google_toolbar); |
| 717 } | 717 } |
| 718 } | 718 } |
| OLD | NEW |