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

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

Issue 10959045: Switch WebIntentPickerController to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 2 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 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/string16.h" 14 #include "base/string16.h"
15 #include "chrome/browser/extensions/webstore_installer.h" 15 #include "chrome/browser/extensions/webstore_installer.h"
16 #include "chrome/browser/favicon/favicon_service.h" 16 #include "chrome/browser/favicon/favicon_service.h"
17 #include "chrome/browser/intents/cws_intents_registry.h" 17 #include "chrome/browser/intents/cws_intents_registry.h"
18 #include "chrome/browser/intents/web_intents_registry.h" 18 #include "chrome/browser/intents/web_intents_registry.h"
19 #include "chrome/browser/intents/web_intents_reporting.h" 19 #include "chrome/browser/intents/web_intents_reporting.h"
20 #include "chrome/browser/tab_contents/web_contents_user_data.h"
20 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" 21 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h"
21 #include "content/public/browser/notification_observer.h" 22 #include "content/public/browser/notification_observer.h"
22 #include "content/public/browser/notification_registrar.h" 23 #include "content/public/browser/notification_registrar.h"
23 #include "webkit/glue/web_intent_data.h" 24 #include "webkit/glue/web_intent_data.h"
24 #include "webkit/glue/web_intent_reply_data.h" 25 #include "webkit/glue/web_intent_reply_data.h"
25 #include "webkit/glue/web_intent_service_data.h" 26 #include "webkit/glue/web_intent_service_data.h"
26 27
27 class Browser; 28 class Browser;
28 struct DefaultWebIntentService; 29 struct DefaultWebIntentService;
29 class GURL; 30 class GURL;
30 class TabContents; 31 class Profile;
31 class WebIntentPicker; 32 class WebIntentPicker;
32 class WebIntentPickerModel; 33 class WebIntentPickerModel;
33 34
34 namespace content { 35 namespace content {
35 class WebContents; 36 class WebContents;
36 class WebIntentsDispatcher; 37 class WebIntentsDispatcher;
37 } 38 }
38 39
39 namespace webkit_glue { 40 namespace webkit_glue {
40 struct WebIntentServiceData; 41 struct WebIntentServiceData;
41 } 42 }
42 43
43 // Controls the creation of the WebIntentPicker UI and forwards the user's 44 // Controls the creation of the WebIntentPicker UI and forwards the user's
44 // intent handler choice back to the WebContents object. 45 // intent handler choice back to the WebContents object.
45 class WebIntentPickerController 46 class WebIntentPickerController
46 : public content::NotificationObserver, 47 : public content::NotificationObserver,
47 public WebIntentPickerDelegate, 48 public WebIntentPickerDelegate,
48 public extensions::WebstoreInstaller::Delegate { 49 public extensions::WebstoreInstaller::Delegate,
50 public WebContentsUserData<WebIntentPickerController> {
49 public: 51 public:
50 52
51 // The various states that the UI may be in. Public for testing. 53 // The various states that the UI may be in. Public for testing.
52 enum WebIntentPickerState { 54 enum WebIntentPickerState {
53 kPickerHidden, // Picker not displayed at all. 55 kPickerHidden, // Picker not displayed at all.
54 kPickerSetup, // Initial setup. Acquires data, keeps picker hidden. 56 kPickerSetup, // Initial setup. Acquires data, keeps picker hidden.
55 kPickerWaiting, // Displaying "waiting for CWS". 57 kPickerWaiting, // Displaying "waiting for CWS".
56 kPickerWaitLong, // "waiting" has displayed for longer than min. time. 58 kPickerWaitLong, // "waiting" has displayed for longer than min. time.
57 kPickerMain, // Displaying main picker dialog. 59 kPickerMain, // Displaying main picker dialog.
58 kPickerInline, // Displaying inline intent handler. 60 kPickerInline, // Displaying inline intent handler.
59 }; 61 };
60 62
61 // Events that happen during picker life time. Drive state machine. 63 // Events that happen during picker life time. Drive state machine.
62 enum WebIntentPickerEvent { 64 enum WebIntentPickerEvent {
63 kPickerEventHiddenSetupTimeout, // Time for hidden setup exired. 65 kPickerEventHiddenSetupTimeout, // Time for hidden setup exired.
64 kPickerEventMaxWaitTimeExceeded, // Exceeded max wait time for CWS results. 66 kPickerEventMaxWaitTimeExceeded, // Exceeded max wait time for CWS results.
65 kPickerEventRegistryDataComplete, // Data from the registry has arrived. 67 kPickerEventRegistryDataComplete, // Data from the registry has arrived.
66 kPickerEventAsyncDataComplete, // Data from registry and CWS has arrived. 68 kPickerEventAsyncDataComplete, // Data from registry and CWS has arrived.
67 }; 69 };
68 70
69 explicit WebIntentPickerController(TabContents* tab_contents);
70 virtual ~WebIntentPickerController(); 71 virtual ~WebIntentPickerController();
71 72
72 // Sets the intent data and return pathway handler object for which 73 // Sets the intent data and return pathway handler object for which
73 // this picker was created. The picker takes ownership of 74 // this picker was created. The picker takes ownership of
74 // |intents_dispatcher|. |intents_dispatcher| must not be NULL. 75 // |intents_dispatcher|. |intents_dispatcher| must not be NULL.
75 void SetIntentsDispatcher(content::WebIntentsDispatcher* intents_dispatcher); 76 void SetIntentsDispatcher(content::WebIntentsDispatcher* intents_dispatcher);
76 77
77 // Shows the web intent picker given the intent |action| and MIME-type |type|. 78 // Shows the web intent picker given the intent |action| and MIME-type |type|.
78 void ShowDialog(const string16& action, 79 void ShowDialog(const string16& action,
79 const string16& type); 80 const string16& type);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 virtual void OnUserCancelledPickerDialog() OVERRIDE; 112 virtual void OnUserCancelledPickerDialog() OVERRIDE;
112 virtual void OnChooseAnotherService() OVERRIDE; 113 virtual void OnChooseAnotherService() OVERRIDE;
113 virtual void OnClosing() OVERRIDE; 114 virtual void OnClosing() OVERRIDE;
114 115
115 // extensions::WebstoreInstaller::Delegate implementation. 116 // extensions::WebstoreInstaller::Delegate implementation.
116 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; 117 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE;
117 virtual void OnExtensionInstallFailure(const std::string& id, 118 virtual void OnExtensionInstallFailure(const std::string& id,
118 const std::string& error) OVERRIDE; 119 const std::string& error) OVERRIDE;
119 120
120 private: 121 private:
122 explicit WebIntentPickerController(content::WebContents* web_contents);
123 static int kUserDataKey;
James Hawkins 2012/09/25 17:46:25 Is this used anywhere? If so please document it.
Avi (use Gerrit) 2012/09/25 18:14:36 Yes it is. It's part of the WebContentsUserData ma
124 friend class WebContentsUserData<WebIntentPickerController>;
125
121 friend class WebIntentPickerControllerTest; 126 friend class WebIntentPickerControllerTest;
122 friend class WebIntentPickerControllerBrowserTest; 127 friend class WebIntentPickerControllerBrowserTest;
123 friend class WebIntentPickerControllerIncognitoBrowserTest; 128 friend class WebIntentPickerControllerIncognitoBrowserTest;
124 friend class WebIntentsButtonDecorationTest; 129 friend class WebIntentsButtonDecorationTest;
125 130
126 // Forward declaraton of the internal implementation class. 131 // Forward declaraton of the internal implementation class.
127 class UMAReporter; 132 class UMAReporter;
128 133
129 // Dispatches intent to a just-installed extension with ID |extension_id|. 134 // Dispatches intent to a just-installed extension with ID |extension_id|.
130 void DispatchToInstalledExtension(const std::string& extension_id); 135 void DispatchToInstalledExtension(const std::string& extension_id);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // Re-starts the process of showing the dialog, suppressing any default 244 // Re-starts the process of showing the dialog, suppressing any default
240 // queries. Called on the user clicking Use-Another-Service. 245 // queries. Called on the user clicking Use-Another-Service.
241 void ReshowDialog(); 246 void ReshowDialog();
242 247
243 // Delegate for ShowDialog and ReshowDialog. Starts all the data queries for 248 // Delegate for ShowDialog and ReshowDialog. Starts all the data queries for
244 // loading the picker model and showing the dialog. 249 // loading the picker model and showing the dialog.
245 void ShowDialog(bool suppress_defaults); 250 void ShowDialog(bool suppress_defaults);
246 251
247 WebIntentPickerState dialog_state_; // Current state of the dialog. 252 WebIntentPickerState dialog_state_; // Current state of the dialog.
248 253
249 // A weak pointer to the tab contents that the picker is displayed on. 254 // A weak pointer to the web contents that the picker is displayed on.
250 TabContents* tab_contents_; 255 content::WebContents* web_contents_;
256
257 // A weak pointer to the profile for the web contents.
258 Profile* profile_;
251 259
252 // A notification registrar, listening for notifications when the tab closes 260 // A notification registrar, listening for notifications when the tab closes
253 // to close the picker ui. 261 // to close the picker ui.
254 content::NotificationRegistrar registrar_; 262 content::NotificationRegistrar registrar_;
255 263
256 // A weak pointer to the picker this controller controls. 264 // A weak pointer to the picker this controller controls.
257 WebIntentPicker* picker_; 265 WebIntentPicker* picker_;
258 266
259 // The model for the picker. Owned by this controller. It should not be NULL 267 // The model for the picker. Owned by this controller. It should not be NULL
260 // while this controller exists, even if the picker is not shown. 268 // while this controller exists, even if the picker is not shown.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 // Bucket identifier for UMA reporting. Saved off in a field 329 // Bucket identifier for UMA reporting. Saved off in a field
322 // to avoid repeated calculation of the bucket across 330 // to avoid repeated calculation of the bucket across
323 // multiple UMA calls. Should be recalculated each time 331 // multiple UMA calls. Should be recalculated each time
324 // |intents_dispatcher_| is set. 332 // |intents_dispatcher_| is set.
325 web_intents::UMABucket uma_bucket_; 333 web_intents::UMABucket uma_bucket_;
326 334
327 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerController); 335 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerController);
328 }; 336 };
329 337
330 #endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_CONTROLLER_H_ 338 #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