| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/json/json_parser.h" | 5 #include "base/json/json_parser.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" | 8 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher.h" |
| 9 #include "chrome/browser/enhanced_bookmarks/android/bookmark_image_service_andro
id.h" | 9 #include "chrome/browser/enhanced_bookmarks/android/bookmark_image_service_andro
id.h" |
| 10 #include "chrome/browser/enhanced_bookmarks/enhanced_bookmark_model_factory.h" | 10 #include "chrome/browser/enhanced_bookmarks/enhanced_bookmark_model_factory.h" |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 int height, width; | 102 int height, width; |
| 103 if (enhanced_bookmark_model_->GetOriginalImage(bookmark, &url, &width, | 103 if (enhanced_bookmark_model_->GetOriginalImage(bookmark, &url, &width, |
| 104 &height) || | 104 &height) || |
| 105 enhanced_bookmark_model_->GetThumbnailImage(bookmark, &url, &width, | 105 enhanced_bookmark_model_->GetThumbnailImage(bookmark, &url, &width, |
| 106 &height)) { | 106 &height)) { |
| 107 return; | 107 return; |
| 108 } | 108 } |
| 109 | 109 |
| 110 if (script_.empty()) { | 110 if (script_.empty()) { |
| 111 script_ = | 111 script_ = |
| 112 base::UTF8ToUTF16(ResourceBundle::GetSharedInstance() | 112 base::UTF8ToUTF16( |
| 113 .GetRawDataResource(IDR_GET_SALIENT_IMAGE_URL_JS) | 113 ResourceBundle::GetSharedInstance() |
| 114 .as_string()); | 114 .GetRawDataResource(IDR_GET_SALIENT_IMAGE_URL_GEN_JS) |
| 115 .as_string()); |
| 115 } | 116 } |
| 116 | 117 |
| 117 render_frame_host->ExecuteJavaScript( | 118 render_frame_host->ExecuteJavaScript( |
| 118 script_, | 119 script_, |
| 119 base::Bind( | 120 base::Bind( |
| 120 &BookmarkImageServiceAndroid::RetrieveSalientImageFromContextCallback, | 121 &BookmarkImageServiceAndroid::RetrieveSalientImageFromContextCallback, |
| 121 base::Unretained(this), page_url, update_bookmark)); | 122 base::Unretained(this), page_url, update_bookmark)); |
| 122 } | 123 } |
| 123 | 124 |
| 124 void BookmarkImageServiceAndroid::FinishSuccessfulPageLoadForTab( | 125 void BookmarkImageServiceAndroid::FinishSuccessfulPageLoadForTab( |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 gfx::ImageSkia imageSkia = gfx::ImageSkia::CreateFrom1xBitmap(*bitmap); | 258 gfx::ImageSkia imageSkia = gfx::ImageSkia::CreateFrom1xBitmap(*bitmap); |
| 258 imageSkia.MakeThreadSafe(); | 259 imageSkia.MakeThreadSafe(); |
| 259 image = gfx::Image(imageSkia); | 260 image = gfx::Image(imageSkia); |
| 260 } | 261 } |
| 261 service_->ProcessNewImage(page_url_, update_bookmark_, url, image); | 262 service_->ProcessNewImage(page_url_, update_bookmark_, url, image); |
| 262 | 263 |
| 263 delete this; | 264 delete this; |
| 264 } | 265 } |
| 265 | 266 |
| 266 } // namespace enhanced_bookmarks | 267 } // namespace enhanced_bookmarks |
| OLD | NEW |