| OLD | NEW |
| 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 #include "stdafx.h" | 5 #include "stdafx.h" |
| 6 #include "secondary_tile.h" | 6 #include "secondary_tile.h" |
| 7 | 7 |
| 8 #include <windows.ui.startscreen.h> | 8 #include <windows.ui.startscreen.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 pin_state = type_ == PIN ? | 82 pin_state = type_ == PIN ? |
| 83 base::win::METRO_PIN_RESULT_ERROR : | 83 base::win::METRO_PIN_RESULT_ERROR : |
| 84 base::win::METRO_UNPIN_RESULT_ERROR; | 84 base::win::METRO_UNPIN_RESULT_ERROR; |
| 85 } | 85 } |
| 86 callback_.Run(pin_state); | 86 callback_.Run(pin_state); |
| 87 | 87 |
| 88 delete this; | 88 delete this; |
| 89 return S_OK; | 89 return S_OK; |
| 90 } | 90 } |
| 91 | 91 |
| 92 void DeleteTileFromStartScreen(const string16& tile_id, | 92 void DeleteTileFromStartScreen(const base::string16& tile_id, |
| 93 const MetroPinUmaResultCallback& callback) { | 93 const MetroPinUmaResultCallback& callback) { |
| 94 DVLOG(1) << __FUNCTION__; | 94 DVLOG(1) << __FUNCTION__; |
| 95 mswr::ComPtr<winui::StartScreen::ISecondaryTileFactory> tile_factory; | 95 mswr::ComPtr<winui::StartScreen::ISecondaryTileFactory> tile_factory; |
| 96 HRESULT hr = winrt_utils::CreateActivationFactory( | 96 HRESULT hr = winrt_utils::CreateActivationFactory( |
| 97 RuntimeClass_Windows_UI_StartScreen_SecondaryTile, | 97 RuntimeClass_Windows_UI_StartScreen_SecondaryTile, |
| 98 tile_factory.GetAddressOf()); | 98 tile_factory.GetAddressOf()); |
| 99 CheckHR(hr, "Failed to create instance of ISecondaryTileFactory"); | 99 CheckHR(hr, "Failed to create instance of ISecondaryTileFactory"); |
| 100 | 100 |
| 101 mswrw::HString id; | 101 mswrw::HString id; |
| 102 id.Attach(MakeHString(tile_id)); | 102 id.Attach(MakeHString(tile_id)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 114 return; | 114 return; |
| 115 } | 115 } |
| 116 | 116 |
| 117 // Deleted in TileRequestCompleter::Respond when the async operation | 117 // Deleted in TileRequestCompleter::Respond when the async operation |
| 118 // completes. | 118 // completes. |
| 119 TileRequestCompleter* completer = | 119 TileRequestCompleter* completer = |
| 120 new TileRequestCompleter(TileRequestCompleter::UNPIN, callback); | 120 new TileRequestCompleter(TileRequestCompleter::UNPIN, callback); |
| 121 completer->Complete(completion); | 121 completer->Complete(completion); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void CreateTileOnStartScreen(const string16& tile_id, | 124 void CreateTileOnStartScreen(const base::string16& tile_id, |
| 125 const string16& title_str, | 125 const base::string16& title_str, |
| 126 const string16& url_str, | 126 const base::string16& url_str, |
| 127 const base::FilePath& logo_path, | 127 const base::FilePath& logo_path, |
| 128 const MetroPinUmaResultCallback& callback) { | 128 const MetroPinUmaResultCallback& callback) { |
| 129 VLOG(1) << __FUNCTION__; | 129 VLOG(1) << __FUNCTION__; |
| 130 | 130 |
| 131 mswr::ComPtr<winui::StartScreen::ISecondaryTileFactory> tile_factory; | 131 mswr::ComPtr<winui::StartScreen::ISecondaryTileFactory> tile_factory; |
| 132 HRESULT hr = winrt_utils::CreateActivationFactory( | 132 HRESULT hr = winrt_utils::CreateActivationFactory( |
| 133 RuntimeClass_Windows_UI_StartScreen_SecondaryTile, | 133 RuntimeClass_Windows_UI_StartScreen_SecondaryTile, |
| 134 tile_factory.GetAddressOf()); | 134 tile_factory.GetAddressOf()); |
| 135 CheckHR(hr, "Failed to create instance of ISecondaryTileFactory"); | 135 CheckHR(hr, "Failed to create instance of ISecondaryTileFactory"); |
| 136 | 136 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 149 GURL url(url_str); | 149 GURL url(url_str); |
| 150 args.Attach(MakeHString(UTF8ToUTF16(url.spec()))); | 150 args.Attach(MakeHString(UTF8ToUTF16(url.spec()))); |
| 151 | 151 |
| 152 mswr::ComPtr<winfoundtn::IUriRuntimeClassFactory> uri_factory; | 152 mswr::ComPtr<winfoundtn::IUriRuntimeClassFactory> uri_factory; |
| 153 hr = winrt_utils::CreateActivationFactory( | 153 hr = winrt_utils::CreateActivationFactory( |
| 154 RuntimeClass_Windows_Foundation_Uri, | 154 RuntimeClass_Windows_Foundation_Uri, |
| 155 uri_factory.GetAddressOf()); | 155 uri_factory.GetAddressOf()); |
| 156 CheckHR(hr, "Failed to create URIFactory"); | 156 CheckHR(hr, "Failed to create URIFactory"); |
| 157 | 157 |
| 158 mswrw::HString logo_url; | 158 mswrw::HString logo_url; |
| 159 logo_url.Attach(MakeHString(string16(L"file:///").append(logo_path.value()))); | 159 logo_url.Attach( |
| 160 MakeHString(base::string16(L"file:///").append(logo_path.value()))); |
| 160 mswr::ComPtr<winfoundtn::IUriRuntimeClass> uri; | 161 mswr::ComPtr<winfoundtn::IUriRuntimeClass> uri; |
| 161 hr = uri_factory->CreateUri(logo_url.Get(), &uri); | 162 hr = uri_factory->CreateUri(logo_url.Get(), &uri); |
| 162 CheckHR(hr, "Failed to create URI"); | 163 CheckHR(hr, "Failed to create URI"); |
| 163 | 164 |
| 164 mswr::ComPtr<winui::StartScreen::ISecondaryTile> tile; | 165 mswr::ComPtr<winui::StartScreen::ISecondaryTile> tile; |
| 165 hr = tile_factory->CreateTile(id.Get(), | 166 hr = tile_factory->CreateTile(id.Get(), |
| 166 title.Get(), | 167 title.Get(), |
| 167 title.Get(), | 168 title.Get(), |
| 168 args.Get(), | 169 args.Get(), |
| 169 options, | 170 options, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 185 | 186 |
| 186 // Deleted in TileRequestCompleter::Respond when the async operation | 187 // Deleted in TileRequestCompleter::Respond when the async operation |
| 187 // completes. | 188 // completes. |
| 188 TileRequestCompleter* completer = | 189 TileRequestCompleter* completer = |
| 189 new TileRequestCompleter(TileRequestCompleter::PIN, callback); | 190 new TileRequestCompleter(TileRequestCompleter::PIN, callback); |
| 190 completer->Complete(completion); | 191 completer->Complete(completion); |
| 191 } | 192 } |
| 192 | 193 |
| 193 } // namespace | 194 } // namespace |
| 194 | 195 |
| 195 BOOL MetroIsPinnedToStartScreen(const string16& tile_id) { | 196 BOOL MetroIsPinnedToStartScreen(const base::string16& tile_id) { |
| 196 mswr::ComPtr<winui::StartScreen::ISecondaryTileStatics> tile_statics; | 197 mswr::ComPtr<winui::StartScreen::ISecondaryTileStatics> tile_statics; |
| 197 HRESULT hr = winrt_utils::CreateActivationFactory( | 198 HRESULT hr = winrt_utils::CreateActivationFactory( |
| 198 RuntimeClass_Windows_UI_StartScreen_SecondaryTile, | 199 RuntimeClass_Windows_UI_StartScreen_SecondaryTile, |
| 199 tile_statics.GetAddressOf()); | 200 tile_statics.GetAddressOf()); |
| 200 CheckHR(hr, "Failed to create instance of ISecondaryTileStatics"); | 201 CheckHR(hr, "Failed to create instance of ISecondaryTileStatics"); |
| 201 | 202 |
| 202 boolean exists; | 203 boolean exists; |
| 203 hr = tile_statics->Exists(MakeHString(tile_id), &exists); | 204 hr = tile_statics->Exists(MakeHString(tile_id), &exists); |
| 204 CheckHR(hr, "ISecondaryTileStatics.Exists failed"); | 205 CheckHR(hr, "ISecondaryTileStatics.Exists failed"); |
| 205 return exists; | 206 return exists; |
| 206 } | 207 } |
| 207 | 208 |
| 208 void MetroUnPinFromStartScreen(const string16& tile_id, | 209 void MetroUnPinFromStartScreen(const base::string16& tile_id, |
| 209 const MetroPinUmaResultCallback& callback) { | 210 const MetroPinUmaResultCallback& callback) { |
| 210 globals.appview_msg_loop->PostTask( | 211 globals.appview_msg_loop->PostTask( |
| 211 FROM_HERE, base::Bind(&DeleteTileFromStartScreen, | 212 FROM_HERE, base::Bind(&DeleteTileFromStartScreen, |
| 212 tile_id, | 213 tile_id, |
| 213 callback)); | 214 callback)); |
| 214 } | 215 } |
| 215 | 216 |
| 216 void MetroPinToStartScreen(const string16& tile_id, | 217 void MetroPinToStartScreen(const base::string16& tile_id, |
| 217 const string16& title, | 218 const base::string16& title, |
| 218 const string16& url, | 219 const base::string16& url, |
| 219 const base::FilePath& logo_path, | 220 const base::FilePath& logo_path, |
| 220 const MetroPinUmaResultCallback& callback) { | 221 const MetroPinUmaResultCallback& callback) { |
| 221 globals.appview_msg_loop->PostTask( | 222 globals.appview_msg_loop->PostTask( |
| 222 FROM_HERE, base::Bind(&CreateTileOnStartScreen, | 223 FROM_HERE, base::Bind(&CreateTileOnStartScreen, |
| 223 tile_id, | 224 tile_id, |
| 224 title, | 225 title, |
| 225 url, | 226 url, |
| 226 logo_path, | 227 logo_path, |
| 227 callback)); | 228 callback)); |
| 228 } | 229 } |
| OLD | NEW |