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

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

Issue 943643002: Pull up get{User,}BookmarkId from ChromeTab to Tab. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix indent Created 5 years, 10 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
« no previous file with comments | « chrome/browser/android/tab_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/uma_utils.h" 15 #include "chrome/browser/android/uma_utils.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"
16 #include "chrome/browser/browser_about_handler.h" 19 #include "chrome/browser/browser_about_handler.h"
17 #include "chrome/browser/chrome_notification_types.h" 20 #include "chrome/browser/chrome_notification_types.h"
18 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 21 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
19 #include "chrome/browser/favicon/favicon_tab_helper.h" 22 #include "chrome/browser/favicon/favicon_tab_helper.h"
20 #include "chrome/browser/infobars/infobar_service.h" 23 #include "chrome/browser/infobars/infobar_service.h"
21 #include "chrome/browser/prerender/prerender_contents.h" 24 #include "chrome/browser/prerender/prerender_contents.h"
22 #include "chrome/browser/prerender/prerender_manager.h" 25 #include "chrome/browser/prerender/prerender_manager.h"
23 #include "chrome/browser/prerender/prerender_manager_factory.h" 26 #include "chrome/browser/prerender/prerender_manager_factory.h"
24 #include "chrome/browser/printing/print_view_manager_basic.h" 27 #include "chrome/browser/printing/print_view_manager_basic.h"
25 #include "chrome/browser/profiles/profile.h" 28 #include "chrome/browser/profiles/profile.h"
(...skipping 13 matching lines...) Expand all
39 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" 42 #include "chrome/browser/ui/android/tab_model/tab_model_list.h"
40 #include "chrome/browser/ui/android/window_android_helper.h" 43 #include "chrome/browser/ui/android/window_android_helper.h"
41 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" 44 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h"
42 #include "chrome/browser/ui/search/instant_search_prerenderer.h" 45 #include "chrome/browser/ui/search/instant_search_prerenderer.h"
43 #include "chrome/browser/ui/search/search_tab_helper.h" 46 #include "chrome/browser/ui/search/search_tab_helper.h"
44 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" 47 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
45 #include "chrome/browser/ui/tab_helpers.h" 48 #include "chrome/browser/ui/tab_helpers.h"
46 #include "chrome/common/instant_types.h" 49 #include "chrome/common/instant_types.h"
47 #include "chrome/common/render_messages.h" 50 #include "chrome/common/render_messages.h"
48 #include "chrome/common/url_constants.h" 51 #include "chrome/common/url_constants.h"
52 #include "components/bookmarks/browser/bookmark_model.h"
53 #include "components/bookmarks/browser/bookmark_node.h"
54 #include "components/bookmarks/browser/bookmark_utils.h"
55 #include "components/dom_distiller/core/url_utils.h"
49 #include "components/infobars/core/infobar_container.h" 56 #include "components/infobars/core/infobar_container.h"
50 #include "components/navigation_interception/intercept_navigation_delegate.h" 57 #include "components/navigation_interception/intercept_navigation_delegate.h"
51 #include "components/navigation_interception/navigation_params.h" 58 #include "components/navigation_interception/navigation_params.h"
52 #include "components/url_fixer/url_fixer.h" 59 #include "components/url_fixer/url_fixer.h"
53 #include "content/public/browser/android/content_view_core.h" 60 #include "content/public/browser/android/content_view_core.h"
54 #include "content/public/browser/browser_thread.h" 61 #include "content/public/browser/browser_thread.h"
55 #include "content/public/browser/navigation_entry.h" 62 #include "content/public/browser/navigation_entry.h"
56 #include "content/public/browser/notification_service.h" 63 #include "content/public/browser/notification_service.h"
57 #include "content/public/browser/render_frame_host.h" 64 #include "content/public/browser/render_frame_host.h"
58 #include "content/public/browser/render_process_host.h" 65 #include "content/public/browser/render_process_host.h"
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 content::RenderFrameHost* render_frame_host = 730 content::RenderFrameHost* render_frame_host =
724 web_contents()->GetMainFrame(); 731 web_contents()->GetMainFrame();
725 render_frame_host->Send( 732 render_frame_host->Send(
726 new ChromeViewMsg_RequestThumbnailForContextNode( 733 new ChromeViewMsg_RequestThumbnailForContextNode(
727 render_frame_host->GetRoutingID(), 734 render_frame_host->GetRoutingID(),
728 kImageSearchThumbnailMinSize, 735 kImageSearchThumbnailMinSize,
729 gfx::Size(kImageSearchThumbnailMaxWidth, 736 gfx::Size(kImageSearchThumbnailMaxWidth,
730 kImageSearchThumbnailMaxHeight))); 737 kImageSearchThumbnailMaxHeight)));
731 } 738 }
732 739
740 jlong TabAndroid::GetBookmarkId(JNIEnv* env,
741 jobject obj,
742 jboolean only_editable) {
743 const GURL& url = dom_distiller::url_utils::GetOriginalUrlFromDistillerUrl(
744 web_contents()->GetURL());
745 Profile* profile = GetProfile();
746
747 // Get all the nodes for |url| and sort them by date added.
748 std::vector<const bookmarks::BookmarkNode*> nodes;
749 ChromeBookmarkClient* client =
750 ChromeBookmarkClientFactory::GetForProfile(profile);
751 bookmarks::BookmarkModel* model =
752 BookmarkModelFactory::GetForProfile(profile);
753 model->GetNodesByURL(url, &nodes);
754 std::sort(nodes.begin(), nodes.end(), &bookmarks::MoreRecentlyAdded);
755
756 // Return the first node matching the search criteria.
757 for (size_t i = 0; i < nodes.size(); ++i) {
758 if (only_editable && !client->CanBeEditedByUser(nodes[i]))
759 continue;
760 return nodes[i]->id();
761 }
762
763 return -1;
764 }
765
733 namespace { 766 namespace {
734 767
735 class ChromeInterceptNavigationDelegate : public InterceptNavigationDelegate { 768 class ChromeInterceptNavigationDelegate : public InterceptNavigationDelegate {
736 public: 769 public:
737 ChromeInterceptNavigationDelegate(JNIEnv* env, jobject jdelegate) 770 ChromeInterceptNavigationDelegate(JNIEnv* env, jobject jdelegate)
738 : InterceptNavigationDelegate(env, jdelegate) {} 771 : InterceptNavigationDelegate(env, jdelegate) {}
739 772
740 bool ShouldIgnoreNavigation( 773 bool ShouldIgnoreNavigation(
741 const NavigationParams& navigation_params) override { 774 const NavigationParams& navigation_params) override {
742 NavigationParams chrome_navigation_params(navigation_params); 775 NavigationParams chrome_navigation_params(navigation_params);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 // s^{n+1} / s^{n} = 2100 / 2000 848 // s^{n+1} / s^{n} = 2100 / 2000
816 // s = 1.05 849 // s = 1.05
817 // s^b = 60000 850 // s^b = 60000
818 // b = ln(60000) / ln(1.05) ~= 225 851 // b = ln(60000) / ln(1.05) ~= 225
819 UMA_HISTOGRAM_CUSTOM_TIMES("Startup.FirstCommitNavigationTime", 852 UMA_HISTOGRAM_CUSTOM_TIMES("Startup.FirstCommitNavigationTime",
820 base::Time::Now() - chrome::android::GetMainEntryPointTime(), 853 base::Time::Now() - chrome::android::GetMainEntryPointTime(),
821 base::TimeDelta::FromMilliseconds(1), 854 base::TimeDelta::FromMilliseconds(1),
822 base::TimeDelta::FromMinutes(1), 855 base::TimeDelta::FromMinutes(1),
823 225); 856 225);
824 } 857 }
OLDNEW
« no previous file with comments | « chrome/browser/android/tab_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698