| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "chrome/browser/extensions/bookmark_app_helper.h" | 5 #include "chrome/browser/extensions/bookmark_app_helper.h" |
| 6 | 6 |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 on_icons_downloaded_closure_.Run(); | 45 on_icons_downloaded_closure_.Run(); |
| 46 BookmarkAppHelper::OnIconsDownloaded(success, bitmaps); | 46 BookmarkAppHelper::OnIconsDownloaded(success, bitmaps); |
| 47 } | 47 } |
| 48 | 48 |
| 49 private: | 49 private: |
| 50 base::Closure on_icons_downloaded_closure_; | 50 base::Closure on_icons_downloaded_closure_; |
| 51 | 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(TestBookmarkAppHelper); | 52 DISALLOW_COPY_AND_ASSIGN(TestBookmarkAppHelper); |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 // Intercepts the ChromeViewHostMsg_DidGetWebApplicationInfo that would usually | 55 // Intercepts the ChromeFrameHostMsg_DidGetWebApplicationInfo that would usually |
| 56 // get sent to extensions::TabHelper to create a BookmarkAppHelper that lets us | 56 // get sent to extensions::TabHelper to create a BookmarkAppHelper that lets us |
| 57 // detect when icons are downloaded and the dialog is ready to show. | 57 // detect when icons are downloaded and the dialog is ready to show. |
| 58 class WebAppReadyMsgWatcher : public content::BrowserMessageFilter { | 58 class WebAppReadyMsgWatcher : public content::BrowserMessageFilter { |
| 59 public: | 59 public: |
| 60 explicit WebAppReadyMsgWatcher(Browser* browser) | 60 explicit WebAppReadyMsgWatcher(Browser* browser) |
| 61 : BrowserMessageFilter(ChromeMsgStart), browser_(browser) {} | 61 : BrowserMessageFilter(ChromeMsgStart), browser_(browser) {} |
| 62 | 62 |
| 63 content::WebContents* web_contents() { | 63 content::WebContents* web_contents() { |
| 64 return browser_->tab_strip_model()->GetActiveWebContents(); | 64 return browser_->tab_strip_model()->GetActiveWebContents(); |
| 65 } | 65 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 89 | 89 |
| 90 void Wait() { | 90 void Wait() { |
| 91 base::RunLoop run_loop; | 91 base::RunLoop run_loop; |
| 92 quit_closure_ = run_loop.QuitClosure(); | 92 quit_closure_ = run_loop.QuitClosure(); |
| 93 run_loop.Run(); | 93 run_loop.Run(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 // BrowserMessageFilter: | 96 // BrowserMessageFilter: |
| 97 void OverrideThreadForMessage(const IPC::Message& message, | 97 void OverrideThreadForMessage(const IPC::Message& message, |
| 98 content::BrowserThread::ID* thread) override { | 98 content::BrowserThread::ID* thread) override { |
| 99 if (message.type() == ChromeViewHostMsg_DidGetWebApplicationInfo::ID) | 99 if (message.type() == ChromeFrameHostMsg_DidGetWebApplicationInfo::ID) |
| 100 *thread = content::BrowserThread::UI; | 100 *thread = content::BrowserThread::UI; |
| 101 } | 101 } |
| 102 | 102 |
| 103 bool OnMessageReceived(const IPC::Message& message) override { | 103 bool OnMessageReceived(const IPC::Message& message) override { |
| 104 bool handled = true; | 104 bool handled = true; |
| 105 IPC_BEGIN_MESSAGE_MAP(WebAppReadyMsgWatcher, message) | 105 IPC_BEGIN_MESSAGE_MAP(WebAppReadyMsgWatcher, message) |
| 106 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_DidGetWebApplicationInfo, | 106 IPC_MESSAGE_HANDLER(ChromeFrameHostMsg_DidGetWebApplicationInfo, |
| 107 OnDidGetWebApplicationInfo) | 107 OnDidGetWebApplicationInfo) |
| 108 IPC_MESSAGE_UNHANDLED(handled = false) | 108 IPC_MESSAGE_UNHANDLED(handled = false) |
| 109 IPC_END_MESSAGE_MAP() | 109 IPC_END_MESSAGE_MAP() |
| 110 return handled; | 110 return handled; |
| 111 } | 111 } |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 ~WebAppReadyMsgWatcher() override {} | 114 ~WebAppReadyMsgWatcher() override {} |
| 115 | 115 |
| 116 Browser* browser_; | 116 Browser* browser_; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 143 | 143 |
| 144 private: | 144 private: |
| 145 DISALLOW_COPY_AND_ASSIGN(BookmarkAppHelperTest); | 145 DISALLOW_COPY_AND_ASSIGN(BookmarkAppHelperTest); |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 IN_PROC_BROWSER_TEST_F(BookmarkAppHelperTest, InvokeDialog_create) { | 148 IN_PROC_BROWSER_TEST_F(BookmarkAppHelperTest, InvokeDialog_create) { |
| 149 RunDialog(); | 149 RunDialog(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 } // namespace extensions | 152 } // namespace extensions |
| OLD | NEW |