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

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

Issue 1203713002: Limit access to ChromeBookmarkClient to bookmarks code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup_bookmark_client
Patch Set: Rebase 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/tab_android.h" 5 #include "chrome/browser/android/tab_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/trace_event/trace_event.h" 11 #include "base/trace_event/trace_event.h"
12 #include "cc/layers/layer.h" 12 #include "cc/layers/layer.h"
13 #include "chrome/browser/android/chrome_web_contents_delegate_android.h" 13 #include "chrome/browser/android/chrome_web_contents_delegate_android.h"
14 #include "chrome/browser/android/compositor/tab_content_manager.h" 14 #include "chrome/browser/android/compositor/tab_content_manager.h"
15 #include "chrome/browser/android/metrics/uma_utils.h" 15 #include "chrome/browser/android/metrics/uma_utils.h"
16 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 16 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
17 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
18 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
19 #include "chrome/browser/browser_about_handler.h" 17 #include "chrome/browser/browser_about_handler.h"
20 #include "chrome/browser/chrome_notification_types.h" 18 #include "chrome/browser/chrome_notification_types.h"
21 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 19 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
22 #include "chrome/browser/infobars/infobar_service.h" 20 #include "chrome/browser/infobars/infobar_service.h"
23 #include "chrome/browser/prerender/prerender_contents.h" 21 #include "chrome/browser/prerender/prerender_contents.h"
24 #include "chrome/browser/prerender/prerender_manager.h" 22 #include "chrome/browser/prerender/prerender_manager.h"
25 #include "chrome/browser/prerender/prerender_manager_factory.h" 23 #include "chrome/browser/prerender/prerender_manager_factory.h"
26 #include "chrome/browser/printing/print_view_manager_basic.h" 24 #include "chrome/browser/printing/print_view_manager_basic.h"
27 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/profiles/profile_android.h" 26 #include "chrome/browser/profiles/profile_android.h"
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 761
764 jlong TabAndroid::GetBookmarkId(JNIEnv* env, 762 jlong TabAndroid::GetBookmarkId(JNIEnv* env,
765 jobject obj, 763 jobject obj,
766 jboolean only_editable) { 764 jboolean only_editable) {
767 const GURL& url = dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl( 765 const GURL& url = dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl(
768 web_contents()->GetURL()); 766 web_contents()->GetURL());
769 Profile* profile = GetProfile(); 767 Profile* profile = GetProfile();
770 768
771 // Get all the nodes for |url| and sort them by date added. 769 // Get all the nodes for |url| and sort them by date added.
772 std::vector<const bookmarks::BookmarkNode*> nodes; 770 std::vector<const bookmarks::BookmarkNode*> nodes;
773 ChromeBookmarkClient* client =
774 ChromeBookmarkClientFactory::GetForProfile(profile);
775 bookmarks::BookmarkModel* model = 771 bookmarks::BookmarkModel* model =
776 BookmarkModelFactory::GetForProfile(profile); 772 BookmarkModelFactory::GetForProfile(profile);
777 model->GetNodesByURL(url, &nodes); 773 model->GetNodesByURL(url, &nodes);
778 std::sort(nodes.begin(), nodes.end(), &bookmarks::MoreRecentlyAdded); 774 std::sort(nodes.begin(), nodes.end(), &bookmarks::MoreRecentlyAdded);
779 775
780 // Return the first node matching the search criteria. 776 // Return the first node matching the search criteria.
781 for (size_t i = 0; i < nodes.size(); ++i) { 777 for (size_t i = 0; i < nodes.size(); ++i) {
782 if (only_editable && !client->CanBeEditedByUser(nodes[i])) 778 if (only_editable && !model->CanBeEditedByUser(nodes[i]))
783 continue; 779 continue;
784 return nodes[i]->id(); 780 return nodes[i]->id();
785 } 781 }
786 782
787 return -1; 783 return -1;
788 } 784 }
789 785
790 bool TabAndroid::HasPrerenderedUrl(JNIEnv* env, jobject obj, jstring url) { 786 bool TabAndroid::HasPrerenderedUrl(JNIEnv* env, jobject obj, jstring url) {
791 GURL gurl(base::android::ConvertJavaStringToUTF8(env, url)); 787 GURL gurl(base::android::ConvertJavaStringToUTF8(env, url));
792 return HasPrerenderedUrl(gurl); 788 return HasPrerenderedUrl(gurl);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 // s^{n+1} / s^{n} = 2100 / 2000 874 // s^{n+1} / s^{n} = 2100 / 2000
879 // s = 1.05 875 // s = 1.05
880 // s^b = 60000 876 // s^b = 60000
881 // b = ln(60000) / ln(1.05) ~= 225 877 // b = ln(60000) / ln(1.05) ~= 225
882 UMA_HISTOGRAM_CUSTOM_TIMES("Startup.FirstCommitNavigationTime", 878 UMA_HISTOGRAM_CUSTOM_TIMES("Startup.FirstCommitNavigationTime",
883 base::Time::Now() - chrome::android::GetMainEntryPointTime(), 879 base::Time::Now() - chrome::android::GetMainEntryPointTime(),
884 base::TimeDelta::FromMilliseconds(1), 880 base::TimeDelta::FromMilliseconds(1),
885 base::TimeDelta::FromMinutes(1), 881 base::TimeDelta::FromMinutes(1),
886 225); 882 225);
887 } 883 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698