Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: chrome/browser/android/shortcut_helper.cc

Issue 24063004: Adding a dialog on click of "add to homescreen" menu item to edit the title. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Error uploading patchset, trying again Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/android/jni_string.h" 10 #include "base/android/jni_string.h"
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/threading/worker_pool.h" 14 #include "base/threading/worker_pool.h"
15 #include "chrome/browser/android/tab_android.h" 15 #include "chrome/browser/android/tab_android.h"
16 #include "chrome/browser/favicon/favicon_service.h" 16 #include "chrome/browser/favicon/favicon_service.h"
17 #include "chrome/browser/favicon/favicon_service_factory.h" 17 #include "chrome/browser/favicon/favicon_service_factory.h"
18 #include "chrome/common/cancelable_task_tracker.h" 18 #include "chrome/common/cancelable_task_tracker.h"
19 #include "chrome/common/render_messages.h" 19 #include "chrome/common/render_messages.h"
20 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
21 #include "content/public/browser/web_contents_observer.h" 21 #include "content/public/browser/web_contents_observer.h"
22 #include "content/public/common/frame_navigate_params.h" 22 #include "content/public/common/frame_navigate_params.h"
23 #include "jni/ShortcutHelper_jni.h" 23 #include "jni/ShortcutHelper_jni.h"
24 #include "ui/gfx/android/java_bitmap.h" 24 #include "ui/gfx/android/java_bitmap.h"
25 #include "ui/gfx/codec/png_codec.h" 25 #include "ui/gfx/codec/png_codec.h"
26 #include "ui/gfx/color_analysis.h" 26 #include "ui/gfx/color_analysis.h"
27 #include "url/gurl.h" 27 #include "url/gurl.h"
28 28
29 ShortcutBuilder::ShortcutBuilder(content::WebContents* web_contents) 29 ShortcutBuilder::ShortcutBuilder(content::WebContents* web_contents,
30 string16 title)
30 : is_webapp_capable_(false) { 31 : is_webapp_capable_(false) {
31 Observe(web_contents); 32 Observe(web_contents);
32 url_ = web_contents->GetURL(); 33 url_ = web_contents->GetURL();
33 title_ = web_contents->GetTitle(); 34 if (title.length() != 0)
gone 2013/09/13 00:31:53 nit: > 0
Ramya 2013/09/13 01:04:34 Done.
35 title_ = title;
36 else
37 title_ = web_contents->GetTitle();
34 38
35 // Send a message to the renderer to retrieve information about the page. 39 // Send a message to the renderer to retrieve information about the page.
36 Send(new ChromeViewMsg_RetrieveWebappInformation(routing_id(), url_)); 40 Send(new ChromeViewMsg_RetrieveWebappInformation(routing_id(), url_));
37 } 41 }
38 42
39 void ShortcutBuilder::OnDidRetrieveWebappInformation(bool success, 43 void ShortcutBuilder::OnDidRetrieveWebappInformation(bool success,
40 bool is_webapp_capable, 44 bool is_webapp_capable,
41 const GURL& expected_url) { 45 const GURL& expected_url) {
42 Profile* profile = 46 Profile* profile =
43 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 47 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 Destroy(); 105 Destroy();
102 } 106 }
103 107
104 void ShortcutBuilder::Destroy() { 108 void ShortcutBuilder::Destroy() {
105 if (cancelable_task_tracker_.HasTrackedTasks()) { 109 if (cancelable_task_tracker_.HasTrackedTasks()) {
106 cancelable_task_tracker_.TryCancelAll(); 110 cancelable_task_tracker_.TryCancelAll();
107 } 111 }
108 delete this; 112 delete this;
109 } 113 }
110 114
111 void ShortcutHelper::AddShortcut(content::WebContents* web_contents) { 115 void ShortcutHelper::AddShortcut(content::WebContents* web_contents,
116 string16 title) {
112 // The ShortcutBuilder deletes itself when it's done. 117 // The ShortcutBuilder deletes itself when it's done.
113 new ShortcutBuilder(web_contents); 118 new ShortcutBuilder(web_contents, title);
114 } 119 }
115 120
116 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { 121 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) {
117 return RegisterNativesImpl(env); 122 return RegisterNativesImpl(env);
118 } 123 }
119 124
120 void ShortcutHelper::AddShortcutInBackground( 125 void ShortcutHelper::AddShortcutInBackground(
121 const GURL& url, 126 const GURL& url,
122 const string16& title, 127 const string16& title,
123 bool is_webapp_capable, 128 bool is_webapp_capable,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 r_value, 165 r_value,
161 g_value, 166 g_value,
162 b_value, 167 b_value,
163 is_webapp_capable); 168 is_webapp_capable);
164 } 169 }
165 170
166 // Adds a shortcut to the current URL to the Android home screen, firing 171 // Adds a shortcut to the current URL to the Android home screen, firing
167 // background tasks to pull all the data required. 172 // background tasks to pull all the data required.
168 // Note that we don't actually care about the tab here -- we just want 173 // Note that we don't actually care about the tab here -- we just want
169 // its otherwise inaccessible WebContents. 174 // its otherwise inaccessible WebContents.
170 static void AddShortcut(JNIEnv* env, jclass clazz, jint tab_android_ptr) { 175 static void AddShortcut(JNIEnv* env,
176 jclass clazz,
177 jint tab_android_ptr,
178 jstring title) {
171 TabAndroid* tab = reinterpret_cast<TabAndroid*>(tab_android_ptr); 179 TabAndroid* tab = reinterpret_cast<TabAndroid*>(tab_android_ptr);
172 ShortcutHelper::AddShortcut(tab->web_contents()); 180 ShortcutHelper::AddShortcut(
181 tab->web_contents(),
182 base::android::ConvertJavaStringToUTF16(env, title));
173 } 183 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698