| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/android/provider/chrome_browser_provider.h" | 5 #include "chrome/browser/android/provider/chrome_browser_provider.h" |
| 6 | 6 |
| 7 #include <cmath> |
| 7 #include <list> | 8 #include <list> |
| 8 #include <utility> | 9 #include <utility> |
| 9 | 10 |
| 10 #include "base/android/jni_android.h" | 11 #include "base/android/jni_android.h" |
| 11 #include "base/android/jni_array.h" | 12 #include "base/android/jni_array.h" |
| 12 #include "base/android/jni_string.h" | 13 #include "base/android/jni_string.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/memory/ref_counted_memory.h" | 15 #include "base/memory/ref_counted_memory.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/task/cancelable_task_tracker.h" | 17 #include "base/task/cancelable_task_tracker.h" |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 CancelableRequestConsumer* cancelable_consumer, | 677 CancelableRequestConsumer* cancelable_consumer, |
| 677 base::CancelableTaskTracker* cancelable_tracker) | 678 base::CancelableTaskTracker* cancelable_tracker) |
| 678 : FaviconServiceTask(favicon_service, | 679 : FaviconServiceTask(favicon_service, |
| 679 profile, | 680 profile, |
| 680 cancelable_consumer, | 681 cancelable_consumer, |
| 681 cancelable_tracker) {} | 682 cancelable_tracker) {} |
| 682 | 683 |
| 683 favicon_base::FaviconRawBitmapResult Run(const GURL& url) { | 684 favicon_base::FaviconRawBitmapResult Run(const GURL& url) { |
| 684 float max_scale = ui::GetScaleForScaleFactor( | 685 float max_scale = ui::GetScaleForScaleFactor( |
| 685 ResourceBundle::GetSharedInstance().GetMaxScaleFactor()); | 686 ResourceBundle::GetSharedInstance().GetMaxScaleFactor()); |
| 687 int desired_size_in_pixel = std::ceil(gfx::kFaviconSize * max_scale); |
| 686 RunAsyncRequestOnUIThreadBlocking( | 688 RunAsyncRequestOnUIThreadBlocking( |
| 687 base::Bind(&FaviconService::GetRawFaviconForPageURL, | 689 base::Bind(&FaviconService::GetRawFaviconForPageURL, |
| 688 base::Unretained(service()), | 690 base::Unretained(service()), |
| 689 FaviconService::FaviconForPageURLParams( | 691 url, |
| 690 url, | 692 favicon_base::FAVICON | favicon_base::TOUCH_ICON, |
| 691 favicon_base::FAVICON | favicon_base::TOUCH_ICON, | 693 desired_size_in_pixel, |
| 692 gfx::kFaviconSize), | |
| 693 max_scale, | |
| 694 base::Bind(&BookmarkIconFetchTask::OnFaviconRetrieved, | 694 base::Bind(&BookmarkIconFetchTask::OnFaviconRetrieved, |
| 695 base::Unretained(this)), | 695 base::Unretained(this)), |
| 696 cancelable_tracker())); | 696 cancelable_tracker())); |
| 697 return result_; | 697 return result_; |
| 698 } | 698 } |
| 699 | 699 |
| 700 private: | 700 private: |
| 701 void OnFaviconRetrieved( | 701 void OnFaviconRetrieved( |
| 702 const favicon_base::FaviconRawBitmapResult& bitmap_result) { | 702 const favicon_base::FaviconRawBitmapResult& bitmap_result) { |
| 703 result_ = bitmap_result; | 703 result_ = bitmap_result; |
| (...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1630 Java_ChromeBrowserProvider_onBookmarkChanged(env, obj.obj()); | 1630 Java_ChromeBrowserProvider_onBookmarkChanged(env, obj.obj()); |
| 1631 } else if (type == | 1631 } else if (type == |
| 1632 chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED) { | 1632 chrome::NOTIFICATION_HISTORY_KEYWORD_SEARCH_TERM_UPDATED) { |
| 1633 JNIEnv* env = AttachCurrentThread(); | 1633 JNIEnv* env = AttachCurrentThread(); |
| 1634 ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env); | 1634 ScopedJavaLocalRef<jobject> obj = weak_java_provider_.get(env); |
| 1635 if (obj.is_null()) | 1635 if (obj.is_null()) |
| 1636 return; | 1636 return; |
| 1637 Java_ChromeBrowserProvider_onSearchTermChanged(env, obj.obj()); | 1637 Java_ChromeBrowserProvider_onSearchTermChanged(env, obj.obj()); |
| 1638 } | 1638 } |
| 1639 } | 1639 } |
| OLD | NEW |