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

Side by Side Diff: chrome/browser/ui/tab_contents/core_tab_helper.h

Issue 2737893002: Mojoify the RequestThumbnailForContextNode IPC message and reply (Closed)
Patch Set: Created 3 years, 9 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 #ifndef CHROME_BROWSER_UI_TAB_CONTENTS_CORE_TAB_HELPER_H_ 5 #ifndef CHROME_BROWSER_UI_TAB_CONTENTS_CORE_TAB_HELPER_H_
6 #define CHROME_BROWSER_UI_TAB_CONTENTS_CORE_TAB_HELPER_H_ 6 #define CHROME_BROWSER_UI_TAB_CONTENTS_CORE_TAB_HELPER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/id_map.h" 11 #include "base/id_map.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "chrome/common/thumbnail_capturer.mojom.h"
14 #include "content/public/browser/web_contents_observer.h" 15 #include "content/public/browser/web_contents_observer.h"
15 #include "content/public/browser/web_contents_user_data.h" 16 #include "content/public/browser/web_contents_user_data.h"
16 #include "ui/gfx/geometry/size.h" 17 #include "ui/gfx/geometry/size.h"
17 #include "url/gurl.h" 18 #include "url/gurl.h"
18 19
19 class CoreTabHelperDelegate; 20 class CoreTabHelperDelegate;
20 21
21 // Per-tab class to handle functionality that is core to the operation of tabs. 22 // Per-tab class to handle functionality that is core to the operation of tabs.
22 class CoreTabHelper : public content::WebContentsObserver, 23 class CoreTabHelper : public content::WebContentsObserver,
23 public content::WebContentsUserData<CoreTabHelper> { 24 public content::WebContentsUserData<CoreTabHelper> {
24 public: 25 public:
25 using ContextNodeThumbnailCallback = 26 using ContextNodeThumbnailCallback =
26 base::Callback<void(const std::string&, const gfx::Size&)>; 27 chrome::mojom::ThumbnailCapturer::RequestThumbnailForContextNodeCallback;
27 28
28 ~CoreTabHelper() override; 29 ~CoreTabHelper() override;
29 30
30 // Initial title assigned to NavigationEntries from Navigate. 31 // Initial title assigned to NavigationEntries from Navigate.
31 static base::string16 GetDefaultTitle(); 32 static base::string16 GetDefaultTitle();
32 33
33 // Returns a human-readable description the tab's loading state. 34 // Returns a human-readable description the tab's loading state.
34 base::string16 GetStatusText() const; 35 base::string16 GetStatusText() const;
35 36
36 // Notification that tab closing has started. This can be called multiple 37 // Notification that tab closing has started. This can be called multiple
(...skipping 14 matching lines...) Expand all
51 52
52 void UpdateContentRestrictions(int content_restrictions); 53 void UpdateContentRestrictions(int content_restrictions);
53 54
54 // Perform an image search for the image that triggered the context menu. The 55 // Perform an image search for the image that triggered the context menu. The
55 // |src_url| is passed to the search request and is not used directly to fetch 56 // |src_url| is passed to the search request and is not used directly to fetch
56 // the image resources. 57 // the image resources.
57 void SearchByImageInNewTab(content::RenderFrameHost* render_frame_host, 58 void SearchByImageInNewTab(content::RenderFrameHost* render_frame_host,
58 const GURL& src_url); 59 const GURL& src_url);
59 void RequestThumbnailForContextNode( 60 void RequestThumbnailForContextNode(
60 content::RenderFrameHost* render_frame_host, 61 content::RenderFrameHost* render_frame_host,
61 int minimum_size, 62 int thumbnail_min_area_pixels,
62 gfx::Size maximum_size, 63 gfx::Size thumbnail_max_size_pixels,
63 const ContextNodeThumbnailCallback& callback); 64 const ContextNodeThumbnailCallback& callback);
64 65
65 CoreTabHelperDelegate* delegate() const { return delegate_; } 66 CoreTabHelperDelegate* delegate() const { return delegate_; }
66 void set_delegate(CoreTabHelperDelegate* d) { delegate_ = d; } 67 void set_delegate(CoreTabHelperDelegate* d) { delegate_ = d; }
67 68
68 void set_new_tab_start_time(const base::TimeTicks& time) { 69 void set_new_tab_start_time(const base::TimeTicks& time) {
69 new_tab_start_time_ = time; 70 new_tab_start_time_ = time;
70 } 71 }
71 72
72 base::TimeTicks new_tab_start_time() const { return new_tab_start_time_; } 73 base::TimeTicks new_tab_start_time() const { return new_tab_start_time_; }
73 int content_restrictions() const { return content_restrictions_; } 74 int content_restrictions() const { return content_restrictions_; }
74 75
75 private: 76 private:
76 explicit CoreTabHelper(content::WebContents* web_contents); 77 explicit CoreTabHelper(content::WebContents* web_contents);
77 friend class content::WebContentsUserData<CoreTabHelper>; 78 friend class content::WebContentsUserData<CoreTabHelper>;
78 79
79 static bool GetStatusTextForWebContents(base::string16* status_text, 80 static bool GetStatusTextForWebContents(base::string16* status_text,
80 content::WebContents* source); 81 content::WebContents* source);
81 82
82 // content::WebContentsObserver overrides: 83 // content::WebContentsObserver overrides:
83 void DidStartLoading() override; 84 void DidStartLoading() override;
84 void WasShown() override; 85 void WasShown() override;
85 void WebContentsDestroyed() override; 86 void WebContentsDestroyed() override;
86 void BeforeUnloadFired(const base::TimeTicks& proceed_time) override; 87 void BeforeUnloadFired(const base::TimeTicks& proceed_time) override;
87 void BeforeUnloadDialogCancelled() override; 88 void BeforeUnloadDialogCancelled() override;
88 bool OnMessageReceived(const IPC::Message& message,
89 content::RenderFrameHost* render_frame_host) override;
90 89
91 void OnRequestThumbnailForContextNodeACK(const std::string& thumbnail_data, 90 void OnThumbnailForContextNodeReceived(
92 const gfx::Size& original_size, 91 int interface_id,
93 int callback_id); 92 const ContextNodeThumbnailCallback& callback,
93 const std::string& thumbnail_data,
94 const gfx::Size& original_size);
95
94 void DoSearchByImageInNewTab(const GURL& src_url, 96 void DoSearchByImageInNewTab(const GURL& src_url,
95 const std::string& thumbnail_data, 97 const std::string& thumbnail_data,
96 const gfx::Size& original_size); 98 const gfx::Size& original_size);
97 99
98 // Delegate for notifying our owner about stuff. Not owned by us. 100 // Delegate for notifying our owner about stuff. Not owned by us.
99 CoreTabHelperDelegate* delegate_; 101 CoreTabHelperDelegate* delegate_;
100 102
101 // The time when we started to create the new tab page. This time is from 103 // The time when we started to create the new tab page. This time is from
102 // before we created this WebContents. 104 // before we created this WebContents.
103 base::TimeTicks new_tab_start_time_; 105 base::TimeTicks new_tab_start_time_;
104 106
105 // The time that we started to close this WebContents. 107 // The time that we started to close this WebContents.
106 base::TimeTicks close_start_time_; 108 base::TimeTicks close_start_time_;
107 109
108 // The time when onbeforeunload ended. 110 // The time when onbeforeunload ended.
109 base::TimeTicks before_unload_end_time_; 111 base::TimeTicks before_unload_end_time_;
110 112
111 // The time when the tab was removed from view during close. 113 // The time when the tab was removed from view during close.
112 base::TimeTicks unload_detached_start_time_; 114 base::TimeTicks unload_detached_start_time_;
113 115
114 // Content restrictions, used to disable print/copy etc based on content's 116 // Content restrictions, used to disable print/copy etc based on content's
115 // (full-page plugins for now only) permissions. 117 // (full-page plugins for now only) permissions.
116 int content_restrictions_; 118 int content_restrictions_;
117 119
118 IDMap<std::unique_ptr<ContextNodeThumbnailCallback>> thumbnail_callbacks_; 120 IDMap<std::unique_ptr<chrome::mojom::ThumbnailCapturerPtr>>
121 thumbnail_capturers_;
119 122
120 DISALLOW_COPY_AND_ASSIGN(CoreTabHelper); 123 DISALLOW_COPY_AND_ASSIGN(CoreTabHelper);
121 }; 124 };
122 125
123 #endif // CHROME_BROWSER_UI_TAB_CONTENTS_CORE_TAB_HELPER_H_ 126 #endif // CHROME_BROWSER_UI_TAB_CONTENTS_CORE_TAB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698