| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" | 13 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" |
| 14 #include "content/common/notification_observer.h" | 14 #include "content/common/notification_observer.h" |
| 15 #include "content/common/notification_registrar.h" | 15 #include "content/common/notification_registrar.h" |
| 16 | 16 |
| 17 class FaviconService; | 17 class FaviconService; |
| 18 class GURL; | 18 class GURL; |
| 19 class SkBitmap; | 19 class SkBitmap; |
| 20 class TabContents; | 20 class TabContentsWrapper; |
| 21 class WebDataService; | 21 class WebDataService; |
| 22 class WebIntentPicker; | 22 class WebIntentPicker; |
| 23 class WebIntentPickerFactory; | 23 class WebIntentPickerFactory; |
| 24 struct WebIntentData; | 24 struct WebIntentData; |
| 25 | 25 |
| 26 // Controls the creation of the WebIntentPicker UI and forwards the user's | 26 // Controls the creation of the WebIntentPicker UI and forwards the user's |
| 27 // intent handler choice back to the TabContents object. | 27 // intent handler choice back to the TabContents object. |
| 28 class WebIntentPickerController : public NotificationObserver, | 28 class WebIntentPickerController : public NotificationObserver, |
| 29 public WebIntentPickerDelegate { | 29 public WebIntentPickerDelegate { |
| 30 public: | 30 public: |
| 31 // Takes ownership of |factory|. | 31 // Takes ownership of |factory|. |
| 32 WebIntentPickerController(TabContents* tab_contents, | 32 WebIntentPickerController(TabContentsWrapper* wrapper, |
| 33 WebIntentPickerFactory* factory); | 33 WebIntentPickerFactory* factory); |
| 34 virtual ~WebIntentPickerController(); | 34 virtual ~WebIntentPickerController(); |
| 35 | 35 |
| 36 // Shows the web intent picker, given the intent |action| and mime-type | 36 // Shows the web intent picker, given the intent |action| and mime-type |
| 37 // |type|. | 37 // |type|. |
| 38 void ShowDialog(const string16& action, const string16& type); | 38 void ShowDialog(const string16& action, const string16& type); |
| 39 | 39 |
| 40 protected: | 40 protected: |
| 41 // NotificationObserver implementation. | 41 // NotificationObserver implementation. |
| 42 virtual void Observe(int type, | 42 virtual void Observe(int type, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 60 // Called from the FaviconDataFetcher when a favicon is available. | 60 // Called from the FaviconDataFetcher when a favicon is available. |
| 61 void OnFaviconDataAvailable(size_t index, const SkBitmap& icon_bitmap); | 61 void OnFaviconDataAvailable(size_t index, const SkBitmap& icon_bitmap); |
| 62 | 62 |
| 63 // Called from the FaviconDataFetcher when a favicon is not available. | 63 // Called from the FaviconDataFetcher when a favicon is not available. |
| 64 void OnFaviconDataUnavailable(size_t index); | 64 void OnFaviconDataUnavailable(size_t index); |
| 65 | 65 |
| 66 // Closes the currently active picker. | 66 // Closes the currently active picker. |
| 67 void ClosePicker(); | 67 void ClosePicker(); |
| 68 | 68 |
| 69 // A weak pointer to the tab contents that the picker is displayed on. | 69 // A weak pointer to the tab contents that the picker is displayed on. |
| 70 TabContents* tab_contents_; | 70 TabContentsWrapper* wrapper_; |
| 71 | 71 |
| 72 // A notification registrar, listening for notifications when the tab closes | 72 // A notification registrar, listening for notifications when the tab closes |
| 73 // to close the picker ui. | 73 // to close the picker ui. |
| 74 NotificationRegistrar registrar_; | 74 NotificationRegistrar registrar_; |
| 75 | 75 |
| 76 // A factory to create a new picker. | 76 // A factory to create a new picker. |
| 77 scoped_ptr<WebIntentPickerFactory> picker_factory_; | 77 scoped_ptr<WebIntentPickerFactory> picker_factory_; |
| 78 | 78 |
| 79 // A helper class to fetch web intent data asynchronously. | 79 // A helper class to fetch web intent data asynchronously. |
| 80 scoped_ptr<WebIntentDataFetcher> web_intent_data_fetcher_; | 80 scoped_ptr<WebIntentDataFetcher> web_intent_data_fetcher_; |
| 81 | 81 |
| 82 // A helper class to fetch favicon data asynchronously. | 82 // A helper class to fetch favicon data asynchronously. |
| 83 scoped_ptr<FaviconFetcher> favicon_fetcher_; | 83 scoped_ptr<FaviconFetcher> favicon_fetcher_; |
| 84 | 84 |
| 85 // A weak pointer to the picker this controller controls. | 85 // A weak pointer to the picker this controller controls. |
| 86 WebIntentPicker* picker_; | 86 WebIntentPicker* picker_; |
| 87 | 87 |
| 88 // A list of URLs to display in the UI. | 88 // A list of URLs to display in the UI. |
| 89 std::vector<GURL> urls_; | 89 std::vector<GURL> urls_; |
| 90 | 90 |
| 91 // A count of the outstanding asynchronous calls. | 91 // A count of the outstanding asynchronous calls. |
| 92 int pending_async_count_; | 92 int pending_async_count_; |
| 93 | 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerController); | 94 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerController); |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 #endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_CONTROLLER_H_ | 97 #endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_CONTROLLER_H_ |
| OLD | NEW |