OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "apps/launcher.h" | 5 #include "apps/launcher.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 PlatformAppContextMenu(content::RenderFrameHost* render_frame_host, | 71 PlatformAppContextMenu(content::RenderFrameHost* render_frame_host, |
72 const content::ContextMenuParams& params) | 72 const content::ContextMenuParams& params) |
73 : RenderViewContextMenu(render_frame_host, params) {} | 73 : RenderViewContextMenu(render_frame_host, params) {} |
74 | 74 |
75 bool HasCommandWithId(int command_id) { | 75 bool HasCommandWithId(int command_id) { |
76 return menu_model_.GetIndexOfCommandId(command_id) != -1; | 76 return menu_model_.GetIndexOfCommandId(command_id) != -1; |
77 } | 77 } |
78 | 78 |
79 protected: | 79 protected: |
80 // RenderViewContextMenu implementation. | 80 // RenderViewContextMenu implementation. |
81 virtual bool GetAcceleratorForCommandId( | 81 bool GetAcceleratorForCommandId(int command_id, |
82 int command_id, | 82 ui::Accelerator* accelerator) override { |
83 ui::Accelerator* accelerator) override { | |
84 return false; | 83 return false; |
85 } | 84 } |
86 }; | 85 }; |
87 | 86 |
88 // This class keeps track of tabs as they are added to the browser. It will be | 87 // This class keeps track of tabs as they are added to the browser. It will be |
89 // "done" (i.e. won't block on Wait()) once |observations| tabs have been added. | 88 // "done" (i.e. won't block on Wait()) once |observations| tabs have been added. |
90 class TabsAddedNotificationObserver | 89 class TabsAddedNotificationObserver |
91 : public content::WindowedNotificationObserver { | 90 : public content::WindowedNotificationObserver { |
92 public: | 91 public: |
93 explicit TabsAddedNotificationObserver(size_t observations) | 92 explicit TabsAddedNotificationObserver(size_t observations) |
94 : content::WindowedNotificationObserver( | 93 : content::WindowedNotificationObserver( |
95 chrome::NOTIFICATION_TAB_ADDED, | 94 chrome::NOTIFICATION_TAB_ADDED, |
96 content::NotificationService::AllSources()), | 95 content::NotificationService::AllSources()), |
97 observations_(observations) { | 96 observations_(observations) { |
98 } | 97 } |
99 | 98 |
100 virtual void Observe(int type, | 99 void Observe(int type, |
101 const content::NotificationSource& source, | 100 const content::NotificationSource& source, |
102 const content::NotificationDetails& details) override { | 101 const content::NotificationDetails& details) override { |
103 observed_tabs_.push_back( | 102 observed_tabs_.push_back( |
104 content::Details<WebContents>(details).ptr()); | 103 content::Details<WebContents>(details).ptr()); |
105 if (observed_tabs_.size() == observations_) | 104 if (observed_tabs_.size() == observations_) |
106 content::WindowedNotificationObserver::Observe(type, source, details); | 105 content::WindowedNotificationObserver::Observe(type, source, details); |
107 } | 106 } |
108 | 107 |
109 const std::vector<content::WebContents*>& tabs() { return observed_tabs_; } | 108 const std::vector<content::WebContents*>& tabs() { return observed_tabs_; } |
110 | 109 |
111 private: | 110 private: |
112 size_t observations_; | 111 size_t observations_; |
(...skipping 10 matching lines...) Expand all Loading... |
123 total_page_count_(1), | 122 total_page_count_(1), |
124 rendered_page_count_(0) { | 123 rendered_page_count_(0) { |
125 PrintPreviewUI::SetDelegateForTesting(this); | 124 PrintPreviewUI::SetDelegateForTesting(this); |
126 } | 125 } |
127 | 126 |
128 ~ScopedPreviewTestingDelegate() { | 127 ~ScopedPreviewTestingDelegate() { |
129 PrintPreviewUI::SetDelegateForTesting(NULL); | 128 PrintPreviewUI::SetDelegateForTesting(NULL); |
130 } | 129 } |
131 | 130 |
132 // PrintPreviewUI::TestingDelegate implementation. | 131 // PrintPreviewUI::TestingDelegate implementation. |
133 virtual bool IsAutoCancelEnabled() override { | 132 bool IsAutoCancelEnabled() override { return auto_cancel_; } |
134 return auto_cancel_; | |
135 } | |
136 | 133 |
137 // PrintPreviewUI::TestingDelegate implementation. | 134 // PrintPreviewUI::TestingDelegate implementation. |
138 virtual void DidGetPreviewPageCount(int page_count) override { | 135 void DidGetPreviewPageCount(int page_count) override { |
139 total_page_count_ = page_count; | 136 total_page_count_ = page_count; |
140 } | 137 } |
141 | 138 |
142 // PrintPreviewUI::TestingDelegate implementation. | 139 // PrintPreviewUI::TestingDelegate implementation. |
143 virtual void DidRenderPreviewPage(content::WebContents* preview_dialog) | 140 void DidRenderPreviewPage(content::WebContents* preview_dialog) override { |
144 override { | |
145 dialog_size_ = preview_dialog->GetContainerBounds().size(); | 141 dialog_size_ = preview_dialog->GetContainerBounds().size(); |
146 ++rendered_page_count_; | 142 ++rendered_page_count_; |
147 CHECK(rendered_page_count_ <= total_page_count_); | 143 CHECK(rendered_page_count_ <= total_page_count_); |
148 if (waiting_runner_.get() && rendered_page_count_ == total_page_count_) { | 144 if (waiting_runner_.get() && rendered_page_count_ == total_page_count_) { |
149 waiting_runner_->Quit(); | 145 waiting_runner_->Quit(); |
150 } | 146 } |
151 } | 147 } |
152 | 148 |
153 void WaitUntilPreviewIsReady() { | 149 void WaitUntilPreviewIsReady() { |
154 CHECK(!waiting_runner_.get()); | 150 CHECK(!waiting_runner_.get()); |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 this, | 938 this, |
943 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, | 939 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, |
944 content::NotificationService::AllSources()); | 940 content::NotificationService::AllSources()); |
945 } | 941 } |
946 | 942 |
947 bool seen() const { | 943 bool seen() const { |
948 return seen_; | 944 return seen_; |
949 }; | 945 }; |
950 | 946 |
951 // NotificationObserver: | 947 // NotificationObserver: |
952 virtual void Observe(int type, | 948 void Observe(int type, |
953 const content::NotificationSource& source, | 949 const content::NotificationSource& source, |
954 const content::NotificationDetails& details) override { | 950 const content::NotificationDetails& details) override { |
955 EXPECT_FALSE(seen_); | 951 EXPECT_FALSE(seen_); |
956 seen_ = true; | 952 seen_ = true; |
957 } | 953 } |
958 | 954 |
959 private: | 955 private: |
960 bool seen_; | 956 bool seen_; |
961 content::NotificationRegistrar registrar_; | 957 content::NotificationRegistrar registrar_; |
962 }; | 958 }; |
963 | 959 |
964 } // namespace | 960 } // namespace |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 LoadAndLaunchPlatformApp("reinstall_data_cleanup", "Launched"); | 1323 LoadAndLaunchPlatformApp("reinstall_data_cleanup", "Launched"); |
1328 ASSERT_TRUE(extension); | 1324 ASSERT_TRUE(extension); |
1329 ASSERT_EQ(extension_id, extension->id()); | 1325 ASSERT_EQ(extension_id, extension->id()); |
1330 | 1326 |
1331 ResultCatcher result_catcher; | 1327 ResultCatcher result_catcher; |
1332 EXPECT_TRUE(result_catcher.GetNextResult()); | 1328 EXPECT_TRUE(result_catcher.GetNextResult()); |
1333 } | 1329 } |
1334 } | 1330 } |
1335 | 1331 |
1336 } // namespace extensions | 1332 } // namespace extensions |
OLD | NEW |