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

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

Issue 105193002: Replace string16 with base::string16. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
« no previous file with comments | « chrome/browser/android/shortcut_helper.h ('k') | chrome/browser/android/tab_android.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 11 matching lines...) Expand all
22 #include "content/public/browser/web_contents_observer.h" 22 #include "content/public/browser/web_contents_observer.h"
23 #include "content/public/common/frame_navigate_params.h" 23 #include "content/public/common/frame_navigate_params.h"
24 #include "jni/ShortcutHelper_jni.h" 24 #include "jni/ShortcutHelper_jni.h"
25 #include "ui/gfx/android/java_bitmap.h" 25 #include "ui/gfx/android/java_bitmap.h"
26 #include "ui/gfx/codec/png_codec.h" 26 #include "ui/gfx/codec/png_codec.h"
27 #include "ui/gfx/color_analysis.h" 27 #include "ui/gfx/color_analysis.h"
28 #include "ui/gfx/favicon_size.h" 28 #include "ui/gfx/favicon_size.h"
29 #include "url/gurl.h" 29 #include "url/gurl.h"
30 30
31 ShortcutBuilder::ShortcutBuilder(content::WebContents* web_contents, 31 ShortcutBuilder::ShortcutBuilder(content::WebContents* web_contents,
32 const string16& title, 32 const base::string16& title,
33 int launcher_large_icon_size) 33 int launcher_large_icon_size)
34 : launcher_large_icon_size_(launcher_large_icon_size), 34 : launcher_large_icon_size_(launcher_large_icon_size),
35 shortcut_type_(BOOKMARK) { 35 shortcut_type_(BOOKMARK) {
36 Observe(web_contents); 36 Observe(web_contents);
37 url_ = web_contents->GetURL(); 37 url_ = web_contents->GetURL();
38 if (title.length() > 0) 38 if (title.length() > 0)
39 title_ = title; 39 title_ = title;
40 else 40 else
41 title_ = web_contents->GetTitle(); 41 title_ = web_contents->GetTitle();
42 42
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 118 }
119 119
120 void ShortcutBuilder::Destroy() { 120 void ShortcutBuilder::Destroy() {
121 if (cancelable_task_tracker_.HasTrackedTasks()) { 121 if (cancelable_task_tracker_.HasTrackedTasks()) {
122 cancelable_task_tracker_.TryCancelAll(); 122 cancelable_task_tracker_.TryCancelAll();
123 } 123 }
124 delete this; 124 delete this;
125 } 125 }
126 126
127 void ShortcutHelper::AddShortcut(content::WebContents* web_contents, 127 void ShortcutHelper::AddShortcut(content::WebContents* web_contents,
128 const string16& title, 128 const base::string16& title,
129 int launcher_large_icon_size) { 129 int launcher_large_icon_size) {
130 // The ShortcutBuilder deletes itself when it's done. 130 // The ShortcutBuilder deletes itself when it's done.
131 new ShortcutBuilder(web_contents, title, launcher_large_icon_size); 131 new ShortcutBuilder(web_contents, title, launcher_large_icon_size);
132 } 132 }
133 133
134 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) { 134 bool ShortcutHelper::RegisterShortcutHelper(JNIEnv* env) {
135 return RegisterNativesImpl(env); 135 return RegisterNativesImpl(env);
136 } 136 }
137 137
138 void ShortcutHelper::AddShortcutInBackground( 138 void ShortcutHelper::AddShortcutInBackground(
139 const GURL& url, 139 const GURL& url,
140 const string16& title, 140 const base::string16& title,
141 ShortcutBuilder::ShortcutType shortcut_type, 141 ShortcutBuilder::ShortcutType shortcut_type,
142 const chrome::FaviconBitmapResult& bitmap_result) { 142 const chrome::FaviconBitmapResult& bitmap_result) {
143 DCHECK(base::WorkerPool::RunsTasksOnCurrentThread()); 143 DCHECK(base::WorkerPool::RunsTasksOnCurrentThread());
144 144
145 // Grab the average color from the bitmap. 145 // Grab the average color from the bitmap.
146 SkColor color = SK_ColorWHITE; 146 SkColor color = SK_ColorWHITE;
147 SkBitmap favicon_bitmap; 147 SkBitmap favicon_bitmap;
148 if (bitmap_result.is_valid()) { 148 if (bitmap_result.is_valid()) {
149 color_utils::GridSampler sampler; 149 color_utils::GridSampler sampler;
150 color = color_utils::CalculateKMeanColorOfPNG(bitmap_result.bitmap_data, 150 color = color_utils::CalculateKMeanColorOfPNG(bitmap_result.bitmap_data,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 jclass clazz, 207 jclass clazz,
208 jlong tab_android_ptr, 208 jlong tab_android_ptr,
209 jstring title, 209 jstring title,
210 jint launcher_large_icon_size) { 210 jint launcher_large_icon_size) {
211 TabAndroid* tab = reinterpret_cast<TabAndroid*>(tab_android_ptr); 211 TabAndroid* tab = reinterpret_cast<TabAndroid*>(tab_android_ptr);
212 ShortcutHelper::AddShortcut( 212 ShortcutHelper::AddShortcut(
213 tab->web_contents(), 213 tab->web_contents(),
214 base::android::ConvertJavaStringToUTF16(env, title), 214 base::android::ConvertJavaStringToUTF16(env, title),
215 launcher_large_icon_size); 215 launcher_large_icon_size);
216 } 216 }
OLDNEW
« no previous file with comments | « chrome/browser/android/shortcut_helper.h ('k') | chrome/browser/android/tab_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698