| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_CONTROLLER_H_ | |
| 6 #define CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_CONTROLLER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "base/string16.h" | |
| 13 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" | |
| 14 #include "content/common/notification_observer.h" | |
| 15 #include "content/common/notification_registrar.h" | |
| 16 | |
| 17 class FaviconService; | |
| 18 class GURL; | |
| 19 class SkBitmap; | |
| 20 class TabContents; | |
| 21 class WebDataService; | |
| 22 class WebIntentPicker; | |
| 23 class WebIntentPickerFactory; | |
| 24 struct WebIntentData; | |
| 25 | |
| 26 // Controls the creation of the WebIntentPicker UI and forwards the user's | |
| 27 // intent handler choice back to the TabContents object. | |
| 28 class WebIntentPickerController : public NotificationObserver, | |
| 29 public WebIntentPickerDelegate { | |
| 30 public: | |
| 31 // Takes ownership of |factory|. | |
| 32 WebIntentPickerController(TabContents* tab_contents, | |
| 33 WebIntentPickerFactory* factory); | |
| 34 virtual ~WebIntentPickerController(); | |
| 35 | |
| 36 // Shows the web intent picker, given the intent |action| and mime-type | |
| 37 // |type|. | |
| 38 void ShowDialog(const string16& action, const string16& type); | |
| 39 | |
| 40 protected: | |
| 41 // NotificationObserver implementation. | |
| 42 virtual void Observe(int type, | |
| 43 const NotificationSource& source, | |
| 44 const NotificationDetails& details) OVERRIDE; | |
| 45 | |
| 46 // WebIntentPickerDelegate implementation. | |
| 47 virtual void OnServiceChosen(size_t index) OVERRIDE; | |
| 48 virtual void OnCancelled() OVERRIDE; | |
| 49 | |
| 50 private: | |
| 51 friend class WebIntentPickerControllerTest; | |
| 52 class WebIntentDataFetcher; | |
| 53 class FaviconFetcher; | |
| 54 | |
| 55 int pending_async_count() const { return pending_async_count_; } | |
| 56 | |
| 57 // Called from the WebIntentDataFetcher when intent data is available. | |
| 58 void OnWebIntentDataAvailable(const std::vector<WebIntentData>& intent_data); | |
| 59 | |
| 60 // Called from the FaviconDataFetcher when a favicon is available. | |
| 61 void OnFaviconDataAvailable(size_t index, const SkBitmap& icon_bitmap); | |
| 62 | |
| 63 // Called from the FaviconDataFetcher when a favicon is not available. | |
| 64 void OnFaviconDataUnavailable(size_t index); | |
| 65 | |
| 66 // Closes the currently active picker. | |
| 67 void ClosePicker(); | |
| 68 | |
| 69 // A weak pointer to the tab contents that the picker is displayed on. | |
| 70 TabContents* tab_contents_; | |
| 71 | |
| 72 // A notification registrar, listening for notifications when the tab closes | |
| 73 // to close the picker ui. | |
| 74 NotificationRegistrar registrar_; | |
| 75 | |
| 76 // A factory to create a new picker. | |
| 77 scoped_ptr<WebIntentPickerFactory> picker_factory_; | |
| 78 | |
| 79 // A helper class to fetch web intent data asynchronously. | |
| 80 scoped_ptr<WebIntentDataFetcher> web_intent_data_fetcher_; | |
| 81 | |
| 82 // A helper class to fetch favicon data asynchronously. | |
| 83 scoped_ptr<FaviconFetcher> favicon_fetcher_; | |
| 84 | |
| 85 // A weak pointer to the picker this controller controls. | |
| 86 WebIntentPicker* picker_; | |
| 87 | |
| 88 // A list of URLs to display in the UI. | |
| 89 std::vector<GURL> urls_; | |
| 90 | |
| 91 // A count of the outstanding asynchronous calls. | |
| 92 int pending_async_count_; | |
| 93 | |
| 94 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerController); | |
| 95 }; | |
| 96 | |
| 97 #endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_CONTROLLER_H_ | |
| OLD | NEW |