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

Side by Side Diff: components/arc/intent_helper/link_handler_model_impl.h

Issue 2498223002: arc: enable use_new_wrapper_types for intent_helper.mojom (Closed)
Patch Set: rebase Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 COMPONENTS_ARC_INTENT_HELPER_LINK_HANDLER_MODEL_IMPL_H_ 5 #ifndef COMPONENTS_ARC_INTENT_HELPER_LINK_HANDLER_MODEL_IMPL_H_
6 #define COMPONENTS_ARC_INTENT_HELPER_LINK_HANDLER_MODEL_IMPL_H_ 6 #define COMPONENTS_ARC_INTENT_HELPER_LINK_HANDLER_MODEL_IMPL_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <vector>
9 10
10 #include "ash/link_handler_model.h" 11 #include "ash/link_handler_model.h"
11 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
13 #include "base/observer_list.h" 14 #include "base/observer_list.h"
14 #include "components/arc/arc_service.h" 15 #include "components/arc/arc_service.h"
15 #include "components/arc/common/intent_helper.mojom.h" 16 #include "components/arc/common/intent_helper.mojom.h"
16 #include "components/arc/intent_helper/activity_icon_loader.h" 17 #include "components/arc/intent_helper/activity_icon_loader.h"
17 18
18 namespace arc { 19 namespace arc {
19 20
20 class LinkHandlerModelImpl : public ash::LinkHandlerModel { 21 class LinkHandlerModelImpl : public ash::LinkHandlerModel {
21 public: 22 public:
22 explicit LinkHandlerModelImpl(scoped_refptr<ActivityIconLoader> icon_loader); 23 explicit LinkHandlerModelImpl(scoped_refptr<ActivityIconLoader> icon_loader);
23 ~LinkHandlerModelImpl() override; 24 ~LinkHandlerModelImpl() override;
24 25
25 // ash::LinkHandlerModel overrides: 26 // ash::LinkHandlerModel overrides:
26 void AddObserver(Observer* observer) override; 27 void AddObserver(Observer* observer) override;
27 void OpenLinkWithHandler(const GURL& url, uint32_t handler_id) override; 28 void OpenLinkWithHandler(const GURL& url, uint32_t handler_id) override;
28 29
29 // Starts retrieving handler information for the |url| and returns true. 30 // Starts retrieving handler information for the |url| and returns true.
30 // Returns false when the information cannot be retrieved. In that case, 31 // Returns false when the information cannot be retrieved. In that case,
31 // the caller should delete |this| object. 32 // the caller should delete |this| object.
32 bool Init(const GURL& url); 33 bool Init(const GURL& url);
33 34
34 static GURL RewriteUrlFromQueryIfAvailableForTesting(const GURL& url); 35 static GURL RewriteUrlFromQueryIfAvailableForTesting(const GURL& url);
35 36
36 private: 37 private:
37 mojom::IntentHelperInstance* GetIntentHelper(); 38 mojom::IntentHelperInstance* GetIntentHelper();
38 void OnUrlHandlerList(mojo::Array<mojom::IntentHandlerInfoPtr> handlers); 39 void OnUrlHandlerList(std::vector<mojom::IntentHandlerInfoPtr> handlers);
39 void NotifyObserver( 40 void NotifyObserver(
40 std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> icons); 41 std::unique_ptr<ActivityIconLoader::ActivityToIconsMap> icons);
41 42
42 // Checks if the |url| matches the following pattern: 43 // Checks if the |url| matches the following pattern:
43 // "http(s)://<valid_google_hostname>/url?...&url=<valid_url>&..." 44 // "http(s)://<valid_google_hostname>/url?...&url=<valid_url>&..."
44 // If it does, creates a new GURL object from the <valid_url> and returns it. 45 // If it does, creates a new GURL object from the <valid_url> and returns it.
45 // Otherwise, returns the original |url| as-us. 46 // Otherwise, returns the original |url| as-us.
46 static GURL RewriteUrlFromQueryIfAvailable(const GURL& url); 47 static GURL RewriteUrlFromQueryIfAvailable(const GURL& url);
47 48
48 base::ObserverList<Observer> observer_list_; 49 base::ObserverList<Observer> observer_list_;
49 50
50 // Url handler info passed from ARC. 51 // Url handler info passed from ARC.
51 mojo::Array<mojom::IntentHandlerInfoPtr> handlers_; 52 std::vector<mojom::IntentHandlerInfoPtr> handlers_;
52 // Activity icon info passed from ARC. 53 // Activity icon info passed from ARC.
53 ActivityIconLoader::ActivityToIconsMap icons_; 54 ActivityIconLoader::ActivityToIconsMap icons_;
54 55
55 // Use refptr to retain the object even if ArcIntentHelperBridge is destructed 56 // Use refptr to retain the object even if ArcIntentHelperBridge is destructed
56 // first. 57 // first.
57 scoped_refptr<ActivityIconLoader> icon_loader_; 58 scoped_refptr<ActivityIconLoader> icon_loader_;
58 59
59 // Always keep this the last member of this class to make sure it's the 60 // Always keep this the last member of this class to make sure it's the
60 // first thing to be destructed. 61 // first thing to be destructed.
61 base::WeakPtrFactory<LinkHandlerModelImpl> weak_ptr_factory_; 62 base::WeakPtrFactory<LinkHandlerModelImpl> weak_ptr_factory_;
62 63
63 DISALLOW_COPY_AND_ASSIGN(LinkHandlerModelImpl); 64 DISALLOW_COPY_AND_ASSIGN(LinkHandlerModelImpl);
64 }; 65 };
65 66
66 } // namespace arc 67 } // namespace arc
67 68
68 #endif // COMPONENTS_ARC_INTENT_HELPER_LINK_HANDLER_MODEL_IMPL_H_ 69 #endif // COMPONENTS_ARC_INTENT_HELPER_LINK_HANDLER_MODEL_IMPL_H_
OLDNEW
« no previous file with comments | « components/arc/intent_helper/intent_filter_unittest.cc ('k') | components/arc/intent_helper/link_handler_model_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698