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

Side by Side Diff: chrome/browser/dom_distiller/tab_utils_android.cc

Issue 1128173005: Clean up ProfileManager interface. Base URL: https://chromium.googlesource.com/chromium/src@issue479309
Patch Set: sync Created 5 years, 6 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
OLDNEW
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 "chrome/browser/dom_distiller/tab_utils_android.h" 5 #include "chrome/browser/dom_distiller/tab_utils_android.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/dom_distiller/tab_utils.h" 12 #include "chrome/browser/dom_distiller/tab_utils.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profile_manager.h" 14 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
15 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
16 #include "content/public/common/content_constants.h" 17 #include "content/public/common/content_constants.h"
17 #include "jni/DomDistillerTabUtils_jni.h" 18 #include "jni/DomDistillerTabUtils_jni.h"
18 #include "net/base/net_util.h" 19 #include "net/base/net_util.h"
19 #include "url/gurl.h" 20 #include "url/gurl.h"
20 21
(...skipping 15 matching lines...) Expand all
36 content::WebContents::FromJavaWebContents(j_source_web_contents); 37 content::WebContents::FromJavaWebContents(j_source_web_contents);
37 content::WebContents* destination_web_contents = 38 content::WebContents* destination_web_contents =
38 content::WebContents::FromJavaWebContents(j_destination_web_contents); 39 content::WebContents::FromJavaWebContents(j_destination_web_contents);
39 ::DistillAndView(source_web_contents, destination_web_contents); 40 ::DistillAndView(source_web_contents, destination_web_contents);
40 } 41 }
41 42
42 jstring GetFormattedUrlFromOriginalDistillerUrl(JNIEnv* env, 43 jstring GetFormattedUrlFromOriginalDistillerUrl(JNIEnv* env,
43 jclass clazz, 44 jclass clazz,
44 jstring j_url) { 45 jstring j_url) {
45 GURL url(base::android::ConvertJavaStringToUTF8(env, j_url)); 46 GURL url(base::android::ConvertJavaStringToUTF8(env, j_url));
46 Profile* profile = ProfileManager::GetLastUsedProfile(); 47 Profile* profile = g_browser_process->profile_manager()->GetLastUsedProfile();
47 std::string languages; // Empty if Profile cannot be retrieved. 48 std::string languages; // Empty if Profile cannot be retrieved.
48 if (profile) { 49 if (profile) {
49 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); 50 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
50 } 51 }
51 52
52 if (url.spec().length() > content::kMaxURLDisplayChars) 53 if (url.spec().length() > content::kMaxURLDisplayChars)
53 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":"); 54 url = url.IsStandard() ? url.GetOrigin() : GURL(url.scheme() + ":");
54 55
55 // Note that we can't unescape spaces here, because if the user copies this 56 // Note that we can't unescape spaces here, because if the user copies this
56 // and pastes it into another program, that program may think the URL ends at 57 // and pastes it into another program, that program may think the URL ends at
57 // the space. 58 // the space.
58 return base::android::ConvertUTF16ToJavaString( 59 return base::android::ConvertUTF16ToJavaString(
59 env, 60 env,
60 net::FormatUrl(url, 61 net::FormatUrl(url,
61 languages, 62 languages,
62 net::kFormatUrlOmitAll, 63 net::kFormatUrlOmitAll,
63 net::UnescapeRule::NORMAL, 64 net::UnescapeRule::NORMAL,
64 NULL, 65 NULL,
65 NULL, 66 NULL,
66 NULL)).Release(); 67 NULL)).Release();
67 } 68 }
68 69
69 } // namespace android 70 } // namespace android
70 71
71 bool RegisterDomDistillerTabUtils(JNIEnv* env) { 72 bool RegisterDomDistillerTabUtils(JNIEnv* env) {
72 return android::RegisterNativesImpl(env); 73 return android::RegisterNativesImpl(env);
73 } 74 }
OLDNEW
« no previous file with comments | « chrome/browser/devtools/chrome_devtools_discovery_provider.cc ('k') | chrome/browser/feedback/show_feedback_page.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698