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

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

Issue 9838003: Revert 128189 - [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 WebIntentPickerControllerIncognitoBrowserTest; 78 friend class WebIntentPickerControllerIncognitoBrowserTest;
88 friend class InvokingTabObserver; 79 friend class InvokingTabObserver;
89 80
90 // Gets a notification when the return message is sent to the source tab, 81 // Gets a notification when the return message is sent to the source tab,
91 // so we can close the picker dialog or service tab. 82 // so we can close the picker dialog or service tab.
92 void OnSendReturnMessage(webkit_glue::WebIntentReplyType reply_type); 83 void OnSendReturnMessage(webkit_glue::WebIntentReplyType reply_type);
93 84
94 // Exposed for tests only. 85 // Exposed for tests only.
95 void set_picker(WebIntentPicker* picker) { picker_ = picker; } 86 void set_picker(WebIntentPicker* picker) { picker_ = picker; }
96 87
97 // Exposed for tests only. 88 // Exposed for tests only.
98 void set_model_observer(WebIntentPickerModelObserver* observer) { 89 void set_model_observer(WebIntentPickerModelObserver* observer) {
99 picker_model_->set_observer(observer); 90 picker_model_->set_observer(observer);
100 } 91 }
101 92
102 // Called when WebIntentServiceData is returned from the WebIntentsRegistry. 93 // Called when WebIntentServiceData is returned from the WebIntentsRegistry.
103 void OnWebIntentServicesAvailable( 94 virtual void OnIntentsQueryDone(
104 const std::vector<webkit_glue::WebIntentServiceData>& services); 95 WebIntentsRegistry::QueryID,
96 const std::vector<webkit_glue::WebIntentServiceData>& services) OVERRIDE;
97
98 // Called when the WebIntentsRegistry returns responses to a defaults request.
99 virtual void OnIntentsDefaultsQueryDone(
100 WebIntentsRegistry::QueryID,
101 const DefaultWebIntentService& default_service) OVERRIDE;
105 102
106 // Called when FaviconData is returned from the FaviconService. 103 // Called when FaviconData is returned from the FaviconService.
107 void OnFaviconDataAvailable(FaviconService::Handle handle, 104 void OnFaviconDataAvailable(FaviconService::Handle handle,
108 history::FaviconData favicon_data); 105 history::FaviconData favicon_data);
109 106
110 // Called when IntentExtensionInfo is returned from the CWSIntentsRegistry. 107 // Called when IntentExtensionInfo is returned from the CWSIntentsRegistry.
111 void OnCWSIntentServicesAvailable( 108 void OnCWSIntentServicesAvailable(
112 const CWSIntentsRegistry::IntentExtensionList& extensions); 109 const CWSIntentsRegistry::IntentExtensionList& extensions);
113 110
114 // Called when a suggested extension's icon is fetched. 111 // Called when a suggested extension's icon is fetched.
115 void OnExtensionIconURLFetchComplete(const string16& extension_id, 112 void OnExtensionIconURLFetchComplete(const string16& extension_id,
116 const content::URLFetcher* source); 113 const content::URLFetcher* source);
117 114
118 typedef base::Callback<void(const gfx::Image&)> 115 typedef base::Callback<void(const gfx::Image&)>
119 ExtensionIconAvailableCallback; 116 ExtensionIconAvailableCallback;
120 // Called on a worker thread to decode and resize the extension's icon. 117 // Called on a worker thread to decode and resize the extension's icon.
121 static void DecodeExtensionIconAndResize( 118 static void DecodeExtensionIconAndResize(
122 scoped_ptr<std::string> icon_response, 119 scoped_ptr<std::string> icon_response,
123 const ExtensionIconAvailableCallback& callback, 120 const ExtensionIconAvailableCallback& callback,
124 const base::Closure& unavailable_callback); 121 const base::Closure& unavailable_callback);
125 122
126 // Called when an extension's icon is successfully decoded and resized. 123 // Called when an extension's icon is successfully decoded and resized.
127 void OnExtensionIconAvailable(const string16& extension_id, 124 void OnExtensionIconAvailable(const string16& extension_id,
128 const gfx::Image& icon_image); 125 const gfx::Image& icon_image);
129 126
130 // Called when an extension's icon failed to be decoded or resized. 127 // Called when an extension's icon failed to be decoded or resized.
131 void OnExtensionIconUnavailable(const string16& extension_id); 128 void OnExtensionIconUnavailable(const string16& extension_id);
132 129
133 // When an extension is installed, all that is known is the extension id.
134 // This callback receives the intent service data for that extension.
135 // |services| must be a non-empty list.
136 void OnExtensionInstallServiceAvailable(
137 const std::vector<webkit_glue::WebIntentServiceData>& services);
138
139 // Decrements the |pending_async_count_| and notifies the picker if it 130 // Decrements the |pending_async_count_| and notifies the picker if it
140 // reaches zero. 131 // reaches zero.
141 void AsyncOperationFinished(); 132 void AsyncOperationFinished();
142 133
143 // Closes the currently active picker. 134 // Closes the currently active picker.
144 void ClosePicker(); 135 void ClosePicker();
145 136
146 // A weak pointer to the tab contents that the picker is displayed on. 137 // A weak pointer to the tab contents that the picker is displayed on.
147 TabContentsWrapper* wrapper_; 138 TabContentsWrapper* wrapper_;
148 139
(...skipping 21 matching lines...) Expand all
170 // client page. 161 // client page.
171 content::WebIntentsDispatcher* intents_dispatcher_; 162 content::WebIntentsDispatcher* intents_dispatcher_;
172 163
173 // Weak pointer to the tab servicing the intent. Remembered in order to 164 // Weak pointer to the tab servicing the intent. Remembered in order to
174 // close it when a reply is sent. 165 // close it when a reply is sent.
175 content::WebContents* service_tab_; 166 content::WebContents* service_tab_;
176 167
177 // Request consumer used when asynchronously loading favicons. 168 // Request consumer used when asynchronously loading favicons.
178 CancelableRequestConsumerTSimple<size_t> favicon_consumer_; 169 CancelableRequestConsumerTSimple<size_t> favicon_consumer_;
179 170
180 // Used to install extensions from the Chrome Web Store.
181 scoped_refptr<WebstoreInstaller> webstore_installer_;
182
183 base::WeakPtrFactory<WebIntentPickerController> weak_ptr_factory_; 171 base::WeakPtrFactory<WebIntentPickerController> weak_ptr_factory_;
184 172
185 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerController); 173 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerController);
186 }; 174 };
187 175
188 #endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_CONTROLLER_H_ 176 #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