| 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/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" | 14 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" |
| 15 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 17 #include "webkit/glue/web_intent_data.h" | 17 #include "webkit/glue/web_intent_data.h" |
| 18 | 18 |
| 19 class Browser; | 19 class Browser; |
| 20 class GURL; | 20 class GURL; |
| 21 class SkBitmap; | 21 class SkBitmap; |
| 22 class TabContents; | 22 class TabContents; |
| 23 class TabContentsWrapper; | 23 class TabContentsWrapper; |
| 24 class WebIntentPicker; | 24 class WebIntentPicker; |
| 25 class WebIntentPickerFactory; | 25 class WebIntentPickerFactory; |
| 26 | 26 |
| 27 namespace content { |
| 28 class IntentsHost; |
| 29 } |
| 30 |
| 27 namespace webkit_glue { | 31 namespace webkit_glue { |
| 28 struct WebIntentServiceData; | 32 struct WebIntentServiceData; |
| 29 } | 33 } |
| 30 | 34 |
| 31 // Controls the creation of the WebIntentPicker UI and forwards the user's | 35 // Controls the creation of the WebIntentPicker UI and forwards the user's |
| 32 // intent handler choice back to the TabContents object. | 36 // intent handler choice back to the TabContents object. |
| 33 class WebIntentPickerController : public content::NotificationObserver, | 37 class WebIntentPickerController : public content::NotificationObserver, |
| 34 public WebIntentPickerDelegate { | 38 public WebIntentPickerDelegate { |
| 35 public: | 39 public: |
| 36 // Takes ownership of |factory|. | 40 // Takes ownership of |factory|. |
| 37 WebIntentPickerController(TabContentsWrapper* wrapper, | 41 WebIntentPickerController(TabContentsWrapper* wrapper, |
| 38 WebIntentPickerFactory* factory); | 42 WebIntentPickerFactory* factory); |
| 39 virtual ~WebIntentPickerController(); | 43 virtual ~WebIntentPickerController(); |
| 40 | 44 |
| 41 // Sets the intent data for which this picker was created. The picker will | 45 // Sets the intent data and return pathway handler object for which |
| 42 // copy and hold this data until the user has made a service selection. | 46 // this picker was created. The picker takes ownership of this object. |
| 43 // |routing_id| is the IPC routing ID of the source renderer. | 47 void SetIntentsHost(content::IntentsHost* intents_host); |
| 44 // |intent| is the intent data as created by the client content. | |
| 45 // |intent_id| is the ID assigned by the source renderer. | |
| 46 void SetIntent(int routing_id, | |
| 47 const webkit_glue::WebIntentData& intent, | |
| 48 int intent_id); | |
| 49 | 48 |
| 50 // Shows the web intent picker for |browser|, given the intent | 49 // Shows the web intent picker for |browser|, given the intent |
| 51 // |action| and MIME-type |type|. | 50 // |action| and MIME-type |type|. |
| 52 void ShowDialog(Browser* browser, | 51 void ShowDialog(Browser* browser, |
| 53 const string16& action, | 52 const string16& action, |
| 54 const string16& type); | 53 const string16& type); |
| 55 | 54 |
| 56 protected: | 55 protected: |
| 57 // content::NotificationObserver implementation. | 56 // content::NotificationObserver implementation. |
| 58 virtual void Observe(int type, | 57 virtual void Observe(int type, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 110 |
| 112 // A list of URLs to display in the UI. | 111 // A list of URLs to display in the UI. |
| 113 std::vector<GURL> urls_; | 112 std::vector<GURL> urls_; |
| 114 | 113 |
| 115 // A list of the service data on display in the UI. | 114 // A list of the service data on display in the UI. |
| 116 std::vector<webkit_glue::WebIntentServiceData> service_data_; | 115 std::vector<webkit_glue::WebIntentServiceData> service_data_; |
| 117 | 116 |
| 118 // A count of the outstanding asynchronous calls. | 117 // A count of the outstanding asynchronous calls. |
| 119 int pending_async_count_; | 118 int pending_async_count_; |
| 120 | 119 |
| 121 // The routing id of the renderer which launched the intent. Should be the | 120 // The routing object for the renderer which launched the intent. |
| 122 // renderer associated with the TabContents which owns this object. | 121 // Contains the intent data and a way to signal back to the client page. |
| 123 int routing_id_; | 122 scoped_ptr<content::IntentsHost> intents_host_; |
| 124 | |
| 125 // The intent data from the client. | |
| 126 webkit_glue::WebIntentData intent_; | |
| 127 | |
| 128 // The intent ID assigned to this intent by the renderer. | |
| 129 int intent_id_; | |
| 130 | 123 |
| 131 // Weak pointer to the tab servicing the intent. Remembered in order to | 124 // Weak pointer to the tab servicing the intent. Remembered in order to |
| 132 // close it when a reply is sent. | 125 // close it when a reply is sent. |
| 133 TabContents* service_tab_; | 126 TabContents* service_tab_; |
| 134 | 127 |
| 135 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerController); | 128 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerController); |
| 136 }; | 129 }; |
| 137 | 130 |
| 138 #endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_CONTROLLER_H_ | 131 #endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_CONTROLLER_H_ |
| OLD | NEW |