Index: chrome/browser/android/shortcut_helper.cc |
diff --git a/chrome/browser/android/shortcut_helper.cc b/chrome/browser/android/shortcut_helper.cc |
index 71f32233dc23e6ed0ca71f39a044c3d11698ea7a..17d0a8294a86e140625441ca4efff9c9d694fa35 100644 |
--- a/chrome/browser/android/shortcut_helper.cc |
+++ b/chrome/browser/android/shortcut_helper.cc |
@@ -17,6 +17,7 @@ |
#include "chrome/browser/favicon/favicon_service.h" |
#include "chrome/browser/favicon/favicon_service_factory.h" |
#include "chrome/common/render_messages.h" |
+#include "chrome/common/web_application_info.h" |
#include "content/public/browser/user_metrics.h" |
#include "content/public/browser/web_contents.h" |
#include "content/public/browser/web_contents_observer.h" |
@@ -44,38 +45,23 @@ ShortcutHelper::ShortcutHelper(JNIEnv* env, |
: WebContentsObserver(web_contents), |
java_ref_(env, obj), |
url_(web_contents->GetURL()), |
- shortcut_type_(BOOKMARK) { |
+ mobile_capable_(WebApplicationInfo::MOBILE_CAPABLE_UNSPECIFIED) { |
} |
void ShortcutHelper::Initialize() { |
// Send a message to the renderer to retrieve information about the page. |
- Send(new ChromeViewMsg_RetrieveWebappInformation(routing_id(), url_)); |
+ Send(new ChromeViewMsg_GetWebApplicationInfo(routing_id())); |
} |
ShortcutHelper::~ShortcutHelper() { |
} |
-void ShortcutHelper::OnDidRetrieveWebappInformation( |
- bool success, |
- bool is_mobile_webapp_capable, |
- bool is_apple_mobile_webapp_capable, |
- const GURL& expected_url) { |
- // This should silently fail. |
- if (!success) { |
- LOG(ERROR) << "Failed to parse webpage."; |
- } else if (expected_url != url_) { |
- LOG(ERROR) << "Unexpected URL returned."; |
- } |
- |
- if (is_apple_mobile_webapp_capable && !is_mobile_webapp_capable) { |
- shortcut_type_ = APP_SHORTCUT_APPLE; |
- } else if (is_apple_mobile_webapp_capable || is_mobile_webapp_capable) { |
- shortcut_type_ = APP_SHORTCUT; |
- } else { |
- shortcut_type_ = BOOKMARK; |
- } |
+void ShortcutHelper::OnDidGetWebApplicationInfo( |
+ const WebApplicationInfo& web_app_info) { |
+ mobile_capable_ = web_app_info.mobile_capable; |
gone
2014/09/15 16:55:17
mobile_capable_ is a really strange name for this.
mlamouri (slow - plz ping)
2014/09/15 20:30:53
Renamed web_app_capable_.
|
- title_ = web_contents()->GetTitle(); |
+ title_ = !web_app_info.title.empty() ? web_app_info.title |
gone
2014/09/15 16:55:17
nit: ! seems redundant when you can just flip the
mlamouri (slow - plz ping)
2014/09/15 20:30:53
Done.
|
+ : web_contents()->GetTitle(); |
JNIEnv* env = base::android::AttachCurrentThread(); |
ScopedJavaLocalRef<jobject> j_obj = java_ref_.get(env); |
@@ -137,7 +123,7 @@ void ShortcutHelper::FinishAddingShortcut( |
base::Bind(&ShortcutHelper::AddShortcutInBackground, |
url_, |
title_, |
- shortcut_type_, |
+ mobile_capable_, |
icon_), |
true); |
@@ -148,8 +134,8 @@ bool ShortcutHelper::OnMessageReceived(const IPC::Message& message) { |
bool handled = true; |
IPC_BEGIN_MESSAGE_MAP(ShortcutHelper, message) |
- IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidRetrieveWebappInformation, |
- OnDidRetrieveWebappInformation) |
+ IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidGetWebApplicationInfo, |
+ OnDidGetWebApplicationInfo) |
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
@@ -167,7 +153,7 @@ bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { |
void ShortcutHelper::AddShortcutInBackground( |
const GURL& url, |
const base::string16& title, |
- ShortcutType shortcut_type, |
+ WebApplicationInfo::MobileCapable mobile_capable, |
const favicon_base::FaviconRawBitmapResult& bitmap_result) { |
DCHECK(base::WorkerPool::RunsTasksOnCurrentThread()); |
@@ -195,27 +181,28 @@ void ShortcutHelper::AddShortcutInBackground( |
if (favicon_bitmap.getSize()) |
java_bitmap = gfx::ConvertToJavaBitmap(&favicon_bitmap); |
- Java_ShortcutHelper_addShortcut(env, |
- base::android::GetApplicationContext(), |
- java_url.obj(), |
- java_title.obj(), |
- java_bitmap.obj(), |
- r_value, |
- g_value, |
- b_value, |
- shortcut_type != BOOKMARK); |
+ Java_ShortcutHelper_addShortcut( |
+ env, |
+ base::android::GetApplicationContext(), |
+ java_url.obj(), |
+ java_title.obj(), |
+ java_bitmap.obj(), |
+ r_value, |
+ g_value, |
+ b_value, |
+ mobile_capable != WebApplicationInfo::MOBILE_CAPABLE_UNSPECIFIED); |
// Record what type of shortcut was added by the user. |
- switch (shortcut_type) { |
- case APP_SHORTCUT: |
+ switch (mobile_capable) { |
+ case WebApplicationInfo::MOBILE_CAPABLE: |
content::RecordAction( |
base::UserMetricsAction("webapps.AddShortcut.AppShortcut")); |
break; |
- case APP_SHORTCUT_APPLE: |
+ case WebApplicationInfo::MOBILE_CAPABLE_APPLE: |
content::RecordAction( |
base::UserMetricsAction("webapps.AddShortcut.AppShortcutApple")); |
break; |
- case BOOKMARK: |
+ case WebApplicationInfo::MOBILE_CAPABLE_UNSPECIFIED: |
content::RecordAction( |
base::UserMetricsAction("webapps.AddShortcut.Bookmark")); |
break; |