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

Side by Side Diff: chrome/browser/ui/intents/web_intent_picker_controller.h

Issue 9751014: Revert 127716 - [Web Intents] Inline installation of extensions in web intents picker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
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_INTENTS_WEB_INTENT_PICKER_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_CONTROLLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
15 #include "base/string16.h" 14 #include "base/string16.h"
16 #include "chrome/browser/extensions/webstore_installer.h"
17 #include "chrome/browser/favicon/favicon_service.h" 15 #include "chrome/browser/favicon/favicon_service.h"
18 #include "chrome/browser/intents/web_intents_registry.h" 16 #include "chrome/browser/intents/web_intents_registry.h"
19 #include "chrome/browser/intents/cws_intents_registry.h" 17 #include "chrome/browser/intents/cws_intents_registry.h"
20 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" 18 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h"
21 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
23 #include "webkit/glue/web_intent_data.h" 21 #include "webkit/glue/web_intent_data.h"
24 #include "webkit/glue/web_intent_reply_data.h" 22 #include "webkit/glue/web_intent_reply_data.h"
25 23
26 class Browser; 24 class Browser;
27 struct DefaultWebIntentService; 25 struct DefaultWebIntentService;
28 class GURL; 26 class GURL;
29 class TabContentsWrapper; 27 class TabContentsWrapper;
30 class WebIntentPicker; 28 class WebIntentPicker;
31 class WebIntentPickerModel; 29 class WebIntentPickerModel;
32 class WebstoreInstaller;
33 30
34 namespace content { 31 namespace content {
35 class WebContents; 32 class WebContents;
36 class WebIntentsDispatcher; 33 class WebIntentsDispatcher;
37 } 34 }
38 35
39 namespace webkit_glue { 36 namespace webkit_glue {
40 struct WebIntentServiceData; 37 struct WebIntentServiceData;
41 } 38 }
42 39
43 // Controls the creation of the WebIntentPicker UI and forwards the user's 40 // Controls the creation of the WebIntentPicker UI and forwards the user's
44 // intent handler choice back to the TabContents object. 41 // intent handler choice back to the TabContents object.
45 class WebIntentPickerController : public content::NotificationObserver, 42 class WebIntentPickerController : public content::NotificationObserver,
46 public WebIntentPickerDelegate, 43 public WebIntentPickerDelegate,
47 public WebstoreInstaller::Delegate { 44 public WebIntentsRegistry::Consumer {
48 public: 45 public:
49 // Takes ownership of |factory|. 46 // Takes ownership of |factory|.
50 explicit WebIntentPickerController(TabContentsWrapper* wrapper); 47 explicit WebIntentPickerController(TabContentsWrapper* wrapper);
51 virtual ~WebIntentPickerController(); 48 virtual ~WebIntentPickerController();
52 49
53 // Sets the intent data and return pathway handler object for which 50 // Sets the intent data and return pathway handler object for which
54 // this picker was created. The picker takes ownership of 51 // this picker was created. The picker takes ownership of
55 // |intents_dispatcher|. |intents_dispatcher| must not be NULL. 52 // |intents_dispatcher|. |intents_dispatcher| must not be NULL.
56 void SetIntentsDispatcher(content::WebIntentsDispatcher* intents_dispatcher); 53 void SetIntentsDispatcher(content::WebIntentsDispatcher* intents_dispatcher);
57 54
58 // Shows the web intent picker for |browser|, given the intent 55 // Shows the web intent picker for |browser|, given the intent
59 // |action| and MIME-type |type|. 56 // |action| and MIME-type |type|.
60 void ShowDialog(Browser* browser, 57 void ShowDialog(Browser* browser,
61 const string16& action, 58 const string16& action,
62 const string16& type); 59 const string16& type);
63 60
64 protected: 61 protected:
65 // content::NotificationObserver implementation. 62 // content::NotificationObserver implementation.
66 virtual void Observe(int type, 63 virtual void Observe(int type,
67 const content::NotificationSource& source, 64 const content::NotificationSource& source,
68 const content::NotificationDetails& details) OVERRIDE; 65 const content::NotificationDetails& details) OVERRIDE;
69 66
70 // WebIntentPickerDelegate implementation. 67 // WebIntentPickerDelegate implementation.
71 virtual void OnServiceChosen(const GURL& url, 68 virtual void OnServiceChosen(const GURL& url,
72 Disposition disposition) OVERRIDE; 69 Disposition disposition) OVERRIDE;
73 virtual void OnInlineDispositionWebContentsCreated( 70 virtual void OnInlineDispositionWebContentsCreated(
74 content::WebContents* web_contents) OVERRIDE; 71 content::WebContents* web_contents) OVERRIDE;
75 virtual void OnExtensionInstallRequested(const std::string& id) OVERRIDE;
76 virtual void OnCancelled() OVERRIDE; 72 virtual void OnCancelled() OVERRIDE;
77 virtual void OnClosing() OVERRIDE; 73 virtual void OnClosing() OVERRIDE;
78 74
79 // WebstoreInstaller::Delegate implementation.
80 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE;
81 virtual void OnExtensionInstallFailure(const std::string& id,
82 const std::string& error) OVERRIDE;
83
84 private: 75 private:
85 friend class WebIntentPickerControllerTest; 76 friend class WebIntentPickerControllerTest;
86 friend class WebIntentPickerControllerBrowserTest; 77 friend class WebIntentPickerControllerBrowserTest;
87 friend class InvokingTabObserver; 78 friend class InvokingTabObserver;
88 79
89 // Gets a notification when the return message is sent to the source tab, 80 // Gets a notification when the return message is sent to the source tab,
90 // so we can close the picker dialog or service tab. 81 // so we can close the picker dialog or service tab.
91 void OnSendReturnMessage(webkit_glue::WebIntentReplyType reply_type); 82 void OnSendReturnMessage(webkit_glue::WebIntentReplyType reply_type);
92 83
93 // Exposed for tests only. 84 // Exposed for tests only.
94 void set_picker(WebIntentPicker* picker) { picker_ = picker; } 85 void set_picker(WebIntentPicker* picker) { picker_ = picker; }
95 86
96 // Exposed for tests only. 87 // Exposed for tests only.
97 void set_model_observer(WebIntentPickerModelObserver* observer) { 88 void set_model_observer(WebIntentPickerModelObserver* observer) {
98 picker_model_->set_observer(observer); 89 picker_model_->set_observer(observer);
99 } 90 }
100 91
101 // Called when WebIntentServiceData is returned from the WebIntentsRegistry. 92 // Called when WebIntentServiceData is returned from the WebIntentsRegistry.
102 void OnWebIntentServicesAvailable( 93 virtual void OnIntentsQueryDone(
103 const std::vector<webkit_glue::WebIntentServiceData>& services); 94 WebIntentsRegistry::QueryID,
95 const std::vector<webkit_glue::WebIntentServiceData>& services) OVERRIDE;
96
97 // Called when the WebIntentsRegistry returns responses to a defaults request.
98 virtual void OnIntentsDefaultsQueryDone(
99 WebIntentsRegistry::QueryID,
100 const DefaultWebIntentService& default_service) OVERRIDE;
104 101
105 // Called when FaviconData is returned from the FaviconService. 102 // Called when FaviconData is returned from the FaviconService.
106 void OnFaviconDataAvailable(FaviconService::Handle handle, 103 void OnFaviconDataAvailable(FaviconService::Handle handle,
107 history::FaviconData favicon_data); 104 history::FaviconData favicon_data);
108 105
109 // Called when IntentExtensionInfo is returned from the CWSIntentsRegistry. 106 // Called when IntentExtensionInfo is returned from the CWSIntentsRegistry.
110 void OnCWSIntentServicesAvailable( 107 void OnCWSIntentServicesAvailable(
111 const CWSIntentsRegistry::IntentExtensionList& extensions); 108 const CWSIntentsRegistry::IntentExtensionList& extensions);
112 109
113 // Called when a suggested extension's icon is fetched. 110 // Called when a suggested extension's icon is fetched.
114 void OnExtensionIconURLFetchComplete(const string16& extension_id, 111 void OnExtensionIconURLFetchComplete(const string16& extension_id,
115 const content::URLFetcher* source); 112 const content::URLFetcher* source);
116 113
117 typedef base::Callback<void(const gfx::Image&)> 114 typedef base::Callback<void(const gfx::Image&)>
118 ExtensionIconAvailableCallback; 115 ExtensionIconAvailableCallback;
119 // Called on a worker thread to decode and resize the extension's icon. 116 // Called on a worker thread to decode and resize the extension's icon.
120 static void DecodeExtensionIconAndResize( 117 static void DecodeExtensionIconAndResize(
121 scoped_ptr<std::string> icon_response, 118 scoped_ptr<std::string> icon_response,
122 const ExtensionIconAvailableCallback& callback, 119 const ExtensionIconAvailableCallback& callback,
123 const base::Closure& unavailable_callback); 120 const base::Closure& unavailable_callback);
124 121
125 // Called when an extension's icon is successfully decoded and resized. 122 // Called when an extension's icon is successfully decoded and resized.
126 void OnExtensionIconAvailable(const string16& extension_id, 123 void OnExtensionIconAvailable(const string16& extension_id,
127 const gfx::Image& icon_image); 124 const gfx::Image& icon_image);
128 125
129 // Called when an extension's icon failed to be decoded or resized. 126 // Called when an extension's icon failed to be decoded or resized.
130 void OnExtensionIconUnavailable(const string16& extension_id); 127 void OnExtensionIconUnavailable(const string16& extension_id);
131 128
132 // When an extension is installed, all that is known is the extension id.
133 // This callback receives the intent service data for that extension.
134 // |services| must be a non-empty list.
135 void OnExtensionInstallServiceAvailable(
136 const std::vector<webkit_glue::WebIntentServiceData>& services);
137
138 // Decrements the |pending_async_count_| and notifies the picker if it 129 // Decrements the |pending_async_count_| and notifies the picker if it
139 // reaches zero. 130 // reaches zero.
140 void AsyncOperationFinished(); 131 void AsyncOperationFinished();
141 132
142 // Closes the currently active picker. 133 // Closes the currently active picker.
143 void ClosePicker(); 134 void ClosePicker();
144 135
145 // A weak pointer to the tab contents that the picker is displayed on. 136 // A weak pointer to the tab contents that the picker is displayed on.
146 TabContentsWrapper* wrapper_; 137 TabContentsWrapper* wrapper_;
147 138
(...skipping 21 matching lines...) Expand all
169 // client page. 160 // client page.
170 content::WebIntentsDispatcher* intents_dispatcher_; 161 content::WebIntentsDispatcher* intents_dispatcher_;
171 162
172 // Weak pointer to the tab servicing the intent. Remembered in order to 163 // Weak pointer to the tab servicing the intent. Remembered in order to
173 // close it when a reply is sent. 164 // close it when a reply is sent.
174 content::WebContents* service_tab_; 165 content::WebContents* service_tab_;
175 166
176 // Request consumer used when asynchronously loading favicons. 167 // Request consumer used when asynchronously loading favicons.
177 CancelableRequestConsumerTSimple<size_t> favicon_consumer_; 168 CancelableRequestConsumerTSimple<size_t> favicon_consumer_;
178 169
179 // Used to install extensions from the Chrome Web Store.
180 scoped_refptr<WebstoreInstaller> webstore_installer_;
181
182 base::WeakPtrFactory<WebIntentPickerController> weak_ptr_factory_; 170 base::WeakPtrFactory<WebIntentPickerController> weak_ptr_factory_;
183 171
184 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerController); 172 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerController);
185 }; 173 };
186 174
187 #endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_CONTROLLER_H_ 175 #endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/intents/web_intent_picker.h ('k') | chrome/browser/ui/intents/web_intent_picker_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698