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/android/shortcut_helper.h" | 5 #include "chrome/browser/android/shortcut_helper.h" |
6 | 6 |
7 #include <jni.h> | 7 #include <jni.h> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/common/render_messages.h" | 23 #include "chrome/common/render_messages.h" |
24 #include "chrome/common/web_application_info.h" | 24 #include "chrome/common/web_application_info.h" |
25 #include "components/dom_distiller/core/url_utils.h" | 25 #include "components/dom_distiller/core/url_utils.h" |
26 #include "content/public/browser/user_metrics.h" | 26 #include "content/public/browser/user_metrics.h" |
27 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
28 #include "content/public/browser/web_contents_observer.h" | 28 #include "content/public/browser/web_contents_observer.h" |
29 #include "content/public/common/frame_navigate_params.h" | 29 #include "content/public/common/frame_navigate_params.h" |
30 #include "content/public/common/manifest.h" | 30 #include "content/public/common/manifest.h" |
31 #include "jni/ShortcutHelper_jni.h" | 31 #include "jni/ShortcutHelper_jni.h" |
32 #include "net/base/mime_util.h" | 32 #include "net/base/mime_util.h" |
| 33 #include "third_party/WebKit/public/platform/WebScreenOrientationLockType.h" |
33 #include "ui/gfx/android/java_bitmap.h" | 34 #include "ui/gfx/android/java_bitmap.h" |
34 #include "ui/gfx/codec/png_codec.h" | 35 #include "ui/gfx/codec/png_codec.h" |
35 #include "ui/gfx/color_analysis.h" | 36 #include "ui/gfx/color_analysis.h" |
36 #include "ui/gfx/favicon_size.h" | 37 #include "ui/gfx/favicon_size.h" |
37 #include "ui/gfx/screen.h" | 38 #include "ui/gfx/screen.h" |
38 #include "url/gurl.h" | 39 #include "url/gurl.h" |
39 | 40 |
40 using content::Manifest; | 41 using content::Manifest; |
41 | 42 |
42 // Android's preferred icon size in DP is 48, as defined in | 43 // Android's preferred icon size in DP is 48, as defined in |
43 // http://developer.android.com/design/style/iconography.html | 44 // http://developer.android.com/design/style/iconography.html |
44 const int ShortcutHelper::kPreferredIconSizeInDp = 48; | 45 const int ShortcutHelper::kPreferredIconSizeInDp = 48; |
45 | 46 |
46 jlong Initialize(JNIEnv* env, jobject obj, jlong tab_android_ptr) { | 47 jlong Initialize(JNIEnv* env, jobject obj, jlong tab_android_ptr) { |
47 TabAndroid* tab = reinterpret_cast<TabAndroid*>(tab_android_ptr); | 48 TabAndroid* tab = reinterpret_cast<TabAndroid*>(tab_android_ptr); |
48 | 49 |
49 ShortcutHelper* shortcut_helper = | 50 ShortcutHelper* shortcut_helper = |
50 new ShortcutHelper(env, obj, tab->web_contents()); | 51 new ShortcutHelper(env, obj, tab->web_contents()); |
51 shortcut_helper->Initialize(); | 52 shortcut_helper->Initialize(); |
52 | 53 |
53 return reinterpret_cast<intptr_t>(shortcut_helper); | 54 return reinterpret_cast<intptr_t>(shortcut_helper); |
54 } | 55 } |
55 | 56 |
56 ShortcutHelper::ShortcutHelper(JNIEnv* env, | 57 ShortcutHelper::ShortcutHelper(JNIEnv* env, |
57 jobject obj, | 58 jobject obj, |
58 content::WebContents* web_contents) | 59 content::WebContents* web_contents) |
59 : WebContentsObserver(web_contents), | 60 : WebContentsObserver(web_contents), |
60 java_ref_(env, obj), | 61 java_ref_(env, obj), |
61 url_(dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl( | 62 shortcut_info_(dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl( |
62 web_contents->GetURL())), | 63 web_contents->GetURL())), |
63 display_(content::Manifest::DISPLAY_MODE_BROWSER), | |
64 orientation_(blink::WebScreenOrientationLockDefault), | |
65 add_shortcut_requested_(false), | 64 add_shortcut_requested_(false), |
66 manifest_icon_status_(MANIFEST_ICON_STATUS_NONE), | 65 manifest_icon_status_(MANIFEST_ICON_STATUS_NONE), |
67 preferred_icon_size_in_px_(kPreferredIconSizeInDp * | 66 preferred_icon_size_in_px_(kPreferredIconSizeInDp * |
68 gfx::Screen::GetScreenFor(web_contents->GetNativeView())-> | 67 gfx::Screen::GetScreenFor(web_contents->GetNativeView())-> |
69 GetPrimaryDisplay().device_scale_factor()), | 68 GetPrimaryDisplay().device_scale_factor()), |
70 weak_ptr_factory_(this) { | 69 weak_ptr_factory_(this) { |
71 } | 70 } |
72 | 71 |
73 void ShortcutHelper::Initialize() { | 72 void ShortcutHelper::Initialize() { |
74 // Send a message to the renderer to retrieve information about the page. | 73 // Send a message to the renderer to retrieve information about the page. |
75 Send(new ChromeViewMsg_GetWebApplicationInfo(routing_id())); | 74 Send(new ChromeViewMsg_GetWebApplicationInfo(routing_id())); |
76 } | 75 } |
77 | 76 |
78 ShortcutHelper::~ShortcutHelper() { | 77 ShortcutHelper::~ShortcutHelper() { |
79 } | 78 } |
80 | 79 |
81 void ShortcutHelper::OnDidGetWebApplicationInfo( | 80 void ShortcutHelper::OnDidGetWebApplicationInfo( |
82 const WebApplicationInfo& received_web_app_info) { | 81 const WebApplicationInfo& received_web_app_info) { |
83 // Sanitize received_web_app_info. | 82 // Sanitize received_web_app_info. |
84 WebApplicationInfo web_app_info = received_web_app_info; | 83 WebApplicationInfo web_app_info = received_web_app_info; |
85 web_app_info.title = | 84 web_app_info.title = |
86 web_app_info.title.substr(0, chrome::kMaxMetaTagAttributeLength); | 85 web_app_info.title.substr(0, chrome::kMaxMetaTagAttributeLength); |
87 web_app_info.description = | 86 web_app_info.description = |
88 web_app_info.description.substr(0, chrome::kMaxMetaTagAttributeLength); | 87 web_app_info.description.substr(0, chrome::kMaxMetaTagAttributeLength); |
89 | 88 |
90 title_ = web_app_info.title.empty() ? web_contents()->GetTitle() | 89 shortcut_info_.title = web_app_info.title.empty() ? web_contents()->GetTitle() |
91 : web_app_info.title; | 90 : web_app_info.title; |
92 | 91 |
93 if (web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE || | 92 if (web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE || |
94 web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE_APPLE) { | 93 web_app_info.mobile_capable == WebApplicationInfo::MOBILE_CAPABLE_APPLE) { |
95 display_ = content::Manifest::DISPLAY_MODE_STANDALONE; | 94 shortcut_info_.display = content::Manifest::DISPLAY_MODE_STANDALONE; |
96 } | 95 } |
97 | 96 |
98 // Record what type of shortcut was added by the user. | 97 // Record what type of shortcut was added by the user. |
99 switch (web_app_info.mobile_capable) { | 98 switch (web_app_info.mobile_capable) { |
100 case WebApplicationInfo::MOBILE_CAPABLE: | 99 case WebApplicationInfo::MOBILE_CAPABLE: |
101 content::RecordAction( | 100 content::RecordAction( |
102 base::UserMetricsAction("webapps.AddShortcut.AppShortcut")); | 101 base::UserMetricsAction("webapps.AddShortcut.AppShortcut")); |
103 break; | 102 break; |
104 case WebApplicationInfo::MOBILE_CAPABLE_APPLE: | 103 case WebApplicationInfo::MOBILE_CAPABLE_APPLE: |
105 content::RecordAction( | 104 content::RecordAction( |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 231 |
233 return url; | 232 return url; |
234 } | 233 } |
235 | 234 |
236 void ShortcutHelper::OnDidGetManifest(const content::Manifest& manifest) { | 235 void ShortcutHelper::OnDidGetManifest(const content::Manifest& manifest) { |
237 if (!manifest.IsEmpty()) { | 236 if (!manifest.IsEmpty()) { |
238 content::RecordAction( | 237 content::RecordAction( |
239 base::UserMetricsAction("webapps.AddShortcut.Manifest")); | 238 base::UserMetricsAction("webapps.AddShortcut.Manifest")); |
240 } | 239 } |
241 | 240 |
242 // Set the title based on the manifest value, if any. | 241 shortcut_info_.UpdateFromManifest(manifest); |
243 if (!manifest.short_name.is_null()) | |
244 title_ = manifest.short_name.string(); | |
245 else if (!manifest.name.is_null()) | |
246 title_ = manifest.name.string(); | |
247 | |
248 // Set the url based on the manifest value, if any. | |
249 if (manifest.start_url.is_valid()) | |
250 url_ = manifest.start_url; | |
251 | |
252 // Set the display based on the manifest value, if any. | |
253 if (manifest.display != content::Manifest::DISPLAY_MODE_UNSPECIFIED) | |
254 display_ = manifest.display; | |
255 | |
256 // 'fullscreen' and 'minimal-ui' are not yet supported, fallback to the right | |
257 // mode in those cases. | |
258 if (manifest.display == content::Manifest::DISPLAY_MODE_FULLSCREEN) | |
259 display_ = content::Manifest::DISPLAY_MODE_STANDALONE; | |
260 if (manifest.display == content::Manifest::DISPLAY_MODE_MINIMAL_UI) | |
261 display_ = content::Manifest::DISPLAY_MODE_BROWSER; | |
262 | |
263 // Set the orientation based on the manifest value, if any. | |
264 if (manifest.orientation != blink::WebScreenOrientationLockDefault) { | |
265 // Ignore the orientation if the display mode is different from | |
266 // 'standalone'. | |
267 // TODO(mlamouri): send a message to the developer console about this. | |
268 if (display_ == content::Manifest::DISPLAY_MODE_STANDALONE) | |
269 orientation_ = manifest.orientation; | |
270 } | |
271 | 242 |
272 GURL icon_src = FindBestMatchingIcon(manifest.icons); | 243 GURL icon_src = FindBestMatchingIcon(manifest.icons); |
273 if (icon_src.is_valid()) { | 244 if (icon_src.is_valid()) { |
274 web_contents()->DownloadImage(icon_src, | 245 web_contents()->DownloadImage(icon_src, |
275 false, | 246 false, |
276 preferred_icon_size_in_px_, | 247 preferred_icon_size_in_px_, |
277 base::Bind(&ShortcutHelper::OnDidDownloadIcon, | 248 base::Bind(&ShortcutHelper::OnDidDownloadIcon, |
278 weak_ptr_factory_.GetWeakPtr())); | 249 weak_ptr_factory_.GetWeakPtr())); |
279 manifest_icon_status_ = MANIFEST_ICON_STATUS_FETCHING; | 250 manifest_icon_status_ = MANIFEST_ICON_STATUS_FETCHING; |
280 } | 251 } |
281 | 252 |
282 // The ShortcutHelper is now able to notify its Java counterpart that it is | 253 // The ShortcutHelper is now able to notify its Java counterpart that it is |
283 // initialized. OnInitialized method is not conceptually part of getting the | 254 // initialized. OnInitialized method is not conceptually part of getting the |
284 // manifest data but it happens that the initialization is finalized when | 255 // manifest data but it happens that the initialization is finalized when |
285 // these data are available. | 256 // these data are available. |
286 JNIEnv* env = base::android::AttachCurrentThread(); | 257 JNIEnv* env = base::android::AttachCurrentThread(); |
287 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); | 258 ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
288 ScopedJavaLocalRef<jstring> j_title = | 259 ScopedJavaLocalRef<jstring> j_title = |
289 base::android::ConvertUTF16ToJavaString(env, title_); | 260 base::android::ConvertUTF16ToJavaString(env, shortcut_info_.title); |
290 | 261 |
291 Java_ShortcutHelper_onInitialized(env, j_obj.obj(), j_title.obj()); | 262 Java_ShortcutHelper_onInitialized(env, j_obj.obj(), j_title.obj()); |
292 } | 263 } |
293 | 264 |
294 void ShortcutHelper::OnDidDownloadIcon(int id, | 265 void ShortcutHelper::OnDidDownloadIcon(int id, |
295 int http_status_code, | 266 int http_status_code, |
296 const GURL& url, | 267 const GURL& url, |
297 const std::vector<SkBitmap>& bitmaps, | 268 const std::vector<SkBitmap>& bitmaps, |
298 const std::vector<gfx::Size>& sizes) { | 269 const std::vector<gfx::Size>& sizes) { |
299 // If getting the candidate manifest icon failed, the ShortcutHelper should | 270 // If getting the candidate manifest icon failed, the ShortcutHelper should |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 | 306 |
336 void ShortcutHelper::AddShortcut( | 307 void ShortcutHelper::AddShortcut( |
337 JNIEnv* env, | 308 JNIEnv* env, |
338 jobject obj, | 309 jobject obj, |
339 jstring jtitle, | 310 jstring jtitle, |
340 jint launcher_large_icon_size) { | 311 jint launcher_large_icon_size) { |
341 add_shortcut_requested_ = true; | 312 add_shortcut_requested_ = true; |
342 | 313 |
343 base::string16 title = base::android::ConvertJavaStringToUTF16(env, jtitle); | 314 base::string16 title = base::android::ConvertJavaStringToUTF16(env, jtitle); |
344 if (!title.empty()) | 315 if (!title.empty()) |
345 title_ = title; | 316 shortcut_info_.title = title; |
346 | 317 |
347 switch (manifest_icon_status_) { | 318 switch (manifest_icon_status_) { |
348 case MANIFEST_ICON_STATUS_NONE: | 319 case MANIFEST_ICON_STATUS_NONE: |
349 AddShortcutUsingFavicon(); | 320 AddShortcutUsingFavicon(); |
350 break; | 321 break; |
351 case MANIFEST_ICON_STATUS_FETCHING: | 322 case MANIFEST_ICON_STATUS_FETCHING: |
352 // ::OnDidDownloadIcon() will call AddShortcutUsingManifestIcon(). | 323 // ::OnDidDownloadIcon() will call AddShortcutUsingManifestIcon(). |
353 break; | 324 break; |
354 case MANIFEST_ICON_STATUS_DONE: | 325 case MANIFEST_ICON_STATUS_DONE: |
355 AddShortcutUsingManifestIcon(); | 326 AddShortcutUsingManifestIcon(); |
356 break; | 327 break; |
357 } | 328 } |
358 } | 329 } |
359 | 330 |
360 void ShortcutHelper::AddShortcutUsingManifestIcon() { | 331 void ShortcutHelper::AddShortcutUsingManifestIcon() { |
361 // Stop observing so we don't get destroyed while doing the last steps. | 332 // Stop observing so we don't get destroyed while doing the last steps. |
362 Observe(NULL); | 333 Observe(NULL); |
363 | 334 |
364 base::WorkerPool::PostTask( | 335 base::WorkerPool::PostTask( |
365 FROM_HERE, | 336 FROM_HERE, |
366 base::Bind(&ShortcutHelper::AddShortcutInBackgroundWithSkBitmap, | 337 base::Bind(&ShortcutHelper::AddShortcutInBackgroundWithSkBitmap, |
367 url_, | 338 shortcut_info_, |
368 title_, | 339 manifest_icon_), |
369 display_, | |
370 manifest_icon_, | |
371 orientation_), | |
372 true); | 340 true); |
373 | 341 |
374 Destroy(); | 342 Destroy(); |
375 } | 343 } |
376 | 344 |
377 void ShortcutHelper::AddShortcutUsingFavicon() { | 345 void ShortcutHelper::AddShortcutUsingFavicon() { |
378 Profile* profile = | 346 Profile* profile = |
379 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 347 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
380 | 348 |
381 // Grab the best, largest icon we can find to represent this bookmark. | 349 // Grab the best, largest icon we can find to represent this bookmark. |
382 // TODO(dfalcantara): Try combining with the new BookmarksHandler once its | 350 // TODO(dfalcantara): Try combining with the new BookmarksHandler once its |
383 // rewrite is further along. | 351 // rewrite is further along. |
384 std::vector<int> icon_types; | 352 std::vector<int> icon_types; |
385 icon_types.push_back(favicon_base::FAVICON); | 353 icon_types.push_back(favicon_base::FAVICON); |
386 icon_types.push_back(favicon_base::TOUCH_PRECOMPOSED_ICON | | 354 icon_types.push_back(favicon_base::TOUCH_PRECOMPOSED_ICON | |
387 favicon_base::TOUCH_ICON); | 355 favicon_base::TOUCH_ICON); |
388 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( | 356 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( |
389 profile, ServiceAccessType::EXPLICIT_ACCESS); | 357 profile, ServiceAccessType::EXPLICIT_ACCESS); |
390 | 358 |
391 // Using favicon if its size is not smaller than platform required size, | 359 // Using favicon if its size is not smaller than platform required size, |
392 // otherwise using the largest icon among all avaliable icons. | 360 // otherwise using the largest icon among all avaliable icons. |
393 int threshold_to_get_any_largest_icon = preferred_icon_size_in_px_ - 1; | 361 int threshold_to_get_any_largest_icon = preferred_icon_size_in_px_ - 1; |
394 favicon_service->GetLargestRawFaviconForPageURL(url_, icon_types, | 362 favicon_service->GetLargestRawFaviconForPageURL( |
| 363 shortcut_info_.url, |
| 364 icon_types, |
395 threshold_to_get_any_largest_icon, | 365 threshold_to_get_any_largest_icon, |
396 base::Bind(&ShortcutHelper::OnDidGetFavicon, | 366 base::Bind(&ShortcutHelper::OnDidGetFavicon, |
397 base::Unretained(this)), | 367 base::Unretained(this)), |
398 &cancelable_task_tracker_); | 368 &cancelable_task_tracker_); |
399 } | 369 } |
400 | 370 |
401 void ShortcutHelper::OnDidGetFavicon( | 371 void ShortcutHelper::OnDidGetFavicon( |
402 const favicon_base::FaviconRawBitmapResult& bitmap_result) { | 372 const favicon_base::FaviconRawBitmapResult& bitmap_result) { |
403 // Stop observing so we don't get destroyed while doing the last steps. | 373 // Stop observing so we don't get destroyed while doing the last steps. |
404 Observe(NULL); | 374 Observe(NULL); |
405 | 375 |
406 base::WorkerPool::PostTask( | 376 base::WorkerPool::PostTask( |
407 FROM_HERE, | 377 FROM_HERE, |
408 base::Bind(&ShortcutHelper::AddShortcutInBackgroundWithRawBitmap, | 378 base::Bind(&ShortcutHelper::AddShortcutInBackgroundWithRawBitmap, |
409 url_, | 379 shortcut_info_, |
410 title_, | 380 bitmap_result), |
411 display_, | |
412 bitmap_result, | |
413 orientation_), | |
414 true); | 381 true); |
415 | 382 |
416 Destroy(); | 383 Destroy(); |
417 } | 384 } |
418 | 385 |
419 bool ShortcutHelper::OnMessageReceived(const IPC::Message& message) { | 386 bool ShortcutHelper::OnMessageReceived(const IPC::Message& message) { |
420 bool handled = true; | 387 bool handled = true; |
421 | 388 |
422 IPC_BEGIN_MESSAGE_MAP(ShortcutHelper, message) | 389 IPC_BEGIN_MESSAGE_MAP(ShortcutHelper, message) |
423 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidGetWebApplicationInfo, | 390 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidGetWebApplicationInfo, |
424 OnDidGetWebApplicationInfo) | 391 OnDidGetWebApplicationInfo) |
425 IPC_MESSAGE_UNHANDLED(handled = false) | 392 IPC_MESSAGE_UNHANDLED(handled = false) |
426 IPC_END_MESSAGE_MAP() | 393 IPC_END_MESSAGE_MAP() |
427 | 394 |
428 return handled; | 395 return handled; |
429 } | 396 } |
430 | 397 |
431 void ShortcutHelper::WebContentsDestroyed() { | 398 void ShortcutHelper::WebContentsDestroyed() { |
432 Destroy(); | 399 Destroy(); |
433 } | 400 } |
434 | 401 |
435 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { | 402 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { |
436 return RegisterNativesImpl(env); | 403 return RegisterNativesImpl(env); |
437 } | 404 } |
438 | 405 |
439 void ShortcutHelper::AddShortcutInBackgroundWithRawBitmap( | 406 void ShortcutHelper::AddShortcutInBackgroundWithRawBitmap( |
440 const GURL& url, | 407 const ShortcutInfo& info, |
441 const base::string16& title, | 408 const favicon_base::FaviconRawBitmapResult& bitmap_result) { |
442 content::Manifest::DisplayMode display, | |
443 const favicon_base::FaviconRawBitmapResult& bitmap_result, | |
444 blink::WebScreenOrientationLockType orientation) { | |
445 DCHECK(base::WorkerPool::RunsTasksOnCurrentThread()); | 409 DCHECK(base::WorkerPool::RunsTasksOnCurrentThread()); |
446 | 410 |
447 SkBitmap icon_bitmap; | 411 SkBitmap icon_bitmap; |
448 if (bitmap_result.is_valid()) { | 412 if (bitmap_result.is_valid()) { |
449 gfx::PNGCodec::Decode(bitmap_result.bitmap_data->front(), | 413 gfx::PNGCodec::Decode(bitmap_result.bitmap_data->front(), |
450 bitmap_result.bitmap_data->size(), | 414 bitmap_result.bitmap_data->size(), |
451 &icon_bitmap); | 415 &icon_bitmap); |
452 } | 416 } |
453 | 417 |
454 AddShortcutInBackgroundWithSkBitmap( | 418 AddShortcutInBackgroundWithSkBitmap(info, icon_bitmap); |
455 url, title, display, icon_bitmap, orientation); | |
456 } | 419 } |
457 | 420 |
458 void ShortcutHelper::AddShortcutInBackgroundWithSkBitmap( | 421 void ShortcutHelper::AddShortcutInBackgroundWithSkBitmap( |
459 const GURL& url, | 422 const ShortcutInfo& info, |
460 const base::string16& title, | 423 const SkBitmap& icon_bitmap) { |
461 content::Manifest::DisplayMode display, | |
462 const SkBitmap& icon_bitmap, | |
463 blink::WebScreenOrientationLockType orientation) { | |
464 DCHECK(base::WorkerPool::RunsTasksOnCurrentThread()); | 424 DCHECK(base::WorkerPool::RunsTasksOnCurrentThread()); |
465 | 425 |
466 SkColor color = color_utils::CalculateKMeanColorOfBitmap(icon_bitmap); | 426 SkColor color = color_utils::CalculateKMeanColorOfBitmap(icon_bitmap); |
467 int r_value = SkColorGetR(color); | 427 int r_value = SkColorGetR(color); |
468 int g_value = SkColorGetG(color); | 428 int g_value = SkColorGetG(color); |
469 int b_value = SkColorGetB(color); | 429 int b_value = SkColorGetB(color); |
470 | 430 |
471 // Send the data to the Java side to create the shortcut. | 431 // Send the data to the Java side to create the shortcut. |
472 JNIEnv* env = base::android::AttachCurrentThread(); | 432 JNIEnv* env = base::android::AttachCurrentThread(); |
473 ScopedJavaLocalRef<jstring> java_url = | 433 ScopedJavaLocalRef<jstring> java_url = |
474 base::android::ConvertUTF8ToJavaString(env, url.spec()); | 434 base::android::ConvertUTF8ToJavaString(env, info.url.spec()); |
475 ScopedJavaLocalRef<jstring> java_title = | 435 ScopedJavaLocalRef<jstring> java_title = |
476 base::android::ConvertUTF16ToJavaString(env, title); | 436 base::android::ConvertUTF16ToJavaString(env, info.title); |
477 ScopedJavaLocalRef<jobject> java_bitmap; | 437 ScopedJavaLocalRef<jobject> java_bitmap; |
478 if (icon_bitmap.getSize()) | 438 if (icon_bitmap.getSize()) |
479 java_bitmap = gfx::ConvertToJavaBitmap(&icon_bitmap); | 439 java_bitmap = gfx::ConvertToJavaBitmap(&icon_bitmap); |
480 | 440 |
481 Java_ShortcutHelper_addShortcut( | 441 Java_ShortcutHelper_addShortcut( |
482 env, | 442 env, |
483 base::android::GetApplicationContext(), | 443 base::android::GetApplicationContext(), |
484 java_url.obj(), | 444 java_url.obj(), |
485 java_title.obj(), | 445 java_title.obj(), |
486 java_bitmap.obj(), | 446 java_bitmap.obj(), |
487 r_value, | 447 r_value, |
488 g_value, | 448 g_value, |
489 b_value, | 449 b_value, |
490 display == content::Manifest::DISPLAY_MODE_STANDALONE, | 450 info.display == content::Manifest::DISPLAY_MODE_STANDALONE, |
491 orientation); | 451 info.orientation); |
492 } | 452 } |
OLD | NEW |